Skip to content

Commit 7499790

Browse files
unicornxRbb666
authored andcommitted
utest: core: move perf testcase from example to src
Also: - Add "RT_" prefix for the UTEST config options. - Follow the naming rules to update the case name. Signed-off-by: Chen Wang <[email protected]>
1 parent 66448d9 commit 7499790

File tree

14 files changed

+34
-42
lines changed

14 files changed

+34
-42
lines changed

Kconfig.utestcases

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ rsource "examples/utest/testcases/drivers/ipc/Kconfig"
1414
rsource "examples/utest/testcases/posix/Kconfig"
1515
rsource "examples/utest/testcases/mm/Kconfig"
1616
rsource "examples/utest/testcases/tmpfs/Kconfig"
17-
rsource "examples/utest/testcases/perf/Kconfig"
1817

1918
rsource "src/klibc/utest/Kconfig"
2019

examples/utest/testcases/perf/Kconfig

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/utest/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ config UTEST_MEMPOOL_TC
8484
default n
8585
depends on RT_USING_MEMPOOL
8686

87+
rsource "perf/Kconfig"
88+
8789
if RT_USING_SMP
8890
rsource "smp/Kconfig"
8991
endif

src/utest/perf/Kconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
config RT_UTEST_SYS_PERF
2+
bool "Performance Test"
3+
default n
4+
5+
config RT_UTEST_SYS_PERF_TC_COUNT
6+
int "PerfTest: Number of cycles"
7+
default 1000
8+
depends on RT_UTEST_SYS_PERF
9+
10+
config RT_UTEST_HWTIMER_DEV_NAME
11+
string "PerfTest: Hardware timer device name"
12+
default "timer0"
13+
depends on RT_USING_HWTIMER && RT_UTEST_SYS_PERF
14+
help
15+
Specify the hardware timer device name used for context switch testing (e.g., timer0).
File renamed without changes.

examples/utest/testcases/perf/SConscript renamed to src/utest/perf/SConscript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ cwd = GetCurrentDir()
55
src = Glob('*.c')
66
CPPPATH = [cwd]
77

8-
group = DefineGroup('utestcases', src, depend = ['UTEST_SYS_PERF_TC'], CPPPATH = CPPPATH)
8+
group = DefineGroup('utestcases', src, depend = ['RT_UTEST_SYS_PERF'], CPPPATH = CPPPATH)
99

1010
Return('group')

examples/utest/testcases/perf/context_switch_tc.c renamed to src/utest/perf/context_switch_tc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static void perf_thread_event2(void *parameter)
3737
{
3838
rt_perf_t *perf = (rt_perf_t *)parameter;
3939

40-
for (rt_uint32_t i = 0; i < UTEST_SYS_PERF_TC_COUNT; i++)
40+
for (rt_uint32_t i = 0; i < RT_UTEST_SYS_PERF_TC_COUNT; i++)
4141
{
4242
perf->tmp_time = 0;
4343
rt_perf_start(perf);

examples/utest/testcases/perf/irq_latency_tc.c renamed to src/utest/perf/irq_latency_tc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static void modify_time(rt_perf_t *perf)
2828
static rt_err_t timer_callback(rt_device_t dev, rt_size_t size)
2929
{
3030
rt_perf_stop(perf_local);
31-
if (perf_local->count >= UTEST_SYS_PERF_TC_COUNT)
31+
if (perf_local->count >= RT_UTEST_SYS_PERF_TC_COUNT)
3232
{
3333
rt_sem_release(complete_sem);
3434
return RT_EOK;
@@ -48,11 +48,11 @@ rt_err_t rt_perf_irq_latency(rt_perf_t *perf)
4848
rt_hwtimer_mode_t mode = HWTIMER_MODE_PERIOD;
4949

5050
perf_local = perf;
51-
hw_dev = rt_device_find(UTEST_HWTIMER_DEV_NAME);
51+
hw_dev = rt_device_find(RT_UTEST_HWTIMER_DEV_NAME);
5252
if (hw_dev == RT_NULL)
5353
{
5454
ret = RT_ERROR;
55-
LOG_E("hwtimer sample run failed! can't find %s device!", UTEST_HWTIMER_DEV_NAME);
55+
LOG_E("hwtimer sample run failed! can't find %s device!", RT_UTEST_HWTIMER_DEV_NAME);
5656
return ret;
5757
}
5858

examples/utest/testcases/perf/perf_tc.c renamed to src/utest/perf/perf_tc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,17 @@ static rt_err_t utest_tc_init(void)
167167
{
168168
int ret = RT_EOK;
169169

170-
hw_dev = rt_device_find(UTEST_HWTIMER_DEV_NAME);
170+
hw_dev = rt_device_find(RT_UTEST_HWTIMER_DEV_NAME);
171171
if (hw_dev == RT_NULL)
172172
{
173173
ret = RT_ERROR;
174-
LOG_E("hwtimer sample run failed! can't find %s device!", UTEST_HWTIMER_DEV_NAME);
174+
LOG_E("hwtimer sample run failed! can't find %s device!", RT_UTEST_HWTIMER_DEV_NAME);
175175
return ret;
176176
}
177177
ret = rt_device_open(hw_dev, RT_DEVICE_OFLAG_RDWR);
178178
if (ret != RT_EOK)
179179
{
180-
LOG_E("open %s device failed!", UTEST_HWTIMER_DEV_NAME);
180+
LOG_E("open %s device failed!", RT_UTEST_HWTIMER_DEV_NAME);
181181
return ret;
182182
}
183183

@@ -198,5 +198,5 @@ static void testcase(void)
198198
UTEST_UNIT_RUN(rt_perf_all_test);
199199
}
200200

201-
UTEST_TC_EXPORT(testcase, "testcase.pref.all", utest_tc_init, utest_tc_cleanup, 10);
201+
UTEST_TC_EXPORT(testcase, "core.pref_test", utest_tc_init, utest_tc_cleanup, 10);
202202

File renamed without changes.

0 commit comments

Comments
 (0)