refactor: 内核测试套整改,简化分类

close: #I4OX3O
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>

Change-Id: I3ba65509135cee2ae3af82fec923a01e00ffdbe8
This commit is contained in:
arvinzzz
2022-01-14 11:50:31 +08:00
parent d6dc0642c5
commit a1ae2ecc13
2402 changed files with 225539 additions and 1054 deletions

View File

@@ -0,0 +1,52 @@
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_a/testsuites/unittest/config.gni")
mem_shm_include_dirs = [ "$TEST_UNITTEST_DIR/basic/mem/shm" ]
mem_shm_sources_entry = [ "$TEST_UNITTEST_DIR/basic/mem/shm/mem_shm_test.cpp" ]
mem_shm_sources_smoke =
[ "$TEST_UNITTEST_DIR/basic/mem/shm/smoke/shm_test_011.cpp" ]
mem_shm_sources_full = [
"$TEST_UNITTEST_DIR/basic/mem/shm/full/shm_test_001.cpp",
"$TEST_UNITTEST_DIR/basic/mem/shm/full/shm_test_002.cpp",
"$TEST_UNITTEST_DIR/basic/mem/shm/full/shm_test_003.cpp",
"$TEST_UNITTEST_DIR/basic/mem/shm/full/shm_test_004.cpp",
"$TEST_UNITTEST_DIR/basic/mem/shm/full/shm_test_005.cpp",
"$TEST_UNITTEST_DIR/basic/mem/shm/full/shm_test_006.cpp",
"$TEST_UNITTEST_DIR/basic/mem/shm/full/shm_test_007.cpp",
"$TEST_UNITTEST_DIR/basic/mem/shm/full/shm_test_008.cpp",
"$TEST_UNITTEST_DIR/basic/mem/shm/full/shm_test_009.cpp",
"$TEST_UNITTEST_DIR/basic/mem/shm/full/shm_test_010.cpp",
"$TEST_UNITTEST_DIR/basic/mem/shm/full/shm_test_012.cpp",
"$TEST_UNITTEST_DIR/basic/mem/shm/full/shm_test_013.cpp",
"$TEST_UNITTEST_DIR/basic/mem/shm/full/shm_test_014.cpp",
]

View File

