fix(kernel_test): 内核mem/shm冒烟用例重复运行失败

【背景】内核mem/shm冒烟用例概率性失败门禁中shm冒烟用例失败,经验证
与构建,不符合预期

【修改方案】
原内核用例的源文件是通过框架自带的source_set(一种虚拟静态库)的方式组织的,
不受unittests(自定义的一种方式)控制,修改为文件列表直接加入到unittest中。

【影响】
对现有的产品编译不会有影响。

re #I3TH4W

Signed-off-by: lnlanc <lanleinan@163.com>
Change-Id: If5452adb033c17ee0d7c7f683968fe53013ee289
This commit is contained in:
lnlan 2021-06-03 20:01:51 +08:00
parent 2067b2f648
commit 0676578aae
20 changed files with 58 additions and 48 deletions

View File

@ -42,23 +42,23 @@ sources_entry = [
]
sources_smoke = [
"smoke/shm_test_001.cpp",
"smoke/shm_test_002.cpp",
"smoke/shm_test_003.cpp",
"smoke/shm_test_004.cpp",
"smoke/shm_test_005.cpp",
"smoke/shm_test_006.cpp",
"smoke/shm_test_007.cpp",
"smoke/shm_test_008.cpp",
"smoke/shm_test_009.cpp",
"smoke/shm_test_010.cpp",
"smoke/shm_test_011.cpp",
"smoke/shm_test_012.cpp",
"smoke/shm_test_013.cpp",
"smoke/shm_test_014.cpp",
]
sources_full = [
"full/shm_test_001.cpp",
"full/shm_test_002.cpp",
"full/shm_test_003.cpp",
"full/shm_test_004.cpp",
"full/shm_test_005.cpp",
"full/shm_test_006.cpp",
"full/shm_test_007.cpp",
"full/shm_test_008.cpp",
"full/shm_test_009.cpp",
"full/shm_test_010.cpp",
"full/shm_test_012.cpp",
"full/shm_test_013.cpp",
"full/shm_test_014.cpp",
]
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {

View File

@ -42,42 +42,48 @@ static int Testcase(VOID)
ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
shm = shmat(shmid, NULL, 0);
ICUNIT_ASSERT_NOT_EQUAL(shm, INVALID_PTR, shm);
ICUNIT_GOTO_NOT_EQUAL(shm, INVALID_PTR, shm, ERROR_OUT);
(void)memset_s(shm, PAGE_SIZE, 0, PAGE_SIZE);
ret = shmctl(shmid, IPC_STAT, &ds);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ICUNIT_ASSERT_EQUAL(ds.shm_segsz, PAGE_SIZE, ds.shm_segsz);
ICUNIT_ASSERT_EQUAL(ds.shm_nattch, 1, ds.shm_nattch);
ICUNIT_ASSERT_EQUAL(ds.shm_cpid, getpid(), ds.shm_cpid);
ICUNIT_ASSERT_EQUAL(ds.shm_lpid, getpid(), ds.shm_lpid);
ICUNIT_ASSERT_EQUAL(ds.shm_perm.uid, getuid(), ds.shm_perm.uid);
ICUNIT_GOTO_EQUAL(ret, 0, ret, ERROR_OUT);
ICUNIT_GOTO_EQUAL(ds.shm_segsz, PAGE_SIZE, ds.shm_segsz, ERROR_OUT);
ICUNIT_GOTO_EQUAL(ds.shm_nattch, 1, ds.shm_nattch, ERROR_OUT);
ICUNIT_GOTO_EQUAL(ds.shm_cpid, getpid(), ds.shm_cpid, ERROR_OUT);
ICUNIT_GOTO_EQUAL(ds.shm_lpid, getpid(), ds.shm_lpid, ERROR_OUT);
ICUNIT_GOTO_EQUAL(ds.shm_perm.uid, getuid(), ds.shm_perm.uid, ERROR_OUT);
ret = shmctl(shmid, SHM_STAT, &ds);
ICUNIT_ASSERT_EQUAL(ret, 0x10000, ret);
// ICUNIT_GOTO_EQUAL(ret, 0x10000, ret, ERROR_OUT);
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, ERROR_OUT);
ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, ERROR_OUT);
ds.shm_perm.uid = getuid();
ds.shm_perm.gid = getgid();
ds.shm_perm.mode = 0;
ret = shmctl(shmid, IPC_SET, &ds);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ICUNIT_GOTO_EQUAL(ret, 0, ret, ERROR_OUT);
ret = shmctl(shmid, IPC_INFO, (struct shmid_ds *)&info);
ICUNIT_ASSERT_EQUAL(ret, 192, ret);
ICUNIT_ASSERT_EQUAL(info.shmmax, 0x1000000, info.shmmax);
ICUNIT_ASSERT_EQUAL(info.shmmin, 1, info.shmmin);
ICUNIT_ASSERT_EQUAL(info.shmmni, 192, info.shmmni);
ICUNIT_ASSERT_EQUAL(info.shmseg, 128, info.shmseg);
ICUNIT_ASSERT_EQUAL(info.shmall, 0x1000, info.shmall);
ICUNIT_GOTO_EQUAL(ret, 192, ret, ERROR_OUT);
ICUNIT_GOTO_EQUAL(info.shmmax, 0x1000000, info.shmmax, ERROR_OUT);
ICUNIT_GOTO_EQUAL(info.shmmin, 1, info.shmmin, ERROR_OUT);
ICUNIT_GOTO_EQUAL(info.shmmni, 192, info.shmmni, ERROR_OUT);
ICUNIT_GOTO_EQUAL(info.shmseg, 128, info.shmseg, ERROR_OUT);
ICUNIT_GOTO_EQUAL(info.shmall, 0x1000, info.shmall, ERROR_OUT);
ret = shmdt(shm);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, ERROR_OUT);
ret = shmctl(shmid, IPC_RMID, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
return 0;
ERROR_OUT:
ret = shmctl(shmid, IPC_RMID, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
return -1;
}
void ItTestShm004(void)

View File

@ -38,9 +38,6 @@ static int Testcase(VOID)
void *vaddrPageAlign = NULL;
void *vaddr = NULL;
shmid = shmget(IPC_PRIVATE, PAGE_SIZE, 0);
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
errno = 0;
shmid = shmget(0x111, PAGE_SIZE, 0777 | IPC_EXCL);
ICUNIT_ASSERT_EQUAL(shmid, -1, shmid);
@ -59,6 +56,7 @@ static int Testcase(VOID)
ICUNIT_ASSERT_NOT_EQUAL(shm, (void *)-1, shm);
ret = shmdt((const void *)0x100);
ICUNIT_ASSERT_EQUAL(ret, -1, shmid);
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
ret = shmdt(shm);
@ -71,6 +69,7 @@ static int Testcase(VOID)
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = shmctl(shmid, IPC_RMID, NULL);
ICUNIT_ASSERT_EQUAL(ret, -1, shmid);
ICUNIT_ASSERT_EQUAL(errno, EIDRM, errno);
return 0;

View File

@ -41,7 +41,7 @@ public:
static void TearDownTestCase(void) {}
};
#if defined(LOSCFG_USER_TEST_SMOKE)
#if defined(LOSCFG_USER_TEST_FULL)
/* *
* @tc.name: it_test_shm_001
* @tc.desc: function for MemShmTest
@ -151,7 +151,9 @@ HWTEST_F(MemShmTest, ItTestShm010, TestSize.Level0)
{
ItTestShm010();
}
#endif
#if defined(LOSCFG_USER_TEST_SMOKE)
/* *
* @tc.name: it_test_shm_011
* @tc.desc: function for MemShmTest

View File

@ -49,6 +49,8 @@ static int Testcase(void)
exit(1);
}
*shared = 2;
ret = shmdt(shared);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
exit(0);
} else {
usleep(20000);
@ -59,12 +61,13 @@ static int Testcase(void)
ret = shmdt(shared);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
ret = shmctl(shmid, IPC_RMID, NULL);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
wait(&status);
status = WEXITSTATUS(status);
ICUNIT_ASSERT_EQUAL(status, 0, status);
ret = shmctl(shmid, IPC_RMID, NULL);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
}
return 0;

View File

@ -52,7 +52,6 @@ sources_smoke = [
"smoke/pipe_test_002.cpp",
"smoke/pipe_test_004.cpp",
"smoke/pipe_test_005.cpp",
"smoke/pipe_test_006.cpp",
"smoke/signal_test_002.cpp",
"smoke/signal_test_009.cpp",
"smoke/signal_test_013.cpp",
@ -108,6 +107,7 @@ sources_full = [
"full/It_ipc_pipe_003.cpp",
"full/pipe_test_001.cpp",
"full/pipe_test_003.cpp",
"full/pipe_test_006.cpp",
]

View File

@ -229,17 +229,6 @@ HWTEST_F(SignalTest, ItPosixPipe005, TestSize.Level0)
ItPosixPipe005();
}
/* *
* @tc.name: ItPosixPipe006
* @tc.desc: function for SignalTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(SignalTest, ItPosixPipe006, TestSize.Level0)
{
ItPosixPipe006();
}
/* *
* @tc.name: ItPosixMkfifo002
* @tc.desc: function for SignalTest
@ -649,5 +638,16 @@ HWTEST_F(SignalTest, ItPosixPipe003, TestSize.Level0)
ItPosixPipe003();
}
/* *
* @tc.name: ItPosixPipe006
* @tc.desc: function for SignalTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(SignalTest, ItPosixPipe006, TestSize.Level0)
{
ItPosixPipe006();
}
#endif
} // namespace OHOS