Skip to content

Commit 2f1b938

Browse files
committed
fix ci problem.
1 parent 4dd4285 commit 2f1b938

File tree

5 files changed

+84
-29
lines changed

5 files changed

+84
-29
lines changed

.github/utest/default.cfg

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
CONFIG_RT_USING_CI_ACTION=y
2-
CONFIG_RT_CONSOLEBUF_SIZE=1024
1+
# dependencies
2+
CONFIG_RT_CONSOLEBUF_SIZE=1024
3+
CONFIG_RT_USING_CI_ACTION=y

.github/utest/dfs/dfs.cfg

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
CONFIG_UTEST_OBJECT_TC=y
2-
31
# dependencies
4-
CONFIG_RT_USING_CI_ACTION=y
52
CONFIG_RT_CONSOLEBUF_SIZE=1024
3+
CONFIG_RT_NAME_MAX=24
4+
CONFIG_RT_USING_CI_ACTION=y
65

76
CONFIG_RT_UTEST_DFS_API_TC=y
87
CONFIG_RT_UTEST_POSIX_API_TC=y
98
CONFIG_RT_UTEST_DFS_MNT_PATH=""
109
CONFIG_RT_UTEST_DFS_FS_TYPE="elm"
11-
CONFIG_RT_UTEST_DFS_BLOCK_DEV="sd0"
12-
CONFIG_RT_NAME_MAX=24
10+
CONFIG_RT_UTEST_DFS_BLOCK_DEV="sd0"

.github/utest/kernel/object.cfg

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
CONFIG_UTEST_OBJECT_TC=y
2-
31
# dependencies
2+
CONFIG_RT_CONSOLEBUF_SIZE=1024
43
CONFIG_RT_USING_CI_ACTION=y
5-
CONFIG_RT_USING_DEVICE=y
6-
CONFIG_RT_USING_SEMAPHORE=y
7-
CONFIG_RT_NAME_MAX=24
4+
CONFIG_UTEST_OBJECT_TC=y

.github/workflows/utest_auto_run.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,16 @@ jobs:
4646

4747
config_file:
4848
- "default.cfg"
49-
- "kernel/object.cfg"
5049

5150
include:
52-
# dfs.cfg only run on qemu-vexpress-a9
51+
# only run on qemu-vexpress-a9
52+
- platform: { UTEST: "A9", RTT_BSP: "bsp/qemu-vexpress-a9", QEMU_ARCH: "arm", QEMU_MACHINE: "vexpress-a9", SD_FILE: "sd.bin", KERNEL: "standard", "SMP_RUN":"" }
53+
config_file: "kernel/object.cfg"
54+
5355
- platform: { UTEST: "A9", RTT_BSP: "bsp/qemu-vexpress-a9", QEMU_ARCH: "arm", QEMU_MACHINE: "vexpress-a9", SD_FILE: "sd.bin", KERNEL: "standard", "SMP_RUN":"" }
5456
config_file: "dfs/dfs.cfg"
57+
58+
- platform: { UTEST: "A9", RTT_BSP: "bsp/qemu-vexpress-a9", QEMU_ARCH: "arm", QEMU_MACHINE: "vexpress-a9", SD_FILE: "sd.bin", KERNEL: "standard", "SMP_RUN":"" }
5559
config_file: "cpp11/cpp11.cfg"
5660

5761
env:

examples/utest/testcases/kernel/object_tc.c

