Compare commits
17 Commits
OpenHarmon
...
weekly_202
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e76dd685c2 | ||
|
|
54a5365a25 | ||
|
|
2d1160fdc4 | ||
|
|
f3d606b6dd | ||
|
|
392e4c2cec | ||
|
|
b334658723 | ||
|
|
2b1f2d554e | ||
|
|
2cf290bb7c | ||
|
|
8fc9852e34 | ||
|
|
816d03f5c1 | ||
|
|
61877ec97a | ||
|
|
f94d3ee119 | ||
|
|
1a764df92a | ||
|
|
cf50cde1b7 | ||
|
|
bfef7bfb2e | ||
|
|
5bae8b58c6 | ||
|
|
6377f98e9e |
@@ -43,7 +43,6 @@
|
||||
static pthread_mutex_t g_fsLocalMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static struct PartitionCfg g_partitionCfg;
|
||||
static struct lfs_config g_lfsCfg;
|
||||
static struct DeviceDesc *g_lfsDevice = NULL;
|
||||
|
||||
static uint32_t LfsGetStartAddr(int partition)
|
||||
@@ -177,6 +176,7 @@ int LfsMount(struct MountPoint *mp, unsigned long mountflags, const void *data)
|
||||
{
|
||||
int ret;
|
||||
lfs_t *mountHdl = NULL;
|
||||
struct lfs_config *cfg = NULL;
|
||||
|
||||
if ((mp == NULL) || (mp->mPath == NULL) || (data == NULL)) {
|
||||
errno = EFAULT;
|
||||
@@ -184,22 +184,23 @@ int LfsMount(struct MountPoint *mp, unsigned long mountflags, const void *data)
|
||||
goto errout;
|
||||
}
|
||||
|
||||
mountHdl = (lfs_t *)malloc(sizeof(lfs_t));
|
||||
mountHdl = (lfs_t *)malloc(sizeof(lfs_t) + sizeof(struct lfs_config));
|
||||
if (mountHdl == NULL) {
|
||||
errno = ENODEV;
|
||||
ret = (int)LOS_NOK;
|
||||
goto errout;
|
||||
}
|
||||
(void)memset_s(mountHdl, sizeof(lfs_t), 0, sizeof(lfs_t));
|
||||
(void)memset_s(mountHdl, sizeof(lfs_t) + sizeof(struct lfs_config), 0, sizeof(lfs_t) + sizeof(struct lfs_config));
|
||||
mp->mData = (void *)mountHdl;
|
||||
cfg = (void *)((UINTPTR)mountHdl + sizeof(lfs_t));
|
||||
|
||||
LfsConfigAdapter((struct PartitionCfg *)data, &g_lfsCfg);
|
||||
LfsConfigAdapter((struct PartitionCfg *)data, cfg);
|
||||
|
||||
ret = lfs_mount((lfs_t *)mp->mData, &g_lfsCfg);
|
||||
ret = lfs_mount((lfs_t *)mp->mData, cfg);
|
||||
if (ret != 0) {
|
||||
ret = lfs_format((lfs_t *)mp->mData, &g_lfsCfg);
|
||||
ret = lfs_format((lfs_t *)mp->mData, cfg);
|
||||
if (ret == 0) {
|
||||
ret = lfs_mount((lfs_t *)mp->mData, &g_lfsCfg);
|
||||
ret = lfs_mount((lfs_t *)mp->mData, cfg);
|
||||
}
|
||||
}
|
||||
if (ret != 0) {
|
||||
@@ -655,12 +656,13 @@ int LfsFormat(const char *partName, void *privData)
|
||||
{
|
||||
int ret;
|
||||
lfs_t lfs = {0};
|
||||
struct lfs_config cfg = {0};
|
||||
|
||||
(void)partName;
|
||||
|
||||
LfsConfigAdapter((struct PartitionCfg *)privData, &g_lfsCfg);
|
||||
LfsConfigAdapter((struct PartitionCfg *)privData, &cfg);
|
||||
|
||||
ret = lfs_format(&lfs, &g_lfsCfg);
|
||||
ret = lfs_format(&lfs, &cfg);
|
||||
if (ret != 0) {
|
||||
errno = LittlefsErrno(ret);
|
||||
ret = (int)LOS_NOK;
|
||||
|
||||
@@ -122,14 +122,45 @@ struct MountPoint *VfsMpFind(const char *path, const char **pathInMp)
|
||||
return bestMp;
|
||||
}
|
||||
|
||||
STATIC struct MountPoint *MountPointInit(const char *target, const char *fsType, unsigned long mountflags)
|
||||
{
|
||||
struct MountPoint *mp = NULL;
|
||||
const char *pathInMp = NULL;
|
||||
struct FsMap *mFs = NULL;
|
||||
|
||||
/* find mp by target, to see if it was mounted */
|
||||
mp = VfsMpFind(target, &pathInMp);
|
||||
if (mp != NULL && pathInMp != NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Find fsMap coresponding to the fsType */
|
||||
mFs = VfsFsMapGet(fsType);
|
||||
if ((mFs == NULL) || (mFs->fsMops == NULL) || (mFs->fsMops->mount == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mp = (struct MountPoint *)malloc(sizeof(struct MountPoint));
|
||||
if (mp == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mp->mFs = mFs;
|
||||
mp->mDev = NULL;
|
||||
mp->mRefs = 0;
|
||||
mp->mWriteEnable = (mountflags & MS_RDONLY) ? FALSE : TRUE;
|
||||
mp->mFs->fsRefs++;
|
||||
mp->mNext = g_mountPoints;
|
||||
|
||||
return mp;
|
||||
}
|
||||
|
||||
int LOS_FsMount(const char *source, const char *target,
|
||||
const char *fsType, unsigned long mountflags,
|
||||
const void *data)
|
||||
{
|
||||
int ret;
|
||||
struct MountPoint *mp = NULL;
|
||||
struct FsMap *mFs = NULL;
|
||||
const char *pathInMp = NULL;
|
||||
|
||||
/* target must begin with '/', for example /system, /data, etc. */
|
||||
if ((target == NULL) || (target[0] != '/')) {
|
||||
@@ -137,29 +168,19 @@ int LOS_FsMount(const char *source, const char *target,
|
||||
}
|
||||
|
||||
(void)VfsLock();
|
||||
/* find mp by target, to see if it was mounted */
|
||||
mp = VfsMpFind(target, &pathInMp);
|
||||
if (mp != NULL && pathInMp != NULL) {
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Find fsMap coresponding to the fsType */
|
||||
mFs = VfsFsMapGet(fsType);
|
||||
if ((mFs == NULL) || (mFs->fsMops == NULL) || (mFs->fsMops->mount == NULL)) {
|
||||
goto errout;
|
||||
}
|
||||
|
||||
mp = (struct MountPoint *)malloc(sizeof(struct MountPoint));
|
||||
mp = MountPointInit(target, fsType, mountflags);
|
||||
if (mp == NULL) {
|
||||
goto errout;
|
||||
VfsUnlock();
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
|
||||
mp->mFs = mFs;
|
||||
mp->mDev = NULL;
|
||||
if (source != NULL) {
|
||||
mp->mDev = strdup(source);
|
||||
if (mp->mDev == NULL) {
|
||||
goto errout;
|
||||
free(mp);
|
||||
VfsUnlock();
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,10 +195,7 @@ int LOS_FsMount(const char *source, const char *target,
|
||||
PRINT_ERR("mount failed, target %s.\n", target);
|
||||
goto errout;
|
||||
}
|
||||
mp->mRefs = 0;
|
||||
mp->mWriteEnable = (mountflags & MS_RDONLY) ? FALSE : TRUE;
|
||||
mp->mFs->fsRefs++;
|
||||
mp->mNext = g_mountPoints;
|
||||
|
||||
g_mountPoints = mp;
|
||||
VfsUnlock();
|
||||
return LOS_OK;
|
||||
|
||||
@@ -240,4 +240,7 @@
|
||||
#define LWIP_SOCKET_OFFSET CONFIG_NFILE_DESCRIPTORS
|
||||
#endif
|
||||
|
||||
#define LWIP_SOCKET_IOCTL 0
|
||||
#define LWIP_SOCKET_FCNTL 0
|
||||
|
||||
#endif /* _LWIP_PORTING_LWIPOPTS_H_ */
|
||||
|
||||
@@ -211,6 +211,7 @@ int close(int fd)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LWIP_SOCKET_IOCTL
|
||||
#ifdef LWIP_SOCKET_IOCTL_FUNC
|
||||
int ioctl(int fd, int req, ...)
|
||||
{
|
||||
@@ -222,7 +223,9 @@ int ioctl(int fd, int req, ...)
|
||||
return lwip_ioctl(fd, (long)req, (void *)arg);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if LWIP_SOCKET_FCNTL
|
||||
#ifdef LWIP_SOCKET_FCNTL_FUNC
|
||||
int fcntl(int fd, int cmd, ...)
|
||||
{
|
||||
@@ -234,6 +237,7 @@ int fcntl(int fd, int cmd, ...)
|
||||
return lwip_fcntl(fd, cmd, val);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if LWIP_SOCKET_SELECT
|
||||
#ifdef LWIP_SOCKET_SELECT_FUNC
|
||||
|
||||
@@ -130,7 +130,7 @@ STATIC BOOL OsPmTickTimerStop(LosPmCB *pm)
|
||||
LosPmTickTimer *tickTimer = pm->tickTimer;
|
||||
|
||||
if ((tickTimer == NULL) || (tickTimer->tickLock == NULL) ||
|
||||
(pm->pmMode == LOS_SYS_NORMAL_SLEEP)) {
|
||||
(pm->sysMode == LOS_SYS_NORMAL_SLEEP)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -264,6 +264,7 @@ STATIC UINT32 OsPmSuspendSleep(LosPmCB *pm)
|
||||
|
||||
if (pm->sysctrl->suspendCheck != NULL) {
|
||||
pm->sysctrl->suspendCheck(mode);
|
||||
pm->sysMode = pm->pmMode;
|
||||
}
|
||||
|
||||
tickTimerStop = OsPmTickTimerStop(pm);
|
||||
|
||||
@@ -43,6 +43,10 @@
|
||||
#include "los_debugtools.h"
|
||||
#endif
|
||||
|
||||
#if (LOSCFG_KERNEL_TRACE == 1)
|
||||
#include "los_trace_pri.h"
|
||||
#endif
|
||||
|
||||
#define SHELL_INIT_MAGIC_FLAG 0xABABABAB
|
||||
|
||||
STATIC CmdModInfo cmdInfo;
|
||||
@@ -75,6 +79,13 @@ CmdItem g_shellcmdAll[] = {
|
||||
{CMD_TYPE_EX, "st", 1, (CmdCallBackFunc)OsShellCmdSchedTrace},
|
||||
#endif
|
||||
{CMD_TYPE_EX, "help", 0, (CmdCallBackFunc)OsShellCmdHelp},
|
||||
#if (LOSCFG_KERNEL_TRACE == 1)
|
||||
{CMD_TYPE_EX, "trace_start", 0, (CmdCallBackFunc)LOS_TraceStart},
|
||||
{CMD_TYPE_EX, "trace_stop", 0, (CmdCallBackFunc)LOS_TraceStop},
|
||||
{CMD_TYPE_EX, "trace_mask", 1, (CmdCallBackFunc)OsShellCmdTraceSetMask},
|
||||
{CMD_TYPE_EX, "trace_reset", 0, (CmdCallBackFunc)LOS_TraceReset},
|
||||
{CMD_TYPE_EX, "trace_dump", 1, (CmdCallBackFunc)OsShellCmdTraceDump},
|
||||
#endif
|
||||
};
|
||||
|
||||
CmdModInfo *OsCmdInfoGet(VOID)
|
||||
|
||||
@@ -64,3 +64,11 @@ kernel_module(module_name) {
|
||||
include_dirs += [ "pipeline/serial" ]
|
||||
}
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [
|
||||
".",
|
||||
"cnv",
|
||||
"pipeline",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -411,12 +411,6 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdTraceDump(INT32 argc, const CHAR **argv)
|
||||
LOS_TraceRecordDump(toClient);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
SHELLCMD_ENTRY(tracestart_shellcmd, CMD_TYPE_EX, "trace_start", 0, (CmdCallBackFunc)LOS_TraceStart);
|
||||
SHELLCMD_ENTRY(tracestop_shellcmd, CMD_TYPE_EX, "trace_stop", 0, (CmdCallBackFunc)LOS_TraceStop);
|
||||
SHELLCMD_ENTRY(tracesetmask_shellcmd, CMD_TYPE_EX, "trace_mask", 1, (CmdCallBackFunc)OsShellCmdTraceSetMask);
|
||||
SHELLCMD_ENTRY(tracereset_shellcmd, CMD_TYPE_EX, "trace_reset", 0, (CmdCallBackFunc)LOS_TraceReset);
|
||||
SHELLCMD_ENTRY(tracedump_shellcmd, CMD_TYPE_EX, "trace_dump", 1, (CmdCallBackFunc)OsShellCmdTraceDump);
|
||||
#endif
|
||||
|
||||
#endif /* LOSCFG_KERNEL_TRACE == 1 */
|
||||
|
||||
@@ -152,6 +152,11 @@ extern VOID OsTraceRecordDump(BOOL toClient);
|
||||
#define OsTraceNotifyStop()
|
||||
#endif
|
||||
|
||||
#if (LOSCFG_SHELL == 1)
|
||||
extern UINT32 OsShellCmdTraceSetMask(INT32 argc, const CHAR **argv);
|
||||
extern UINT32 OsShellCmdTraceDump(INT32 argc, const CHAR **argv);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
|
||||
#include "los_trace_pri.h"
|
||||
#include "trace_pipeline.h"
|
||||
#include "los_memory.h"
|
||||
#include "securec.h"
|
||||
|
||||
#if (LOSCFG_RECORDER_MODE_OFFLINE == 1)
|
||||
#define BITS_NUM_FOR_TASK_ID 16
|
||||
|
||||
@@ -27,7 +27,35 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
static_library("test_posix") {
|
||||
sources = [ "pthread_func_test.c" ]
|
||||
sources = [
|
||||
"pthread/It_posix_pthread.c",
|
||||
"pthread/It_posix_pthread_001.c",
|
||||
"pthread/It_posix_pthread_002.c",
|
||||
"pthread/It_posix_pthread_003.c",
|
||||
"pthread/It_posix_pthread_004.c",
|
||||
"pthread/It_posix_pthread_005.c",
|
||||
"pthread/It_posix_pthread_006.c",
|
||||
"pthread/It_posix_pthread_007.c",
|
||||
"pthread/It_posix_pthread_008.c",
|
||||
"pthread/It_posix_pthread_009.c",
|
||||
"pthread/It_posix_pthread_010.c",
|
||||
"pthread/It_posix_pthread_011.c",
|
||||
"pthread/It_posix_pthread_012.c",
|
||||
"pthread/It_posix_pthread_013.c",
|
||||
"pthread/It_posix_pthread_014.c",
|
||||
"pthread/It_posix_pthread_015.c",
|
||||
"pthread/It_posix_pthread_016.c",
|
||||
"pthread/It_posix_pthread_017.c",
|
||||
"pthread/It_posix_pthread_018.c",
|
||||
"pthread/It_posix_pthread_019.c",
|
||||
"pthread/It_posix_pthread_020.c",
|
||||
"pthread/It_posix_pthread_021.c",
|
||||
"pthread/It_posix_pthread_022.c",
|
||||
"pthread/It_posix_pthread_023.c",
|
||||
"pthread/It_posix_pthread_024.c",
|
||||
"pthread/It_posix_pthread_025.c",
|
||||
"pthread_func_test.c",
|
||||
]
|
||||
|
||||
configs += [ "//kernel/liteos_m/testsuites:include" ]
|
||||
}
|
||||
|
||||
74
testsuites/sample/posix/pthread/It_posix_pthread.c
Normal file
74
testsuites/sample/posix/pthread/It_posix_pthread.c
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
/*
|
||||
* return value of pthread_self() is 0 when
|
||||
* pthread create from LOS_TaskCreate()
|
||||
*/
|
||||
pthread_t TestPthreadSelf(void)
|
||||
{
|
||||
pthread_t tid = pthread_self();
|
||||
if (tid == 0) {
|
||||
tid = ((LosTaskCB *)(OsCurrTaskGet()))->taskID;
|
||||
}
|
||||
return tid;
|
||||
}
|
||||
|
||||
VOID ItSuitePosixPthread()
|
||||
{
|
||||
printf("************** begin SAMPLE POSIX pthread test *************\n");
|
||||
ItPosixPthread001();
|
||||
ItPosixPthread002();
|
||||
ItPosixPthread003();
|
||||
ItPosixPthread004();
|
||||
ItPosixPthread005();
|
||||
ItPosixPthread006();
|
||||
ItPosixPthread007();
|
||||
ItPosixPthread008();
|
||||
ItPosixPthread009();
|
||||
ItPosixPthread010();
|
||||
ItPosixPthread011();
|
||||
ItPosixPthread012();
|
||||
ItPosixPthread013();
|
||||
ItPosixPthread014();
|
||||
ItPosixPthread015();
|
||||
ItPosixPthread016();
|
||||
ItPosixPthread017();
|
||||
ItPosixPthread018();
|
||||
ItPosixPthread019();
|
||||
ItPosixPthread020();
|
||||
ItPosixPthread021();
|
||||
ItPosixPthread022();
|
||||
ItPosixPthread023();
|
||||
ItPosixPthread024();
|
||||
ItPosixPthread025();
|
||||
}
|
||||
115
testsuites/sample/posix/pthread/It_posix_pthread.h
Normal file
115
testsuites/sample/posix/pthread/It_posix_pthread.h
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#ifndef IT_POSIX_PTHREAD_H
|
||||
#define IT_POSIX_PTHREAD_H
|
||||
|
||||
#include "sched.h"
|
||||
#include "signal.h"
|
||||
#include "semaphore.h"
|
||||
#include "sched.h"
|
||||
#include "osTest.h"
|
||||
#include "pthread.h"
|
||||
#include "limits.h"
|
||||
#include "unistd.h"
|
||||
#include "mqueue.h"
|
||||
#include "signal.h"
|
||||
|
||||
/* Some routines are part of the XSI Extensions */
|
||||
#ifndef WITHOUT_XOPEN
|
||||
#define _XOPEN_SOURCE 600
|
||||
#endif
|
||||
|
||||
#define PTHREAD_IS_ERROR (-1)
|
||||
#define PTHREAD_PRIORITY_TEST 20
|
||||
#define PTHREAD_DEFAULT_STACK_SIZE (LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE)
|
||||
#define PTHREAD_KEY_NUM 10
|
||||
#define THREAD_NUM 3
|
||||
#define PTHREAD_TIMEOUT (THREAD_NUM * 2)
|
||||
#define PTHREAD_INTHREAD_TEST 0 /* Control going to or is already for Thread */
|
||||
#define PTHREAD_INMAIN_TEST 1 /* Control going to or is already for Main */
|
||||
#define INVALID_PSHARED_VALUE (-100)
|
||||
#define NUM_OF_CONDATTR 10
|
||||
#define RUNTIME 5
|
||||
#define PTHREAD_THREADS_NUM 3
|
||||
#define TCOUNT 5 // Number of single-threaded polling
|
||||
#define COUNT_LIMIT 7 // The number of times the signal is sent
|
||||
#define HIGH_PRIORITY 5
|
||||
#define LOW_PRIORITY 10
|
||||
#define PTHREAD_EXIT_VALUE ((void *)100) /* The return code of the thread when using pthread_exit(). */
|
||||
|
||||
#define PTHREAD_EXISTED_NUM TASK_EXISTED_NUM
|
||||
#define PTHREAD_EXISTED_SEM_NUM SEM_EXISTED_NUM
|
||||
|
||||
/* We are testing conformance to IEEE Std 1003.1, 2003 Edition */
|
||||
#define _POSIX_C_SOURCE 200112L
|
||||
|
||||
#define PTHREAD_MUTEX_RECURSIVE 0
|
||||
#define PTHREAD_MUTEX_ERRORCHECK 0
|
||||
|
||||
#define PRIORITY_OTHER (-1)
|
||||
#define PRIORITY_FIFO 20
|
||||
#define PRIORITY_RR 20
|
||||
|
||||
#ifdef LOSCFG_AARCH64
|
||||
#define PTHREAD_STACK_MIN_TEST (PTHREAD_STACK_MIN * 3)
|
||||
#else
|
||||
#define PTHREAD_STACK_MIN_TEST PTHREAD_STACK_MIN
|
||||
#endif
|
||||
|
||||
pthread_t TestPthreadSelf(void);
|
||||
|
||||
VOID ItPosixPthread001(VOID);
|
||||
VOID ItPosixPthread002(VOID);
|
||||
VOID ItPosixPthread003(VOID);
|
||||
VOID ItPosixPthread004(VOID);
|
||||
VOID ItPosixPthread005(VOID);
|
||||
VOID ItPosixPthread006(VOID);
|
||||
VOID ItPosixPthread007(VOID);
|
||||
VOID ItPosixPthread008(VOID);
|
||||
VOID ItPosixPthread009(VOID);
|
||||
VOID ItPosixPthread010(VOID);
|
||||
VOID ItPosixPthread011(VOID);
|
||||
VOID ItPosixPthread012(VOID);
|
||||
VOID ItPosixPthread013(VOID);
|
||||
VOID ItPosixPthread014(VOID);
|
||||
VOID ItPosixPthread015(VOID);
|
||||
VOID ItPosixPthread016(VOID);
|
||||
VOID ItPosixPthread017(VOID);
|
||||
VOID ItPosixPthread018(VOID);
|
||||
VOID ItPosixPthread019(VOID);
|
||||
VOID ItPosixPthread020(VOID);
|
||||
VOID ItPosixPthread021(VOID);
|
||||
VOID ItPosixPthread022(VOID);
|
||||
VOID ItPosixPthread023(VOID);
|
||||
VOID ItPosixPthread024(VOID);
|
||||
VOID ItPosixPthread025(VOID);
|
||||
|
||||
#endif /* IT_POSIX_PTHREAD_H */
|
||||
79
testsuites/sample/posix/pthread/It_posix_pthread_001.c
Normal file
79
testsuites/sample/posix/pthread/It_posix_pthread_001.c
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static void *ThreadF01(void *arg)
|
||||
{
|
||||
sleep(1);
|
||||
|
||||
/* Shouldn't reach here. If we do, then the pthread_cancel()
|
||||
* function did not succeed. */
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_t newTh;
|
||||
UINT32 ret;
|
||||
UINTPTR temp;
|
||||
|
||||
if (pthread_create(&newTh, NULL, ThreadF01, NULL) < 0) {
|
||||
uart_printf_func("Error creating thread\n");
|
||||
ICUNIT_ASSERT_EQUAL(1, 0, errno);
|
||||
}
|
||||
|
||||
LOS_TaskDelay(1);
|
||||
/* Try to cancel the newly created thread. If an error is returned,
|
||||
* then the thread wasn't created successfully. */
|
||||
if (pthread_cancel(newTh) != 0) {
|
||||
dprintf("Test FAILED: pthread cancel failed\n");
|
||||
ICUNIT_ASSERT_EQUAL(1, 0, errno);
|
||||
}
|
||||
|
||||
ret = pthread_join(newTh, (void *)&temp);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ICUNIT_ASSERT_EQUAL(temp, 0, temp);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread001
|
||||
* @tc.desc: Test interface pthread_cancel
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread001(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread001", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
78
testsuites/sample/posix/pthread/It_posix_pthread_002.c
Normal file
78
testsuites/sample/posix/pthread/It_posix_pthread_002.c
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static void *ThreadF01(void *arg)
|
||||
{
|
||||
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
|
||||
|
||||
sleep(1);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
void *temp = NULL;
|
||||
pthread_t a;
|
||||
|
||||
if (pthread_create(&a, NULL, ThreadF01, NULL) != 0) {
|
||||
uart_printf_func("Error creating thread\n");
|
||||
ICUNIT_ASSERT_EQUAL(1, 0, errno);
|
||||
}
|
||||
|
||||
LOS_TaskDelay(1);
|
||||
if (pthread_cancel(a) != 0) {
|
||||
dprintf("Test failed: pthread cancel failed\n");
|
||||
return LOS_NOK;
|
||||
}
|
||||
/* If 'main' has reached here, then the test passed because it means
|
||||
* that the thread is truly asynchronise, and main isn't waiting for
|
||||
* it to return in order to move on. */
|
||||
|
||||
ret = pthread_join(a, &temp);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(temp, PTHREAD_CANCELED, ret);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread002
|
||||
* @tc.desc: Test interface pthread_cancel
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread002(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread002", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
56
testsuites/sample/posix/pthread/It_posix_pthread_003.c
Normal file
56
testsuites/sample/posix/pthread/It_posix_pthread_003.c
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
|
||||
ret = pthread_attr_init(NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
|
||||
|
||||
ret = pthread_attr_destroy(NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread003
|
||||
* @tc.desc: Test interface pthread_attr_init
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread003(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread003", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
81
testsuites/sample/posix/pthread/It_posix_pthread_004.c
Normal file
81
testsuites/sample/posix/pthread/It_posix_pthread_004.c
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_attr_t attr;
|
||||
UINT32 ret;
|
||||
int detachstate;
|
||||
|
||||
ret = pthread_attr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_attr_setdetachstate(NULL, PTHREAD_CREATE_DETACHED);
|
||||
ICUNIT_GOTO_EQUAL(ret, EINVAL, ret, EXIT);
|
||||
|
||||
ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE - 1);
|
||||
ICUNIT_GOTO_EQUAL(ret, EINVAL, ret, EXIT);
|
||||
|
||||
ret = pthread_attr_setdetachstate(&attr, 3); // 3, test the param of function.
|
||||
ICUNIT_GOTO_EQUAL(ret, EINVAL, ret, EXIT);
|
||||
|
||||
ret = pthread_attr_getdetachstate(NULL, &detachstate);
|
||||
ICUNIT_GOTO_EQUAL(ret, EINVAL, ret, EXIT);
|
||||
|
||||
ret = pthread_attr_getdetachstate(&attr, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, EINVAL, ret, EXIT);
|
||||
|
||||
ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
ret = pthread_attr_getdetachstate(&attr, &detachstate);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
ICUNIT_GOTO_EQUAL(detachstate, PTHREAD_CREATE_DETACHED, detachstate, EXIT);
|
||||
|
||||
EXIT:
|
||||
ret = pthread_attr_destroy(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread004
|
||||
* @tc.desc: Test interface pthread_setdetachstate
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread004(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread004", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
80
testsuites/sample/posix/pthread/It_posix_pthread_005.c
Normal file
80
testsuites/sample/posix/pthread/It_posix_pthread_005.c
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_attr_t attr;
|
||||
UINT32 ret;
|
||||
int inherit;
|
||||
|
||||
ret = pthread_attr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_attr_setinheritsched(NULL, PTHREAD_INHERIT_SCHED);
|
||||
ICUNIT_GOTO_EQUAL(ret, EINVAL, ret, EXIT);
|
||||
|
||||
ret = pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED - 1);
|
||||
ICUNIT_GOTO_EQUAL(ret, EINVAL, ret, EXIT);
|
||||
|
||||
ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED + 1);
|
||||
ICUNIT_GOTO_EQUAL(ret, EINVAL, ret, EXIT);
|
||||
|
||||
ret = pthread_attr_getinheritsched(NULL, &inherit);
|
||||
ICUNIT_GOTO_EQUAL(ret, EINVAL, ret, EXIT);
|
||||
|
||||
ret = pthread_attr_getinheritsched(&attr, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, EINVAL, ret, EXIT);
|
||||
|
||||
ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
ret = pthread_attr_getinheritsched(&attr, &inherit);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
ICUNIT_GOTO_EQUAL(inherit, PTHREAD_EXPLICIT_SCHED, inherit, EXIT);
|
||||
|
||||
EXIT:
|
||||
ret = pthread_attr_destroy(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread005
|
||||
* @tc.desc: Test interface pthread_attr_setinheritsched
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread005(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread005", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
71
testsuites/sample/posix/pthread/It_posix_pthread_006.c
Normal file
71
testsuites/sample/posix/pthread/It_posix_pthread_006.c
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_condattr_t condattr;
|
||||
pthread_cond_t cond1;
|
||||
pthread_cond_t cond2;
|
||||
int rc;
|
||||
|
||||
rc = pthread_condattr_init(&condattr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
rc = pthread_cond_init(&cond1, &condattr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
rc = pthread_cond_init(&cond2, NULL);
|
||||
ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
|
||||
|
||||
rc = pthread_cond_destroy(&cond1);
|
||||
ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
|
||||
rc = pthread_cond_destroy(&cond2);
|
||||
ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
|
||||
|
||||
return LOS_OK;
|
||||
EXIT:
|
||||
(void)pthread_cond_destroy(&cond1);
|
||||
(void)pthread_cond_destroy(&cond2);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread006
|
||||
* @tc.desc: Test interface pthread_cond_init
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread006(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread006", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
81
testsuites/sample/posix/pthread/It_posix_pthread_007.c
Normal file
81
testsuites/sample/posix/pthread/It_posix_pthread_007.c
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_condattr_t condattr;
|
||||
int rc;
|
||||
pthread_cond_t cond1, cond2;
|
||||
pthread_cond_t cond3 = PTHREAD_COND_INITIALIZER;
|
||||
|
||||
/* Initialize a condition variable attribute object */
|
||||
rc = pthread_condattr_init(&condattr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
/* Initialize cond1 with the default condition variable attribute */
|
||||
rc = pthread_cond_init(&cond1, &condattr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
/* Initialize cond2 with NULL attributes */
|
||||
rc = pthread_cond_init(&cond2, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
/* Destroy the condition variable attribute object */
|
||||
rc = pthread_condattr_destroy(&condattr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
/* Destroy cond1 */
|
||||
rc = pthread_cond_destroy(&cond1);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
/* Destroy cond2 */
|
||||
rc = pthread_cond_destroy(&cond2);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
/* Destroy cond3 */
|
||||
rc = pthread_cond_destroy(&cond3);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread007
|
||||
* @tc.desc: Test interface pthread_cond_destroy
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread007(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread007", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
71
testsuites/sample/posix/pthread/It_posix_pthread_008.c
Normal file
71
testsuites/sample/posix/pthread/It_posix_pthread_008.c
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static INT32 g_pthreadSchedPolicy = 0;
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_attr_t attr;
|
||||
INT32 ret;
|
||||
struct sched_param param;
|
||||
INT32 priority;
|
||||
INT32 offset = 0xff;
|
||||
|
||||
ret = pthread_attr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
g_pthreadSchedPolicy = SCHED_FIFO;
|
||||
ret = pthread_attr_setschedpolicy(&attr, g_pthreadSchedPolicy);
|
||||
ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
|
||||
|
||||
priority = sched_get_priority_max(g_pthreadSchedPolicy);
|
||||
ICUNIT_ASSERT_EQUAL(priority, PTHREAD_IS_ERROR, priority);
|
||||
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
|
||||
|
||||
param.sched_priority = priority + offset;
|
||||
ret = pthread_attr_setschedparam(&attr, ¶m);
|
||||
ICUNIT_ASSERT_EQUAL(ret, ENOTSUP, ret);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread008
|
||||
* @tc.desc: Test interface pthread_attr_setschedpolicy
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread008(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread008", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
66
testsuites/sample/posix/pthread/It_posix_pthread_009.c
Normal file
66
testsuites/sample/posix/pthread/It_posix_pthread_009.c
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_condattr_t condattr;
|
||||
int rc;
|
||||
|
||||
/* Initialize a condition variable attributes object */
|
||||
rc = pthread_condattr_init(&condattr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
/* Destroy the condition variable attributes object */
|
||||
rc = pthread_condattr_destroy(&condattr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
/* Initialize the condition variable attributes object again. This shouldn't result in an error. */
|
||||
rc = pthread_condattr_init(&condattr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
rc = pthread_condattr_destroy(&condattr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread009
|
||||
* @tc.desc: Test interface pthread_condattr_destroy
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread009(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread009", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
59
testsuites/sample/posix/pthread/It_posix_pthread_010.c
Normal file
59
testsuites/sample/posix/pthread/It_posix_pthread_010.c
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2020-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.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_condattr_t *condattr = NULL;
|
||||
int rc;
|
||||
|
||||
/* Initialize a condition variable attributes object */
|
||||
rc = pthread_condattr_init(condattr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, EINVAL, rc);
|
||||
|
||||
/* Destroy the condition variable attributes object */
|
||||
rc = pthread_condattr_destroy(condattr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, EINVAL, rc);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread010
|
||||
* @tc.desc: Test interface pthread_condattr_init
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread010(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread010", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
63
testsuites/sample/posix/pthread/It_posix_pthread_011.c
Normal file
63
testsuites/sample/posix/pthread/It_posix_pthread_011.c
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2020-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.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_condattr_t attr;
|
||||
int ret;
|
||||
|
||||
/* Initialize a cond attributes object */
|
||||
ret = pthread_condattr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
/* Set 'pshared' to INVALID_PSHARED_VALUE. */
|
||||
ret = pthread_condattr_setpshared(&attr, INVALID_PSHARED_VALUE);
|
||||
ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
|
||||
|
||||
/* Destroy the cond attributes object */
|
||||
ret = pthread_condattr_destroy(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread011
|
||||
* @tc.desc: Test interface pthread_condattr_setpshared
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread011(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread011", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
75
testsuites/sample/posix/pthread/It_posix_pthread_012.c
Normal file
75
testsuites/sample/posix/pthread/It_posix_pthread_012.c
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
INT32 inheritsched;
|
||||
INT32 g_pthreadSchedInherit;
|
||||
pthread_attr_t attr;
|
||||
|
||||
ret = pthread_attr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
g_pthreadSchedInherit = PTHREAD_INHERIT_SCHED;
|
||||
ret = pthread_attr_setinheritsched(&attr, g_pthreadSchedInherit);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_attr_getinheritsched(&attr, &inheritsched);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ICUNIT_ASSERT_EQUAL(inheritsched, g_pthreadSchedInherit, inheritsched);
|
||||
|
||||
g_pthreadSchedInherit = PTHREAD_EXPLICIT_SCHED;
|
||||
ret = pthread_attr_setinheritsched(&attr, g_pthreadSchedInherit);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_attr_getinheritsched(&attr, &inheritsched);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ICUNIT_ASSERT_EQUAL(inheritsched, g_pthreadSchedInherit, inheritsched);
|
||||
|
||||
ret = pthread_attr_destroy(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread012
|
||||
* @tc.desc: Test interface pthread_attr_getinheritsched
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread012(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread012", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
132
testsuites/sample/posix/pthread/It_posix_pthread_013.c
Normal file
132
testsuites/sample/posix/pthread/It_posix_pthread_013.c
Normal file
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (c) 2020-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.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
#define LOOP_NUM 2
|
||||
static pthread_mutex_t g_pthreadMutexTest1 = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_cond_t g_pthreadCondTest1 = PTHREAD_COND_INITIALIZER;
|
||||
|
||||
static VOID *PthreadF01(void *t)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = pthread_mutex_lock(&g_pthreadMutexTest1);
|
||||
ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
|
||||
|
||||
g_testCount++;
|
||||
LOS_TaskDelay(1);
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result.
|
||||
g_testCount++;
|
||||
|
||||
rc = pthread_cond_wait(&g_pthreadCondTest1, &g_pthreadMutexTest1);
|
||||
ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, here assert the result.
|
||||
rc = pthread_mutex_unlock(&g_pthreadMutexTest1);
|
||||
ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
|
||||
|
||||
EXIT:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static VOID *PthreadF02(void *t)
|
||||
{
|
||||
int i;
|
||||
int rc;
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
|
||||
g_testCount++;
|
||||
rc = pthread_mutex_lock(&g_pthreadMutexTest1);
|
||||
ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result.
|
||||
g_testCount++;
|
||||
rc = pthread_cond_signal(&g_pthreadCondTest1);
|
||||
ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, here assert the result.
|
||||
g_testCount++;
|
||||
|
||||
rc = pthread_mutex_unlock(&g_pthreadMutexTest1); /* Increase latency for thread polling mutex */
|
||||
ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
|
||||
LOS_TaskDelay(2); // 2, delay for Timing control.
|
||||
|
||||
EXIT:
|
||||
return NULL;
|
||||
}
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
int i;
|
||||
long t1 = 1;
|
||||
long t2 = 2; // 2, init
|
||||
int rc;
|
||||
pthread_t threads[3]; // 3, need 3 pthread for test.
|
||||
pthread_attr_t attr;
|
||||
|
||||
g_testCount = 0;
|
||||
pthread_mutex_init(&g_pthreadMutexTest1, NULL);
|
||||
/* When creating thread, it is set to connectable state, which is easy to transplant */
|
||||
pthread_cond_init(&g_pthreadCondTest1, NULL);
|
||||
pthread_attr_init(&attr);
|
||||
|
||||
rc = pthread_create(&threads[0], &attr, PthreadF01, (void *)t1);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
rc = pthread_create(&threads[1], &attr, PthreadF02, (void *)t2);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
for (i = 0; i < LOOP_NUM; i++) {
|
||||
rc = pthread_join(threads[i], NULL);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
}
|
||||
|
||||
rc = pthread_attr_destroy(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
rc = pthread_mutex_destroy(&g_pthreadMutexTest1);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
rc = pthread_cond_destroy(&g_pthreadCondTest1);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread013
|
||||
* @tc.desc: Test interface pthread_mutex_init
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread013(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread013", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
73
testsuites/sample/posix/pthread/It_posix_pthread_014.c
Normal file
73
testsuites/sample/posix/pthread/It_posix_pthread_014.c
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_condattr_t condattr;
|
||||
pthread_cond_t cond1;
|
||||
pthread_cond_t cond2;
|
||||
int pshared;
|
||||
int rc;
|
||||
|
||||
rc = pthread_condattr_init(&condattr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
rc = pthread_condattr_getpshared(NULL, &pshared);
|
||||
ICUNIT_ASSERT_EQUAL(rc, EINVAL, rc);
|
||||
|
||||
rc = pthread_condattr_getpshared(&condattr, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(rc, EINVAL, rc);
|
||||
|
||||
rc = pthread_condattr_getpshared(NULL, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(rc, EINVAL, rc);
|
||||
|
||||
rc = pthread_condattr_getpshared(&condattr, &pshared);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
ICUNIT_ASSERT_EQUAL(pshared, PTHREAD_PROCESS_PRIVATE, pshared);
|
||||
|
||||
rc = pthread_condattr_destroy(&condattr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread014
|
||||
* @tc.desc: Test interface pthread_condattr_getpshared
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread014(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread014", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
52
testsuites/sample/posix/pthread/It_posix_pthread_015.c
Normal file
52
testsuites/sample/posix/pthread/It_posix_pthread_015.c
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = pthread_cond_init(NULL, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(rc, EINVAL, rc);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread015
|
||||
* @tc.desc: Test interface pthread_cond_init
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread015(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread015", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
56
testsuites/sample/posix/pthread/It_posix_pthread_016.c
Normal file
56
testsuites/sample/posix/pthread/It_posix_pthread_016.c
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = pthread_cond_signal(NULL);
|
||||
ICUNIT_ASSERT_EQUAL(rc, EINVAL, rc);
|
||||
|
||||
rc = pthread_cond_broadcast(NULL);
|
||||
ICUNIT_ASSERT_EQUAL(rc, EINVAL, rc);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread016
|
||||
* @tc.desc: Test interface pthread_cond_signal
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread016(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread016", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
77
testsuites/sample/posix/pthread/It_posix_pthread_017.c
Normal file
77
testsuites/sample/posix/pthread/It_posix_pthread_017.c
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static int g_testCnt;
|
||||
|
||||
static VOID *PthreadF01(VOID *num)
|
||||
{
|
||||
intptr_t i = (intptr_t)num;
|
||||
PRINTK("Passed argument for thread: %d, g_testCnt = %d\n", (int)i, g_testCnt);
|
||||
ICUNIT_TRACK_EQUAL(g_testCnt, i, g_testCnt);
|
||||
g_testCnt++;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_t newTh;
|
||||
long i;
|
||||
INT32 ret;
|
||||
|
||||
g_testCnt = 1;
|
||||
|
||||
for (i = 1; i < PTHREAD_THREADS_NUM + 1; i++) {
|
||||
ret = pthread_create(&newTh, NULL, PthreadF01, (void *)i);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
ret = pthread_join(newTh, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
}
|
||||
|
||||
return LOS_OK;
|
||||
EXIT:
|
||||
pthread_detach(newTh);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread017
|
||||
* @tc.desc: Test interface pthread_create
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread017(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread017", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
76
testsuites/sample/posix/pthread/It_posix_pthread_018.c
Normal file
76
testsuites/sample/posix/pthread/It_posix_pthread_018.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static VOID *PthreadF01(VOID *num)
|
||||
{
|
||||
int *arg = (int *)num;
|
||||
|
||||
for (int i = 0; i < PTHREAD_THREADS_NUM; i++) {
|
||||
dprintf("Passed argument %d for thread\n", arg[i]);
|
||||
ICUNIT_TRACK_EQUAL(arg[i], i + 1, arg[i]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_t newTh;
|
||||
INT32 arg[PTHREAD_THREADS_NUM], ret;
|
||||
|
||||
for (int i = 0; i < PTHREAD_THREADS_NUM; i++) {
|
||||
arg[i] = i + 1;
|
||||
}
|
||||
|
||||
ret = pthread_create(&newTh, NULL, PthreadF01, (void *)&arg);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
ret = pthread_join(newTh, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
return LOS_OK;
|
||||
EXIT:
|
||||
pthread_detach(newTh);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread018
|
||||
* @tc.desc: Test interface pthread_join
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread018(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread018", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
65
testsuites/sample/posix/pthread/It_posix_pthread_019.c
Normal file
65
testsuites/sample/posix/pthread/It_posix_pthread_019.c
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static VOID *PthreadF01(VOID *argument)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_t newTh;
|
||||
INT32 ret;
|
||||
|
||||
ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_equal(newTh, newTh);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_join(newTh, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread019
|
||||
* @tc.desc: Test interface pthread_equal
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread019(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread019", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
72
testsuites/sample/posix/pthread/It_posix_pthread_020.c
Normal file
72
testsuites/sample/posix/pthread/It_posix_pthread_020.c
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static VOID *PthreadF01(VOID *argument)
|
||||
{
|
||||
sleep(1);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_t newTh1, newTh2;
|
||||
INT32 ret;
|
||||
|
||||
ret = pthread_create(&newTh1, NULL, PthreadF01, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_create(&newTh2, NULL, PthreadF01, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_equal(newTh1, newTh2);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_join(newTh1, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_join(newTh2, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread020
|
||||
* @tc.desc: Test interface pthread_equal
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread020(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread020", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
64
testsuites/sample/posix/pthread/It_posix_pthread_021.c
Normal file
64
testsuites/sample/posix/pthread/It_posix_pthread_021.c
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_attr_t newAttr;
|
||||
INT32 detachState, ret;
|
||||
|
||||
ret = pthread_attr_init(&newAttr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
/* The test passes if the attribute object has a detachstate of
|
||||
* PTHREAD_CREATE_JOINABLE, which is the default value for this
|
||||
* attribute. */
|
||||
ret = pthread_attr_getdetachstate(&newAttr, &detachState);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ICUNIT_ASSERT_EQUAL(detachState, PTHREAD_CREATE_JOINABLE, detachState);
|
||||
|
||||
ret = pthread_attr_destroy(&newAttr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread021
|
||||
* @tc.desc: Test interface pthread_getdetachstate
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread021(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread021", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
82
testsuites/sample/posix/pthread/It_posix_pthread_022.c
Normal file
82
testsuites/sample/posix/pthread/It_posix_pthread_022.c
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static INT32 g_pthreadSchedPolicy = 0;
|
||||
|
||||
static VOID *PthreadF01(VOID *argument)
|
||||
{
|
||||
struct sched_param sparam;
|
||||
INT32 priority, policy;
|
||||
INT32 ret;
|
||||
|
||||
g_pthreadSchedPolicy = SCHED_RR;
|
||||
|
||||
priority = sched_get_priority_max(g_pthreadSchedPolicy);
|
||||
|
||||
sparam.sched_priority = priority;
|
||||
|
||||
ret = pthread_setschedparam(pthread_self(), g_pthreadSchedPolicy, &sparam);
|
||||
ICUNIT_TRACK_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_getschedparam(pthread_self(), &policy, &sparam);
|
||||
ICUNIT_TRACK_EQUAL(ret, 0, ret);
|
||||
ICUNIT_TRACK_EQUAL(policy, g_pthreadSchedPolicy, policy);
|
||||
ICUNIT_TRACK_EQUAL(sparam.sched_priority, priority, sparam.sched_priority);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_t newTh;
|
||||
INT32 ret;
|
||||
|
||||
ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_join(newTh, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread022
|
||||
* @tc.desc: Test interface pthread_setschedparam
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread022(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread022", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
63
testsuites/sample/posix/pthread/It_posix_pthread_023.c
Normal file
63
testsuites/sample/posix/pthread/It_posix_pthread_023.c
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_attr_t newAttr;
|
||||
INT32 ret;
|
||||
|
||||
ret = pthread_attr_init(&newAttr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_attr_destroy(&newAttr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_attr_init(&newAttr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_attr_destroy(&newAttr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread023
|
||||
* @tc.desc: Test interface pthread_attr_init
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread023(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread023", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
82
testsuites/sample/posix/pthread/It_posix_pthread_024.c
Normal file
82
testsuites/sample/posix/pthread/It_posix_pthread_024.c
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static VOID *PthreadF01(VOID *arg)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_t newTh;
|
||||
pthread_attr_t attr;
|
||||
size_t stackSize = PTHREAD_STACK_MIN;
|
||||
size_t ssize;
|
||||
INT32 ret;
|
||||
|
||||
ret = pthread_attr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_attr_getstacksize(&attr, &ssize);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ICUNIT_ASSERT_EQUAL(ssize, PTHREAD_DEFAULT_STACK_SIZE, ssize);
|
||||
|
||||
ret = pthread_attr_setstacksize(&attr, stackSize);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_attr_getstacksize(&attr, &ssize);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ICUNIT_ASSERT_EQUAL(ssize, stackSize, ssize);
|
||||
|
||||
ret = pthread_create(&newTh, &attr, PthreadF01, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_join(newTh, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_attr_destroy(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread024
|
||||
* @tc.desc: Test interface pthread_attr_getstacksize
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread024(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread024", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
62
testsuites/sample/posix/pthread/It_posix_pthread_025.c
Normal file
62
testsuites/sample/posix/pthread/It_posix_pthread_025.c
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
pthread_attr_t attr;
|
||||
|
||||
INT32 g_pthreadScopeValue = 999; // 999, init
|
||||
|
||||
ret = pthread_attr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_attr_setscope(&attr, g_pthreadScopeValue);
|
||||
ICUNIT_ASSERT_EQUAL(ret, EINVAL, errno);
|
||||
|
||||
ret = pthread_attr_destroy(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread025
|
||||
* @tc.desc: Test interface pthread_attr_setscope
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread025(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread025", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -34,6 +34,7 @@ void ItSuitePosix(void)
|
||||
{
|
||||
PRINTF("***********************BEGIN POSIX TEST**********************\n");
|
||||
PthreadFuncTestSuite();
|
||||
ItSuitePosixPthread();
|
||||
PosixCtypeFuncTest();
|
||||
PosixIsdigitFuncTest();
|
||||
PosixIslowerFuncTest();
|
||||
|
||||
Reference in New Issue
Block a user