From 8c0b7d0f382cf0dff57ccb608e82931207f7c624 Mon Sep 17 00:00:00 2001 From: xiacong Date: Wed, 28 Sep 2022 16:42:13 +0800 Subject: [PATCH] =?UTF-8?q?=20=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E4=B8=8D=E8=BF=87=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.修复执行liteos_a_basic_unittest.bin时间过长的问题 2.修复测试shm系列系统调用函数用例失败的问题 Signed-off-by: xiacong Change-Id: Iabc541cb1c0e97dac0fe13aaeb98e85404e5bf6f Signed-off-by: xiacong --- .../unittest/basic/exc/smoke/it_test_exc_001.cpp | 3 +++ .../unittest/basic/exc/smoke/it_test_exc_004.cpp | 3 +++ .../unittest/basic/mem/shm/full/shm_test_002.cpp | 16 +++++++++++----- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/testsuites/unittest/basic/exc/smoke/it_test_exc_001.cpp b/testsuites/unittest/basic/exc/smoke/it_test_exc_001.cpp index 26512427..c86223f8 100644 --- a/testsuites/unittest/basic/exc/smoke/it_test_exc_001.cpp +++ b/testsuites/unittest/basic/exc/smoke/it_test_exc_001.cpp @@ -34,9 +34,11 @@ static int TestCase(void) { int ret; int status = 0; + int *test = NULL; // for trggering an exception pid_t pid = fork(); ICUNIT_ASSERT_WITHIN_EQUAL(pid, 0, INVALID_PROCESS_ID, pid); if (pid == 0) { + *test = 0x1; // Deliberately trigger an exceptioin exit(0); } @@ -52,6 +54,7 @@ static int TestCase(void) pid = fork(); ICUNIT_ASSERT_WITHIN_EQUAL(pid, 0, INVALID_PROCESS_ID, pid); if (pid == 0) { + *test = 0x1; // Deliberately trigger an exceptioin exit(0); } diff --git a/testsuites/unittest/basic/exc/smoke/it_test_exc_004.cpp b/testsuites/unittest/basic/exc/smoke/it_test_exc_004.cpp index 3299fefa..21c5d5fd 100644 --- a/testsuites/unittest/basic/exc/smoke/it_test_exc_004.cpp +++ b/testsuites/unittest/basic/exc/smoke/it_test_exc_004.cpp @@ -36,13 +36,16 @@ static int TestThread(void) { int ret; + int *test = nullptr; // For triggering an exceptioin pid_t pid = fork(); ICUNIT_ASSERT_WITHIN_EQUAL(pid, 0, INVALID_PROCESS_ID, pid); if (pid == 0) { + *test = 0x1; // Deliberately trigger an exceptioin while (1) { } } + *test = 0x1; // Deliberately trigger an exceptioin ret = waitpid(pid, NULL, 0); ICUNIT_ASSERT_EQUAL(ret, pid, ret); diff --git a/testsuites/unittest/basic/mem/shm/full/shm_test_002.cpp b/testsuites/unittest/basic/mem/shm/full/shm_test_002.cpp index c624257f..7740e758 100644 --- a/testsuites/unittest/basic/mem/shm/full/shm_test_002.cpp +++ b/testsuites/unittest/basic/mem/shm/full/shm_test_002.cpp @@ -37,6 +37,12 @@ static int Testcase(VOID) int shmid[SHMID_MAX + 1] = {-1}; int ret; int i; + struct shm_info shmInfo; + int leftShmIds; + + ret = shmctl(0, SHM_INFO, reinterpret_cast(&shmInfo)); + ICUNIT_ASSERT_EQUAL(ret, SHMID_MAX, ret); + leftShmIds = SHMID_MAX - shmInfo.used_ids; shmid[0] = shmget((key_t)0x1234, PAGE_SIZE, 0777 | IPC_CREAT); ICUNIT_ASSERT_NOT_EQUAL(shmid[0], -1, shmid[0]); @@ -50,20 +56,20 @@ static int Testcase(VOID) ret = shmctl(shmid[0], IPC_RMID, NULL); ICUNIT_ASSERT_EQUAL(ret, 0, ret); - for (i = 0; i < SHMID_MAX; i++) { + for (i = 0; i < leftShmIds; i++) { shmid[i] = shmget(IPC_PRIVATE, PAGE_SIZE, 0777 | IPC_CREAT); ICUNIT_ASSERT_NOT_EQUAL(shmid[i], -1, shmid[i]); } - shmid[SHMID_MAX] = shmget(IPC_PRIVATE, PAGE_SIZE, 0777 | IPC_CREAT); - ICUNIT_ASSERT_EQUAL(shmid[SHMID_MAX], -1, shmid[SHMID_MAX]); + shmid[leftShmIds] = shmget(IPC_PRIVATE, PAGE_SIZE, 0777 | IPC_CREAT); + ICUNIT_ASSERT_EQUAL(shmid[leftShmIds], -1, shmid[leftShmIds]); - for (i = 0; i < SHMID_MAX; i++) { + for (i = 0; i < leftShmIds; i++) { ret = shmctl(shmid[i], IPC_RMID, NULL); ICUNIT_ASSERT_EQUAL(ret, 0, ret); } - for (i = 0; i < SHMID_MAX; i++) { + for (i = 0; i < leftShmIds; i++) { ret = shmctl(shmid[i], IPC_RMID, NULL); ICUNIT_ASSERT_EQUAL(ret, -1, ret); } -- GitLab