From f995c7c7afdd15620986bd4c55eeb2b768a8a3c9 Mon Sep 17 00:00:00 2001 From: zhangdengyu Date: Tue, 7 Feb 2023 15:42:52 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E4=BF=AE=E5=A4=8D=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E4=B8=8D=E8=A7=84=E8=8C=83=E7=9A=84=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1、在编译kernel/liteos_a测试用例时process、extended、libc三个模块出现报错,主要分为以下几种类型: 1.1、函数返回值为int或其它类型,错误使用了返回NULL的断言宏。修改断言宏返回正确的类型。 1.2、函数返回值为int或其它类型,错误的return了NULL。修改成正确的返回值类型。 1.3、waitpid函数第三个参数为int类型,错误传入了NULL。修改成正确的入参类型。 1.4、使用的断言宏传入的参数一个为int或其他类型,一个为NULL,类似不匹配。修改成匹配的类型。 1.5、testsuites/unittest/process/basic/pthread/smoke/pthread_test_012.cpp中调用Syscall接口, 第二个参数为in类型,错误的传入了NULL。修改入参为正确的类型。 2、hb set选择ipcamera_hispark_taurus,编译之后使用nfs将out/hispark_taurus/ipcamera_hispark_taurus/test/unittest/kernel/bin目录中的 9个测试用例放到单板上进行测试,运行结果全部通过,并生成对应结果从xml文件,其中liteos_a_basic_unittest.bin无xml文件生成是由于gtest框架升级引入。 Close: #I6J7QK Signed-off-by: zhangdengyu Change-Id: Ifa977658bfc47ba85484e06465735cdffef3dbe2 --- .../extended/signal/smoke/It_ipc_pipe_004.cpp | 2 +- .../unittest/libc/io/full/IO_test_confstr_001.cpp | 6 +++--- .../unittest/libc/io/full/IO_test_locale_001.cpp | 6 +++--- .../unittest/libc/io/full/IO_test_locale_002.cpp | 6 +++--- .../libc/io/full/IO_test_nl_langinfo_001.cpp | 2 +- .../libc/io/full/IO_test_nl_langinfo_l_001.cpp | 2 +- .../unittest/libc/io/full/It_stdio_hasmntopt_001.cpp | 2 +- .../process/basic/process/full/process_test_049.cpp | 12 ++++++------ .../process/basic/process/full/process_test_050.cpp | 8 ++++---- .../process/basic/process/full/process_test_051.cpp | 10 +++++----- .../process/basic/process/smoke/process_test_010.cpp | 2 +- .../process/basic/pthread/smoke/pthread_test_012.cpp | 2 +- 12 files changed, 30 insertions(+), 30 deletions(-) diff --git a/testsuites/unittest/extended/signal/smoke/It_ipc_pipe_004.cpp b/testsuites/unittest/extended/signal/smoke/It_ipc_pipe_004.cpp index 7dd997cb..32305026 100644 --- a/testsuites/unittest/extended/signal/smoke/It_ipc_pipe_004.cpp +++ b/testsuites/unittest/extended/signal/smoke/It_ipc_pipe_004.cpp @@ -53,7 +53,7 @@ static UINT32 TestCase(VOID) char sentence1[15] = "Hello World"; char a[4] = {0}; retValue = sprintf_s(a, sizeof(a), "%d", i); - ICUNIT_ASSERT_NOT_EQUAL(retValue, NULL, retValue); + ICUNIT_ASSERT_NOT_EQUAL(retValue, 0, retValue); retValue = strcat_s(sentence1, sizeof(sentence1), a); ICUNIT_ASSERT_EQUAL(retValue, 0, retValue); ret = write(*writeFd, sentence1, strlen(sentence1) + 1); diff --git a/testsuites/unittest/libc/io/full/IO_test_confstr_001.cpp b/testsuites/unittest/libc/io/full/IO_test_confstr_001.cpp index ee364b4c..b63c3ba3 100644 --- a/testsuites/unittest/libc/io/full/IO_test_confstr_001.cpp +++ b/testsuites/unittest/libc/io/full/IO_test_confstr_001.cpp @@ -44,7 +44,7 @@ static UINT32 testcase(VOID) return LOS_NOK; } confstr(_CS_PATH, pathbuf, n); - ICUNIT_ASSERT_NOT_EQUAL_NULL(pathbuf, NULL, -1); + ICUNIT_ASSERT_NOT_EQUAL(pathbuf, NULL, -1); free(pathbuf); pathbuf = NULL; @@ -57,7 +57,7 @@ static UINT32 testcase(VOID) return LOS_NOK; } confstr(_CS_GNU_LIBPTHREAD_VERSION, gun_libpthread_version_buf, n); - ICUNIT_ASSERT_NOT_EQUAL_NULL(gun_libpthread_version_buf, NULL, -1); + ICUNIT_ASSERT_NOT_EQUAL(gun_libpthread_version_buf, NULL, -1); free(gun_libpthread_version_buf); gun_libpthread_version_buf = NULL; @@ -70,7 +70,7 @@ static UINT32 testcase(VOID) return LOS_NOK; } confstr(_CS_GNU_LIBC_VERSION, gun_libc_version_buf, n); - ICUNIT_ASSERT_NOT_EQUAL_NULL(gun_libc_version_buf, NULL, -1); + ICUNIT_ASSERT_NOT_EQUAL(gun_libc_version_buf, NULL, -1); free(gun_libc_version_buf); gun_libc_version_buf = NULL; diff --git a/testsuites/unittest/libc/io/full/IO_test_locale_001.cpp b/testsuites/unittest/libc/io/full/IO_test_locale_001.cpp index f2bbf1c6..a6d5b825 100644 --- a/testsuites/unittest/libc/io/full/IO_test_locale_001.cpp +++ b/testsuites/unittest/libc/io/full/IO_test_locale_001.cpp @@ -47,17 +47,17 @@ static UINT32 testcase(VOID) printf("Locale is: %s\n", setlocale(LC_TIME, "en_US.UTF-8")); strftime(buffer, 80, "%c", timer); printf("Date is: %s\n", buffer); - ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1); + ICUNIT_ASSERT_NOT_EQUAL(buffer, NULL, -1); printf("Locale is: %s\n", setlocale(LC_TIME, "zh_CN.UTF-8")); strftime(buffer, 80, "%c", timer); printf("Date is: %s\n", buffer); - ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1); + ICUNIT_ASSERT_NOT_EQUAL(buffer, NULL, -1); printf("Locale is: %s\n", setlocale(LC_TIME, "")); strftime(buffer, 80, "%c", timer); printf("Date is: %s\n", buffer); - ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1); + ICUNIT_ASSERT_NOT_EQUAL(buffer, NULL, -1); setlocale(LC_ALL, "C"); return LOS_OK; diff --git a/testsuites/unittest/libc/io/full/IO_test_locale_002.cpp b/testsuites/unittest/libc/io/full/IO_test_locale_002.cpp index daaca4c7..a7e1fd6b 100644 --- a/testsuites/unittest/libc/io/full/IO_test_locale_002.cpp +++ b/testsuites/unittest/libc/io/full/IO_test_locale_002.cpp @@ -47,17 +47,17 @@ static UINT32 testcase(VOID) printf("Locale is: %s\n", setlocale(LC_TIME, "en_US.UTF-8")); (void)strftime(buffer, sizeof(buffer), "%c", timer); printf("Date is: %s\n", buffer); - ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1); + ICUNIT_ASSERT_NOT_EQUAL(buffer, NULL, -1); printf("Locale is: %s\n", setlocale(LC_TIME, "zh_CN.UTF-8")); (void)strftime(buffer, sizeof(buffer), "%c", timer); printf("Date is: %s\n", buffer); - ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1); + ICUNIT_ASSERT_NOT_EQUAL(buffer, NULL, -1); printf("Locale is: %s\n", setlocale(LC_TIME, "")); (void)strftime(buffer, sizeof(buffer), "%c", timer); printf("Date is: %s\n", buffer); - ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1); + ICUNIT_ASSERT_NOT_EQUAL(buffer, NULL, -1); setlocale(LC_ALL, "C"); return LOS_OK; diff --git a/testsuites/unittest/libc/io/full/IO_test_nl_langinfo_001.cpp b/testsuites/unittest/libc/io/full/IO_test_nl_langinfo_001.cpp index b33fb2ff..f843a728 100644 --- a/testsuites/unittest/libc/io/full/IO_test_nl_langinfo_001.cpp +++ b/testsuites/unittest/libc/io/full/IO_test_nl_langinfo_001.cpp @@ -89,7 +89,7 @@ static UINT32 testcase(VOID) printf("%s\n", nl_langinfo(CRNCYSTR)); char *string = nl_langinfo(CRNCYSTR); - ICUNIT_ASSERT_NOT_EQUAL_NULL(string, NULL, string); + ICUNIT_ASSERT_NOT_EQUAL(string, NULL, string); setlocale(LC_ALL, "C"); return LOS_OK; diff --git a/testsuites/unittest/libc/io/full/IO_test_nl_langinfo_l_001.cpp b/testsuites/unittest/libc/io/full/IO_test_nl_langinfo_l_001.cpp index a7c35710..f954de3c 100644 --- a/testsuites/unittest/libc/io/full/IO_test_nl_langinfo_l_001.cpp +++ b/testsuites/unittest/libc/io/full/IO_test_nl_langinfo_l_001.cpp @@ -57,7 +57,7 @@ static UINT32 testcase(VOID) { printf("%s\n", nl_langinfo_l(RADIXCHAR, reinterpret_cast(const_cast("zh_CN.UTF-8")))); char *string = nl_langinfo_l(CRNCYSTR, reinterpret_cast(const_cast("zh_CN.UTF-8"))); - ICUNIT_ASSERT_NOT_EQUAL_NULL(string, NULL, string); + ICUNIT_ASSERT_NOT_EQUAL(string, NULL, string); setlocale(LC_ALL, "C"); return LOS_OK; diff --git a/testsuites/unittest/libc/io/full/It_stdio_hasmntopt_001.cpp b/testsuites/unittest/libc/io/full/It_stdio_hasmntopt_001.cpp index 904b5853..a0d605b6 100644 --- a/testsuites/unittest/libc/io/full/It_stdio_hasmntopt_001.cpp +++ b/testsuites/unittest/libc/io/full/It_stdio_hasmntopt_001.cpp @@ -77,7 +77,7 @@ static UINT32 testcase(VOID) if (mnt && !(feof(fp) || ferror(fp))) { ret = hasmntopt(mnt, opt); printf("hasmntopt=%s\n", ret); - ICUNIT_ASSERT_NOT_EQUAL_NULL(ret, NULL, -1); + ICUNIT_ASSERT_NOT_EQUAL(ret, NULL, -1); mnt = getmntent(fp); } diff --git a/testsuites/unittest/process/basic/process/full/process_test_049.cpp b/testsuites/unittest/process/basic/process/full/process_test_049.cpp index 740352ee..70d38ea3 100644 --- a/testsuites/unittest/process/basic/process/full/process_test_049.cpp +++ b/testsuites/unittest/process/basic/process/full/process_test_049.cpp @@ -45,11 +45,11 @@ static int TestThread(void *arg) int ret = 0; pthread_t gTh; ret = pthread_create(&gTh, NULL, PthreadTest115, NULL); - ICUNIT_ASSERT_EQUAL_NULL(ret, 0, ret); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); ret = pthread_join(gTh, NULL); - ICUNIT_ASSERT_EQUAL_NULL(ret, 0, ret); - ICUNIT_ASSERT_EQUAL_NULL(g_usetTestCount, 1, g_usetTestCount); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ICUNIT_ASSERT_EQUAL(g_usetTestCount, 1, g_usetTestCount); *g_shmptr = 100; // 100, set shared num. @@ -66,11 +66,11 @@ static int TestThread(void *arg) ret = waitpid(pid, NULL, 0); printf("waitpid ret : %d errno : %d pid : %d getpid : %d\n", ret, errno, pid, getpid()); - ICUNIT_ASSERT_EQUAL_NULL(ret, pid, ret); + ICUNIT_ASSERT_EQUAL(ret, pid, ret); *g_shmptr = data; EXIT: - return NULL; + return 0; } // This testcase us used for undefination of LOSCFG_USER_TEST_SMP @@ -100,7 +100,7 @@ static int Testcase(void) ICUNIT_GOTO_EQUAL(*g_shmptr, arg, *g_shmptr, EXIT2); - ret = waitpid(pid, &status, NULL); + ret = waitpid(pid, &status, 0); ICUNIT_GOTO_EQUAL(ret, pid, ret, EXIT2); EXIT2: diff --git a/testsuites/unittest/process/basic/process/full/process_test_050.cpp b/testsuites/unittest/process/basic/process/full/process_test_050.cpp index 720cde9c..51da4d6e 100644 --- a/testsuites/unittest/process/basic/process/full/process_test_050.cpp +++ b/testsuites/unittest/process/basic/process/full/process_test_050.cpp @@ -39,10 +39,10 @@ static int TestThread(void *arg) printf("TestThread ppid : %d g_ppid : %d\n", ppid, g_ppid); - ICUNIT_ASSERT_EQUAL_NULL(ppid, g_ppid, g_ppid); + ICUNIT_ASSERT_EQUAL(ppid, g_ppid, g_ppid); *g_shmptr = 100; // 100, set shared num. - return NULL; + return 0; } // This testcase us used for undefination of LOSCFG_USER_TEST_SMP @@ -55,7 +55,7 @@ static int Testcase(void) int ret; int count; pid_t pid; - + int shmid = shmget(IPC_PRIVATE, sizeof(int), IPC_CREAT | 0600); // 0600 config of shmget ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid); @@ -73,7 +73,7 @@ static int Testcase(void) stackTop = reinterpret_cast(reinterpret_cast(stack) + arg); pid = clone(TestThread, (void *)stackTop, CLONE_PARENT, &arg); - ret = waitpid(pid, &status, NULL); + ret = waitpid(pid, &status, 0); ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2); count = 0; diff --git a/testsuites/unittest/process/basic/process/full/process_test_051.cpp b/testsuites/unittest/process/basic/process/full/process_test_051.cpp index 2e29096a..e46eacf6 100644 --- a/testsuites/unittest/process/basic/process/full/process_test_051.cpp +++ b/testsuites/unittest/process/basic/process/full/process_test_051.cpp @@ -41,7 +41,7 @@ static int TestThread(void *arg) printf("TestThread ppid : %d g_ppid : %d\n", ppid, g_ppid); - ICUNIT_ASSERT_EQUAL_NULL(ppid, g_ppid, g_ppid); + ICUNIT_ASSERT_EQUAL(ppid, g_ppid, g_ppid); *g_shmptr = 1000; // 1000, set shared num. @@ -54,11 +54,11 @@ static int TestThread(void *arg) } ret = waitpid(pid, NULL, 0); - ICUNIT_ASSERT_EQUAL_NULL(ret, pid, ret); + ICUNIT_ASSERT_EQUAL(ret, pid, ret); *g_shmptr = 100; // 100, set shared num. EXIT: - return NULL; + return 0; } // This testcase us used for undefination of LOSCFG_USER_TEST_SMP @@ -70,7 +70,7 @@ static int Testcase(void) void *stack; char *stackTop; int ret; - + int shmid = shmget(IPC_PRIVATE, sizeof(int), IPC_CREAT | 0600); // 0600 config of shmget ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid); @@ -90,7 +90,7 @@ static int Testcase(void) ICUNIT_GOTO_EQUAL(*g_shmptr, 100, *g_shmptr, EXIT2); // 100, assert g_shmptr equal to this. - ret = waitpid(pid, &status, NULL); + ret = waitpid(pid, &status, 0); ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2); EXIT2: diff --git a/testsuites/unittest/process/basic/process/smoke/process_test_010.cpp b/testsuites/unittest/process/basic/process/smoke/process_test_010.cpp index d8fc46e5..7c5c4843 100644 --- a/testsuites/unittest/process/basic/process/smoke/process_test_010.cpp +++ b/testsuites/unittest/process/basic/process/smoke/process_test_010.cpp @@ -105,7 +105,7 @@ static int Testcase(void) exit(Child()); } else if (ret > 0) { pid = ret; - ret = waitpid(pid, &status, NULL); + ret = waitpid(pid, &status, 0); status = WEXITSTATUS(status); ICUNIT_ASSERT_EQUAL(ret, pid, ret); ICUNIT_ASSERT_EQUAL(status, 0, status); diff --git a/testsuites/unittest/process/basic/pthread/smoke/pthread_test_012.cpp b/testsuites/unittest/process/basic/pthread/smoke/pthread_test_012.cpp index f89b31d4..f33e7672 100644 --- a/testsuites/unittest/process/basic/pthread/smoke/pthread_test_012.cpp +++ b/testsuites/unittest/process/basic/pthread/smoke/pthread_test_012.cpp @@ -33,7 +33,7 @@ static int Testcase(void) { int ret; - ret = Syscall(SYS_set_thread_area, NULL, 0, 0, 0); + ret = Syscall(SYS_set_thread_area, 0x0, 0, 0, 0); ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret); ret = Syscall(SYS_set_thread_area, 0x100, 0, 0, 0); -- GitLab