Skip to content

Commit ed67ae9

Browse files
committed
[asan] move unit tests into component directory
Move C and C++ tests with their Kconfig and build entry points into the ASan component. Keep tests in a separate instrumented group and preserve existing configuration and testcase names.
1 parent 6bee968 commit ed67ae9

8 files changed

Lines changed: 25 additions & 10 deletions

File tree

‎components/utilities/asan/SConscript‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,7 @@ group = DefineGroup('asan', src, depend=['RT_USING_ASAN'], CPPPATH=CPPPATH,
2020
CFLAGS=CFLAGS, CXXFLAGS=CFLAGS, LINKFLAGS=LINKFLAGS,
2121
LOCAL_CFLAGS=' -fno-sanitize=kernel-address')
2222

23+
# Do not extend in place: DefineGroup retains the runtime source list.
24+
group = group + SConscript('utest/SConscript')
25+
2326
Return('group')
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
menu "AddressSanitizer"
2+
3+
config RT_UTEST_ASAN
4+
bool "AddressSanitizer Test"
5+
default n
6+
depends on RT_USING_ASAN
7+
8+
endmenu
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from building import *
2+
3+
cwd = GetCurrentDir()
4+
src = ['asan_tc.c']
5+
if GetDepend('RT_USING_CPLUSPLUS'):
6+
src += ['asan_cpp_test.cpp']
7+
8+
# Tests need global instrumentation; do not inherit the runtime's LOCAL_CFLAGS.
9+
group = DefineGroup('asan_utest', src,
10+
depend=['RT_USING_UTESTCASES', 'RT_UTEST_ASAN', 'RT_USING_ASAN'],
11+
CPPPATH=[cwd])
12+
13+
Return('group')
File renamed without changes.

‎components/utilities/utest/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ menu "RT-Thread Utestcases"
2929
rsource "../../../components/lwp/utest/Kconfig"
3030
rsource "../../../components/mm/utest/Kconfig"
3131
rsource "../../../components/net/utest/Kconfig"
32+
rsource "../asan/utest/Kconfig"
3233
rsource "../../../components/utilities/utest/utest/Kconfig"
3334

3435
endmenu

‎src/utest/Kconfig‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@ menu "Kernel Core"
8989
default n
9090
depends on RT_USING_HEAP
9191

92-
config RT_UTEST_ASAN
93-
bool "AddressSanitizer Test"
94-
default n
95-
depends on RT_USING_ASAN
96-
9792
rsource "perf/Kconfig"
9893
rsource "../klibc/utest/Kconfig"
9994

‎src/utest/SConscript‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@ if GetDepend(['RT_UTEST_MEMPOOL']):
6161
if GetDepend(['RT_UTEST_MEM_ALIGN']):
6262
src += [os.path.join(cwd, '../../examples/test/mem_align_test.c')]
6363

64-
if GetDepend(['RT_UTEST_ASAN']):
65-
src += ['asan_tc.c']
66-
if GetDepend(['RT_USING_CPLUSPLUS']):
67-
src += [os.path.join(cwd, '../../examples/test/asan_cpp_test.cpp')]
68-
6964
# Stressful testcase for scheduler (MP/UP)
7065
if GetDepend(['RT_UTEST_SCHEDULER']):
7166
src += ['sched_timeout_race_tc.c']

0 commit comments

Comments
 (0)