提交 0c3dbb4c 编写于 作者: Z zwx1232718

test:xts用例补齐,mem、process、sched、sys部分

Signed-off-by: Nzwx1232718 <zhenghui23@huawei.com>
上级 22702a27
......@@ -34,6 +34,10 @@ static_library("xts_test") {
"io:io_test",
"ipc:ipc_test",
"math:math_test",
"mem:mem_test",
"process:pthread_test",
"sched:sched_test",
"sys:system_test",
]
configs += [ "$LITEOSTOPDIR/testsuites:include" ]
}
# Copyright (c) 2023-2023 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_m/liteos.gni")
static_library("mem_test") {
sources = [
"acts_mem_api_test.c",
"mem_api_test.c",
"xts_mem.c",
]
include_dirs = [
".",
"$LITEOSTOPDIR/testsuites/include",
"$LITEOSTOPDIR/testsuites/unittest/xts",
]
}
/*
* Copyright (c) 2023-2023 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 "xts_mem.h"
LITE_TEST_SUIT(MEM, ActsMemApi, ActsMemApiTestSuite);
static BOOL ActsMemApiTestSuiteSetUp(void)
{
return TRUE;
}
static BOOL ActsMemApiTestSuiteTearDown(void)
{
return TRUE;
}
/**
* @tc.number SUB_KERNEL_NDKAPI_MEM_MEMCHR_0100
* @tc.name test memchr api
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(ActsMemApiTestSuite, testMemchr_0100, Function | MediumTest | Level1) {
char srcStr[] = "this is str a;";
char *pos = (char *)memchr(srcStr, 'a', 14); /* 14, common data for test, no special meaning */
ICUNIT_ASSERT_STRING_EQUAL(pos, (char *)"a;", pos);
return 0;
}
/**
* @tc.number SUB_KERNEL_NDKAPI_MEM_MEMCHR_1000
* @tc.name test memchr api para len not enough
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(ActsMemApiTestSuite, testMemchr_1000, Function | MediumTest | Level1) {
char srcStr[] = "this is str a;";
char *pos = (char *)memchr(srcStr, 'a', 4); /* 4, common data for test, no special meaning */
ICUNIT_ASSERT_EQUAL(pos, 0, pos);
return 0;
}
/**
* @tc.number SUB_KERNEL_NDKAPI_MEM_MEMCHR_1100
* @tc.name test memchr api para c not found
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(ActsMemApiTestSuite, testMemchr_1100, Function | MediumTest | Level1) {
char srcStr[] = "this is str a;";
char *pos = (char *)memchr(srcStr, 'b', 14); /* 14, common data for test, no special meaning */
ICUNIT_ASSERT_EQUAL(pos, 0, pos);
return 0;
}
RUN_TEST_SUITE(ActsMemApiTestSuite);
void ActsMemApiTest(void)
{
RUN_ONE_TESTCASE(testMemchr_0100);
RUN_ONE_TESTCASE(testMemchr_1000);
RUN_ONE_TESTCASE(testMemchr_1100);
}
/*
* Copyright (c) 2023-2023 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 "xts_mem.h"
LITE_TEST_SUIT(MEM, MemApi, MemApiTestSuite);
static BOOL MemApiTestSuiteSetUp(void)
{
return TRUE;
}
static BOOL MemApiTestSuiteTearDown(void)
{
return TRUE;
}
/**
* @tc.number SUB_KERNEL_MEM_MEMSET_0100
* @tc.name memset function set buffer value test
* @tc.desc [C-L*-311]
*/
LITE_TEST_CASE(MemApiTestSuite, testMemset, Function | MediumTest | Level1)
{
char chr = 'A';
int i, len, failure;
len = GetRandom(1024); /* 1024, common data for test, no special meaning */
errno_t err = EOK;
char buf[1024]; /* 1024, common data for test, no special meaning */
err = memset_s(buf, sizeof(buf), chr, len);
ICUNIT_ASSERT_EQUAL(err, 0, err);
failure = 0;
for (i = 0; i < len; i++) {
if (buf[i] != chr) {
failure = 1; /* 1, common data for test, no special meaning */
break;
}
}
ICUNIT_ASSERT_EQUAL(failure, 0, failure);
return 0;
}
/**
* @tc.number SUB_KERNEL_MEM_MEMCPY_0100
* @tc.name memcpy function copy buffer test
* @tc.desc [C-L*-311]
*/
LITE_TEST_CASE(MemApiTestSuite, testMemcpy, Function | MediumTest | Level2)
{
char chr = 'A';
int i, len, failure;
char src[1024]; /* 1024, common data for test, no special meaning */
char dst[1024]; /* 1024, common data for test, no special meaning */
len = GetRandom(1024); /* 1024, common data for test, no special meaning */
for (i = 0; i < len; i++) {
src[i] = chr + i % 26; /* 26, common data for test, no special meaning */
}
errno_t err = memcpy_s(dst, sizeof(dst) / sizeof(dst[0]), src, len);
ICUNIT_ASSERT_EQUAL(err, 0, err);
failure = 0;
for (i = 0; i < len; i++) {
if (dst[i] != src[i]) {
failure = 1; /* 1, common data for test, no special meaning */
break;
}
}
ICUNIT_ASSERT_EQUAL(failure, 0, failure);
return 0;
}
/**
* @tc.number SUB_KERNEL_MEM_MEMMOVE_0100
* @tc.name memmove function move buffer test
* @tc.desc [C-L*-311]
*/
LITE_TEST_CASE(MemApiTestSuite, testMemmove, Function | MediumTest | Level2)
{
char chr = 'A';
char buf[1024]; /* 1024, common data for test, no special meaning */
int i, len, failure;
len = sizeof(buf);
for (i = 0; i < len; i++) {
buf[i] = chr + GetRandom(26); /* 26, common data for test, no special meaning */
}
errno_t err = memmove_s(&buf[0], sizeof(buf) / sizeof(buf[0]), &buf[len / 2], len / 2); /* 2, common data for test, no special meaning */
ICUNIT_ASSERT_EQUAL(err, 0, err);
failure = 0;
for (i = 0; i < len / 2; i++) { /* 2, common data for test, no special meaning */
if (buf[i] != buf[len / 2 + i]) { /* 2, common data for test, no special meaning */
failure = 1; /* 1, common data for test, no special meaning */
break;
}
}
ICUNIT_ASSERT_EQUAL(failure, 0, failure);
return 0;
}
/**
* @tc.number SUB_KERNEL_MEM_MEMMOVE_0200
* @tc.name memmove function overlay move buffer test
* @tc.desc [C-L*-311]
*/
LITE_TEST_CASE(MemApiTestSuite, testMemmoveOverlay, Function | MediumTest | Level3)
{
char chr = 'A';
char buf[1024]; /* 1024, common data for test, no special meaning */
char backup[1024]; /* 1024, common data for test, no special meaning */
int i, len, failure;
len = sizeof(buf);
for (i = 0; i < len; i++) {
buf[i] = chr + GetRandom(26); /* 26, common data for test, no special meaning */
backup[i] = buf[i];
}
errno_t err = memmove_s(&buf[16], sizeof(buf) / sizeof(buf[0]) - 16, &buf[0], len / 2); /* 16, 2, common data for test, no special meaning */
ICUNIT_ASSERT_EQUAL(err, 0, err);
failure = 0;
for (i = 0; i < len / 2; i++) { /* 2, common data for test, no special meaning */
if (buf[i + 16] != backup[i]) { /* 16, common data for test, no special meaning */
failure = 1; /* 1, common data for test, no special meaning */
break;
}
}
ICUNIT_ASSERT_EQUAL(failure, 0, failure);
return 0;
}
/**
* @tc.number SUB_KERNEL_MEM_MEMCMP_0100
* @tc.name memmove function move buffer test
* @tc.desc [C-L*-311]
*/
LITE_TEST_CASE(MemApiTestSuite, testMemcmp, Function | MediumTest | Level2)
{
char orign[8] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88}; /* 8, common data for test, no special meaning */
char lt[8] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x77}; /* 8, common data for test, no special meaning */
char eq[8] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88}; /* 8, common data for test, no special meaning */
char gt[8] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x99}; /* 8, common data for test, no special meaning */
int ret;
int len = sizeof(orign);
ret = memcmp(lt, orign, len);
ICUNIT_ASSERT_WITHIN_EQUAL(ret, INT_MIN, 0, ret);
ret = memcmp(eq, orign, len);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = memcmp(gt, orign, len);
ICUNIT_ASSERT_WITHIN_EQUAL(ret, 0, INT_MAX, ret);
ret = memcmp(gt, orign, 0);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
return 0;
}
RUN_TEST_SUITE(MemApiTestSuite);
void MemApiTest(void)
{
RUN_ONE_TESTCASE(testMemset);
RUN_ONE_TESTCASE(testMemcpy);
RUN_ONE_TESTCASE(testMemmove);
RUN_ONE_TESTCASE(testMemmoveOverlay);
RUN_ONE_TESTCASE(testMemcmp);
}
/*
* Copyright (c) 2023-2023 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 "xts_test.h"
void MemFuncTest(void)
{
ActsMemApiTest();
MemApiTest();
}
\ No newline at end of file
/*
* Copyright (c) 2023-2023 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 XTS_MEM_H
#define XTS_MEM_H
#include "xts_test.h"
#include <unistd.h>
#include <stdio.h>
#include <securec.h>
#include <pthread.h>
#include <time.h>
#include <sys/resource.h>
#include <limits.h>
#endif
\ No newline at end of file
# Copyright (c) 2023-2023 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_m/liteos.gni")
static_library("pthread_test") {
sources = [
"acts_process_api_test.c",
"pthread_attr_test.c",
"pthread_basic_api_test.c",
"pthread_test.c",
]
include_dirs = [
".",
"$LITEOSTOPDIR/testsuites/include",
"$LITEOSTOPDIR/testsuites/unittest/xts",
]
}
/*
* Copyright (c) 2023-2023 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 "pthread_test.h"
LITE_TEST_SUIT(PROCESS, ProcessApi, ProcessApiTestSuite);
static BOOL ProcessApiTestSuiteSetUp(void)
{
return TRUE;
}
static BOOL ProcessApiTestSuiteTearDown(void)
{
return TRUE;
}
static void *ThreadFunc(void* arg)
{
return NULL;
}
/**
* @tc.number SUB_KERNEL_NDKAPI_PROCESS_PTHREAD_SETNAME_NP_1000
* @tc.name test pthread_setname_np api para stringlong
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(ProcessApiTestSuite, testPthreadSetnameNp1000, Function | MediumTest | Level1) {
pthread_t thisThread;
int returnVal = pthread_create(&thisThread, NULL, ThreadFunc, NULL);
returnVal = pthread_setname_np(thisThread, "funcThreadNamelongName");
ICUNIT_ASSERT_NOT_EQUAL(returnVal, 0, returnVal);
ICUNIT_ASSERT_EQUAL(returnVal, ERANGE, returnVal);
return 0;
}
RUN_TEST_SUITE(ProcessApiTestSuite);
void ActsProcessApiTest(void)
{
RUN_ONE_TESTCASE(testPthreadSetnameNp1000);
}
/*
* Copyright (c) 2023-2023 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 "pthread_test.h"
LITE_TEST_SUIT(PROCESS, PthreadAttr, PthreadAttrTestSuite);
static BOOL PthreadAttrTestSuiteSetUp(void)
{
return TRUE;
}
static BOOL PthreadAttrTestSuiteTearDown(void)
{
return TRUE;
}
/**
* @tc.number SUB_KERNEL_PTHREAD_ATTR_SETDETACHSTATE_0100
* @tc.name basic test about pthread_attr_setdetachstate
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(PthreadAttrTestSuite, testPthreadAttrSetdetachstate, Function | MediumTest | Level3)
{
int ret;
pthread_t tid;
pthread_attr_t attr;
int param;
ret = pthread_attr_init(&attr);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_attr_getdetachstate(&attr, &param);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ICUNIT_ASSERT_EQUAL(param, PTHREAD_CREATE_DETACHED, param);
ret = pthread_create(&tid, &attr, ThreadPublic, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_attr_destroy(&attr);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_join(tid, NULL);
ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
ret = pthread_attr_init(&attr);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_attr_getdetachstate(&attr, &param);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ICUNIT_ASSERT_EQUAL(param, PTHREAD_CREATE_JOINABLE, param);
ret = pthread_create(&tid, &attr, ThreadPublic, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_attr_destroy(&attr);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_join(tid, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
return 0;
}
/**
* @tc.number SUB_KERNEL_PTHREAD_ATTR_SETSTACKSIZE_0200
* @tc.name test pthread_attr_setstacksize EINVAL
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(PthreadAttrTestSuite, testPthreadAttrSetstacksizeEINVAL, Function | MediumTest | Level3)
{
int ret;
pthread_attr_t attr;
size_t stackSize;
ret = pthread_attr_init(&attr);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_attr_getstacksize(&attr, &stackSize);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
stackSize = PTHREAD_STACK_MIN - 1; /* 1, common data for test, no special meaning */
ret = pthread_attr_setstacksize(&attr, stackSize);
ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
ret = pthread_attr_destroy(&attr);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
return 0;
}
RUN_TEST_SUITE(PthreadAttrTestSuite);
void PthreadAttrTest(void)
{
RUN_ONE_TESTCASE(testPthreadAttrSetdetachstate);
RUN_ONE_TESTCASE(testPthreadAttrSetstacksizeEINVAL);
}
/*
* Copyright (c) 2023-2023 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 "pthread_test.h"
LITE_TEST_SUIT(PROCESS, PthreadBasicApi, PthreadBasicApiTestSuite);
static BOOL PthreadBasicApiTestSuiteSetUp(void)
{
return TRUE;
}
static BOOL PthreadBasicApiTestSuiteTearDown(void)
{
return TRUE;
}
void *ThreadPthreadCreateBasic(void *arg)
{
char *s = (char*)arg;
ICUNIT_ASSERT_STRING_EQUAL(s, "1234567890 !@#$%^&*()_= ZXCVBNM [];'./>?:\" +-*/qwertyuiopasdfghjklzxcvbnm", s);
return arg;
}
/**
* @tc.number SUB_KERNEL_PTHREAD_CREATE_0100
* @tc.name pthread_create create a thread
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(PthreadBasicApiTestSuite, testPthreadCreateBasic, Function | MediumTest | Level2)
{
int ret;
pthread_t tid;
char str[] = "1234567890 !@#$%^&*()_= ZXCVBNM [];'./>?:\" +-*/qwertyuiopasdfghjklzxcvbnm";
ret = pthread_create(&tid, NULL, ThreadPthreadCreateBasic, (void*)str);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_join(tid, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
return 0;
}
/**
* @tc.number SUB_KERNEL_PTHREAD_JOIN_0200
* @tc.name Test the function of pthread_join to get the return value
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(PthreadBasicApiTestSuite, testJoinReturn, Function | MediumTest | Level3)
{
int ret;
pthread_t tid;
int num = 4; /* 4, common data for test, no special meaning */
void *joinRe = NULL;
ret = pthread_create(&tid, NULL, ThreadPublic, (void*)&num);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_join(tid, &joinRe);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
int *p = (int*)joinRe;
ICUNIT_ASSERT_EQUAL(&num, p, &num);
return 0;
}
/**
* @tc.number SUB_KERNEL_PTHREAD_JOIN_0300
* @tc.name Test the function about pthread_join, but child thread Exited
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(PthreadBasicApiTestSuite, testJoinExited, Function | MediumTest | Level3)
{
int ret;
pthread_t tid;
ret = pthread_create(&tid, NULL, ThreadPublic, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
usleep(50); /* 50, common data for test, no special meaning */
ret = pthread_join(tid, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
return 0;
}
void *ThreadPthreadExitThread(void *arg)
{
pthread_exit(arg);
return NULL;
}
/**
* @tc.number SUB_KERNEL_PTHREAD_EXIT_0100
* @tc.name Test the return function of pthread_exit in the child thread
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(PthreadBasicApiTestSuite, testPthreadExitThread, Function | MediumTest | Level3)
{
int ret;
pthread_t tid;
int num = 4; /* 4, common data for test, no special meaning */
void *joinRe = NULL;
ret = pthread_create(&tid, NULL, ThreadPthreadExitThread, (void*)&num);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_join(tid, &joinRe);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
int *p = (int*)joinRe;
ICUNIT_ASSERT_EQUAL(&num, p, &num);
return 0;
}
void FunPthreadExit(void *arg)
{
pthread_exit(arg);
}
void *ThreadPthreadExitFunction(void *arg)
{
FunPthreadExit(arg);
return NULL;
}
/**
* @tc.number SUB_KERNEL_PTHREAD_EXIT_0200
* @tc.name Test the return function of pthread_exit in the child thread function
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(PthreadBasicApiTestSuite, testPthreadExitFunction, Function | MediumTest | Level3)
{
int ret;
pthread_t tid;
int num = 4; /* 4, common data for test, no special meaning */
void *joinRe = NULL;
ret = pthread_create(&tid, NULL, ThreadPthreadExitFunction, (void*)&num);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_join(tid, &joinRe);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
int *p = (int*)joinRe;
ICUNIT_ASSERT_EQUAL(&num, p, &num);
return 0;
}
/**
* @tc.number SUB_KERNEL_PTHREAD_DETACH_0100
* @tc.name Use pthread_detach to detach child threads
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(PthreadBasicApiTestSuite, testPthreadDetach, Function | MediumTest | Level3)
{
int ret;
pthread_t tid;
ret = pthread_create(&tid, NULL, ThreadPublic, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_detach(tid);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_join(tid, NULL);
ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
return 0;
}
void *ThreadPthreadEqual(void *arg)
{
int ret;
pthread_t *tid = (pthread_t*)arg;
ret = pthread_equal(*tid, pthread_self());
ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
usleep(10); /* 10, common data for test, no special meaning */
return arg;
}
/**
* @tc.number SUB_KERNEL_PTHREAD_EQUAL_0100
* @tc.name Use pthread_equal checks process equality
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(PthreadBasicApiTestSuite, testPthreadEqual, Function | MediumTest | Level3)
{
int ret;
pthread_t tid;
ret = pthread_create(&tid, NULL, ThreadPthreadEqual, (void*)&tid);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_equal(tid, pthread_self());
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = pthread_join(tid, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
return 0;
}
RUN_TEST_SUITE(PthreadBasicApiTestSuite);
void PthreadBasicApiTest(void)
{
RUN_ONE_TESTCASE(testPthreadCreateBasic);
RUN_ONE_TESTCASE(testJoinReturn);
RUN_ONE_TESTCASE(testJoinExited);
RUN_ONE_TESTCASE(testPthreadExitThread);
RUN_ONE_TESTCASE(testPthreadExitFunction);
RUN_ONE_TESTCASE(testPthreadDetach);
RUN_ONE_TESTCASE(testPthreadEqual);
}
/*
* Copyright (c) 2023-2023 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 "xts_test.h"
void *ThreadPublic(void *arg)
{
usleep(10); /* 10, common data for test, no special meaning */
return arg;
}
void PthreadFuncTest(void)
{
ActsProcessApiTest();
PthreadAttrTest();
PthreadBasicApiTest();
}
/*
* Copyright (c) 2023-2023 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 XTS_PROCESS_H
#define XTS_PROCESS_H
#include "xts_test.h"
#include <unistd.h>
#include <stdio.h>
#include <setjmp.h>
#include <securec.h>
#include <pthread.h>
#include <time.h>
#include <sys/resource.h>
#include <limits.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <string.h>
extern void *ThreadPublic(void *arg);
#endif
# Copyright (c) 2023-2023 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_m/liteos.gni")
static_library("sched_test") {
sources = [
"process_sched_api_test.c",
"pthread_sched_api_test.c",
"sched_api_test.c",
]
include_dirs = [
".",
"$LITEOSTOPDIR/testsuites/include",
"$LITEOSTOPDIR/testsuites/unittest/xts",
]
}
/*
* Copyright (c) 2023-2023 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 "sched_api_test.h"
LITE_TEST_SUIT(SCHED, ProcessSchedApi, ProcessSchedApiTestSuite);
static BOOL ProcessSchedApiTestSuiteSetUp(void)
{
return TRUE;
}
static BOOL ProcessSchedApiTestSuiteTearDown(void)
{
return TRUE;
}
/**
* @tc.number SUB_KERNEL_SCHED_API_GET_PRIORITY_MAX_0200
* @tc.name sched_get_priority_max api error test with unsupport policy.
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(ProcessSchedApiTestSuite, testSchedGetPriorityMaxError0200, Function | MediumTest | Level3)
{
int invalidPolicy[] = {SCHED_FIFO, SCHED_OTHER, SCHED_BATCH, SCHED_IDLE, SCHED_DEADLINE, SCHED_RESET_ON_FORK};
int testLoop = sizeof(invalidPolicy) / sizeof(int);
for (int i = 0; i < testLoop; i++) {
errno = 0;
int prio = sched_get_priority_max(invalidPolicy[i]);
ICUNIT_ASSERT_EQUAL(prio, -1, prio); /* -1, common data for test, no special meaning */
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
}
return 0;
}
/**
* @tc.number SUB_KERNEL_SCHED_API_GET_PRIORITY_MAX_0300
* @tc.name sched_get_priority_max api error test with invalid policy.
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(ProcessSchedApiTestSuite, testSchedGetPriorityMaxError0300, Function | MediumTest | Level3)
{
int invalidPolicyVal;
int prio;
invalidPolicyVal = -GetRandom(10000); /* 10000, common data for test, no special meaning */
errno = 0;
prio = sched_get_priority_max(invalidPolicyVal);
ICUNIT_ASSERT_EQUAL(prio, -1, prio); /* -1, common data for test, no special meaning */
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
invalidPolicyVal = GetRandom(10000) + SCHED_DEADLINE; /* 10000, common data for test, no special meaning */
errno = 0;
prio = sched_get_priority_max(invalidPolicyVal);
ICUNIT_ASSERT_EQUAL(prio, -1, prio); /* -1, common data for test, no special meaning */
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
return 0;
}
/**
* @tc.number SUB_KERNEL_SCHED_API_GET_PRIORITY_MIN_0200
* @tc.name sched_get_priority_min api error test with unsupport policy.
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(ProcessSchedApiTestSuite, testSchedGetPriorityMinError0200, Function | MediumTest | Level3)
{
int invalidPolicy[] = {SCHED_FIFO, SCHED_OTHER, SCHED_BATCH, SCHED_IDLE, SCHED_DEADLINE, SCHED_RESET_ON_FORK};
int testLoop = sizeof(invalidPolicy) / sizeof(int);
for (int i = 0; i < testLoop; i++) {
errno = 0;
int prio = sched_get_priority_min(invalidPolicy[i]);
ICUNIT_ASSERT_EQUAL(prio, -1, prio); /* -1, common data for test, no special meaning */
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
}
return 0;
}
/**
* @tc.number SUB_KERNEL_SCHED_API_GET_PRIORITY_MIN_0300
* @tc.name sched_get_priority_min api error test with invalid policy.
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(ProcessSchedApiTestSuite, testSchedGetPriorityMinError0300, Function | MediumTest | Level3)
{
int invalidPolicyVal;
int prio;
invalidPolicyVal = -GetRandom(10000); /* 10000, common data for test, no special meaning */
errno = 0;
prio = sched_get_priority_min(invalidPolicyVal);
ICUNIT_ASSERT_EQUAL(prio, -1, prio); /* -1, common data for test, no special meaning */
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
invalidPolicyVal = GetRandom(10000) + SCHED_DEADLINE; /* 10000, common data for test, no special meaning */
errno = 0;
prio = sched_get_priority_min(invalidPolicyVal);
ICUNIT_ASSERT_EQUAL(prio, -1, prio); /* -1, common data for test, no special meaning */
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
return 0;
}
RUN_TEST_SUITE(ProcessSchedApiTestSuite);
void ProcessSchedApiTest(void)
{
RUN_ONE_TESTCASE(testSchedGetPriorityMaxError0200);
RUN_ONE_TESTCASE(testSchedGetPriorityMaxError0300);
RUN_ONE_TESTCASE(testSchedGetPriorityMinError0200);
RUN_ONE_TESTCASE(testSchedGetPriorityMinError0300);
}
/*
* Copyright (c) 2023-2023 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 "sched_api_test.h"
LITE_TEST_SUIT(SCHED, PthreadSchedApi, PthreadSchedApiTestSuite);
static int g_policy = 0;
static int g_prioriy = 0;
static BOOL PthreadSchedApiTestSuiteSetUp(void)
{
return TRUE;
}
static BOOL PthreadSchedApiTestSuiteTearDown(void)
{
return TRUE;
}
/**
* @tc.number SUB_KERNEL_SCHED_API_PATTR_INHERIT_0100
* @tc.name test the default value of inheritsched.
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(PthreadSchedApiTestSuite, testAttrGetInheritsched, Function | MediumTest | Level1)
{
int ret;
pthread_attr_t attr;
ret = pthread_attr_init(&attr);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
int inheritsched = -1; /* -1, common data for test, no special meaning */
int rt = pthread_attr_getinheritsched(&attr, &inheritsched);
ICUNIT_ASSERT_EQUAL(rt, 0, rt);
ICUNIT_ASSERT_EQUAL(inheritsched, PTHREAD_INHERIT_SCHED, inheritsched);
return 0;
}
/**
* @tc.number SUB_KERNEL_SCHED_API_PATTR_INHERIT_0200
* @tc.name test set and get inheritsched.
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(PthreadSchedApiTestSuite, testAttrSetInheritsched, Function | MediumTest | Level1)
{
int ret;
pthread_attr_t attr;
ret = pthread_attr_init(&attr);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
int rt = pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
ICUNIT_ASSERT_EQUAL(rt, 0, rt);
int inheritsched = -1; /* -1, common data for test, no special meaning */
rt = pthread_attr_getinheritsched(&attr, &inheritsched);
ICUNIT_ASSERT_EQUAL(rt, 0, rt);
ICUNIT_ASSERT_EQUAL(inheritsched, PTHREAD_INHERIT_SCHED, inheritsched);
rt = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
ICUNIT_ASSERT_EQUAL(rt, 0, rt);
inheritsched = -1; /* -1, common data for test, no special meaning */
rt = pthread_attr_getinheritsched(&attr, &inheritsched);
ICUNIT_ASSERT_EQUAL(rt, 0, rt);
ICUNIT_ASSERT_EQUAL(inheritsched, PTHREAD_EXPLICIT_SCHED, inheritsched);
return 0;
}
/**
* @tc.number SUB_KERNEL_SCHED_API_PATTR_INHERIT_0300
* @tc.name pthread_attr_setinheritsched error test.
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(PthreadSchedApiTestSuite, testAttrSetInheritschedError, Function | MediumTest | Level1)
{
int ret;
pthread_attr_t attr;
ret = pthread_attr_init(&attr);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
int n = -GetRandom(100); /* 100, common data for test, no special meaning */
int rt = pthread_attr_setinheritsched(&attr, n);
ICUNIT_ASSERT_EQUAL(rt, EINVAL, rt);
n = 2 + GetRandom(100); /* 2, 100, common data for test, no special meaning */
rt = pthread_attr_setinheritsched(&attr, n);
ICUNIT_ASSERT_EQUAL(rt, EINVAL, rt);
return 0;
}
/**
* @tc.number SUB_KERNEL_SCHED_API_PATTR_SCHEDPARAM_0200
* @tc.name test set and get sched param.
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(PthreadSchedApiTestSuite, testAttrSetSchedParam, Function | MediumTest | Level1)
{
int ret;
pthread_attr_t attr;
ret = pthread_attr_init(&attr);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
struct sched_param param = {0};
int rt = pthread_attr_getschedparam(&attr, &param);
ICUNIT_ASSERT_EQUAL(rt, 0, rt);
param.sched_priority = 22; /* 22, common data for test, no special meaning */
rt = pthread_attr_setschedparam(&attr, &param);
ICUNIT_ASSERT_EQUAL(rt, 0, rt);
rt = pthread_attr_getschedparam(&attr, &param);
ICUNIT_ASSERT_EQUAL(rt, 0, rt);
ICUNIT_ASSERT_EQUAL(param.sched_priority, 22, param.sched_priority); /* 22, common data for test, no special meaning */
return 0;
}
/**
* @tc.number SUB_KERNEL_SCHED_API_PATTR_SCHEDPOLICY_0100
* @tc.name test the default value of sched policy.
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(PthreadSchedApiTestSuite, testAttrGetSchedPolicy, Function | MediumTest | Level1)
{
int ret;
pthread_attr_t attr;
ret = pthread_attr_init(&attr);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
int policy = -1; /* -1, common data for test, no special meaning */
int rt = pthread_attr_getschedpolicy(&attr, &policy);
ICUNIT_ASSERT_EQUAL(rt, 0, rt);
ICUNIT_ASSERT_EQUAL(policy, SCHED_RR, policy);
return 0;
}
/**
* @tc.number SUB_KERNEL_SCHED_API_PATTR_SCHEDPOLICY_0300
* @tc.name pthread_attr_setschedpolicy error test.
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(PthreadSchedApiTestSuite, testAttrSetSchedPolicyError, Function | MediumTest | Level1)
{
int ret;
pthread_attr_t attr;
ret = pthread_attr_init(&attr);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
int rt;
int invalidPolicy[7] = {SCHED_OTHER, SCHED_BATCH, SCHED_IDLE, SCHED_DEADLINE, SCHED_RESET_ON_FORK}; /* 7, common data for test, no special meaning */
invalidPolicy[5] = -GetRandom(10000); /* 5, 10000, common data for test, no special meaning */
invalidPolicy[6] = GetRandom(10000) + 6; /* 6, 10000, common data for test, no special meaning */
for (int i = 0; i < 7; i++) { /* 7, common data for test, no special meaning */
rt = pthread_attr_setschedpolicy(&attr, invalidPolicy[i]);
ICUNIT_ASSERT_EQUAL(rt, EINVAL, rt);
}
return 0;
}
/**
* @tc.number SUB_KERNEL_SCHED_API_PATTR_SCOPE_0100
* @tc.name test the default value of sched scope.
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(PthreadSchedApiTestSuite, testAttrGetScope, Function | MediumTest | Level1)
{
int ret;
pthread_attr_t attr;
ret = pthread_attr_init(&attr);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
int scope = -1; /* -1, common data for test, no special meaning */
int rt = pthread_attr_getscope(&attr, &scope);
ICUNIT_ASSERT_EQUAL(rt, 0, rt);
ICUNIT_ASSERT_EQUAL(scope, PTHREAD_SCOPE_SYSTEM, scope);
return 0;
}
/**
* @tc.number SUB_KERNEL_SCHED_API_PATTR_SCOPE_0200
* @tc.name test set and get scope.
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(PthreadSchedApiTestSuite, testAttrSetScope, Function | MediumTest | Level1)
{
int ret;
pthread_attr_t attr;
ret = pthread_attr_init(&attr);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
int rt = pthread_attr_setscope(&attr, PTHREAD_SCOPE_PROCESS);
ICUNIT_ASSERT_EQUAL(rt, ENOTSUP, rt);
rt = pthread_attr_setscope(&attr, -GetRandom(10000)); /* 10000, common data for test, no special meaning */
ICUNIT_ASSERT_EQUAL(rt, EINVAL, rt);
rt = pthread_attr_setscope(&attr, GetRandom(10000) + 2); /* 2, 10000, common data for test, no special meaning */
ICUNIT_ASSERT_EQUAL(rt, EINVAL, rt);
int scope = -1; /* -1, common data for test, no special meaning */
rt = pthread_attr_getscope(&attr, &scope);
ICUNIT_ASSERT_EQUAL(rt, 0, rt);
ICUNIT_ASSERT_EQUAL(scope, PTHREAD_SCOPE_SYSTEM, scope);
return 0;
}
RUN_TEST_SUITE(PthreadSchedApiTestSuite);
void PthreadSchedApiTest(void)
{
RUN_ONE_TESTCASE(testAttrGetInheritsched);
RUN_ONE_TESTCASE(testAttrSetInheritsched);
RUN_ONE_TESTCASE(testAttrSetInheritschedError);
RUN_ONE_TESTCASE(testAttrSetSchedParam);
RUN_ONE_TESTCASE(testAttrGetSchedPolicy);
RUN_ONE_TESTCASE(testAttrSetSchedPolicyError);
RUN_ONE_TESTCASE(testAttrGetScope);
RUN_ONE_TESTCASE(testAttrSetScope);
}
/*
* Copyright (c) 2023-2023 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 "xts_test.h"
void SchedApiFuncTest(void)
{
ProcessSchedApiTest();
PthreadSchedApiTest();
}
/*
* Copyright (c) 2023-2023 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 XTS_SCHED_H
#define XTS_SCHED_H
#include "xts_test.h"
#include <unistd.h>
#include <stdio.h>
#include <pthread.h>
#include <sys/resource.h>
#include <fcntl.h>
#include <semaphore.h>
#include <fcntl.h>
#endif
\ No newline at end of file
# Copyright (c) 2023-2023 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_m/liteos.gni")
static_library("system_test") {
sources = [ "sys_api_test.c" ]
include_dirs = [
".",
"$LITEOSTOPDIR/testsuites/include",
"$LITEOSTOPDIR/testsuites/unittest/xts",
]
}
/*
* Copyright (c) 2023-2023 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 XTS_SYS_API_H
#define XTS_SYS_API_H
#include <unistd.h>
#include <string.h>
#include <locale.h>
#include <search.h>
#include <err.h>
#include <regex.h>
#include <sys/types.h>
#include <sys/utsname.h>
#endif
\ No newline at end of file
/*
* Copyright (c) 2023-2023 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 "sys_api.h"
#include "xts_test.h"
LITE_TEST_SUIT(SYSTEM, SysApiTest, SysApiTestSuite);
static BOOL SysApiTestSuiteSetUp(void)
{
return TRUE;
}
static BOOL SysApiTestSuiteTearDown(void)
{
return TRUE;
}
/**
* @tc.number SUB_KERNEL_SYS_STRERROR_0100
* @tc.name test strerror
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(SysApiTestSuite, testStrerror, Function | MediumTest | Level1)
{
ICUNIT_ASSERT_STRING_EQUAL(strerror(-1), "No error information", strerror(-1)); /* -1, common data for test, no special meaning */
ICUNIT_ASSERT_STRING_EQUAL(strerror(0), "No error information", strerror(0));
ICUNIT_ASSERT_STRING_EQUAL(strerror(2), "No such file or directory", strerror(2)); /* 2, common data for test, no special meaning */
ICUNIT_ASSERT_STRING_EQUAL(strerror(10), "No child process", strerror(10)); /* 10, common data for test, no special meaning */
ICUNIT_ASSERT_STRING_EQUAL(strerror(65536), "No error information", strerror(65536)); /* 65536, common data for test, no special meaning */
}
RUN_TEST_SUITE(SysApiTestSuite);
void SysApiFuncTest(void)
{
RUN_ONE_TESTCASE(testStrerror);
}
......@@ -43,4 +43,8 @@ void XtsTestSuite(void)
IpcSemApiTest();
IoFuncTest();
MathFuncTest();
}
MemFuncTest();
PthreadFuncTest();
SchedApiFuncTest();
SysApiFuncTest();
}
\ No newline at end of file
......@@ -61,4 +61,12 @@ extern void IoFuncTest(void);
extern void MathFuncTest(void);
extern void MemFuncTest(void);
extern void PthreadFuncTest(void);
extern void SchedApiFuncTest(void);
extern void SysApiFuncTest(void);
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册