Lines changed: 70 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ static rt_err_t generate_unique_name(char *buf, rt_size_t size, const char *pref
4848

4949
/* Check if name (or truncated name) is unique */
5050
if (rt_object_find(buf, RT_Object_Class_Unknown) == RT_NULL &&
51-
rt_thread_find(buf) == RT_NULL &&
52-
rt_device_find(buf) == RT_NULL)
51+
rt_thread_find(buf) == RT_NULL &&
52+
rt_device_find(buf) == RT_NULL)
5353
{
5454
return RT_EOK;
5555
}
@@ -61,8 +61,20 @@ static void test_object_name_handling(void)
6161
{
6262
struct rt_object static_obj1, static_obj2, static_obj3;
6363
rt_object_t dyn_obj = RT_NULL;
64-
char test_name[TEST_RT_NAME_MAX];
65-
char unique_name[TEST_RT_NAME_MAX];
64+
char *test_name = RT_NULL;
65+
char *unique_name = RT_NULL;
66+
char *exact_name = RT_NULL;
67+
68+
/* Allocate memory for test names to reduce stack usage */
69+
test_name = (char *)rt_malloc(TEST_RT_NAME_MAX);
70+
unique_name = (char *)rt_malloc(TEST_RT_NAME_MAX);
71+
exact_name = (char *)rt_malloc(TEST_RT_NAME_MAX);
72+
73+
if (!test_name || !unique_name || !exact_name)
74+
{
75+
rt_kprintf("Memory allocation failed in test_object_name_handling\n");
76+
goto cleanup;
77+
}
6678

6779
/* Prepare a test name within TEST_RT_NAME_MAX */
6880
rt_memset(test_name, 'A', TEST_RT_NAME_MAX - 1);
@@ -100,23 +112,36 @@ static void test_object_name_handling(void)
100112
rt_object_delete(dyn_obj);
101113

102114
/* Test 4: Exact Length Name */
103-
char exact_name[TEST_RT_NAME_MAX];
104115
rt_memset(exact_name, 'B', TEST_RT_NAME_MAX - 1);
105116
exact_name[TEST_RT_NAME_MAX - 1] = '\0';
106117
uassert_true(generate_unique_name(unique_name, TEST_RT_NAME_MAX, "exact") == RT_EOK);
107118
rt_object_init(&static_obj3, RT_Object_Class_Thread, exact_name);
108119
uassert_str_equal(static_obj3.name, exact_name);
109120
rt_object_detach(&static_obj3);
121+
122+
cleanup:
123+
/* Free allocated memory */
124+
if (test_name) rt_free(test_name);
125+
if (unique_name) rt_free(unique_name);
126+
if (exact_name) rt_free(exact_name);
110127
}
111128

112129
static void test_object_find_operations(void)
113130
{
114131
rt_object_t found;
115132
rt_thread_t found_thread;
116133
rt_device_t found_device;
117-
char name[TEST_RT_NAME_MAX];
134+
char *name = RT_NULL;
118135
rt_err_t ret;
119136

137+
/* Allocate memory for name buffer to reduce stack usage */
138+
name = (char *)rt_malloc(TEST_RT_NAME_MAX);
139+
if (!name)
140+
{
141+
rt_kprintf("Memory allocation failed in test_object_find_operations\n");
142+
return;
143+
}
144+
120145
/* Scenario 1: Object Name Within TEST_RT_NAME_MAX */
121146
/* Test 1.1: Find static thread object with rt_object_find */
122147
struct rt_object static_obj;
@@ -154,8 +179,8 @@ static void test_object_find_operations(void)
154179
/* Test 2: Same Prefix Within TEST_RT_NAME_MAX */
155180
#ifdef RT_USING_DEVICE
156181
struct rt_device dev1, dev2;
157-
char name1[TEST_RT_NAME_MAX] = "norflash1";
158-
char name2[TEST_RT_NAME_MAX] = "norflash2";
182+
const char name1[] = "norflash1";
183+
const char name2[] = "norflash2";
159184
ret = rt_device_register(&dev1, name1, RT_DEVICE_FLAG_RDONLY);
160185
uassert_int_equal(ret, RT_EOK);
161186
ret = rt_device_register(&dev2, name2, RT_DEVICE_FLAG_RDONLY);
@@ -188,13 +213,24 @@ static void test_object_find_operations(void)
188213
found_device = rt_device_find(NULL);
189214
uassert_null(found_device);
190215
#endif
216+
217+
/* Free allocated memory */
218+
rt_free(name);
191219
}
192220