@@ -0,0 +1,60 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "it_test_shm.h"
#include "wchar.h"
#define TEST_STR "abcdefghijk"
static int TestCase(void)
{
int flag;
wchar_t res[] = L"abcd";
wchar_t res1[] = L"mngh";
wchar_t res2[] = L"abcdmngh";
wchar_t *p, *pnew;
pnew = (wchar_t*)malloc(sizeof(wchar_t) * (wcslen(res) + wcslen(res1)));
p = wmempcpy(pnew, res, wcslen(res));
wmempcpy(p, res1, wcslen(res1));
flag = wmemcmp(pnew, res2, wcslen(res));
p = nullptr;
pnew = nullptr;
free(pnew);
ICUNIT_ASSERT_EQUAL(flag, 0, flag);
return 0;
}
void ItTestMem100(void)
{
TEST_ADD_CASE("it_test_mem_100", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
}

View File

@@ -0,0 +1,169 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "it_test_shm.h"
#include "pthread.h"
#define TEXT_SZ 8
static int g_threadCount = 0;
struct shared_use_st {
int written;
char text[TEXT_SZ];
};
VOID *ShmReadFunc(VOID *ptr)
{
void *shm = nullptr;
struct shared_use_st *shared = nullptr;
int shmid;
int ret;
shmid = shmget((key_t)1234, sizeof(struct shared_use_st), 0666 | IPC_CREAT);
ICUNIT_ASSERT_NOT_EQUAL_NULL_VOID(shmid, -1, shmid);
shm = shmat(shmid, 0, 0);
ICUNIT_ASSERT_NOT_EQUAL_NULL_VOID(shm, INVALID_PTR, shm);
printf("Memory attached at %p\n", shm);
shared = (struct shared_use_st *)shm;
while (1) {
if (shared->written == 1) {
printf("You wrote: %s\n", shared->text);
sleep(1);
shared->written = 0;
if (strncmp(shared->text, "end", 3) == 0) {
break;
}
} else {
sleep(1);
}
}
ret = shmdt(shm);
ICUNIT_ASSERT_EQUAL_NULL_VOID(ret, 0, ret);
ret = shmctl(shmid, IPC_RMID, 0);
ICUNIT_ASSERT_EQUAL_NULL_VOID(ret, 0, ret);
g_threadCount++;
return nullptr;
}
VOID *ShmWriteFunc(VOID *ptr)
{
void *shm = nullptr;
struct shared_use_st *shared = nullptr;
char buffer[BUFSIZ + 1] = {'\0'};
int shmid;
int ret;
static int count = 0;
shmid = shmget((key_t)1234, sizeof(struct shared_use_st), 0666 | IPC_CREAT);
ICUNIT_ASSERT_NOT_EQUAL_NULL_VOID(shmid, -1, shmid);
shm = shmat(shmid, (void *)0, 0);
ICUNIT_ASSERT_NOT_EQUAL_NULL_VOID(shm, INVALID_PTR, shm);
printf("Memory attched at %p\n", shm);
shared = (struct shared_use_st *)shm;
while (1) {
while (shared->written == 1) {
sleep(1);
printf("%s %d, Waiting...\n", __FUNCTION__, __LINE__);
}
printf("Enter some text: ");
if (count == 0) {
(void)snprintf_s(buffer, BUFSIZ, BUFSIZ + 1, "test");
} else {
(void)snprintf_s(buffer, BUFSIZ, BUFSIZ + 1, "end");
}
count++;
(void)strncpy_s(shared->text, TEXT_SZ, buffer, TEXT_SZ - 1);
shared->written = 1;
if (strncmp(buffer, "end", 3) == 0) {
break;
}
}
ret = shmdt(shm);
ICUNIT_ASSERT_EQUAL_NULL_VOID(ret, 0, ret);
sleep(1);
g_threadCount++;
return nullptr;
}
static int Testcase(VOID)
{
pthread_t newPthread[2];
int curThreadPri, curThreadPolicy;
pthread_attr_t a = { 0 };
struct sched_param param = { 0 };
int ret;
int i, j;
g_threadCount = 0;
ret = pthread_getschedparam(pthread_self(), &curThreadPolicy, &param);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
curThreadPri = param.sched_priority;
ret = pthread_attr_init(&a);
param.sched_priority = curThreadPri;
pthread_attr_setschedparam(&a, &param);
ret = pthread_create(&newPthread[0], &a, ShmReadFunc, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_create(&newPthread[1], &a, ShmWriteFunc, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_join(newPthread[0], nullptr);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_join(newPthread[1], nullptr);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ICUNIT_ASSERT_EQUAL(g_threadCount, 2, g_threadCount);
return 0;
}
void ItTestShm001(void)
{
TEST_ADD_CASE("IT_MEM_SHM_001", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
}

View File

@@ -0,0 +1,77 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "it_test_shm.h"
#define SHMID_MAX 192
static int Testcase(VOID)
{
int shmid[SHMID_MAX + 1] = {-1};
int ret;
int i;
shmid[0] = shmget((key_t)0x1234, PAGE_SIZE, 0777 | IPC_CREAT);
ICUNIT_ASSERT_NOT_EQUAL(shmid[0], -1, shmid[0]);
ret = shmctl(shmid[0], IPC_RMID, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
shmid[0] = shmget(IPC_PRIVATE, PAGE_SIZE, 0777 | IPC_CREAT);
ICUNIT_ASSERT_NOT_EQUAL(shmid[0], -1, shmid[0]);
ret = shmctl(shmid[0], IPC_RMID, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
for (i = 0; i < SHMID_MAX; 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]);
for (i = 0; i < SHMID_MAX; i++) {
ret = shmctl(shmid[i], IPC_RMID, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
}
for (i = 0; i < SHMID_MAX; i++) {
ret = shmctl(shmid[i], IPC_RMID, NULL);
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
}
return 0;
}
void ItTestShm002(void)
{
TEST_ADD_CASE("IT_MEM_SHM_002", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
}

View File

@@ -0,0 +1,82 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "it_test_shm.h"
static int Testcase(VOID)
{
int shmid;
int ret;
void *shm = NULL;
void *vaddrPageAlign = NULL;
void *vaddr = NULL;
shmid = shmget(IPC_PRIVATE, PAGE_SIZE, 0777 | IPC_CREAT);
ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
shm = shmat(shmid, NULL, 0);
ICUNIT_ASSERT_NOT_EQUAL(shm, INVALID_PTR, shm);
(void)memset_s(shm, PAGE_SIZE, 0, PAGE_SIZE);
ret = shmdt(shm);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
vaddrPageAlign = mmap(NULL, PAGE_SIZE * 2, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
ICUNIT_ASSERT_NOT_EQUAL(vaddrPageAlign, NULL, vaddrPageAlign);
ret = munmap(vaddrPageAlign, PAGE_SIZE * 2);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
shm = shmat(shmid, vaddrPageAlign, 0);
ICUNIT_ASSERT_EQUAL(shm, vaddrPageAlign, shm);
(void)memset_s(shm, PAGE_SIZE, 0, PAGE_SIZE);
ret = shmdt(shm);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
vaddr = (void *)((uintptr_t)vaddrPageAlign + 0x10);
shm = shmat(shmid, vaddr, SHM_REMAP);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
shm = shmat(shmid, vaddr, 0);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
ret = shmctl(shmid, IPC_RMID, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
return 0;
}
void ItTestShm003(void)
{
TEST_ADD_CASE("IT_MEM_SHM_003", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
}

View File

@@ -0,0 +1,92 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "it_test_shm.h"
static int Testcase(VOID)
{
int shmid;
int ret;
void *shm = NULL;
struct shmid_ds ds = { 0 };
struct shminfo info = { 0 };
shmid = shmget(IPC_PRIVATE, PAGE_SIZE, 0777 | IPC_CREAT);
ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
shm = shmat(shmid, NULL, 0);
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_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_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_GOTO_EQUAL(ret, 0, ret, ERROR_OUT);
ret = shmctl(shmid, IPC_INFO, (struct shmid_ds *)&info);
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_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)
{
TEST_ADD_CASE("IT_MEM_SHM_004", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
}

View File

@@ -0,0 +1,81 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "it_test_shm.h"
static int Testcase(VOID)
{
int shmid;
int ret;
void *shm = NULL;
void *vaddrPageAlign = NULL;
void *vaddr = NULL;
errno = 0;
shmid = shmget(0x111, PAGE_SIZE, 0777 | IPC_EXCL);
ICUNIT_ASSERT_EQUAL(shmid, -1, shmid);
ICUNIT_ASSERT_EQUAL(errno, ENOENT, errno);
shmid = shmget(IPC_PRIVATE, PAGE_SIZE, 0777 | IPC_CREAT);
ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
shm = shmat(shmid, NULL, SHM_REMAP);
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
shm = shmat(shmid, (const void *)0x100, 0);
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
shm = shmat(shmid, NULL, 0);
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);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
ret = shmctl(0x111, IPC_RMID, NULL);
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
ret = shmctl(shmid, IPC_RMID, NULL);
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;
}
void ItTestShm005(void)
{
TEST_ADD_CASE("IT_MEM_SHM_005", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
}

View File

@@ -0,0 +1,66 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "it_test_shm.h"
static int Testcase(VOID)
{
const int memSize = PAGE_SIZE;
int ret;
int shmid;
void *shared = NULL;
void *remap = NULL;
shmid = shmget(IPC_PRIVATE, memSize, 0666 | IPC_CREAT);
ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
shared = shmat(shmid, 0, 0);
ICUNIT_ASSERT_NOT_EQUAL(shared, (void *)-1, shared);
ret = shmdt(shared);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
remap = shared;
shared = shmat(shmid, remap, SHM_REMAP);
ICUNIT_ASSERT_NOT_EQUAL(shared, (void *)-1, shared);
ret = shmdt(shared);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
ret = shmctl(shmid, IPC_RMID, NULL);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
return 0;
}
void ItTestShm006(void)
{
TEST_ADD_CASE("IT_MEM_SHM_006", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
}

View File

@@ -0,0 +1,97 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "it_test_shm.h"
#include "sys/types.h"
static int Testcase(void)
{
const int memSize = 1024;
int shmid;
char *shared = NULL;
char testStr[] = "hello shmem";
pid_t pid;
int ret;
int status;
shmid = shmget((key_t)1234, memSize, 0666 | IPC_CREAT);
ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
ret = fork();
if (ret == 0) {
usleep(100000);
if ((shared = (char *)shmat(shmid, 0, 0)) == (void *)-1) {
printf("child : error: shmat()\n");
exit(1);
}
if (strncmp(shared, testStr, sizeof(testStr)) != 0) {
printf("child : error strncmp() shared = %s\n", shared);
exit(1);
}
if ((shmdt(shared)) < 0) {
printf("child : error : shmdt()\n");
exit(1);
}
if (shmctl(shmid, IPC_RMID, NULL) == -1) {
printf("child : error : shmctl()\n");
exit(1);
}
exit(0);
} else {
pid = ret;
usleep(50000);
shared = (char *)shmat(shmid, 0, 0);
ICUNIT_ASSERT_NOT_EQUAL(shared, (void *)-1, shared);
ret = strncpy_s(shared, memSize, testStr, sizeof(testStr));
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = shmdt(shared);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
usleep(100000);
ret = wait(&status);
status = WEXITSTATUS(status);
ICUNIT_ASSERT_EQUAL(ret, pid, ret);
ICUNIT_ASSERT_EQUAL(status, 0, status);
}
return 0;
}
void ItTestShm007(void)
{
TEST_ADD_CASE("IT_MEM_SHM_007", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "it_test_shm.h"
#include "sys/types.h"
static int Testcase(void)
{
const int memSize = PAGE_SIZE;
int ret;
int shmid;
void *shared = NULL;
shmid = shmget(IPC_PRIVATE, memSize, SHM_R | IPC_CREAT);
ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
shared = shmat(shmid, 0, 0);
ICUNIT_ASSERT_EQUAL(shared, (void *)-1, shared);
ICUNIT_ASSERT_EQUAL(errno, EACCES, errno);
shared = shmat(shmid, 0, SHM_RDONLY);
ICUNIT_ASSERT_NOT_EQUAL(shared, (void *)-1, shared);
ret = shmdt(shared);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
ret = shmctl(shmid, IPC_RMID, NULL);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
return 0;
}
void ItTestShm008(void)
{
TEST_ADD_CASE("IT_MEM_SHM_008", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
}

View File

@@ -0,0 +1,159 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "it_test_shm.h"
#include "sys/types.h"
#include <sched.h>
#include <stdio.h>
#include <signal.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
static int *g_shmptr = NULL;
static void ChildProcess(void)
{
struct sched_param param;
param.sched_priority = sched_get_priority_max(SCHED_RR);
if(sched_setparam(getpid(), &param) != 0) {
printf("An error occurs when calling sched_setparam()");
return;
}
/* to avoid blocking */
alarm(2);
while(1);
}
static void TestProcess(void)
{
/* to avoid blocking */
alarm(5);
while(1) {
(*g_shmptr)++;
sched_yield();
}
}
static void ExitChildren(int sig)
{
exit(0);
}
static void KillChildren(int childPid)
{
kill(childPid, SIGTERM);
sleep(1); //wait for kill child finish.
}
static int Testcase(void)
{
int childPid, oldcount, newcount, shmid;
struct sched_param param = {0};
struct sched_param paramCopy = {0};
int processPolicy = 0;
int threadPrio = 0;
int ret;
int pid;
void *ptr = (void *)signal(SIGTERM, ExitChildren);
ICUNIT_ASSERT_NOT_EQUAL(ptr, NULL, ptr);
shmid = shmget(IPC_PRIVATE, sizeof(int), IPC_CREAT | 0600);
ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
g_shmptr = (int *)shmat(shmid, 0, 0);
ICUNIT_ASSERT_NOT_EQUAL(g_shmptr, (int *)-1, g_shmptr);
*g_shmptr = 0;
processPolicy = sched_getscheduler(getpid());
ret = sched_getparam(getpid(), &paramCopy);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
param.sched_priority = (sched_get_priority_min(SCHED_RR) +
sched_get_priority_max(SCHED_RR)) / 2;
ret = sched_setscheduler(getpid(), SCHED_RR, &param);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_getschedparam(pthread_self(), &processPolicy, &param);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
threadPrio = param.sched_priority;
ret = pthread_setschedparam(pthread_self(), SCHED_FIFO, &param);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
childPid = fork();
ICUNIT_GOTO_NOT_EQUAL(childPid, -1, childPid, OUT_SCHEDULER);
if (childPid == 0) {
TestProcess();
exit(0);
}
sleep(1);
param.sched_priority = sched_get_priority_min(SCHED_RR);
oldcount = *g_shmptr;
ret = sched_setparam(childPid, &param);
ICUNIT_GOTO_EQUAL(ret, 0, ret, OUT_SCHEDULER);
ret = 1;
newcount = *g_shmptr;
ICUNIT_GOTO_NOT_EQUAL(oldcount, newcount, newcount, OUT);
ret = 0;
OUT:
KillChildren(childPid);
pid = waitpid(childPid, NULL, 0);
ICUNIT_ASSERT_EQUAL(pid, childPid, pid);
(void)sched_setparam(getpid(), &paramCopy);
OUT_SCHEDULER:
(void)sched_setscheduler(getpid(), processPolicy, &paramCopy);
param.sched_priority = threadPrio;
pthread_setschedparam(pthread_self(), SCHED_RR, &param);
ret = shmdt(g_shmptr);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
ret = shmctl(shmid, IPC_RMID, NULL);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
return ret;
}
void ItTestShm009(void)
{
TEST_ADD_CASE("IT_MEM_SHM_009", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
}

View File

@@ -0,0 +1,70 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "it_test_shm.h"
#include "sys/types.h"
static int Testcase(void)
{
const int memSize = 1024;
int shmid;
int ret;
int status;
ret = fork();
if (ret == 0) {
usleep(10000);
shmid = shmget((key_t)1234, memSize, 0666 | IPC_CREAT);
if (shmid < 0) {
if (errno == EACCES) {
exit(1);
}
}
exit(0);
} else {
shmid = shmget((key_t)1234, memSize, 0000 | IPC_CREAT);
ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
usleep(20000);
ret = shmctl(shmid, IPC_RMID, NULL);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
wait(&status);
status = WEXITSTATUS(status);
ICUNIT_ASSERT_EQUAL(status, 1, status);
}
return 0;
}
void ItTestShm010(void)
{
TEST_ADD_CASE("IT_MEM_SHM_010", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
}

View File

@@ -0,0 +1,78 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "it_test_shm.h"
#include "sys/types.h"
#define SHMNAME "shm_ram"
#define OPEN_FLAG (O_RDWR | O_CREAT | O_EXCL)
#define OPEN_MODE 00777
static int Testcase(void)
{
int fd = shm_open(SHMNAME, OPEN_FLAG, OPEN_MODE);
ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd);
errno = 0;
fd = shm_open(SHMNAME, OPEN_FLAG, OPEN_MODE);
ICUNIT_ASSERT_EQUAL(fd, -1, fd);
ICUNIT_ASSERT_EQUAL(errno, EEXIST, errno);
errno = 0;
fd = shm_open("SHM_RAM", O_RDONLY, OPEN_MODE);
ICUNIT_ASSERT_EQUAL(fd, -1, fd);
ICUNIT_ASSERT_EQUAL(errno, ENOENT, errno);
errno = 0;
fd = shm_open("..../1.txt/123", OPEN_FLAG, OPEN_MODE);
ICUNIT_ASSERT_EQUAL(fd, -1, fd);
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
errno = 0;
fd = shm_open("SHM_RAM", OPEN_FLAG, 0);
ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd);
int ret = shm_unlink(SHMNAME);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = shm_unlink("SHM_RAM");
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
errno = 0;
ret = shm_unlink("shm_ram_unlink");
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
ICUNIT_ASSERT_EQUAL(errno, ENOENT, errno);
return 0;
}
void ItTestShm012(void)
{
TEST_ADD_CASE("IT_MEM_SHM_012", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
}

View File

@@ -0,0 +1,69 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "it_test_shm.h"
#include "sys/types.h"
static int testcase(void)
{
int shmfd;
int ret;
int count;
int pageSize = getpagesize();
char *writebuf = NULL;
char *readbuf = NULL;
shmfd = shm_open("test_1", O_RDWR | O_CREAT | O_EXCL, 0644);
ICUNIT_ASSERT_NOT_EQUAL(shmfd, -1, shmfd);
writebuf = (char*)malloc(pageSize);
readbuf = (char*)malloc(pageSize);
ICUNIT_ASSERT_NOT_EQUAL(readbuf, NULL, readbuf);
ICUNIT_ASSERT_NOT_EQUAL(writebuf, NULL, writebuf);
memset_s(writebuf, pageSize, 0xf, pageSize);
count = write(shmfd, writebuf, pageSize);
ICUNIT_ASSERT_EQUAL(count, pageSize, count);
ret = lseek(shmfd, 0, SEEK_SET);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
count = read(shmfd, readbuf, pageSize);
ICUNIT_ASSERT_EQUAL(count, pageSize, count);
free(readbuf);
free(writebuf);
close(shmfd);
ret = shm_unlink("test_1");
return 0;
}
void it_test_shm_013(void)
{
TEST_ADD_CASE("IT_MEM_SHM_013", testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
}

View File

@@ -0,0 +1,91 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "it_test_shm.h"
#include "sys/types.h"
#define SHMNAME "shm_ram"
static int testcase(void)
{
int shmfd;
int ret;
int count;
int pageSize = getpagesize();
char *writebuf = NULL;
char *readbuf = NULL;
errno = 0;
shmfd = shm_open("test_2", O_RDONLY, 00664);
ICUNIT_ASSERT_EQUAL(shmfd, -1, shmfd);
ICUNIT_ASSERT_EQUAL(errno, 2, errno);
shmfd = shm_open("test_2", O_RDONLY | O_CREAT, 00664);
ICUNIT_ASSERT_NOT_EQUAL(shmfd, -1, shmfd);
writebuf = (char*)malloc(pageSize);
ICUNIT_ASSERT_NOT_EQUAL(writebuf, NULL, writebuf);
readbuf = (char*)malloc(pageSize);
ICUNIT_ASSERT_NOT_EQUAL(readbuf, NULL, readbuf);
memset_s(writebuf, pageSize, 0xf, pageSize);
errno = 0;
count = write(shmfd, writebuf, pageSize);
ICUNIT_ASSERT_EQUAL(count, -1, count);
ICUNIT_ASSERT_EQUAL(errno, EACCES, errno);
close(shmfd);
ret = shm_unlink("test_2");
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
shmfd = shm_open("test_3", O_WRONLY | O_CREAT, 00664);
ICUNIT_ASSERT_NOT_EQUAL(shmfd, -1, shmfd);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
errno = 0;
count = write(shmfd, writebuf, pageSize);
ICUNIT_ASSERT_EQUAL(count, pageSize, count);
errno = 0;
count = read(shmfd, readbuf, pageSize);
ICUNIT_ASSERT_EQUAL(count, -1, count);
ICUNIT_ASSERT_EQUAL(errno, EACCES, errno);
free(writebuf);
free(readbuf);
close(shmfd);
ret = shm_unlink("test_3");
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
return 0;
}
void it_test_shm_014(void)
{
TEST_ADD_CASE("IT_MEM_SHM_014", testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _IT_TEST_MEM_SHM_H
#define _IT_TEST_MEM_SHM_H
#include "osTest.h"
#include "sys/shm.h"
#define INVALID_PTR ((void *)-1)
extern void ItTestShm001(void);
extern void ItTestShm002(void);
extern void ItTestShm003(void);
extern void ItTestShm004(void);
extern void ItTestShm005(void);
extern void ItTestShm006(void);
extern void ItTestShm007(void);
extern void ItTestShm008(void);
extern void ItTestShm009(void);
extern void ItTestShm010(void);
extern void ItTestShm011(void);
extern void ItTestShm012(void);
extern void it_test_shm_013(void);
extern void it_test_shm_014(void);
extern void ItTestMem100(void);
#endif

View File

@@ -0,0 +1,169 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <climits>
#include <gtest/gtest.h>
#include "it_test_shm.h"
using namespace testing::ext;
namespace OHOS {
class MemShmTest : public testing::Test {
public:
static void SetUpTestCase(void) {}
static void TearDownTestCase(void) {}
};
#if defined(LOSCFG_USER_TEST_FULL)
/* *
* @tc.name: it_test_shm_001
* @tc.desc: function for MemShmTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(MemShmTest, ItTestShm001, TestSize.Level0)
{
ItTestShm001();
}
/* *
* @tc.name: it_test_shm_002
* @tc.desc: function for MemShmTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(MemShmTest, ItTestShm002, TestSize.Level0)
{
ItTestShm002();
}
/* *
* @tc.name: it_test_shm_003
* @tc.desc: function for MemShmTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(MemShmTest, ItTestShm003, TestSize.Level0)
{
ItTestShm003();
}
/* *
* @tc.name: it_test_shm_004
* @tc.desc: function for MemShmTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(MemShmTest, ItTestShm004, TestSize.Level0)
{
ItTestShm004();
}
/* *
* @tc.name: it_test_shm_005
* @tc.desc: function for MemShmTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(MemShmTest, ItTestShm005, TestSize.Level0)
{
ItTestShm005();
}
/* *
* @tc.name: it_test_shm_006
* @tc.desc: function for MemShmTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(MemShmTest, ItTestShm006, TestSize.Level0)
{
ItTestShm006();
}
/* *
* @tc.name: it_test_shm_007
* @tc.desc: function for MemShmTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(MemShmTest, ItTestShm007, TestSize.Level0)
{
ItTestShm007();
}
/* *
* @tc.name: it_test_shm_008
* @tc.desc: function for MemShmTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(MemShmTest, ItTestShm008, TestSize.Level0)
{
ItTestShm008();
}
/* *
* @tc.name: it_test_shm_009
* @tc.desc: function for MemShmTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(MemShmTest, ItTestShm009, TestSize.Level0)
{
ItTestShm009();
}
/* *
* @tc.name: it_test_shm_010
* @tc.desc: function for MemShmTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
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
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(MemShmTest, ItTestShm011, TestSize.Level0)
{
ItTestShm011();
}
#endif
}
// namespace OHOS

View File

@@ -0,0 +1,79 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "it_test_shm.h"
#include "sys/types.h"
static int Testcase(void)
{
const int memSize = 1024;
int *shared = NULL;
int shmid;
int ret;
int status;
shmid = shmget((key_t)IPC_PRIVATE, memSize, 0666 | IPC_CREAT);
ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
ret = fork();
if (ret == 0) {
shared = (int *)shmat(shmid, NULL, 0);
if (shared == (int *)-1) {
exit(1);
}
*shared = 2;
ret = shmdt(shared);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
exit(0);
} else {
usleep(20000);
shared = (int *)shmat(shmid, NULL, 0);
ICUNIT_ASSERT_NOT_EQUAL(shared, (int *)-1, shared);
ICUNIT_ASSERT_EQUAL(*shared, 2, *shared);
ret = shmdt(shared);
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;
}
void ItTestShm011(void)
{
TEST_ADD_CASE("IT_MEM_SHM_011", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
}