193221
static void test_object_info_enumeration(void)
194222
{
195223
struct rt_object static_objs[3];
196224
rt_object_t dyn_objs[2] = {RT_NULL, RT_NULL};
197-
char names[5][TEST_RT_NAME_MAX];
225+
char (*names)[TEST_RT_NAME_MAX] = RT_NULL;
226+
227+
/* Allocate memory for names array to reduce stack usage */
228+
names = (char (*)[TEST_RT_NAME_MAX])rt_malloc(5 * TEST_RT_NAME_MAX);
229+
if (!names)
230+
{
231+
rt_kprintf("Memory allocation failed in test_object_info_enumeration\n");
232+
return;
233+
}
198234

199235
/* Generate unique names */
200236
for (int i = 0; i < 5; i++)
@@ -254,12 +290,27 @@ static void test_object_info_enumeration(void)
254290
rt_object_detach(&static_objs[i]);
255291
for (int i = 0; i < 2; i++)
256292
if (dyn_objs[i]) rt_object_delete(dyn_objs[i]);
293+
294+
/* Free allocated memory */
295+
rt_free(names);
257296
}
258297

259298
static void test_object_type_handling(void)
260299
{
261300
struct rt_object obj;
262-
char name[TEST_RT_NAME_MAX];
301+
char *name = RT_NULL;
302+
char *name_buf = RT_NULL;
303+
304+
/* Allocate memory for name buffers to reduce stack usage */
305+
name = (char *)rt_malloc(TEST_RT_NAME_MAX);
306+
name_buf = (char *)rt_malloc(TEST_RT_NAME_MAX);
307+
308+
if (!name || !name_buf)
309+
{
310+
rt_kprintf("Memory allocation failed in test_object_type_handling\n");
311+
goto cleanup;
312+
}
313+
263314
uassert_true(generate_unique_name(name, TEST_RT_NAME_MAX, "typ") == RT_EOK);
264315
rt_object_init(&obj, RT_Object_Class_Thread, name);
265316

@@ -270,8 +321,7 @@ static void test_object_type_handling(void)
270321
uassert_true(rt_object_is_systemobject(&obj));
271322

272323
/* Test 3: Get name with sufficient buffer */
273-
char name_buf[TEST_RT_NAME_MAX];
274-
rt_err_t ret = rt_object_get_name(&obj, name_buf, sizeof(name_buf));
324+
rt_err_t ret = rt_object_get_name(&obj, name_buf, TEST_RT_NAME_MAX);
275325
uassert_int_equal(ret, RT_EOK);
276326
uassert_str_equal(name_buf, name);
277327

@@ -283,14 +333,19 @@ static void test_object_type_handling(void)
283333
uassert_true(small_buf[sizeof(small_buf) - 1] == '\0');
284334

285335
/* Test 5: Get name with invalid parameters */
286-
ret = rt_object_get_name(RT_NULL, name_buf, sizeof(name_buf));
336+
ret = rt_object_get_name(RT_NULL, name_buf, TEST_RT_NAME_MAX);
287337
uassert_int_equal(ret, -RT_EINVAL);
288-
ret = rt_object_get_name(&obj, NULL, sizeof(name_buf));
338+
ret = rt_object_get_name(&obj, NULL, TEST_RT_NAME_MAX);
289339
uassert_int_equal(ret, -RT_EINVAL);
290340
ret = rt_object_get_name(&obj, name_buf, 0);
291341
uassert_int_equal(ret, -RT_EINVAL);
292342

293343
rt_object_detach(&obj);
344+
345+
cleanup:
346+
/* Free allocated memory */
347+
if (name) rt_free(name);
348+
if (name_buf) rt_free(name_buf);
294349
}
295350

296351
static rt_err_t testcase_init(void)
@@ -310,7 +365,7 @@ static rt_err_t testcase_cleanup(void)
310365

311366
static void test_object_suite(void)
312367
{
313-
#ifdef RT_NAME_MAX < 10
368+
#if RT_NAME_MAX < 10
314369
rt_kprintf("Error: Please increase \'RT_NAME_MAX\' to be greater than 10.\n");
315370
return;
316371
#endif

0 commit comments

Comments
 (0)