refactor: 内核测试套整改,简化分类
close: #I4OX3O Signed-off-by: arvinzzz <zhaotianyu9@huawei.com> Change-Id: I3ba65509135cee2ae3af82fec923a01e00ffdbe8
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//build/lite/config/test.gni")
|
||||
import("//kernel/liteos_a/testsuites/unittest/config.gni")
|
||||
import("./config.gni")
|
||||
|
||||
config("libc_config") {
|
||||
if (LOSCFG_USER_TEST_POSIX_MQUEUE == true ||
|
||||
LOSCFG_USER_TEST_POSIX_PTHREAD == true) {
|
||||
cflags = [ "-O1" ]
|
||||
cflags_cc = cflags
|
||||
}
|
||||
}
|
||||
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
unittest("liteos_a_libc_unittest_door") {
|
||||
output_extension = "bin"
|
||||
output_dir = "$root_out_dir/test/unittest/kernel"
|
||||
include_dirs = common_include_dirs
|
||||
sources = sources_entry
|
||||
sources += sources_smoke
|
||||
sources_full = []
|
||||
sources += sources_full
|
||||
configs = [ "..:public_config_for_door" ]
|
||||
configs += [ ":libc_config" ]
|
||||
deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
|
||||
}
|
||||
}
|
||||
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
unittest("liteos_a_libc_unittest") {
|
||||
output_extension = "bin"
|
||||
output_dir = "$root_out_dir/test/unittest/kernel"
|
||||
include_dirs = common_include_dirs
|
||||
sources = sources_entry
|
||||
sources += sources_smoke
|
||||
sources += sources_full
|
||||
configs = [ "..:public_config_for_all" ]
|
||||
configs += [ ":libc_config" ]
|
||||
deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//build/lite/config/test.gni")
|
||||
import("//kernel/liteos_a/testsuites/unittest/config.gni")
|
||||
|
||||
common_include_dirs = [
|
||||
"//third_party/googletest/googletest/include",
|
||||
"../common/include",
|
||||
]
|
||||
|
||||
sources_entry = [ "../common/osTest.cpp" ]
|
||||
|
||||
sources_smoke = []
|
||||
|
||||
sources_full = []
|
||||
|
||||
# io module
|
||||
if (LOSCFG_USER_TEST_IO == true) {
|
||||
import("./io/config.gni")
|
||||
common_include_dirs += io_include_dirs
|
||||
sources_entry += io_sources_entry
|
||||
sources_smoke += io_sources_smoke
|
||||
sources_full += io_sources_full
|
||||
}
|
||||
|
||||
# misc module
|
||||
if (LOSCFG_USER_TEST_MISC == true) {
|
||||
import("./misc/config.gni")
|
||||
common_include_dirs += misc_include_dirs
|
||||
sources_entry += misc_sources_entry
|
||||
sources_smoke += misc_sources_smoke
|
||||
sources_full += misc_sources_full
|
||||
}
|
||||
|
||||
# posix mem module
|
||||
if (LOSCFG_USER_TEST_POSIX_MEM == true) {
|
||||
import("./posix/mem/config.gni")
|
||||
common_include_dirs += posix_mem_include_dirs
|
||||
sources_entry += posix_mem_sources_entry
|
||||
sources_smoke += posix_mem_sources_smoke
|
||||
sources_full += posix_mem_sources_full
|
||||
}
|
||||
|
||||
# posix mqueue module
|
||||
if (LOSCFG_USER_TEST_POSIX_MQUEUE == true) {
|
||||
import("./posix/mqueue/config.gni")
|
||||
common_include_dirs += posix_mqueue_include_dirs
|
||||
sources_entry += posix_mqueue_sources_entry
|
||||
sources_smoke += posix_mqueue_sources_smoke
|
||||
sources_full += posix_mqueue_sources_full
|
||||
}
|
||||
|
||||
# posix pthread module
|
||||
if (LOSCFG_USER_TEST_POSIX_PTHREAD == true) {
|
||||
import("./posix/pthread/config.gni")
|
||||
common_include_dirs += posix_pthread_include_dirs
|
||||
sources_entry += posix_pthread_sources_entry
|
||||
sources_smoke += posix_pthread_sources_smoke
|
||||
sources_full += posix_pthread_sources_full
|
||||
}
|
||||
|
||||
# sys module
|
||||
if (LOSCFG_USER_TEST_SYS == true) {
|
||||
import("./sys/config.gni")
|
||||
common_include_dirs += sys_include_dirs
|
||||
sources_entry += sys_sources_entry
|
||||
sources_smoke += sys_sources_smoke
|
||||
sources_full += sys_sources_full
|
||||
}
|
||||
|
||||
# time module
|
||||
if (LOSCFG_USER_TEST_TIME_CLOCK == true) {
|
||||
import("./time/clock/config.gni")
|
||||
common_include_dirs += time_clock_include_dirs
|
||||
sources_entry += time_clock_sources_entry
|
||||
sources_smoke += time_clock_sources_smoke
|
||||
sources_full += time_clock_sources_full
|
||||
}
|
||||
|
||||
if (LOSCFG_USER_TEST_TIME_TIMER == true) {
|
||||
import("./time/timer/config.gni")
|
||||
common_include_dirs += time_timer_include_dirs
|
||||
sources_entry += time_timer_sources_entry
|
||||
sources_smoke += time_timer_sources_smoke
|
||||
sources_full += time_timer_sources_full
|
||||
}
|
||||
|
||||
# util module
|
||||
if (LOSCFG_USER_TEST_UTIL == true) {
|
||||
import("./util/config.gni")
|
||||
common_include_dirs += util_include_dirs
|
||||
sources_entry += util_sources_entry
|
||||
sources_smoke += util_sources_smoke
|
||||
sources_full += util_sources_full
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef _IT_TEST_IO_H
|
||||
#define _IT_TEST_IO_H
|
||||
|
||||
#include "osTest.h"
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "unistd.h"
|
||||
#include "string.h"
|
||||
#include "termios.h"
|
||||
#include "sys/types.h"
|
||||
#include "sys/stat.h"
|
||||
#include "fcntl.h"
|
||||
#include "locale.h"
|
||||
#include "wctype.h"
|
||||
#include "wchar.h"
|
||||
#include "stdarg.h"
|
||||
#include "semaphore.h"
|
||||
#include "ftw.h"
|
||||
#include "aio.h"
|
||||
#include "shadow.h"
|
||||
#include "pty.h"
|
||||
#include "dirent.h"
|
||||
#include "poll.h"
|
||||
#include "grp.h"
|
||||
#include "pwd.h"
|
||||
#include "sys/uio.h"
|
||||
#include "syslog.h"
|
||||
#include "sys/epoll.h"
|
||||
|
||||
extern int CloseRmAllFile(int fd[], char filePathName[][50], int cnt);
|
||||
extern char *g_ioTestPath;
|
||||
|
||||
extern VOID ItTestIo001(VOID);
|
||||
extern VOID ItTestIo002(VOID);
|
||||
extern VOID ItTestIo003(VOID);
|
||||
extern VOID ItTestIo004(VOID);
|
||||
extern VOID ItTestIo005(VOID);
|
||||
extern VOID ItTestIo006(VOID);
|
||||
extern VOID ItTestIo007(VOID);
|
||||
extern VOID ItTestIo008(VOID);
|
||||
extern VOID ItTestIo009(VOID);
|
||||
extern VOID ItTestIo010(VOID);
|
||||
extern VOID ItTestIo011(VOID);
|
||||
extern VOID ItTestIo012(VOID);
|
||||
extern VOID ItTestIo013(VOID);
|
||||
|
||||
extern VOID ItLocaleFreelocale001(void);
|
||||
extern VOID ItLocaleLocaleconv001(void);
|
||||
extern VOID ItStdioFputws001(void);
|
||||
extern VOID ItStdioFwprintf001(void);
|
||||
extern VOID ItStdioFtruncate001(void);
|
||||
extern VOID ItStdioFtw001(void);
|
||||
extern VOID ItStdlibOpenpty001(void);
|
||||
extern VOID ItStdlibPtsname001(void);
|
||||
extern VOID ItStdioGetcUnlocked001(void);
|
||||
extern VOID ItStdioGetcharUnlocked001(void);
|
||||
extern VOID ItStdioGetw001(void);
|
||||
extern VOID ItStdioGetwchar001(void);
|
||||
extern VOID ItStdioLioListio001(void); // linux erro
|
||||
extern VOID ItStdioMblen001(void);
|
||||
extern VOID ItStdioMbrlen001(void);
|
||||
extern VOID ItStdioMbstowcs001(void);
|
||||
extern VOID ItStdioMbsnrtowcs001(void);
|
||||
extern VOID ItStdioPutcUnlocked001(void);
|
||||
extern VOID ItStdioPutcharUnlocked001(void);
|
||||
extern VOID ItStdioPutgrent001(void);
|
||||
extern VOID ItStdioPutpwent001(void);
|
||||
extern VOID ItStdioPutspent001(void);
|
||||
extern VOID ItStdioPutwc001(void);
|
||||
extern VOID ItStdioPutwchar001(void);
|
||||
extern VOID ItStdioReadv001(void);
|
||||
extern VOID ItStdioRindex001(void);
|
||||
extern VOID ItStdioSelect002(void);
|
||||
extern VOID ItStdioSetgrent001(void);
|
||||
extern VOID ItStdioSetlogmask001(void);
|
||||
extern VOID ItStdioSetmntent001(void);
|
||||
extern VOID ItStdlibGcvt001(void);
|
||||
extern VOID ItStdlibOpenpty001(void);
|
||||
extern VOID ItStdlibPoll001(void);
|
||||
extern VOID ItStdlibPoll002(void);
|
||||
extern VOID ItStdlibPoll003(void);
|
||||
extern VOID ItStdlibPtsname001(void);
|
||||
extern VOID IT_STDIO_HASMNTOPT_001(void);
|
||||
extern VOID IO_TEST_NGETTEXT_001(void);
|
||||
extern VOID IO_TEST_EPOLL_001(void);
|
||||
extern VOID IO_TEST_LOCALE_001(void);
|
||||
extern VOID IO_TEST_LOCALE_002(void);
|
||||
extern VOID IO_TEST_CONFSTR_001(void);
|
||||
extern VOID IO_TEST_NL_LANGINFO_001(VOID);
|
||||
extern VOID IO_TEST_STRCASECMP_L_001(VOID);
|
||||
extern VOID IO_TEST_STRCASECMP_L_002(VOID);
|
||||
extern VOID IO_TEST_STRNCASECMP_L_001(VOID);
|
||||
extern VOID IO_TEST_STRNCASECMP_L_002(VOID);
|
||||
extern VOID IO_TEST_DUPLOCALE_001(void);
|
||||
extern VOID IO_TEST_NL_LANGINFO_l_001(VOID);
|
||||
extern VOID IO_TEST_DNGETTEXT_001(VOID);
|
||||
extern VOID IO_TEST_DNGETTEXT_002(VOID);
|
||||
extern VOID IO_TEST_DCNGETTEXT_001(VOID);
|
||||
extern VOID IO_TEST_DCNGETTEXT_002(VOID);
|
||||
extern VOID IO_TEST_DCGETTEXT_001(VOID);
|
||||
extern VOID IO_TEST_DCGETTEXT_002(VOID);
|
||||
extern VOID IO_TEST_GETTEXT_001(VOID);
|
||||
extern VOID IO_TEST_PSELECT_001(void);
|
||||
extern VOID IO_TEST_PSELECT_002(void);
|
||||
extern VOID IO_TEST_STRFMON_L_001(VOID);
|
||||
extern VOID IO_TEST_STRFMON_L_002(VOID);
|
||||
extern VOID IO_TEST_PPOLL_001(VOID);
|
||||
extern VOID IO_TEST_PPOLL_002(VOID);
|
||||
extern VOID IO_TEST_PPOLL_003(VOID);
|
||||
extern VOID IO_TEST_EPOLL_001(VOID);
|
||||
extern VOID IO_TEST_EPOLL_002(VOID);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,84 @@
|
||||
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/testsuites/unittest/config.gni")
|
||||
|
||||
io_include_dirs = [ "$TEST_UNITTEST_DIR/libc/io" ]
|
||||
|
||||
io_sources_entry = [ "$TEST_UNITTEST_DIR/libc/io/io_test.cpp" ]
|
||||
|
||||
io_sources_smoke = [
|
||||
"$TEST_UNITTEST_DIR/libc/io/smoke/IO_test_005.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/smoke/IO_test_008.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/smoke/IO_test_010.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/smoke/IO_test_013.cpp",
|
||||
]
|
||||
|
||||
io_sources_full = [
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_confstr_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_dcgettext_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_dcgettext_002.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_dcngettext_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_dcngettext_002.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_dngettext_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_dngettext_002.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_duplocale_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_locale_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_locale_002.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_ngettext_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_nl_langinfo_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_nl_langinfo_l_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_strcasecmp_l_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_strcasecmp_l_002.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_strfmon_l_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_strfmon_l_002.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/It_locale_localeconv_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/It_stdio_fputws_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/It_stdio_fwprintf_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/It_stdio_getc_unlocked_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/It_stdio_hasmntopt_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/It_stdio_mblen_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/It_stdio_mbrlen_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/It_stdio_putwc_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/It_stdio_readv_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/It_stdio_rindex_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/It_stdio_setlogmask_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/It_stdlib_gcvt_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/It_stdlib_poll_002.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/It_stdlib_poll_003.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_gettext_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_strncasecmp_l_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_strncasecmp_l_002.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_ppoll_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_ppoll_002.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_ppoll_003.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_pselect_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_pselect_002.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_epoll_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/io/full/IO_test_epoll_002.cpp",
|
||||
]
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
|
||||
static UINT32 testcase(VOID)
|
||||
{
|
||||
char *pathbuf = nullptr;
|
||||
char *gun_libpthread_version_buf = nullptr;
|
||||
char *gun_libc_version_buf = nullptr;
|
||||
size_t n = 0;
|
||||
|
||||
n = confstr(_CS_PATH, NULL, (size_t) 0);
|
||||
ICUNIT_ASSERT_WITHIN_EQUAL(n, 0, UINT_MAX, n);
|
||||
pathbuf = (char *)malloc(n);
|
||||
if (pathbuf == NULL) {
|
||||
return LOS_NOK;
|
||||
}
|
||||
confstr(_CS_PATH, pathbuf, n);
|
||||
ICUNIT_ASSERT_NOT_EQUAL_NULL(pathbuf, NULL, -1);
|
||||
free(pathbuf);
|
||||
pathbuf = NULL;
|
||||
|
||||
n = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, (size_t) 0);
|
||||
ICUNIT_ASSERT_WITHIN_EQUAL(n, 0, UINT_MAX, n);
|
||||
if (n > 0) {
|
||||
gun_libpthread_version_buf = (char *)malloc(n);
|
||||
}
|
||||
if (gun_libpthread_version_buf == NULL) {
|
||||
return LOS_NOK;
|
||||
}
|
||||
confstr(_CS_GNU_LIBPTHREAD_VERSION, gun_libpthread_version_buf, n);
|
||||
ICUNIT_ASSERT_NOT_EQUAL_NULL(gun_libpthread_version_buf, NULL, -1);
|
||||
free(gun_libpthread_version_buf);
|
||||
gun_libpthread_version_buf = NULL;
|
||||
|
||||
n = confstr(_CS_GNU_LIBC_VERSION, NULL, (size_t) 0);
|
||||
ICUNIT_ASSERT_WITHIN_EQUAL(n, 0, UINT_MAX, n);
|
||||
if (n > 0) {
|
||||
gun_libc_version_buf = (char *)malloc(n);
|
||||
}
|
||||
if (gun_libc_version_buf == NULL) {
|
||||
return LOS_NOK;
|
||||
}
|
||||
confstr(_CS_GNU_LIBC_VERSION, gun_libc_version_buf, n);
|
||||
ICUNIT_ASSERT_NOT_EQUAL_NULL(gun_libc_version_buf, NULL, -1);
|
||||
free(gun_libc_version_buf);
|
||||
gun_libc_version_buf = NULL;
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID IO_TEST_CONFSTR_001(void)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
#include <libintl.h>
|
||||
#include <locale.h>
|
||||
|
||||
static UINT32 testcase(VOID)
|
||||
{
|
||||
char *s = "";
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
textdomain("gettext_demo");
|
||||
bindtextdomain("gettext_demo", ".");
|
||||
bind_textdomain_codeset("gettext_demo", "UTF-8");
|
||||
|
||||
printf(dcgettext("www.huawei.com", "TestString1\n", LC_MESSAGES));
|
||||
|
||||
s = dcgettext("www.huawei.com", "TestString1\n", LC_MESSAGES);
|
||||
printf("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
|
||||
ICUNIT_ASSERT_STRING_EQUAL(s, "TestString1\n", s);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID IO_TEST_DCGETTEXT_001(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
#include <libintl.h>
|
||||
#include <locale.h>
|
||||
|
||||
static UINT32 testcase1(VOID)
|
||||
{
|
||||
char *s = "";
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
textdomain("gettext_demo");
|
||||
bindtextdomain("gettext_demo", ".");
|
||||
bind_textdomain_codeset("gettext_demo", "UTF-8");
|
||||
|
||||
errno = 0;
|
||||
s = dcgettext("www.huawei.com", "TestString1\n", LC_MESSAGES);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
|
||||
ICUNIT_GOTO_STRING_EQUAL(s, "TestString1\n", -1, OUT);
|
||||
|
||||
return LOS_OK;
|
||||
OUT:
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
static UINT32 testcase2(VOID)
|
||||
{
|
||||
char *s = "";
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
textdomain("gettext_demo");
|
||||
bindtextdomain("gettext_demo", ".");
|
||||
bind_textdomain_codeset("gettext_demo", "UTF-8");
|
||||
|
||||
errno = 0;
|
||||
s = dcgettext(nullptr, "Hello World!\n", LC_MESSAGES);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
|
||||
ICUNIT_GOTO_STRING_EQUAL(s, "Hello World!\n", -1, OUT);
|
||||
|
||||
return LOS_OK;
|
||||
OUT:
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
static UINT32 testcase3(VOID)
|
||||
{
|
||||
char *s = "";
|
||||
char *domain = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\
|
||||
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\
|
||||
12345678901234567890123456789012345678901234567890123456";
|
||||
char *string = "Domain is NAME_MAX+1 256 characters long!\n";
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
textdomain("gettext_demo");
|
||||
bindtextdomain("gettext_demo", ".");
|
||||
bind_textdomain_codeset("gettext_demo", "UTF-8");
|
||||
|
||||
errno = 0;
|
||||
s = dcgettext(domain, string, LC_MESSAGES);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
|
||||
ICUNIT_GOTO_STRING_EQUAL(s, string, -1, OUT);
|
||||
|
||||
return LOS_OK;
|
||||
OUT:
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
static UINT32 testcase4(VOID)
|
||||
{
|
||||
char *s = "";
|
||||
char *domain = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\
|
||||
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\
|
||||
123456789012345678901234567890123456789012345678901234567";
|
||||
char *string = "Domain is more than NAME_MAX+1(256) 257 characters long!\n";
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
textdomain("gettext_demo");
|
||||
bindtextdomain("gettext_demo", ".");
|
||||
bind_textdomain_codeset("gettext_demo", "UTF-8");
|
||||
|
||||
errno = 0;
|
||||
s = dcgettext(domain, string, LC_MESSAGES);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
|
||||
ICUNIT_GOTO_STRING_EQUAL(s, string, -1, OUT);
|
||||
|
||||
return LOS_OK;
|
||||
OUT:
|
||||
return LOS_NOK;
|
||||
}
|
||||
static UINT32 testcase(VOID)
|
||||
{
|
||||
errno = 0;
|
||||
|
||||
testcase1();
|
||||
testcase2();
|
||||
testcase3();
|
||||
testcase4();
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID IO_TEST_DCGETTEXT_002(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
#include <libintl.h>
|
||||
#include <locale.h>
|
||||
|
||||
static UINT32 testcase(VOID)
|
||||
{
|
||||
char *s = "";
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
textdomain("gettext_demo");
|
||||
bindtextdomain("gettext_demo", ".");
|
||||
bind_textdomain_codeset("gettext_demo", "UTF-8");
|
||||
|
||||
printf(dcngettext("www.huawei.com", "TestString1\n", "TestString2\n", 1, LC_MESSAGES));
|
||||
printf(dcngettext("www.huawei.com", "TestString1\n", "TestString2\n", 2, LC_MESSAGES));
|
||||
|
||||
s = dcngettext("www.huawei.com", "TestString1\n", "TestString2\n", 1, LC_MESSAGES);
|
||||
printf("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
|
||||
ICUNIT_ASSERT_STRING_EQUAL(s, "TestString1\n", s);
|
||||
|
||||
s = dcngettext("www.huawei.com", "TestString1\n", "TestString2\n", 2, LC_MESSAGES);
|
||||
printf("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
|
||||
ICUNIT_ASSERT_STRING_EQUAL(s, "TestString2\n", s);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID IO_TEST_DCNGETTEXT_001(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
#include <libintl.h>
|
||||
#include <locale.h>
|
||||
|
||||
static UINT32 testcase1(VOID)
|
||||
{
|
||||
char *s = "";
|
||||
|
||||
setlocale(LC_ALL, "zh_CN.UTF-8");
|
||||
textdomain("gettext_demo");
|
||||
bindtextdomain("gettext_demo", ".");
|
||||
bind_textdomain_codeset("gettext_demo", "UTF-8");
|
||||
|
||||
errno = 0;
|
||||
s = dcngettext("", "TestString1:Hello world!\n", "TestString2\n", 1, LC_MESSAGES);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
|
||||
ICUNIT_ASSERT_STRING_EQUAL(s, "TestString1:Hello world!\n", s);
|
||||
ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
|
||||
|
||||
errno = 0;
|
||||
s = dcngettext("", "TestString1\n", "TestString2:Hello world!\n", 2, LC_MESSAGES);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
|
||||
ICUNIT_ASSERT_STRING_EQUAL(s, "TestString2:Hello world!\n", s);
|
||||
ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
|
||||
|
||||
return LOS_OK;
|
||||
OUT:
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
static UINT32 testcase2(VOID)
|
||||
{
|
||||
char *s = "";
|
||||
|
||||
setlocale(LC_ALL, "zh_CN.UTF-8");
|
||||
textdomain("gettext_demo");
|
||||
bindtextdomain("gettext_demo", ".");
|
||||
bind_textdomain_codeset("gettext_demo", "UTF-8");
|
||||
|
||||
errno = 0;
|
||||
s = dcngettext("en_US.UTF-8", "TestString1:Hello world!\n", "TestString2:Hello world!\n", 1, LC_MESSAGES);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
|
||||
ICUNIT_ASSERT_STRING_EQUAL(s, "TestString1:Hello world!\n", s);
|
||||
ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
|
||||
|
||||
errno = 0;
|
||||
s = dcngettext("en_US.UTF-8", "TestString1\n", "TestString2:Hello world!\n", 2, LC_MESSAGES);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
|
||||
ICUNIT_ASSERT_STRING_EQUAL(s, "TestString2:Hello world!\n", s);
|
||||
ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
|
||||
|
||||
return LOS_OK;
|
||||
OUT:
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
static UINT32 testcase(VOID)
|
||||
{
|
||||
testcase1();
|
||||
testcase2();
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID IO_TEST_DCNGETTEXT_002(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
#include <libintl.h>
|
||||
#include <locale.h>
|
||||
|
||||
static UINT32 testcase(VOID)
|
||||
{
|
||||
char *s = "";
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
textdomain("gettext_demo");
|
||||
bindtextdomain("gettext_demo", ".");
|
||||
bind_textdomain_codeset("gettext_demo", "UTF-8");
|
||||
|
||||
printf(dngettext("www.huawei.com", "TestString1\n", "TestString2\n", 1));
|
||||
printf(dngettext("www.huawei.com", "TestString1\n", "TestString2\n", 2));
|
||||
|
||||
s = dngettext("www.huawei.com", "TestString1\n", "TestString2\n", 1);
|
||||
printf("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
|
||||
ICUNIT_ASSERT_STRING_EQUAL(s, "TestString1\n", s);
|
||||
|
||||
s = dngettext("www.huawei.com", "TestString1\n", "TestString2\n", 2);
|
||||
printf("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
|
||||
ICUNIT_ASSERT_STRING_EQUAL(s, "TestString2\n", s);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID IO_TEST_DNGETTEXT_001(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
#include <libintl.h>
|
||||
#include <locale.h>
|
||||
|
||||
static UINT32 testcase1(VOID)
|
||||
{
|
||||
char *s = "";
|
||||
|
||||
setlocale(LC_ALL, "zh_CN.UTF-8");
|
||||
textdomain("gettext_demo");
|
||||
bindtextdomain("gettext_demo", ".");
|
||||
bind_textdomain_codeset("gettext_demo", "UTF-8");
|
||||
|
||||
errno = 0;
|
||||
s = dngettext("", "TestString1:Hello world!\n", "TestString2\n", 1);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
|
||||
ICUNIT_ASSERT_STRING_EQUAL(s, "TestString1:Hello world!\n", s);
|
||||
ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
|
||||
|
||||
errno = 0;
|
||||
s = dngettext("", "TestString1\n", "TestString2:Hello world!\n", 2);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
|
||||
ICUNIT_ASSERT_STRING_EQUAL(s, "TestString2:Hello world!\n", s);
|
||||
ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
|
||||
|
||||
return LOS_OK;
|
||||
OUT:
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
static UINT32 testcase2(VOID)
|
||||
{
|
||||
char *s = "";
|
||||
|
||||
setlocale(LC_ALL, "zh_CN.UTF-8");
|
||||
textdomain("gettext_demo");
|
||||
bindtextdomain("gettext_demo", ".");
|
||||
bind_textdomain_codeset("gettext_demo", "UTF-8");
|
||||
|
||||
errno = 0;
|
||||
s = dngettext("en_US.UTF-8", "TestString1:Hello world!\n", "TestString2\n", 1);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
|
||||
ICUNIT_ASSERT_STRING_EQUAL(s, "TestString1:Hello world!\n", s);
|
||||
ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
|
||||
|
||||
errno = 0;
|
||||
s = dngettext("en_US.UTF-8", "TestString1\n", "TestString2:Hello world!\n", 2);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
|
||||
ICUNIT_ASSERT_STRING_EQUAL(s, "TestString2:Hello world!\n", s);
|
||||
ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
|
||||
|
||||
return LOS_OK;
|
||||
OUT:
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
static UINT32 testcase3(VOID)
|
||||
{
|
||||
char *s = "";
|
||||
|
||||
setlocale(LC_ALL, "zh_CN.UTF-8");
|
||||
textdomain("gettext_demo");
|
||||
bindtextdomain("gettext_demo", ".");
|
||||
bind_textdomain_codeset("gettext_demo", "UTF-8");
|
||||
|
||||
errno = 0;
|
||||
s = dngettext("en_US.UTF-8", "TestString1:Hello world!\n", "TestString2!\n", 5);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
|
||||
ICUNIT_GOTO_STRING_EQUAL(s, "TestString2!\n", -1, OUT);
|
||||
ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
|
||||
|
||||
errno = 0;
|
||||
s = dngettext("en_US.UTF-8", "TestString1\n", "TestString2:Hello world!\n", 3);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
|
||||
ICUNIT_GOTO_STRING_EQUAL(s, "TestString2:Hello world!\n", -1, OUT);
|
||||
ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
|
||||
|
||||
return LOS_OK;
|
||||
OUT:
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
static UINT32 testcase(VOID)
|
||||
{
|
||||
testcase1(); /* test the domain is NULL */
|
||||
testcase2(); /* test the domain is different with the setlocale */
|
||||
testcase3(); /* if n != 1,then dngettext will choose msgid2's string */
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID IO_TEST_DNGETTEXT_002(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <time.h>
|
||||
#include <locale.h>
|
||||
#include <langinfo.h>
|
||||
#include "It_test_IO.h"
|
||||
|
||||
/* Zh_cn.utf-8 File content */
|
||||
int fileWords[] = {
|
||||
0x950412de, 0x0, 0x3, 0x1c, 0x34, 0x5,
|
||||
0x4c, 0x0, 0x60, 0x3, 0x61, 0x3,
|
||||
0x65, 0x14f, 0x69, 0x9, 0x1b9, 0x6,
|
||||
0x1c3, 0x1, 0x3, 0x0, 0x0, 0x2,
|
||||
0x69724600, 0x6e614a00, 0x6f725000, 0x7463656a, 0x2d64492d, 0x73726556,
|
||||
0x3a6e6f69, 0x6d695620, 0x6d695328, 0x66696c70, 0x20646569, 0x6e696843,
|
||||
0x29657365, 0x7065520a, 0x2d74726f, 0x6967734d, 0x75422d64, 0x542d7367,
|
||||
0xa203a6f, 0x522d4f50, 0x73697665, 0x2d6e6f69, 0x65746144, 0x3032203a,
|
||||
0x302d3630, 0x31322d34, 0x3a343120, 0x302b3030, 0xa303038, 0x7473614c,
|
||||
0x6172542d, 0x616c736e, 0x3a726f74, 0x68755920, 0x20676e65, 0xa656958,
|
||||
0x676e614c, 0x65676175, 0x6165542d, 0x53203a6d, 0x6c706d69, 0x65696669,
|
||||
0x68432064, 0x73656e69, 0x494d0a65, 0x562d454d, 0x69737265, 0x203a6e6f,
|
||||
0xa302e31, 0x746e6f43, 0x2d746e65, 0x65707954, 0x6574203a, 0x702f7478,
|
||||
0x6e69616c, 0x6863203b, 0x65737261, 0x54553d74, 0xa382d46, 0x746e6f43,
|
||||
0x2d746e65, 0x6e617254, 0x72656673, 0x636e452d, 0x6e69646f, 0x38203a67,
|
||||
0xa746962, 0x72756c50, 0x462d6c61, 0x736d726f, 0x706e203a, 0x6172756c,
|
||||
0x313d736c, 0x6c70203b, 0x6c617275, 0xa3b303d, 0x676e614c, 0x65676175,
|
||||
0x687a203a, 0xa4e435f, 0x65472d58, 0x6172656e, 0x3a726f74, 0x656f5020,
|
||||
0x20746964, 0xa302e33, 0x9f98e600, 0xe49f9ce6, 0xe40094ba, 0x9ce680b8,
|
||||
0x88
|
||||
};
|
||||
|
||||
UINT32 SonFunc(VOID)
|
||||
{
|
||||
int ret;
|
||||
struct tm timer_;
|
||||
struct tm *timer = &timer_;
|
||||
char buffer[80]; /* 80, The number of characters returned by strftime */
|
||||
char *retptr = nullptr;
|
||||
|
||||
/* set timer as 'Thu Jan 1 23:48:56 1970'" */
|
||||
timer->tm_sec = 32; /* 32, example */
|
||||
timer->tm_min = 3; /* 3, example */
|
||||
timer->tm_hour = 1;
|
||||
timer->tm_mday = 2;
|
||||
timer->tm_mon = 0;
|
||||
timer->tm_year = 70; /* 70, example */
|
||||
timer->tm_wday = 5; /* 5, example */
|
||||
timer->tm_yday = 1;
|
||||
timer->tm_isdst = 0;
|
||||
timer->__tm_gmtoff = 0;
|
||||
timer->__tm_zone = nullptr;
|
||||
|
||||
ret = setenv("MUSL_LOCPATH", "/storage", 1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, -1);
|
||||
retptr = getenv("MUSL_LOCPATH");
|
||||
ICUNIT_ASSERT_NOT_EQUAL(retptr, NULL, -1);
|
||||
ICUNIT_ASSERT_STRING_EQUAL(retptr, "/storage", -1);
|
||||
|
||||
retptr = setlocale(LC_TIME, "en_US.UTF-8");
|
||||
ICUNIT_ASSERT_NOT_EQUAL(retptr, NULL, -1);
|
||||
ICUNIT_ASSERT_STRING_EQUAL(retptr, "en_US.UTF-8", -1);
|
||||
|
||||
ret = strftime(buffer, 80, "%c", timer); /* 80, The maximum number of characters in the string str */
|
||||
ICUNIT_ASSERT_NOT_EQUAL(ret, 0, -1);
|
||||
ICUNIT_ASSERT_STRING_EQUAL(buffer, "Fri Jan 2 01:03:32 1970", -1);
|
||||
|
||||
retptr = setlocale(LC_TIME, "zh_CN.UTF-8");
|
||||
ICUNIT_ASSERT_NOT_EQUAL(retptr, NULL, -1);
|
||||
ICUNIT_ASSERT_STRING_EQUAL(retptr, "zh_CN.UTF-8", -1);
|
||||
|
||||
ret = strftime(buffer, 80, "%c", timer); /* 80, The maximum number of characters in the string str */
|
||||
ICUNIT_ASSERT_NOT_EQUAL(ret, 0, -1);
|
||||
ICUNIT_ASSERT_STRING_EQUAL(buffer, "星期五 一月 2 01:03:32 1970", -1);
|
||||
|
||||
retptr = setlocale(LC_TIME, "");
|
||||
ICUNIT_ASSERT_NOT_EQUAL(retptr, NULL, -1);
|
||||
ICUNIT_ASSERT_STRING_EQUAL(retptr, "C", -1);
|
||||
|
||||
ret = strftime(buffer, 80, "%c", timer); /* 80, The maximum number of characters in the string str */
|
||||
ICUNIT_ASSERT_NOT_EQUAL(ret, 0, -1);
|
||||
ICUNIT_ASSERT_STRING_EQUAL(buffer, "Fri Jan 2 01:03:32 1970", -1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static UINT32 testcase(VOID)
|
||||
{
|
||||
int ret, status;
|
||||
locale_t oldloc = LC_GLOBAL_LOCALE;
|
||||
locale_t newloc = nullptr;
|
||||
|
||||
char *pathList[] = {"/storage/zh_CN.UTF-8"};
|
||||
char *streamList[] = {(char *)fileWords};
|
||||
int streamLen[] = {sizeof(fileWords) - 2};
|
||||
|
||||
newloc = duplocale(oldloc);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(newloc, nullptr, -1);
|
||||
free(newloc);
|
||||
|
||||
ret = PrepareFileEnv(pathList, streamList, streamLen, 1);
|
||||
if (ret != 0) {
|
||||
printf("error: need some env file, but prepare is not ok");
|
||||
(VOID)RecoveryFileEnv(pathList, 1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
pid_t pid = fork();
|
||||
if (pid == 0) {
|
||||
ret = SonFunc();
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
ret = waitpid(pid, &status, 0);
|
||||
ICUNIT_ASSERT_EQUAL(ret, pid, ret);
|
||||
(VOID)RecoveryFileEnv(pathList, 1);
|
||||
status = WEXITSTATUS(status);
|
||||
ICUNIT_ASSERT_EQUAL(status, 0, status);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID IO_TEST_DUPLOCALE_001(void)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "It_test_IO.h"
|
||||
#include <sys/epoll.h>
|
||||
#include "signal.h"
|
||||
#include "pthread.h"
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static UINT32 testcase(VOID)
|
||||
{
|
||||
fd_set rfds;
|
||||
int retval;
|
||||
pid_t pid;
|
||||
int pipeFd[2]; /* 2, pipe id num */
|
||||
char buffer[40]; /* 40, buffer size */
|
||||
int i = 0;
|
||||
int status;
|
||||
|
||||
int epFd;
|
||||
sigset_t mask;
|
||||
struct epoll_event ev;
|
||||
struct epoll_event evWait[2]; /* 2, evs num */
|
||||
|
||||
retval = pipe(pipeFd);
|
||||
ICUNIT_GOTO_EQUAL(retval, 0, retval, OUT);
|
||||
|
||||
/* Watch fd to see when it has input. */
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(pipeFd[0], &rfds);
|
||||
|
||||
/* Wait up to three seconds. */
|
||||
epFd = epoll_create1(100); /* 100, cretae input, */
|
||||
ICUNIT_GOTO_NOT_EQUAL(epFd, -1, epFd, OUT);
|
||||
|
||||
ev.events = EPOLLIN | EPOLLOUT | EPOLLRDNORM | EPOLLWRNORM;
|
||||
retval = epoll_ctl(epFd, EPOLL_CTL_ADD, pipeFd[0], &ev);
|
||||
ICUNIT_GOTO_NOT_EQUAL(retval, -1, retval, OUT);
|
||||
|
||||
pid = fork();
|
||||
if (pid == 0) {
|
||||
close(pipeFd[1]);
|
||||
|
||||
memset(evWait, 0, sizeof(struct epoll_event) * 2); /* 2, evs num */
|
||||
retval = epoll_wait(epFd, evWait, 2, 3000); /* 2, num of wait fd. 3000, wait time */
|
||||
close(pipeFd[0]);
|
||||
|
||||
if (retval) {
|
||||
exit(LOS_OK);
|
||||
} else {
|
||||
exit(LOS_NOK);
|
||||
}
|
||||
} else {
|
||||
sleep(1);
|
||||
close(pipeFd[0]);
|
||||
retval = write(pipeFd[1], "0123456789012345678901234567890123456789", 40); /* write 40 bytes to stdin(fd 0) */
|
||||
ICUNIT_GOTO_EQUAL(retval, 40, retval, OUT);
|
||||
close(pipeFd[1]);
|
||||
|
||||
wait(&status);
|
||||
status = WEXITSTATUS(status);
|
||||
ICUNIT_ASSERT_EQUAL(status, LOS_OK, status);
|
||||
}
|
||||
|
||||
return LOS_OK;
|
||||
OUT:
|
||||
close(pipeFd[0]);
|
||||
close(pipeFd[1]);
|
||||
close(epFd);
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
|
||||
VOID IO_TEST_EPOLL_001(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "It_test_IO.h"
|
||||
#include <sys/epoll.h>
|
||||
#include "signal.h"
|
||||
#include "pthread.h"
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void SigPrint(int sig)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static UINT32 testcase(VOID)
|
||||
{
|
||||
fd_set rfds;
|
||||
struct timespec tv;
|
||||
int retval;
|
||||
pid_t pid;
|
||||
int pipeFd[2]; /* 2, pipe id num */
|
||||
char buffer[40]; /* 40, buffer size */
|
||||
int i = 0;
|
||||
int status;
|
||||
|
||||
int epFd;
|
||||
sigset_t mask;
|
||||
void (*retSig)(int);
|
||||
struct epoll_event ev;
|
||||
struct epoll_event evWait[2];
|
||||
|
||||
retSig = signal(SIGALRM, SigPrint);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(retSig, NULL, retSig);
|
||||
|
||||
retSig = signal(SIGUSR1, SigPrint);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(retSig, NULL, retSig);
|
||||
|
||||
retval = sigemptyset(&mask);
|
||||
ICUNIT_ASSERT_EQUAL(retval, 0, retval);
|
||||
|
||||
retval = sigaddset(&mask, SIGALRM);
|
||||
ICUNIT_ASSERT_EQUAL(retval, 0, retval);
|
||||
|
||||
retval = sigaddset(&mask, SIGUSR1);
|
||||
ICUNIT_ASSERT_EQUAL(retval, 0, retval);
|
||||
|
||||
retval = pipe(pipeFd);
|
||||
ICUNIT_GOTO_EQUAL(retval, 0, retval, OUT);
|
||||
|
||||
/* Watch fd to see when it has input. */
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(pipeFd[0], &rfds);
|
||||
|
||||
/* Wait up to three seconds. */
|
||||
tv.tv_sec = 3; /* 3, wait timer, second */
|
||||
tv.tv_nsec = 5; /* 5, wait timer, nano second */
|
||||
|
||||
epFd = epoll_create1(100); /* 100, cretae input, */
|
||||
ICUNIT_GOTO_NOT_EQUAL(epFd, -1, epFd, OUT);
|
||||
|
||||
ev.events = EPOLLRDNORM;
|
||||
retval = epoll_ctl(epFd, EPOLL_CTL_ADD, pipeFd[0], &ev);
|
||||
|
||||
ICUNIT_GOTO_NOT_EQUAL(retval, -1, retval, OUT);
|
||||
|
||||
pid = fork();
|
||||
if (pid == 0) {
|
||||
close(pipeFd[1]);
|
||||
|
||||
memset(evWait, 0, sizeof(struct epoll_event) * 2); /* 2, evs num */
|
||||
evWait[0].data.fd = pipeFd[0];
|
||||
|
||||
retval = epoll_pwait(epFd, evWait, 2, 3000, &mask); /* 2, num of wait fd. 3000, wait time */
|
||||
close(pipeFd[0]);
|
||||
|
||||
if (retval) {
|
||||
exit(LOS_OK);
|
||||
} else {
|
||||
exit(LOS_NOK);
|
||||
}
|
||||
} else {
|
||||
sleep(1);
|
||||
close(pipeFd[0]);
|
||||
|
||||
retval = kill(pid, SIGALRM);
|
||||
ICUNIT_ASSERT_EQUAL(retval, 0, retval);
|
||||
|
||||
retval = kill(pid, SIGUSR1);
|
||||
ICUNIT_ASSERT_EQUAL(retval, 0, retval);
|
||||
close(pipeFd[1]);
|
||||
|
||||
wait(&status);
|
||||
status = WEXITSTATUS(status);
|
||||
ICUNIT_ASSERT_EQUAL(status, LOS_OK, status);
|
||||
}
|
||||
|
||||
return LOS_OK;
|
||||
OUT:
|
||||
close(pipeFd[0]);
|
||||
close(pipeFd[1]);
|
||||
close(epFd);
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
|
||||
VOID IO_TEST_EPOLL_002(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
#include <libintl.h>
|
||||
#include <locale.h>
|
||||
|
||||
static UINT32 testcase1(VOID)
|
||||
{
|
||||
char *s = nullptr;
|
||||
char *tmp = nullptr;
|
||||
|
||||
/* set the locale. */
|
||||
setlocale(LC_ALL, "zh_CN.UTF-8");
|
||||
setenv("MUSL_LOCPATH", "/storage", 1);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,getenv MUSL_LOCPATH=%s\n", __FILE__, __LINE__, __func__, getenv("MUSL_LOCPATH"));
|
||||
tmp = setlocale(LC_TIME, "zh_CN.UTF-8");
|
||||
TEST_PRINT("[INFO]%s:%d,%s,Locale is: %s\n", __FILE__, __LINE__, __func__, tmp);
|
||||
ICUNIT_GOTO_STRING_EQUAL(tmp, "zh_CN.UTF-8", -1, OUT);
|
||||
|
||||
/* choose a domain for your program. */
|
||||
tmp = textdomain("messages");
|
||||
/* bind a directory,use PWD here. */
|
||||
bindtextdomain("messages", ".");
|
||||
/* set the output codeset.It is not needed usually */
|
||||
bind_textdomain_codeset("messages", "UTF-8");
|
||||
|
||||
/* test gettext. */
|
||||
s = gettext("Monday/n\n");
|
||||
|
||||
ICUNIT_ASSERT_STRING_EQUAL(s, "Monday/n\n", s);
|
||||
|
||||
return LOS_OK;
|
||||
OUT:
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
static UINT32 testcase(VOID)
|
||||
{
|
||||
testcase1();
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID IO_TEST_GETTEXT_001(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
#include <time.h>
|
||||
#include <locale.h>
|
||||
|
||||
static UINT32 testcase(VOID)
|
||||
{
|
||||
time_t currtime;
|
||||
struct tm *timer = {nullptr};
|
||||
char buffer[80];
|
||||
|
||||
time(&currtime);
|
||||
timer = localtime(&currtime);
|
||||
|
||||
setenv("MUSL_LOCPATH", "/storage", 1);
|
||||
printf("getenv MUSL_LOCPATH=%s\n", getenv("MUSL_LOCPATH"));
|
||||
|
||||
printf("Locale is: %s\n", setlocale(LC_TIME, "en_US.UTF-8"));
|
||||
strftime(buffer, 80, "%c", timer);
|
||||
printf("Date is: %s\n", buffer);
|
||||
ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1);
|
||||
|
||||
printf("Locale is: %s\n", setlocale(LC_TIME, "zh_CN.UTF-8"));
|
||||
strftime(buffer, 80, "%c", timer);
|
||||
printf("Date is: %s\n", buffer);
|
||||
ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1);
|
||||
|
||||
printf("Locale is: %s\n", setlocale(LC_TIME, ""));
|
||||
strftime(buffer, 80, "%c", timer);
|
||||
printf("Date is: %s\n", buffer);
|
||||
ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID IO_TEST_LOCALE_001(void)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
#include <time.h>
|
||||
#include <locale.h>
|
||||
|
||||
static UINT32 testcase(VOID)
|
||||
{
|
||||
time_t currtime;
|
||||
struct tm *timer = {nullptr};
|
||||
char buffer[80];
|
||||
//locale_t loc = malloc(sizeof(locale_t);
|
||||
|
||||
time(&currtime);
|
||||
timer = localtime(&currtime);
|
||||
|
||||
setenv("MUSL_LOCPATH", "/storage", 1);
|
||||
printf("getenv MUSL_LOCPATH=%s\n", getenv("MUSL_LOCPATH"));
|
||||
|
||||
printf("Locale is: %s\n", setlocale(LC_TIME, "en_US.UTF-8"));
|
||||
strftime(buffer, 80, "%c", timer);
|
||||
printf("Date is: %s\n", buffer);
|
||||
ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1);
|
||||
|
||||
printf("Locale is: %s\n", setlocale(LC_TIME, "zh_CN.UTF-8"));
|
||||
strftime(buffer, 80, "%c", timer);
|
||||
printf("Date is: %s\n", buffer);
|
||||
ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1);
|
||||
|
||||
printf("Locale is: %s\n", setlocale(LC_TIME, ""));
|
||||
strftime(buffer, 80, "%c", timer);
|
||||
printf("Date is: %s\n", buffer);
|
||||
ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID IO_TEST_LOCALE_002(void)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
#include <libintl.h>
|
||||
#include <locale.h>
|
||||
|
||||
static UINT32 testcase(VOID)
|
||||
{
|
||||
char *s = "";
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
textdomain("gettext_demo");
|
||||
bindtextdomain("gettext_demo", ".");
|
||||
bind_textdomain_codeset("gettext_demo", "UTF-8");
|
||||
|
||||
printf(ngettext("Delete the selected file?\n", "Delete the selected files?\n", 1));
|
||||
printf(ngettext("Delete the selected file?\n", "Delete the selected files?\n", 2));
|
||||
|
||||
s = ngettext("0123456789", "0123456789", 2);
|
||||
ICUNIT_ASSERT_STRING_EQUAL(s, "0123456789", s);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID IO_TEST_NGETTEXT_001(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
#include <langinfo.h>
|
||||
#include <locale.h>
|
||||
|
||||
static UINT32 testcase(VOID)
|
||||
{
|
||||
/* set the locale info */
|
||||
setenv("MUSL_LOCPATH", "/storage", 1);
|
||||
printf("getenv MUSL_LOCPATH=%s\n", getenv("MUSL_LOCPATH"));
|
||||
printf("Locale is: %s\n", setlocale(LC_TIME, "zh_CN.UTF-8"));
|
||||
|
||||
setlocale(LC_CTYPE, "");
|
||||
setlocale(LC_NUMERIC, "");
|
||||
|
||||
/* echo the nl_langinfo */
|
||||
printf("%s\n", nl_langinfo(CODESET));
|
||||
printf("%s\n", nl_langinfo(RADIXCHAR));
|
||||
printf("%s\n", nl_langinfo(D_T_FMT));
|
||||
printf("%s\n", nl_langinfo(D_FMT));
|
||||
printf("%s\n", nl_langinfo(T_FMT));
|
||||
printf("%s\n", nl_langinfo(DAY_1));
|
||||
printf("%s\n", nl_langinfo(DAY_7));
|
||||
printf("%s\n", nl_langinfo(ABDAY_1));
|
||||
printf("%s\n", nl_langinfo(ABDAY_7));
|
||||
printf("%s\n", nl_langinfo(MON_1));
|
||||
printf("%s\n", nl_langinfo(MON_12));
|
||||
printf("%s\n", nl_langinfo(ABMON_1));
|
||||
printf("%s\n", nl_langinfo(ABMON_12));
|
||||
printf("%s\n", nl_langinfo(THOUSEP));
|
||||
printf("%s\n", nl_langinfo(YESEXPR));
|
||||
printf("%s\n", nl_langinfo(NOEXPR));
|
||||
printf("%s\n", nl_langinfo(CRNCYSTR));
|
||||
|
||||
/* set the locale info */
|
||||
setenv("MUSL_LOCPATH", "/storage", 1);
|
||||
printf("getenv MUSL_LOCPATH=%s\n", getenv("MUSL_LOCPATH"));
|
||||
printf("Locale is: %s\n", setlocale(LC_TIME, "en_US.UTF-8"));
|
||||
|
||||
setlocale(LC_CTYPE, "");
|
||||
setlocale(LC_NUMERIC, "");
|
||||
|
||||
/* echo the nl_langinfo */
|
||||
printf("%s\n", nl_langinfo(CODESET));
|
||||
printf("%s\n", nl_langinfo(RADIXCHAR));
|
||||
printf("%s\n", nl_langinfo(D_T_FMT));
|
||||
printf("%s\n", nl_langinfo(D_FMT));
|
||||
printf("%s\n", nl_langinfo(T_FMT));
|
||||
printf("%s\n", nl_langinfo(DAY_1));
|
||||
printf("%s\n", nl_langinfo(DAY_7));
|
||||
printf("%s\n", nl_langinfo(ABDAY_1));
|
||||
printf("%s\n", nl_langinfo(ABDAY_7));
|
||||
printf("%s\n", nl_langinfo(MON_1));
|
||||
printf("%s\n", nl_langinfo(MON_12));
|
||||
printf("%s\n", nl_langinfo(ABMON_1));
|
||||
printf("%s\n", nl_langinfo(ABMON_12));
|
||||
printf("%s\n", nl_langinfo(THOUSEP));
|
||||
printf("%s\n", nl_langinfo(YESEXPR));
|
||||
printf("%s\n", nl_langinfo(NOEXPR));
|
||||
printf("%s\n", nl_langinfo(CRNCYSTR));
|
||||
|
||||
char *string = nl_langinfo(CRNCYSTR);
|
||||
ICUNIT_ASSERT_NOT_EQUAL_NULL(string, NULL, string);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID IO_TEST_NL_LANGINFO_001(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
#include <langinfo.h>
|
||||
#include <locale.h>
|
||||
static UINT32 testcase(VOID) {
|
||||
/* set the locale info */
|
||||
setenv("MUSL_LOCPATH", "/storage", 1);
|
||||
printf("getenv MUSL_LOCPATH=%s\n", getenv("MUSL_LOCPATH"));
|
||||
printf("Locale is: %s\n", setlocale(LC_TIME, "en_US.UTF-8"));
|
||||
|
||||
setlocale(LC_CTYPE, "");
|
||||
setlocale(LC_NUMERIC, "");
|
||||
|
||||
/* echo the nl_langinfo_l */
|
||||
printf("%s\n", nl_langinfo_l(CODESET, (locale_t)"en_US.UTF-8"));
|
||||
printf("%s\n", nl_langinfo_l(RADIXCHAR, (locale_t)"en_US.UTF-8"));
|
||||
|
||||
/* set the locale info */
|
||||
setenv("MUSL_LOCPATH", "/storage", 1);
|
||||
printf("getenv MUSL_LOCPATH=%s\n", getenv("MUSL_LOCPATH"));
|
||||
printf("Locale is: %s\n", setlocale(LC_TIME, "zh_CN.UTF-8"));
|
||||
|
||||
setlocale(LC_CTYPE, "");
|
||||
setlocale(LC_NUMERIC, "");
|
||||
|
||||
/* echo the nl_langinfo */
|
||||
printf("%s\n", nl_langinfo_l(CODESET, (locale_t)"zh_CN.UTF-8"));
|
||||
printf("%s\n", nl_langinfo_l(RADIXCHAR, (locale_t)"zh_CN.UTF-8"));
|
||||
|
||||
char *string = nl_langinfo_l(CRNCYSTR, (locale_t)"zh_CN.UTF-8");
|
||||
ICUNIT_ASSERT_NOT_EQUAL_NULL(string, NULL, string);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID IO_TEST_NL_LANGINFO_l_001(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "It_test_IO.h"
|
||||
#include "pthread.h"
|
||||
|
||||
const int BUF_SIZE = 128;
|
||||
const int DELAY_TIME = 200;
|
||||
|
||||
static INT32 pipeFdPpoll[2];
|
||||
static INT32 g_step = 1;
|
||||
static CHAR strBuf[] = "hello world.";
|
||||
static struct pollfd pfd;
|
||||
|
||||
static void *pthread_01(void *arg)
|
||||
{
|
||||
INT32 retVal;
|
||||
CHAR buf[BUF_SIZE];
|
||||
|
||||
/* 执行ppoll监视文件描述符 */
|
||||
while (g_step < 3) { /* 3, 3rd step */
|
||||
usleep(DELAY_TIME);
|
||||
}
|
||||
g_step++;
|
||||
retVal = ppoll(&pfd, 1, NULL, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL_NULL(retVal, -1, retVal);
|
||||
|
||||
while (g_step < 5) { /* 5, 5th step */
|
||||
usleep(DELAY_TIME);
|
||||
}
|
||||
g_step++;
|
||||
|
||||
/* 判断revents */
|
||||
if (pfd.revents & POLLIN) {
|
||||
memset_s(buf, sizeof(buf), 0, sizeof(buf));
|
||||
retVal = read(pfd.fd, buf, BUF_SIZE);
|
||||
ICUNIT_ASSERT_NOT_EQUAL_NULL(retVal, -1, retVal);
|
||||
|
||||
retVal = strcmp(strBuf, buf);
|
||||
ICUNIT_ASSERT_EQUAL_NULL(retVal, 0, retVal);
|
||||
}
|
||||
|
||||
while (g_step < 6) { /* 6, 6th step */
|
||||
usleep(DELAY_TIME);
|
||||
}
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
STATIC UINT32 testcase(VOID)
|
||||
{
|
||||
INT32 retVal;
|
||||
pthread_t tid;
|
||||
|
||||
/* 建立管道 */
|
||||
while (g_step < 1) { /* 1, 1st step */
|
||||
usleep(DELAY_TIME);
|
||||
}
|
||||
retVal = pipe(pipeFdPpoll);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(retVal, -1, retVal);
|
||||
g_step++;
|
||||
|
||||
/* 设置pfd */
|
||||
pfd.fd = pipeFdPpoll[0];
|
||||
pfd.events = POLLIN;
|
||||
|
||||
/* 开辟线程执行 ppoll */
|
||||
while (g_step < 2) { /* 2, 2nd step */
|
||||
usleep(DELAY_TIME);
|
||||
}
|
||||
retVal = pthread_create(&tid, NULL, pthread_01, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(retVal, 0, retVal);
|
||||
g_step++;
|
||||
|
||||
/* 向管道写入数据 */
|
||||
while (g_step < 4) { /* 4, 4th step */
|
||||
usleep(DELAY_TIME);
|
||||
}
|
||||
sleep(1);
|
||||
|
||||
retVal = write(pipeFdPpoll[1], "hello world.", sizeof(strBuf));
|
||||
ICUNIT_ASSERT_NOT_EQUAL(retVal, -1, retVal);
|
||||
g_step++;
|
||||
|
||||
pthread_join(tid, NULL);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID IO_TEST_PPOLL_001(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "It_test_IO.h"
|
||||
#include "signal.h"
|
||||
#include "pthread.h"
|
||||
|
||||
const int BUF_SIZE = 128;
|
||||
const int DELAY_TIME = 200;
|
||||
|
||||
static int pipeFdPpoll[2];
|
||||
static int g_step = 1;
|
||||
static char strBuf[] = "hello world.";
|
||||
static struct pollfd pfd;
|
||||
|
||||
static void *pthread_01(void *arg)
|
||||
{
|
||||
int retVal;
|
||||
char buf[BUF_SIZE];
|
||||
const struct timespec timeout = {10000, 0};
|
||||
|
||||
/* 执行ppoll监视文件描述符 */
|
||||
while (g_step < 4) { /* 4, 4th step */
|
||||
usleep(DELAY_TIME);
|
||||
}
|
||||
g_step++;
|
||||
retVal = ppoll(&pfd, 1, &timeout, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL_NULL(retVal, -1, retVal);
|
||||
|
||||
/* 判断revents */
|
||||
if (pfd.revents & POLLIN) {
|
||||
memset_s(buf, sizeof(buf), 0, sizeof(buf));
|
||||
retVal = read(pfd.fd, buf, BUF_SIZE);
|
||||
ICUNIT_ASSERT_NOT_EQUAL_NULL(retVal, -1, retVal);
|
||||
retVal = strcmp(strBuf, buf);
|
||||
ICUNIT_ASSERT_EQUAL_NULL(retVal, 0, retVal);
|
||||
}
|
||||
|
||||
while (g_step < 5) { /* 5, 5th step */
|
||||
usleep(DELAY_TIME);
|
||||
}
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
static UINT32 testcase(VOID)
|
||||
{
|
||||
int retVal;
|
||||
pthread_t tid;
|
||||
|
||||
/* 建立管道 */
|
||||
while (g_step < 1) {
|
||||
usleep(DELAY_TIME);
|
||||
}
|
||||
retVal = pipe(pipeFdPpoll);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(retVal, -1, retVal);
|
||||
g_step++;
|
||||
|
||||
/* 设置pfd */
|
||||
pfd.fd = pipeFdPpoll[0];
|
||||
pfd.events = POLLIN;
|
||||
|
||||
/* 向管道写入数据 */
|
||||
while (g_step < 2) { /* 2, 2nd step */
|
||||
usleep(DELAY_TIME);
|
||||
}
|
||||
sleep(1);
|
||||
|
||||
retVal = write(pipeFdPpoll[1], "hello world.", sizeof(strBuf));
|
||||
ICUNIT_ASSERT_NOT_EQUAL(retVal, -1, retVal);
|
||||
g_step++;
|
||||
|
||||
/* 开辟线程执行 ppoll */
|
||||
while (g_step < 3) { /* 3, 3rd step */
|
||||
usleep(DELAY_TIME);
|
||||
}
|
||||
retVal = pthread_create(&tid, NULL, pthread_01, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(retVal, 0, retVal);
|
||||
g_step++;
|
||||
|
||||
pthread_join(tid, NULL);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID IO_TEST_PPOLL_002(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "It_test_IO.h"
|
||||
#include "pthread.h"
|
||||
#include "signal.h"
|
||||
|
||||
const int BUF_SIZE = 128;
|
||||
const int DELAY_TIME = 200;
|
||||
|
||||
static INT32 pipeFdPpoll[2];
|
||||
static INT32 g_step = 1;
|
||||
static CHAR strBuf[] = "hello world.";
|
||||
static struct pollfd pfd;
|
||||
static sigset_t sigMask;
|
||||
static UINT32 count = 0;
|
||||
|
||||
static void signalHandle(INT32 sigNum)
|
||||
{
|
||||
g_step++;
|
||||
return;
|
||||
}
|
||||
|
||||
static void *pthread_01(void *arg)
|
||||
{
|
||||
INT32 retVal;
|
||||
CHAR buf[BUF_SIZE];
|
||||
|
||||
(void)signal(SIGUSR1, signalHandle);
|
||||
|
||||
while (1) {
|
||||
/* 执行ppoll监视文件描述符 */
|
||||
while (g_step < 2) { /* 2, 2nd step */
|
||||
usleep(DELAY_TIME);
|
||||
}
|
||||
g_step++;
|
||||
retVal = ppoll(&pfd, 1, NULL, &sigMask);
|
||||
|
||||
ICUNIT_ASSERT_NOT_EQUAL_NULL(retVal, -1, retVal);
|
||||
|
||||
/* 判断revents */
|
||||
if (pfd.revents & POLLIN) {
|
||||
memset_s(buf, sizeof(buf), 0, sizeof(buf));
|
||||
retVal = read(pfd.fd, buf, BUF_SIZE);
|
||||
ICUNIT_ASSERT_NOT_EQUAL_NULL(retVal, -1, retVal);
|
||||
|
||||
retVal = strcmp(strBuf, buf);
|
||||
ICUNIT_ASSERT_EQUAL_NULL(retVal, 0, retVal);
|
||||
|
||||
count++;
|
||||
} else {
|
||||
ICUNIT_ASSERT_NOT_EQUAL_NULL(pfd.revents & POLLIN, 0, pfd.revents & POLLIN);
|
||||
}
|
||||
g_step++;
|
||||
|
||||
if (g_step >= 7) { /* 7, 7th step */
|
||||
ICUNIT_ASSERT_EQUAL_NULL(count, 2, count); /* 2, 2nd step */
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
static UINT32 testcase(VOID)
|
||||
{
|
||||
INT32 retVal;
|
||||
pthread_t tid;
|
||||
|
||||
/* 建立管道 */
|
||||
while (g_step < 1) {
|
||||
usleep(DELAY_TIME);
|
||||
}
|
||||
retVal = pipe(pipeFdPpoll);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(retVal, -1, retVal);
|
||||
|
||||
/* 设置pfd sigmask */
|
||||
pfd.fd = pipeFdPpoll[0];
|
||||
pfd.events = POLLIN;
|
||||
pfd.revents = 0x0;
|
||||
|
||||
sigemptyset(&sigMask);
|
||||
sigaddset(&sigMask, SIGUSR1);
|
||||
|
||||
/* 开辟线程执行 ppoll */
|
||||
retVal = pthread_create(&tid, NULL, pthread_01, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(retVal, 0, retVal);
|
||||
g_step++;
|
||||
|
||||
/* 向管道写入数据 */
|
||||
while (g_step < 3) { /* 3, 3ed step */
|
||||
usleep(DELAY_TIME);
|
||||
}
|
||||
sleep(1); /* 保证先挂起再写入数据 */
|
||||
retVal = write(pipeFdPpoll[1], "hello world.", sizeof(strBuf));
|
||||
ICUNIT_ASSERT_NOT_EQUAL(retVal, -1, retVal);
|
||||
|
||||
/* 向线程发送信号 */
|
||||
while (g_step < 5) { /* 5, 5th step */
|
||||
usleep(DELAY_TIME);
|
||||
}
|
||||
sleep(1); /* 保证先挂起再发送信号 */
|
||||
retVal = pthread_kill(tid, SIGUSR1);
|
||||
ICUNIT_ASSERT_EQUAL(retVal, 0, retVal);
|
||||
|
||||
/* 继续向管道写入数据 */
|
||||
ICUNIT_ASSERT_EQUAL(g_step, 5, g_step); /* 5, sth。判断挂起解除之前信号没有被处理 */
|
||||
retVal = write(pipeFdPpoll[1], "hello world.", sizeof(strBuf));
|
||||
ICUNIT_ASSERT_NOT_EQUAL(retVal, -1, retVal);
|
||||
|
||||
while (g_step < 7) { /* 7, 7th step */
|
||||
usleep(DELAY_TIME);
|
||||
}
|
||||
ICUNIT_ASSERT_EQUAL(count, 2, count); /* 2, 2nd step */
|
||||
/* 等待退出 */
|
||||
pthread_join(tid, NULL);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID IO_TEST_PPOLL_003(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "It_test_IO.h"
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include "sys/select.h"
|
||||
|
||||
static UINT32 Testcase1(VOID)
|
||||
{
|
||||
static const int TAR_STR_LEN = 12; /* 12, str len */
|
||||
int pipeFd[2], ret; /* 2, pipe return 2 file descirpter */
|
||||
fd_set reads;
|
||||
ret = pipe(pipeFd);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
ret = write(pipeFd[1], "Hello World", TAR_STR_LEN);
|
||||
ICUNIT_GOTO_EQUAL(ret, TAR_STR_LEN, ret, EXIT);
|
||||
FD_ZERO(&reads);
|
||||
FD_SET(pipeFd[0], &reads);
|
||||
ret = select(pipeFd[0] + 1, &reads, nullptr, nullptr, nullptr);
|
||||
ICUNIT_GOTO_EQUAL(ret, 1, ret, EXIT);
|
||||
ret = FD_ISSET(pipeFd[0], &reads);
|
||||
ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT);
|
||||
close(pipeFd[0]);
|
||||
close(pipeFd[1]);
|
||||
return LOS_OK;
|
||||
EXIT:
|
||||
close(pipeFd[0]);
|
||||
close(pipeFd[1]);
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
#define V_SIGMASK 0x5555
|
||||
static UINT32 testcase(VOID)
|
||||
{
|
||||
fd_set rfds;
|
||||
struct timespec tv;
|
||||
int retval;
|
||||
pid_t pid;
|
||||
int pipeFd[2]; /* 2, pipe id num */
|
||||
char buffer[40]; /* 40, buffer size */
|
||||
int i = 0;
|
||||
int status;
|
||||
|
||||
sigset_t mask;
|
||||
|
||||
retval = Testcase1(); /* first check select works */
|
||||
ICUNIT_GOTO_EQUAL(retval, 0, retval, OUT);
|
||||
|
||||
retval = pipe(pipeFd);
|
||||
ICUNIT_GOTO_EQUAL(retval, 0, retval, OUT);
|
||||
|
||||
/* Watch fd to see when it has input. */
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(pipeFd[0], &rfds);
|
||||
|
||||
/* Wait up to three seconds. */
|
||||
tv.tv_sec = 3; /* 3, wait timer, second */
|
||||
tv.tv_nsec = 5; /* 5, wait timer, nano second */
|
||||
|
||||
pid = fork();
|
||||
if (pid == 0) {
|
||||
close(pipeFd[1]);
|
||||
|
||||
retval = pselect(pipeFd[0] + 1, &rfds, nullptr, nullptr, &tv, &mask);
|
||||
close(pipeFd[0]);
|
||||
|
||||
if (retval) {
|
||||
exit(LOS_OK);
|
||||
} else {
|
||||
exit(LOS_NOK);
|
||||
}
|
||||
} else {
|
||||
sleep(1);
|
||||
close(pipeFd[0]);
|
||||
retval = write(pipeFd[1], "0123456789012345678901234567890123456789", 40); /* write 40 bytes to stdin(fd 0) */
|
||||
ICUNIT_GOTO_EQUAL(retval, 40, retval, OUT);
|
||||
close(pipeFd[1]);
|
||||
|
||||
wait(&status);
|
||||
status = WEXITSTATUS(status);
|
||||
ICUNIT_ASSERT_EQUAL(status, LOS_OK, status);
|
||||
}
|
||||
|
||||
return LOS_OK;
|
||||
OUT:
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
VOID IO_TEST_PSELECT_001(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "It_test_IO.h"
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include "sys/select.h"
|
||||
|
||||
static void SigPrint(int sig)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static UINT32 testcase(VOID)
|
||||
{
|
||||
fd_set rfds;
|
||||
struct timespec tv;
|
||||
int retval;
|
||||
pid_t pid;
|
||||
int pipeFd[2]; /* 2, pipe id num */
|
||||
char buffer[40]; /* 40, buffer size */
|
||||
|
||||
int i = 0;
|
||||
int status;
|
||||
|
||||
void (*retSig)(int);
|
||||
sigset_t mask;
|
||||
|
||||
retSig = signal(SIGALRM, SigPrint);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(retSig, NULL, retSig);
|
||||
|
||||
retSig = signal(SIGUSR1, SigPrint);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(retSig, NULL, retSig);
|
||||
|
||||
retval = sigemptyset(&mask);
|
||||
ICUNIT_ASSERT_EQUAL(retval, 0, retval);
|
||||
|
||||
retval = sigaddset(&mask, SIGALRM);
|
||||
ICUNIT_ASSERT_EQUAL(retval, 0, retval);
|
||||
|
||||
retval = sigaddset(&mask, SIGUSR1);
|
||||
ICUNIT_ASSERT_EQUAL(retval, 0, retval);
|
||||
|
||||
retval = pipe(pipeFd);
|
||||
ICUNIT_GOTO_EQUAL(retval, 0, retval, OUT);
|
||||
|
||||
/* Watch fd to see when it has input. */
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(pipeFd[0], &rfds);
|
||||
|
||||
/* Wait up to three seconds. */
|
||||
tv.tv_sec = 3; /* 3, wait timer, second */
|
||||
tv.tv_nsec = 5; /* 5, wait timer, nano second */
|
||||
|
||||
pid = fork();
|
||||
if (pid == 0) {
|
||||
close(pipeFd[1]);
|
||||
|
||||
retval = pselect(pipeFd[0] + 1, &rfds, nullptr, nullptr, &tv, &mask);
|
||||
|
||||
close(pipeFd[0]);
|
||||
|
||||
if (retval != 0) {
|
||||
exit(LOS_OK);
|
||||
} else {
|
||||
exit(LOS_NOK);
|
||||
}
|
||||
} else {
|
||||
sleep(1);
|
||||
close(pipeFd[0]);
|
||||
|
||||
retval = kill(pid, SIGALRM);
|
||||
ICUNIT_ASSERT_EQUAL(retval, 0, retval);
|
||||
|
||||
retval = kill(pid, SIGUSR1);
|
||||
ICUNIT_ASSERT_EQUAL(retval, 0, retval);
|
||||
close(pipeFd[1]);
|
||||
|
||||
wait(&status);
|
||||
status = WEXITSTATUS(status);
|
||||
ICUNIT_ASSERT_EQUAL(status, LOS_OK, status);
|
||||
}
|
||||
|
||||
return LOS_OK;
|
||||
OUT:
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
VOID IO_TEST_PSELECT_002(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
#include <string.h>
|
||||
#include "locale.h"
|
||||
|
||||
static UINT32 testcase(VOID)
|
||||
{
|
||||
char *a = "aBcDeF";
|
||||
char *b = "AbCdEf";
|
||||
locale_t loc;
|
||||
|
||||
printf("Strings:a=%s,b=%s,doing if(!strcasecmp(a, b))printf(\"\%s=\%s\\n\", a, b);", a, b, a, b);
|
||||
if (!strcasecmp_l(a, b, loc)) {
|
||||
printf("%s=%s\n", a, b);
|
||||
}
|
||||
ICUNIT_ASSERT_EQUAL(strcasecmp_l(a, b, loc), 0, strcasecmp_l(a, b, loc));
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID IO_TEST_STRCASECMP_L_001(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
#include <string.h>
|
||||
|
||||
static UINT32 testcase1(VOID)
|
||||
{
|
||||
char *a = "aBcDeF";
|
||||
char *b = "AbCEf";
|
||||
int ret = 0;
|
||||
locale_t loc;
|
||||
errno = 0;
|
||||
|
||||
ret = strcasecmp_l(a, b, loc);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
|
||||
ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, OUT);
|
||||
ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
|
||||
|
||||
return LOS_OK;
|
||||
OUT:
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
static UINT32 testcase2(VOID)
|
||||
{
|
||||
char *a = "aBcDfF";
|
||||
char *b = "AbCEe";
|
||||
int ret = 0;
|
||||
locale_t loc;
|
||||
errno = 0;
|
||||
|
||||
ret = strcasecmp_l(a, b, loc);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
|
||||
ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, OUT);
|
||||
ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
|
||||
|
||||
return LOS_OK;
|
||||
OUT:
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
static UINT32 testcase(VOID)
|
||||
{
|
||||
testcase1();
|
||||
testcase2();
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID IO_TEST_STRCASECMP_L_002(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
#include <monetary.h>
|
||||
#include "locale.h"
|
||||
|
||||
static UINT32 testcase(VOID)
|
||||
{
|
||||
char buf[100] = {0};
|
||||
int ret = 0;
|
||||
locale_t loc;
|
||||
|
||||
ret = strfmon_l(buf, sizeof(buf), loc, "[%^=*#6n] [%=*#6i]", 1234.567, 1234.567);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 23, ret);
|
||||
|
||||
ret = strfmon_l(buf, sizeof(buf), loc, "[%^=*#6n] [%=*#6i]", 134.567, 1234.567);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 23, ret);
|
||||
|
||||
ret = strfmon_l(buf, sizeof(buf), loc, "[%^=*#6n] [%=*#6i]", 1234.567, 134.567);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 23, ret);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID IO_TEST_STRFMON_L_001(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
#include <monetary.h>
|
||||
#include "locale.h"
|
||||
|
||||
static UINT32 testcase1(VOID)
|
||||
{
|
||||
char buf[100] = {0};
|
||||
int ret = 0;
|
||||
locale_t loc;
|
||||
errno = 0;
|
||||
|
||||
setenv("MUSL_LOCPATH", "/storage", 1);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,Locale is: %s\n", __FILE__, __LINE__, __func__,setlocale(LC_TIME, "zh_CN.UTF-8"));
|
||||
|
||||
errno = 0;
|
||||
ret = strfmon_l(buf, 2, loc, "[%^=*#6n] [%=*#6i]", 1234.567, 1234.567);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
|
||||
TEST_PRINT("[INFO]%s:%d,%s,ret=%d,buf=%s\n", __FILE__, __LINE__, __func__, ret, buf);
|
||||
ICUNIT_GOTO_EQUAL(ret, -1, ret, OUT);
|
||||
ICUNIT_GOTO_EQUAL(errno, E2BIG, errno, OUT);
|
||||
|
||||
errno = 0;
|
||||
ret = strfmon_l(buf, 3, loc, "[%^=*#6n] [%=*#6i]", 134.567, 1234.567);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
|
||||
TEST_PRINT("[INFO]%s:%d,%s,ret=%d,buf=%s\n", __FILE__, __LINE__, __func__, ret, buf);
|
||||
ICUNIT_GOTO_EQUAL(ret, -1, ret, OUT);
|
||||
ICUNIT_GOTO_EQUAL(errno, E2BIG, errno, OUT);
|
||||
|
||||
errno = 0;
|
||||
ret = strfmon_l(buf, 22, loc, "[%^=*#6n] [%=*#6i]", 1234.567, 134.567);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
|
||||
TEST_PRINT("[INFO]%s:%d,%s,ret=%d,buf=%s\n", __FILE__, __LINE__, __func__, ret, buf);
|
||||
ICUNIT_GOTO_EQUAL(ret, -1, ret, OUT);
|
||||
ICUNIT_GOTO_EQUAL(errno, E2BIG, errno, OUT);
|
||||
|
||||
errno = 0;
|
||||
ret = strfmon_l(buf, 23, loc, "[%^=*#6n] [%=*#6i]", 1234.567, 134.567);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
|
||||
TEST_PRINT("[INFO]%s:%d,%s,ret=%d,buf=%s\n", __FILE__, __LINE__, __func__, ret, buf);
|
||||
ICUNIT_GOTO_EQUAL(ret, 23, ret, OUT);
|
||||
ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
|
||||
|
||||
return LOS_OK;
|
||||
OUT:
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
static UINT32 testcase(VOID)
|
||||
{
|
||||
testcase1();
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID IO_TEST_STRFMON_L_002(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
#include <string.h>
|
||||
#include "locale.h"
|
||||
|
||||
static UINT32 testcase(VOID)
|
||||
{
|
||||
char *a = "aBcDeF";
|
||||
char *b = "AbCdEf";
|
||||
int n = 5;
|
||||
locale_t loc;
|
||||
|
||||
printf("Strings:a=%s,b=%s,doing if(!strncasecmp(a, b, %d))printf(\"\%s=\%s\\n\", a, b);", a, b, n, a, b);
|
||||
if (!strncasecmp_l(a, b, n, loc)) {
|
||||
printf("%s=%s in first %d characters.\n", a, b, n);
|
||||
}
|
||||
ICUNIT_ASSERT_EQUAL(strncasecmp_l(a, b, n, loc), 0, strncasecmp_l(a, b, n, loc));
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID IO_TEST_STRNCASECMP_L_001(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
#include <string.h>
|
||||
|
||||
static UINT32 testcase1(VOID)
|
||||
{
|
||||
char *a = "aBcDeF";
|
||||
char *b = "AbCdEf";
|
||||
int n = 600;
|
||||
int ret = 0;
|
||||
locale_t loc;
|
||||
errno = 0;
|
||||
|
||||
setenv("MUSL_LOCPATH", "/storage", 1);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,Locale is: %s\n", __FILE__, __LINE__, __func__,setlocale(LC_TIME, "zh_CN.UTF-8"));
|
||||
|
||||
errno = 0;
|
||||
ret = strncasecmp_l(a, b, n, loc);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, OUT);
|
||||
ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
|
||||
|
||||
return LOS_OK;
|
||||
OUT:
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
static UINT32 testcase2(VOID)
|
||||
{
|
||||
char *a = "aBcDeF";
|
||||
char *b = "AbCdEi";
|
||||
int n = -6;
|
||||
int ret = 0;
|
||||
locale_t loc;
|
||||
errno = 0;
|
||||
|
||||
setenv("MUSL_LOCPATH", "/storage", 1);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,Locale is: %s\n", __FILE__, __LINE__, __func__,setlocale(LC_TIME, "zh_CN.UTF-8"));
|
||||
|
||||
errno = 0;
|
||||
ret = strncasecmp_l(a, b, n, loc);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
|
||||
ICUNIT_GOTO_EQUAL(ret, -3, ret, OUT);
|
||||
ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
|
||||
|
||||
return LOS_OK;
|
||||
OUT:
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
static UINT32 testcase3(VOID)
|
||||
{
|
||||
char *a = "aBcDeF";
|
||||
char *b = "AbCdAx";
|
||||
int n = 0;
|
||||
int ret = 0;
|
||||
locale_t loc;
|
||||
errno = 0;
|
||||
|
||||
setenv("MUSL_LOCPATH", "/storage", 1);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,Locale is: %s\n", __FILE__, __LINE__, __func__,setlocale(LC_TIME, "zh_CN.UTF-8"));
|
||||
|
||||
errno = 0;
|
||||
ret = strncasecmp_l(a, b, n, loc);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, OUT);
|
||||
ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
|
||||
|
||||
return LOS_OK;
|
||||
OUT:
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
static UINT32 testcase4(VOID)
|
||||
{
|
||||
char *a = "34342aBcDeF";
|
||||
char *b = "AbCdAx";
|
||||
int n = 4;
|
||||
int ret = 0;
|
||||
locale_t loc;
|
||||
errno = 0;
|
||||
|
||||
setenv("MUSL_LOCPATH", "/storage", 1);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,Locale is: %s\n", __FILE__, __LINE__, __func__,setlocale(LC_TIME, "zh_CN.UTF-8"));
|
||||
|
||||
errno = 0;
|
||||
ret = strncasecmp_l(a, b, n, loc);
|
||||
TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
|
||||
ICUNIT_GOTO_EQUAL(ret, -46, ret, OUT);
|
||||
ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
|
||||
|
||||
return LOS_OK;
|
||||
OUT:
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
static UINT32 testcase(VOID)
|
||||
{
|
||||
testcase1();
|
||||
testcase2();
|
||||
testcase3();
|
||||
testcase4();
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID IO_TEST_STRNCASECMP_L_002(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
struct lconv *newloc = localeconv();
|
||||
ICUNIT_ASSERT_NOT_EQUAL(newloc, NULL, newloc);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLocaleLocaleconv001(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
wchar_t *srcStr = L"hello";
|
||||
wchar_t tarStr[20] = {0}; // 20, target buffer size
|
||||
int nRet;
|
||||
unsigned int nPos;
|
||||
int nType;
|
||||
char pathname[50]; // 50, path name buffer size
|
||||
FILE *testFile;
|
||||
strncpy(pathname, g_ioTestPath, 50); // 50, path name buffer size
|
||||
char *filename = "/crtfputwstest1";
|
||||
strcat(pathname, filename);
|
||||
for (nType = 0; nType < 6; nType++) { // 6, test loop num
|
||||
testFile = fopen(pathname, "a");
|
||||
|
||||
ICUNIT_GOTO_NOT_EQUAL(testFile, NULL, testFile, EXIT);
|
||||
fseek(testFile, 0, SEEK_END);
|
||||
nPos = (unsigned int)ftell(testFile);
|
||||
|
||||
nRet = fputws(srcStr, testFile);
|
||||
|
||||
ICUNIT_GOTO_NOT_EQUAL(nRet, -1, nRet, EXIT);
|
||||
if ((nPos + 5) != (unsigned int)ftell(testFile)) { // 5, expect position offset
|
||||
ICUNIT_GOTO_EQUAL(1, 0, 1, EXIT);
|
||||
}
|
||||
fclose(testFile);
|
||||
|
||||
testFile = fopen(pathname, "r");
|
||||
ICUNIT_GOTO_NOT_EQUAL(testFile, NULL, testFile, EXIT);
|
||||
wchar_t *p = fgetws(tarStr, 6, testFile); // 6, "hello" length and '\0'
|
||||
ICUNIT_GOTO_EQUAL(p, tarStr, p, EXIT);
|
||||
nRet = wcscmp(srcStr, tarStr);
|
||||
ICUNIT_GOTO_EQUAL(nRet, 0, nRet, EXIT);
|
||||
fclose(testFile);
|
||||
}
|
||||
|
||||
remove(pathname);
|
||||
return LOS_OK;
|
||||
EXIT:
|
||||
if (testFile != NULL) {
|
||||
fclose(testFile);
|
||||
remove(pathname);
|
||||
}
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
VOID ItStdioFputws001(void)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
wchar_t tarStr[20] = {0}; // 20, buffer size
|
||||
wchar_t *p;
|
||||
int nRet;
|
||||
unsigned int nPos;
|
||||
int nType;
|
||||
char pathname[50]; // 50, path name buffer size
|
||||
strncpy(pathname, g_ioTestPath, 50); // 50, path name buffer size
|
||||
char *filename = "/crtfwprintftest1";
|
||||
FILE *testFile = NULL;
|
||||
|
||||
strcat(pathname, filename);
|
||||
|
||||
for (nType = 0; nType < 6; nType++) { // 6, loop test num
|
||||
testFile = fopen(pathname, "w+");
|
||||
ICUNIT_GOTO_NOT_EQUAL(testFile, NULL, testFile, EXIT);
|
||||
|
||||
nPos = (unsigned int)ftell(testFile);
|
||||
|
||||
nRet = fwprintf(testFile, L"hello world %d", 666); // 666, for test, print to testFile
|
||||
ICUNIT_GOTO_EQUAL(nRet, 15, nRet, EXIT); // 15, total write size
|
||||
|
||||
if ((nPos + 15) != (unsigned int)ftell(testFile)) { // 15, total write size
|
||||
ICUNIT_GOTO_EQUAL(1, 0, 1, EXIT);
|
||||
}
|
||||
fclose(testFile);
|
||||
|
||||
testFile = fopen(pathname, "r");
|
||||
p = fgetws(tarStr, 16, testFile); // 16, read size,total write and '\0'
|
||||
nRet = wcscmp(L"hello world 666", tarStr);
|
||||
ICUNIT_GOTO_EQUAL(nRet, 0, nRet, EXIT);
|
||||
|
||||
fclose(testFile);
|
||||
}
|
||||
|
||||
remove(pathname);
|
||||
return LOS_OK;
|
||||
EXIT:
|
||||
if (testFile != NULL) {
|
||||
fclose(testFile);
|
||||
remove(pathname);
|
||||
}
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
VOID ItStdioFwprintf001(void)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
char ch;
|
||||
unsigned int nPos;
|
||||
int ret;
|
||||
char pathname[50]; // 50, enough space.
|
||||
strncpy(pathname, g_ioTestPath, sizeof(pathname));
|
||||
char *filename = "/crt_getc_unlocked_test1";
|
||||
FILE *testFile = NULL;
|
||||
|
||||
strcat(pathname, filename);
|
||||
testFile = fopen(pathname, "w+");
|
||||
ICUNIT_ASSERT_NOT_EQUAL(testFile, NULL, LOS_NOK);
|
||||
ret = fputs("0123456789abcdefghijklmnopqrstuvwxyz", testFile);
|
||||
ICUNIT_GOTO_NOT_EQUAL(ret, EOF, ret, EXIT);
|
||||
fclose(testFile);
|
||||
|
||||
testFile = fopen(pathname, "r");
|
||||
ICUNIT_GOTO_NOT_EQUAL(testFile, NULL, testFile, EXIT);
|
||||
|
||||
nPos = ftell(testFile);
|
||||
|
||||
ch = getc_unlocked(testFile);
|
||||
ICUNIT_GOTO_EQUAL(ch, '0', ch, EXIT);
|
||||
|
||||
if ((nPos + sizeof(char)) != (unsigned int)ftell(testFile)) {
|
||||
ICUNIT_GOTO_EQUAL(1, 0, 1, EXIT);
|
||||
}
|
||||
|
||||
fclose(testFile);
|
||||
remove(pathname);
|
||||
return LOS_OK;
|
||||
EXIT:
|
||||
if (testFile != NULL) {
|
||||
fclose(testFile);
|
||||
remove(pathname);
|
||||
}
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
VOID ItStdioGetcUnlocked001(void)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
|
||||
static UINT32 testcase(VOID)
|
||||
{
|
||||
struct mntent* mnt = nullptr;
|
||||
struct mntent* mnt_new = nullptr;
|
||||
FILE *fp = nullptr;
|
||||
char *argv[2] = {nullptr};
|
||||
argv[0] = "/etc/fstab";
|
||||
argv[1] = "errors";
|
||||
char *opt = argv[1];
|
||||
char *ret = nullptr;
|
||||
|
||||
char fileWords[] = "/dev/disk/by-uuid/c4992556-a86e-45e8-ba5f-190b16a9073x /usr1 ext3 errors=remount-ro,nofail 0 1";
|
||||
char *pathList[] = {"/etc/fstab"};
|
||||
char *streamList[] = {(char *)fileWords};
|
||||
int streamLen[] = {sizeof(fileWords)};
|
||||
|
||||
int flag = PrepareFileEnv(pathList, streamList, streamLen, 1);
|
||||
if (flag != 0) {
|
||||
printf("error: need some env file, but prepare is not ok");
|
||||
(VOID)RecoveryFileEnv(pathList, 1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
mnt_new = (struct mntent *)malloc(sizeof(struct mntent));
|
||||
mnt_new->mnt_fsname = "UUID=c4992556-a86e-45e8-ba5f-190b16a9073x";
|
||||
mnt_new->mnt_dir = "/usr1";
|
||||
mnt_new->mnt_type = "ext3";
|
||||
mnt_new->mnt_opts = "errors=remount-ro,nofail";
|
||||
mnt_new->mnt_freq = 0;
|
||||
mnt_new->mnt_passno = 1;
|
||||
|
||||
fp = setmntent("/etc/fstab", "r");
|
||||
if (!fp) {
|
||||
printf("fp=0x%x\n", fp);
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
mnt = getmntent(fp);
|
||||
if (mnt && !(feof(fp) || ferror(fp))) {
|
||||
ret = hasmntopt(mnt, opt);
|
||||
printf("hasmntopt=%s\n", ret);
|
||||
ICUNIT_ASSERT_NOT_EQUAL_NULL(ret, NULL, -1);
|
||||
mnt = getmntent(fp);
|
||||
}
|
||||
|
||||
if (fp != NULL) {
|
||||
endmntent(fp);
|
||||
}
|
||||
|
||||
/* test the addmntent below */
|
||||
fp = setmntent(argv[0], "a");
|
||||
if (fopen("/lib/libc.so", "r")) {
|
||||
printf("aha I found you are OHOS!!!\n");
|
||||
if (addmntent(fp, mnt_new)) {
|
||||
printf("a new mnt is added to %s\n", argv[0]);
|
||||
}
|
||||
}
|
||||
|
||||
if (fp != NULL) {
|
||||
endmntent(fp);
|
||||
}
|
||||
(VOID)RecoveryFileEnv(pathList, 1);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID IT_STDIO_HASMNTOPT_001(void)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
setlocale(LC_ALL, "en_US.utf8");
|
||||
size_t result = 0;
|
||||
const char *str = "z\u00df\u6c34\U0001f34c";
|
||||
const char *end = str + strlen(str);
|
||||
|
||||
mblen(NULL, 0);
|
||||
while (str < end) {
|
||||
int next = mblen(str, end - str);
|
||||
if (next == -1) {
|
||||
perror("strlen_mb");
|
||||
break;
|
||||
}
|
||||
str += next;
|
||||
++result;
|
||||
}
|
||||
ICUNIT_GOTO_EQUAL(result, 4, result, EXIT); // 4, except value
|
||||
|
||||
return LOS_OK;
|
||||
EXIT:
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
VOID ItStdioMblen001(void)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
// allow mbrlen() to work with UTF-8 multibyte encoding
|
||||
setlocale(LC_ALL, "en_US.utf8");
|
||||
const char *str = "水";
|
||||
size_t sz = strlen(str);
|
||||
int len1, len2, len3;
|
||||
|
||||
mbstate_t mb;
|
||||
memset(&mb, 0, sizeof(mb));
|
||||
len1 = mbrlen(str, 1, &mb);
|
||||
ICUNIT_GOTO_EQUAL(len1, -2, len1, EXIT); // -2, except return value
|
||||
|
||||
len2 = mbrlen(str + 1, sz - 1, &mb);
|
||||
ICUNIT_GOTO_EQUAL(len2, 2, len2, EXIT); // 2, except return value
|
||||
|
||||
len3 = mbrlen(str + 1, sz - 1, &mb);
|
||||
ICUNIT_GOTO_EQUAL(len3, -1, len3, EXIT);
|
||||
|
||||
return LOS_OK;
|
||||
EXIT:
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
VOID ItStdioMbrlen001(void)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
wchar_t srcWc = L'H';
|
||||
int tarWc, nRet;
|
||||
long nPos;
|
||||
int nType, i;
|
||||
FILE *putwcFile = NULL;
|
||||
char pathname[50]; // 50, pathname size
|
||||
strncpy(pathname, g_ioTestPath, 50); // 50, pathname size
|
||||
char *filename = "/crtputwctest1";
|
||||
|
||||
strcat(pathname, filename);
|
||||
|
||||
for (nType = 0; nType < 6; nType++) { // 6, loop test num
|
||||
putwcFile = fopen(pathname, "w+");
|
||||
ICUNIT_GOTO_NOT_EQUAL(putwcFile, NULL, putwcFile, EXIT);
|
||||
|
||||
nPos = ftell(putwcFile);
|
||||
|
||||
nRet = putwc(srcWc, putwcFile);
|
||||
ICUNIT_GOTO_EQUAL(nRet, L'H', nRet, EXIT);
|
||||
fclose(putwcFile);
|
||||
|
||||
putwcFile = fopen(pathname, "r");
|
||||
tarWc = getwc(putwcFile);
|
||||
ICUNIT_GOTO_EQUAL(tarWc, L'H', tarWc, EXIT);
|
||||
|
||||
if ((nPos + 1) != ftell(putwcFile)) {
|
||||
ICUNIT_GOTO_EQUAL(1, 0, 1, EXIT);
|
||||
}
|
||||
|
||||
fclose(putwcFile);
|
||||
}
|
||||
|
||||
remove(pathname);
|
||||
return LOS_OK;
|
||||
EXIT:
|
||||
if (putwcFile != NULL) {
|
||||
fclose(putwcFile);
|
||||
remove(pathname);
|
||||
}
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
VOID ItStdioPutwc001(void)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
char *srcStr = "helloworld";
|
||||
int nRet, fd;
|
||||
char pathname[50]; // 50, path name size
|
||||
char *filename = "/crtreadvtest1";
|
||||
char buf1[6] = { 0 };
|
||||
char buf2[6] = { 0 };
|
||||
struct iovec iov[2]; // 2, read 2 block
|
||||
ssize_t nread;
|
||||
const int testStrLen = 10;
|
||||
|
||||
iov[0].iov_base = buf1;
|
||||
iov[0].iov_len = sizeof(buf1) - 1;
|
||||
iov[1].iov_base = buf2;
|
||||
iov[1].iov_len = sizeof(buf2) - 1;
|
||||
|
||||
strncpy(pathname, g_ioTestPath, 50); // 50, path name size
|
||||
strcat(pathname, filename);
|
||||
fd = open(pathname, O_CREAT | O_RDWR | O_TRUNC, 0666); // 0666, file authority
|
||||
if (fd < 0) {
|
||||
printf("error: can`t open file\n");
|
||||
}
|
||||
nRet = write(fd, srcStr, testStrLen);
|
||||
ICUNIT_GOTO_EQUAL(nRet, testStrLen, nRet, EXIT);
|
||||
close(fd);
|
||||
|
||||
fd = open(pathname, O_RDWR);
|
||||
if (fd < 0) {
|
||||
printf("error: can`t open file\n");
|
||||
}
|
||||
nread = readv(fd, iov, 2); // 2, read 2 block
|
||||
ICUNIT_GOTO_EQUAL(nread, testStrLen, nread, EXIT);
|
||||
nRet = strcmp(buf2, "world");
|
||||
ICUNIT_GOTO_EQUAL(nRet, 0, nRet, EXIT);
|
||||
nRet = strcmp(buf1, "hello");
|
||||
ICUNIT_GOTO_EQUAL(nRet, 0, nRet, EXIT);
|
||||
|
||||
close(fd);
|
||||
remove(pathname);
|
||||
return LOS_OK;
|
||||
EXIT:
|
||||
close(fd);
|
||||
remove(pathname);
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
VOID ItStdioReadv001(void)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
int ret;
|
||||
char *s = "abcdef123456abcdef";
|
||||
char *p = NULL;
|
||||
p = rindex(s, 'b');
|
||||
ret = strcmp(p, "bcdef");
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
return LOS_OK;
|
||||
EXIT:
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
VOID ItStdioRindex001(void)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
int oldmask;
|
||||
int newmask = 0xff;
|
||||
oldmask = setlogmask(newmask);
|
||||
newmask = setlogmask(oldmask);
|
||||
ICUNIT_ASSERT_EQUAL(newmask, 0xff, newmask);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItStdioSetlogmask001(void)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
double a = 12345678.12549;
|
||||
double b = 0.1234567;
|
||||
char ptr[128] = {0}; // 128, target buffer size
|
||||
int ret;
|
||||
gcvt(a, 10, ptr); // 10, convert significant value setting
|
||||
ret = strcmp(ptr, "12345678.13");
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
gcvt(b, 6, ptr); // 6, convert significant value setting
|
||||
ret = strcmp(ptr, "0.123457");
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID ItStdlibGcvt001(void)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
|
||||
int g_pipeFd[10][2]; // 2, read and write; 10, listen fd number.
|
||||
static pthread_t g_tid = -1;
|
||||
static const int LISTEN_FD_NUM = 10;
|
||||
|
||||
static void *Pthread01(void *arg)
|
||||
{
|
||||
int totalNum = 0;
|
||||
int times = 3; // 3, loop number for test.
|
||||
int i, ret;
|
||||
struct pollfd fds[LISTEN_FD_NUM] = {0};
|
||||
char buffer[20]; // 20, enough space for test.
|
||||
const int pollEvents = 1;
|
||||
|
||||
for (i = 0; i < LISTEN_FD_NUM; i++) {
|
||||
fds[i].fd = g_pipeFd[i][0];
|
||||
fds[i].events = pollEvents;
|
||||
}
|
||||
|
||||
while (times--) {
|
||||
ret = poll(fds, LISTEN_FD_NUM, 1000); // 1000, wait time.
|
||||
totalNum += ((ret > 0) ? ret : 0);
|
||||
|
||||
if (ret <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (i = 0; i < LISTEN_FD_NUM; i++) {
|
||||
if (fds[i].revents & pollEvents) {
|
||||
ret = read(fds[i].fd, buffer, 12); // 12, "hello world" length and '\0'
|
||||
ICUNIT_GOTO_EQUAL(ret, 12, ret, EXIT); // 12, "hello world" length and '\0'
|
||||
ret = strcmp(buffer, "hello world");
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
}
|
||||
}
|
||||
|
||||
if (totalNum == LISTEN_FD_NUM) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ICUNIT_GOTO_EQUAL(totalNum, LISTEN_FD_NUM, -1, EXIT);
|
||||
|
||||
EXIT:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
int i;
|
||||
int ret;
|
||||
|
||||
for (i = 0; i < LISTEN_FD_NUM; i++) {
|
||||
ret = pipe(g_pipeFd[i]);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
}
|
||||
|
||||
ret = pthread_create(&g_tid, NULL, Pthread01, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
for (i = 0; i < LISTEN_FD_NUM; i++) {
|
||||
ret = write(g_pipeFd[i][1], "hello world", 12); // 12, "hello world" length and '\0'
|
||||
ICUNIT_GOTO_EQUAL(ret, 12, ret, EXIT); // 12, "hello world" length and '\0'
|
||||
}
|
||||
|
||||
pthread_join(g_tid, NULL);
|
||||
|
||||
for (i = 0; i < LISTEN_FD_NUM; i++) {
|
||||
close(g_pipeFd[i][0]);
|
||||
close(g_pipeFd[i][1]);
|
||||
}
|
||||
|
||||
return LOS_OK;
|
||||
|
||||
EXIT:
|
||||
for (i = 0; i < LISTEN_FD_NUM; i++) {
|
||||
close(g_pipeFd[i][0]);
|
||||
close(g_pipeFd[i][1]);
|
||||
}
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
VOID ItStdlibPoll002(void)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
|
||||
struct PollParam {
|
||||
int nfds;
|
||||
int timeout;
|
||||
int ret;
|
||||
int err;
|
||||
};
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
const int TEST_STR_LEN = 12;
|
||||
int pipeFd[2], ret, err; // 2, pipe return 2 file descirpter
|
||||
struct pollfd pollFd;
|
||||
struct PollParam pollParam[4] = { /* nfds timeout ret err */
|
||||
{ 0, 100, -1, EINVAL},
|
||||
{ 4096, 10, -1, EINVAL},
|
||||
{ 4095, 10, -1, EFAULT},
|
||||
{ 1, -1, 1, 0}
|
||||
};
|
||||
|
||||
ret = pipe(pipeFd);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ret = write(pipeFd[1], "hello world", TEST_STR_LEN);
|
||||
printf("write first status: %d\n", ret);
|
||||
ICUNIT_GOTO_EQUAL(ret, TEST_STR_LEN, ret, EXIT);
|
||||
|
||||
pollFd.fd = pipeFd[0];
|
||||
pollFd.events = POLLIN;
|
||||
|
||||
for (int i = 0; i < sizeof(pollParam) / sizeof(pollParam[0]); i++) {
|
||||
ret = poll(&pollFd, pollParam[i].nfds, pollParam[i].timeout);
|
||||
ICUNIT_GOTO_EQUAL(ret, pollParam[i].ret, ret, EXIT);
|
||||
if (ret == -1) {
|
||||
printf("i = %d\n", i);
|
||||
if (i == 2) { // 2, pollParam[2].
|
||||
ICUNIT_GOTO_TWO_EQUAL(errno, EFAULT, EBADF, errno, EXIT);
|
||||
} else {
|
||||
ICUNIT_GOTO_EQUAL(errno, pollParam[i].err, errno, EXIT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close(pipeFd[0]);
|
||||
close(pipeFd[1]);
|
||||
return LOS_OK;
|
||||
EXIT:
|
||||
close(pipeFd[0]);
|
||||
close(pipeFd[1]);
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
VOID ItStdlibPoll003(void)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,537 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <climits>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "It_test_IO.h"
|
||||
|
||||
char *g_ioTestPath = "/storage";
|
||||
|
||||
using namespace testing::ext;
|
||||
namespace OHOS {
|
||||
class IoTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase(void) {}
|
||||
static void TearDownTestCase(void) {}
|
||||
};
|
||||
|
||||
#if defined(LOSCFG_USER_TEST_SMOKE)
|
||||
/* *
|
||||
* @tc.name: IT_TEST_IO_005
|
||||
* @tc.desc: function for IoTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, ItTestIo005, TestSize.Level0)
|
||||
{
|
||||
ItTestIo005();
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_USER_TEST_FS_JFFS
|
||||
/* *
|
||||
* @tc.name: IT_TEST_IO_008
|
||||
* @tc.desc: function for IoTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, ItTestIo008, TestSize.Level0)
|
||||
{
|
||||
ItTestIo008();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_TEST_IO_010
|
||||
* @tc.desc: function for IoTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, ItTestIo010, TestSize.Level0)
|
||||
{
|
||||
ItTestIo010();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_TEST_IO_013
|
||||
* @tc.desc: function for IoTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, ItTestIo013, TestSize.Level0)
|
||||
{
|
||||
ItTestIo013();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(LOSCFG_USER_TEST_FULL)
|
||||
/* *
|
||||
* @tc.name: IO_TEST_PSELECT_001
|
||||
* @tc.desc: function for IoTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, IO_TEST_PSELECT_001, TestSize.Level0)
|
||||
{
|
||||
IO_TEST_PSELECT_001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IO_TEST_PSELECT_002
|
||||
* @tc.desc: function for IoTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, IO_TEST_PSELECT_002, TestSize.Level0)
|
||||
{
|
||||
IO_TEST_PSELECT_002();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IO_TEST_PPOLL_001
|
||||
* @tc.desc: function for IoTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, IO_TEST_PPOLL_001, TestSize.Level0)
|
||||
{
|
||||
IO_TEST_PPOLL_001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IO_TEST_PPOLL_002
|
||||
* @tc.desc: function for IoTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, IO_TEST_PPOLL_002, TestSize.Level0)
|
||||
{
|
||||
IO_TEST_PPOLL_002();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IO_TEST_PPOLL_003
|
||||
* @tc.desc: function for IoTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, IO_TEST_PPOLL_003, TestSize.Level0)
|
||||
{
|
||||
IO_TEST_PPOLL_003();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IO_TEST_EPOLL_001
|
||||
* @tc.desc: function for IoTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
|
||||
HWTEST_F(IoTest, IO_TEST_EPOLL_001, TestSize.Level0)
|
||||
{
|
||||
IO_TEST_EPOLL_001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IO_TEST_EPOLL_002
|
||||
* @tc.desc: function for IoTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, IO_TEST_EPOLL_002, TestSize.Level0)
|
||||
{
|
||||
IO_TEST_EPOLL_002();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_STDLIB_POLL_002
|
||||
* @tc.desc: function for IoTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, ItStdlibPoll002, TestSize.Level0)
|
||||
{
|
||||
ItStdlibPoll002();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_STDLIB_POLL_003
|
||||
* @tc.desc: function for IoTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, ItStdlibPoll003, TestSize.Level0)
|
||||
{
|
||||
ItStdlibPoll003();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_STDIO_PUTWC_001
|
||||
* @tc.desc: function for IoTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, ItStdioPutwc001, TestSize.Level0)
|
||||
{
|
||||
ItStdioPutwc001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_STDIO_READV_001
|
||||
* @tc.desc: function for IoTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, ItStdioReadv001, TestSize.Level0)
|
||||
{
|
||||
ItStdioReadv001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_STDIO_RINDEX_001
|
||||
* @tc.desc: function for IoTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, ItStdioRindex001, TestSize.Level0)
|
||||
{
|
||||
ItStdioRindex001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_STDIO_SETLOGMASK_001
|
||||
* @tc.desc: function for IoTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, ItStdioSetlogmask001, TestSize.Level0)
|
||||
{
|
||||
ItStdioSetlogmask001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_STDLIB_GCVT_001
|
||||
* @tc.desc: function for IoTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, ItStdlibGcvt001, TestSize.Level0)
|
||||
{
|
||||
ItStdlibGcvt001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_LOCALE_LOCALECONV_001
|
||||
* @tc.desc: function for IoTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, ItLocaleLocaleconv001, TestSize.Level0)
|
||||
{
|
||||
ItLocaleLocaleconv001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_STDIO_FPUTWS_001
|
||||
* @tc.desc: function for IoTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, ItStdioFputws001, TestSize.Level0)
|
||||
{
|
||||
ItStdioFputws001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_STDIO_FWPRINTF_001
|
||||
* @tc.desc: function for IoTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, ItStdioFwprintf001, TestSize.Level0)
|
||||
{
|
||||
ItStdioFwprintf001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_STDIO_GETC_UNLOCKED_001
|
||||
* @tc.desc: function for IoTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, ItStdioGetcUnlocked001, TestSize.Level0)
|
||||
{
|
||||
ItStdioGetcUnlocked001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_STDIO_MBLEN_001
|
||||
* @tc.desc: function for IoTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, ItStdioMblen001, TestSize.Level0)
|
||||
{
|
||||
ItStdioMblen001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_STDIO_MBRLEN_001
|
||||
* @tc.desc: function for IoTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, ItStdioMbrlen001, TestSize.Level0)
|
||||
{
|
||||
ItStdioMbrlen001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_STDIO_HASMNTOPT_001
|
||||
* @tc.desc: function for IoTest-normal testcase
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, IT_STDIO_HASMNTOPT_001, TestSize.Level0)
|
||||
{
|
||||
IT_STDIO_HASMNTOPT_001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IO_TEST_DUPLOCALE_001
|
||||
* @tc.desc: function for IoTest-dup the locale global pointer
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, IO_TEST_DUPLOCALE_001, TestSize.Level0)
|
||||
{
|
||||
IO_TEST_DUPLOCALE_001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IO_TEST_NL_LANGINFO_001
|
||||
* @tc.desc: function for IoTest-normal testcase
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, IO_TEST_NL_LANGINFO_001, TestSize.Level0)
|
||||
{
|
||||
IO_TEST_NL_LANGINFO_001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IO_TEST_STRCASECMP_L_001
|
||||
* @tc.desc: function for IoTest-normal testcase
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, IO_TEST_STRCASECMP_L_001, TestSize.Level0)
|
||||
{
|
||||
IO_TEST_STRCASECMP_L_001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IO_TEST_STRCASECMP_L_002
|
||||
* @tc.desc: function for IoTest-normal testcase
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, IO_TEST_STRCASECMP_L_002, TestSize.Level0)
|
||||
{
|
||||
IO_TEST_STRCASECMP_L_002();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IO_TEST_STRNCASECMP_L_001
|
||||
* @tc.desc: function for IoTest-normal testcase
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, IO_TEST_STRNCASECMP_L_001, TestSize.Level0)
|
||||
{
|
||||
IO_TEST_STRNCASECMP_L_001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IO_TEST_STRNCASECMP_L_002
|
||||
* @tc.desc: function for IoTest-normal testcase
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, IO_TEST_STRNCASECMP_L_002, TestSize.Level0)
|
||||
{
|
||||
IO_TEST_STRNCASECMP_L_002();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IO_TEST_NL_LANGINFO_l_001
|
||||
* @tc.desc: function for IoTest-query language and locale information
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, IO_TEST_NL_LANGINFO_l_001, TestSize.Level0)
|
||||
{
|
||||
IO_TEST_NL_LANGINFO_l_001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IO_TEST_DNGETTEXT_001
|
||||
* @tc.desc: function for IoTest-print the translated string1 or string2
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, IO_TEST_DNGETTEXT_001, TestSize.Level0)
|
||||
{
|
||||
IO_TEST_DNGETTEXT_001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IO_TEST_DNGETTEXT_002
|
||||
* @tc.desc: function for IoTest-innormal testcases
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, IO_TEST_DNGETTEXT_002, TestSize.Level0)
|
||||
{
|
||||
IO_TEST_DNGETTEXT_002();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IO_TEST_DCNGETTEXT_001
|
||||
* @tc.desc: function for IoTest-print the translated string1 or string2 with locale parameter
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, IO_TEST_DCNGETTEXT_001, TestSize.Level0)
|
||||
{
|
||||
IO_TEST_DCNGETTEXT_001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IO_TEST_DCNGETTEXT_002
|
||||
* @tc.desc: function for IoTest-innormal testcases
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, IO_TEST_DCNGETTEXT_002, TestSize.Level0)
|
||||
{
|
||||
IO_TEST_DCNGETTEXT_002();
|
||||
}
|
||||
/* *
|
||||
* @tc.name: IO_TEST_DCGETTEXT_001
|
||||
* @tc.desc: function for IoTest-print the translated string with locale parameter
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, IO_TEST_DCGETTEXT_001, TestSize.Level0)
|
||||
{
|
||||
IO_TEST_DCGETTEXT_001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IO_TEST_DCGETTEXT_002
|
||||
* @tc.desc: function for IoTest-innormal testcases
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, IO_TEST_DCGETTEXT_002, TestSize.Level0)
|
||||
{
|
||||
IO_TEST_DCGETTEXT_002();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IO_TEST_GETTEXT_001
|
||||
* @tc.desc: function for IoTest-normal testcases
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, IO_TEST_GETTEXT_001, TestSize.Level0)
|
||||
{
|
||||
IO_TEST_GETTEXT_001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IO_TEST_LOCALE_001
|
||||
* @tc.desc: function for IoTest-normal testcases
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, IO_TEST_LOCALE_001, TestSize.Level0)
|
||||
{
|
||||
IO_TEST_LOCALE_001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IO_TEST_LOCALE_002
|
||||
* @tc.desc: function for IoTest-innormal testcases
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, IO_TEST_LOCALE_002, TestSize.Level0)
|
||||
{
|
||||
IO_TEST_LOCALE_002();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IO_TEST_STRFMON_L_001
|
||||
* @tc.desc: function for IoTest-normal testcases
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, IO_TEST_STRFMON_L_001, TestSize.Level0)
|
||||
{
|
||||
IO_TEST_STRFMON_L_001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IO_TEST_STRFMON_L_002
|
||||
* @tc.desc: function for IoTest-innormal testcases
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, IO_TEST_STRFMON_L_002, TestSize.Level0)
|
||||
{
|
||||
IO_TEST_STRFMON_L_002();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IO_TEST_NGETTEXT_001
|
||||
* @tc.desc: function for IoTest-normal testcases
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(IoTest, IO_TEST_NGETTEXT_001, TestSize.Level0)
|
||||
{
|
||||
IO_TEST_NGETTEXT_001();
|
||||
}
|
||||
|
||||
#endif
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 i = 0;
|
||||
wchar_t str[] = L"ABCDEFG";
|
||||
wchar_t str2[] = L"abcdefg";
|
||||
wchar_t c[20];
|
||||
|
||||
wctype_t check = wctype("upper");
|
||||
wctrans_t trans = wctrans("tolower");
|
||||
|
||||
while (str[i]) {
|
||||
c[i] = str[i];
|
||||
if (iswctype(c[i], check)) {
|
||||
c[i] = towctrans(c[i], trans);
|
||||
}
|
||||
if (c[i] != str2[i]) {
|
||||
goto EXIT;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
EXIT:
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
VOID ItTestIo005(void)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
|
||||
static INT32 Vdpfunc(int fd, char *format, ...)
|
||||
{
|
||||
va_list aptr;
|
||||
INT32 ret;
|
||||
|
||||
va_start(aptr, format);
|
||||
ret = vdprintf(fd, format, aptr);
|
||||
va_end(aptr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
CHAR file[30] = "/jffs0/vdprintf";
|
||||
CHAR *str1 = "123456789";
|
||||
CHAR buffer[20];
|
||||
INT32 ret, fd;
|
||||
CHAR str[20] = "789";
|
||||
const int testBufLen = 20;
|
||||
|
||||
fd = open(file, O_CREAT | O_RDWR | O_TRUNC);
|
||||
ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT);
|
||||
|
||||
ret = Vdpfunc(fd, "%s%s", "123456", str);
|
||||
if (ret < 0) {
|
||||
goto EXIT1;
|
||||
}
|
||||
|
||||
ret = close(fd);
|
||||
|
||||
fd = open(file, O_RDWR);
|
||||
ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
|
||||
|
||||
read(fd, buffer, testBufLen);
|
||||
close(fd);
|
||||
|
||||
ICUNIT_GOTO_STRING_EQUAL(buffer, str1, buffer, EXIT2);
|
||||
|
||||
unlink(file);
|
||||
return (0);
|
||||
EXIT1:
|
||||
close(fd);
|
||||
EXIT2:
|
||||
unlink(file);
|
||||
EXIT:
|
||||
return -1;
|
||||
}
|
||||
|
||||
VOID ItTestIo008(void)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
|
||||
|
||||
static VOID GetWideMatches(const wchar_t *str, const wchar_t *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
vswscanf(str, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 val, ret;
|
||||
wchar_t buf[100]; // 100, buffer size
|
||||
wchar_t *str = L"bottles";
|
||||
|
||||
GetWideMatches(L"99 bottles of beer on the wall", L" %d %ls ", &val, buf);
|
||||
ret = wcscmp(buf, str);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
return 0;
|
||||
EXIT:
|
||||
return -1;
|
||||
}
|
||||
|
||||
VOID ItTestIo010(void)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_IO.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 val, ret, result;
|
||||
wchar_t buf[200];
|
||||
wchar_t *str = L"helloworld";
|
||||
|
||||
swscanf(str, L"%ls", buf);
|
||||
|
||||
ret = wcscmp(buf, str);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
return 0;
|
||||
EXIT:
|
||||
return -1;
|
||||
}
|
||||
|
||||
VOID ItTestIo013(void)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef _IT_TEST_MISC_H
|
||||
#define _IT_TEST_MISC_H
|
||||
|
||||
#include "osTest.h"
|
||||
#include "getopt.h"
|
||||
#include "stdlib.h"
|
||||
#include "err.h"
|
||||
#include "unistd.h"
|
||||
#include "search.h"
|
||||
#define MISC_OK 0
|
||||
#define MISC_NOK -1
|
||||
|
||||
extern VOID ItTestMisc001(VOID);
|
||||
extern VOID ItTestMisc002(VOID);
|
||||
extern VOID ItTestMisc003(VOID);
|
||||
extern VOID ItTestMisc004(VOID);
|
||||
extern VOID ItTestMisc005(VOID);
|
||||
extern VOID ItTestMisc006(VOID);
|
||||
extern VOID ItTestMisc007(VOID);
|
||||
extern VOID ItTestMisc008(VOID);
|
||||
extern VOID ItTestMisc009(VOID);
|
||||
extern VOID ItTestMisc010(VOID);
|
||||
extern VOID ItTestMisc011(VOID);
|
||||
extern VOID ItTestMisc012(VOID);
|
||||
extern VOID ItTestMisc013(VOID);
|
||||
extern VOID IT_TEST_MISC_014(VOID);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,53 @@
|
||||
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/testsuites/unittest/config.gni")
|
||||
|
||||
misc_include_dirs = [ "$TEST_UNITTEST_DIR/libc/misc" ]
|
||||
|
||||
misc_sources_entry = [ "$TEST_UNITTEST_DIR/libc/misc/misc_test.cpp" ]
|
||||
|
||||
misc_sources_smoke = [
|
||||
"$TEST_UNITTEST_DIR/libc/misc/smoke/misc_test_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/misc/smoke/misc_test_002.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/misc/smoke/misc_test_003.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/misc/smoke/misc_test_004.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/misc/smoke/misc_test_005.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/misc/smoke/misc_test_014.cpp",
|
||||
]
|
||||
|
||||
misc_sources_full = [
|
||||
"$TEST_UNITTEST_DIR/libc/misc/full/misc_test_006.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/misc/full/misc_test_007.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/misc/full/misc_test_008.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/misc/full/misc_test_009.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/misc/full/misc_test_010.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/misc/full/misc_test_011.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/misc/full/misc_test_012.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/misc/full/misc_test_013.cpp",
|
||||
]
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_misc.h"
|
||||
#include "sys/utsname.h"
|
||||
|
||||
#define INVALID_ADDR_FIRST_PAGE ((struct utsname *)0x1200000)
|
||||
#define INVALID_ADDR_USER_ADDR ((struct utsname *)0x1000000)
|
||||
#define INVALID_ADDR_KERNEL_READONLY_ADDR ((struct utsname *)0x4016c75c)
|
||||
|
||||
static UINT32 TestCase(VOID)
|
||||
{
|
||||
int ret;
|
||||
struct utsname name;
|
||||
|
||||
ret = uname((struct utsname *)NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
|
||||
ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
|
||||
|
||||
ret = uname(INVALID_ADDR_FIRST_PAGE);
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
|
||||
ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
|
||||
|
||||
ret = uname(INVALID_ADDR_USER_ADDR);
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
|
||||
ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
|
||||
|
||||
ret = uname(INVALID_ADDR_KERNEL_READONLY_ADDR);
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
|
||||
ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
|
||||
|
||||
ret = uname(&name);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID ItTestMisc006(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_misc.h"
|
||||
|
||||
static UINT32 TestCase(VOID)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = sysconf(_SC_AIO_LISTIO_MAX);
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
|
||||
|
||||
ret = sysconf(_SC_ARG_MAX);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
|
||||
ret = sysconf(_SC_ATEXIT_MAX);
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
|
||||
ICUNIT_ASSERT_EQUAL(errno, EINVAL, -1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID ItTestMisc007(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_misc.h"
|
||||
|
||||
static UINT32 TestCase(VOID)
|
||||
{
|
||||
char host[100] = {0};
|
||||
int ret = 0;
|
||||
|
||||
ret = gethostname(host, sizeof(host));
|
||||
|
||||
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
|
||||
printf("host = %s\n", host);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID ItTestMisc008(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_misc.h"
|
||||
|
||||
STATIC UINT32 TestCase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR *hostsFileStream = "127.0.0.1 localhost\n192.168.1.3 hisilicon\n::1 localhost\n";
|
||||
CHAR *pathList[] = {"/etc/hosts"};
|
||||
CHAR *streamList[] = {hostsFileStream};
|
||||
INT32 streamLen[] = {strlen(hostsFileStream)};
|
||||
|
||||
ret = PrepareFileEnv(pathList, streamList, streamLen, 1);
|
||||
if (ret != 0) {
|
||||
printf("error: need some env files, but prepare is not ok");
|
||||
(VOID)RecoveryFileEnv(pathList, 1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = gethostid();
|
||||
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, ERROUT);
|
||||
(VOID)RecoveryFileEnv(pathList, 1);
|
||||
return 0;
|
||||
|
||||
ERROUT:
|
||||
(VOID)RecoveryFileEnv(pathList, 1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
VOID ItTestMisc009(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_misc.h"
|
||||
|
||||
static UINT32 TestCase(VOID)
|
||||
{
|
||||
int ret;
|
||||
int rlimit = 512;
|
||||
|
||||
ret = getdtablesize();
|
||||
ICUNIT_ASSERT_EQUAL(ret, rlimit, ret);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID ItTestMisc010(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_misc.h"
|
||||
|
||||
static UINT32 TestCase(VOID)
|
||||
{
|
||||
int ret;
|
||||
struct rlimit rlim;
|
||||
int limit = 512;
|
||||
|
||||
errno = 0;
|
||||
ret = getrlimit(RLIMIT_NOFILE, &rlim);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
|
||||
ICUNIT_ASSERT_EQUAL(rlim.rlim_cur, limit, -1);
|
||||
ret = getrlimit(RLIMIT_RSS, &rlim);
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
|
||||
ICUNIT_ASSERT_EQUAL(errno, EINVAL, -1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID ItTestMisc011(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_misc.h"
|
||||
|
||||
static UINT32 TestCase(VOID)
|
||||
{
|
||||
int ret;
|
||||
struct rlimit rlim1;
|
||||
struct rlimit rlim2 = {10, 10};
|
||||
|
||||
errno = 0;
|
||||
ret = setrlimit(RLIMIT_NOFILE, &rlim2);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
|
||||
ret = getrlimit(RLIMIT_NOFILE, &rlim1);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
|
||||
ICUNIT_ASSERT_EQUAL(rlim1.rlim_cur, rlim2.rlim_cur, ret);
|
||||
ICUNIT_ASSERT_EQUAL(rlim1.rlim_max, rlim2.rlim_max, ret);
|
||||
|
||||
ret = setrlimit(RLIMIT_FSIZE, &rlim2);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
|
||||
ret = getrlimit(RLIMIT_FSIZE, &rlim1);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
|
||||
ICUNIT_ASSERT_EQUAL(rlim1.rlim_cur, rlim2.rlim_cur, ret);
|
||||
ICUNIT_ASSERT_EQUAL(rlim1.rlim_max, rlim2.rlim_max, ret);
|
||||
|
||||
ret = setrlimit(RLIMIT_AS, &rlim2);
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
|
||||
ICUNIT_ASSERT_EQUAL(errno, EINVAL, -1);
|
||||
|
||||
ret = setrlimit(RLIMIT_DATA, &rlim2);
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
|
||||
ICUNIT_ASSERT_EQUAL(errno, EINVAL, -1);
|
||||
|
||||
ret = setrlimit(-100, &rlim2);
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
|
||||
ICUNIT_ASSERT_EQUAL(errno, EINVAL, -1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID ItTestMisc012(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_misc.h"
|
||||
#include "ulimit.h"
|
||||
|
||||
static UINT32 TestCase(VOID)
|
||||
{
|
||||
long ret;
|
||||
long size = 200;
|
||||
long max = 0x7fffffff;
|
||||
|
||||
ret = ulimit(UL_SETFSIZE, size);
|
||||
ICUNIT_ASSERT_EQUAL(ret, size, -1);
|
||||
|
||||
ret = ulimit(UL_GETFSIZE, size);
|
||||
ICUNIT_ASSERT_EQUAL(ret, size, ret);
|
||||
|
||||
ret = ulimit(size, size);
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
|
||||
ICUNIT_ASSERT_EQUAL(errno, EINVAL, ret);
|
||||
|
||||
ret = ulimit(UL_SETFSIZE, max);
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
|
||||
ICUNIT_ASSERT_EQUAL(errno, EPERM, ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID ItTestMisc013(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "stdio.h"
|
||||
#include <climits>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "It_test_misc.h"
|
||||
|
||||
using namespace testing::ext;
|
||||
namespace OHOS {
|
||||
class MiscTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase(void) {}
|
||||
static void TearDownTestCase(void) {}
|
||||
};
|
||||
|
||||
#if defined(LOSCFG_USER_TEST_SMOKE)
|
||||
/* *
|
||||
* @tc.name: IT_TEST_MISC_001
|
||||
* @tc.desc: function for MiscTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(MiscTest, ItTestMisc001, TestSize.Level0)
|
||||
{
|
||||
ItTestMisc001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_TEST_MISC_002
|
||||
* @tc.desc: function for MiscTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(MiscTest, ItTestMisc002, TestSize.Level0)
|
||||
{
|
||||
ItTestMisc002();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_TEST_MISC_003
|
||||
* @tc.desc: function for MiscTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(MiscTest, ItTestMisc003, TestSize.Level0)
|
||||
{
|
||||
ItTestMisc003();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_TEST_MISC_004
|
||||
* @tc.desc: function for MiscTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(MiscTest, ItTestMisc004, TestSize.Level0)
|
||||
{
|
||||
ItTestMisc004();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_TEST_MISC_005
|
||||
* @tc.desc: function for MiscTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(MiscTest, ItTestMisc005, TestSize.Level0)
|
||||
{
|
||||
ItTestMisc005();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_TEST_MISC_014
|
||||
* @tc.desc: function for tmpnam test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(MiscTest, IT_TEST_MISC_014, TestSize.Level0)
|
||||
{
|
||||
IT_TEST_MISC_014();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(LOSCFG_USER_TEST_FULL)
|
||||
/* *
|
||||
* @tc.name: IT_TEST_MISC_006
|
||||
* @tc.desc: function for MiscTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(MiscTest, ItTestMisc006, TestSize.Level0)
|
||||
{
|
||||
ItTestMisc006();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_TEST_MISC_007
|
||||
* @tc.desc: function for MiscTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(MiscTest, ItTestMisc007, TestSize.Level0)
|
||||
{
|
||||
ItTestMisc007();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_TEST_MISC_008
|
||||
* @tc.desc: function for MiscTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(MiscTest, ItTestMisc008, TestSize.Level0)
|
||||
{
|
||||
ItTestMisc008();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_TEST_MISC_009
|
||||
* @tc.desc: function for MiscTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(MiscTest, ItTestMisc009, TestSize.Level0)
|
||||
{
|
||||
ItTestMisc009();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_TEST_MISC_010
|
||||
* @tc.desc: function for MiscTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
/*HWTEST_F(MiscTest, ItTestMisc010, TestSize.Level0)
|
||||
{
|
||||
ItTestMisc010();
|
||||
}*/
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_TEST_MISC_011
|
||||
* @tc.desc: function for MiscTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
/*HWTEST_F(MiscTest, ItTestMisc011, TestSize.Level0)
|
||||
{
|
||||
ItTestMisc011();
|
||||
}*/
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_TEST_MISC_012
|
||||
* @tc.desc: function for MiscTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(MiscTest, ItTestMisc012, TestSize.Level0)
|
||||
{
|
||||
ItTestMisc012();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_TEST_MISC_013
|
||||
* @tc.desc: function for MiscTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
/*HWTEST_F(MiscTest, ItTestMisc013, TestSize.Level0)
|
||||
{
|
||||
ItTestMisc013();
|
||||
}*/
|
||||
#endif
|
||||
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_misc.h"
|
||||
|
||||
#define TEST_MEMSIZE 8
|
||||
static UINT32 TestCase(VOID)
|
||||
{
|
||||
VOID *ptr = NULL;
|
||||
|
||||
ptr = valloc(TEST_MEMSIZE);
|
||||
ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT);
|
||||
|
||||
free(ptr);
|
||||
|
||||
return MISC_OK;
|
||||
EXIT:
|
||||
free(ptr);
|
||||
return MISC_NOK;
|
||||
}
|
||||
|
||||
VOID ItTestMisc001(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_misc.h"
|
||||
|
||||
#define TEST_OK "success"
|
||||
#define STR_LEN 20
|
||||
|
||||
static VOID Vwarnfuc(const char *format, ...)
|
||||
{
|
||||
va_list arglist;
|
||||
|
||||
va_start(arglist, format);
|
||||
vwarn(format, arglist);
|
||||
va_end(arglist);
|
||||
}
|
||||
|
||||
static UINT32 TestCase(VOID)
|
||||
{
|
||||
CHAR ptr[STR_LEN] = TEST_OK;
|
||||
Vwarnfuc("%s", ptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID ItTestMisc002(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_misc.h"
|
||||
|
||||
#define TEST_OK "success"
|
||||
#define STR_LEN 20
|
||||
|
||||
static VOID Vwarnxfuc(const char *format, ...)
|
||||
{
|
||||
va_list arglist;
|
||||
|
||||
va_start(arglist, format);
|
||||
vwarnx(format, arglist);
|
||||
va_end(arglist);
|
||||
}
|
||||
|
||||
static UINT32 TestCase(VOID)
|
||||
{
|
||||
CHAR ptr[STR_LEN] = TEST_OK;
|
||||
Vwarnxfuc("%s", ptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID ItTestMisc003(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_misc.h"
|
||||
|
||||
#define TEST_OK "success"
|
||||
#define STR_LEN 20
|
||||
|
||||
static VOID Verrfuc(INT32 fpid, const char *format, ...)
|
||||
{
|
||||
va_list arglist;
|
||||
|
||||
va_start(arglist, format);
|
||||
verr(fpid, format, arglist);
|
||||
va_end(arglist);
|
||||
}
|
||||
|
||||
static UINT32 TestCase(VOID)
|
||||
{
|
||||
CHAR ptr[STR_LEN] = TEST_OK;
|
||||
INT32 fpid;
|
||||
|
||||
fpid = fork();
|
||||
if (fpid == 0) {
|
||||
Verrfuc(fpid, "%s", ptr);
|
||||
}
|
||||
usleep(20);
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID ItTestMisc004(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_misc.h"
|
||||
|
||||
#define TEST_OK "success"
|
||||
#define STR_LEN 20
|
||||
|
||||
static VOID Verrxfuc(INT32 fpid, const char *format, ...)
|
||||
{
|
||||
va_list arglist;
|
||||
|
||||
va_start(arglist, format);
|
||||
verrx(fpid, format, arglist);
|
||||
va_end(arglist);
|
||||
}
|
||||
|
||||
static UINT32 TestCase(VOID)
|
||||
{
|
||||
CHAR ptr[STR_LEN] = TEST_OK;
|
||||
INT32 fpid;
|
||||
|
||||
fpid = fork();
|
||||
if (fpid == 0) {
|
||||
Verrxfuc(fpid, "%s", ptr);
|
||||
}
|
||||
usleep(20);
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID ItTestMisc005(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_test_misc.h"
|
||||
|
||||
static UINT32 TestCase(VOID)
|
||||
{
|
||||
char *name1 = nullptr;
|
||||
char name2[100] = { 0 };
|
||||
char name3[100] = "hello";
|
||||
int ret;
|
||||
|
||||
name1 = tmpnam(NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(name1, nullptr, -1);
|
||||
ret = strncmp(name1, "/tmp/tmpnam_", 12);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, -1);
|
||||
|
||||
tmpnam(name2);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(name2[0], 0, -1);
|
||||
ret = strncmp(name2, "/tmp/tmpnam_", 12);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, -1);
|
||||
|
||||
tmpnam(name2);
|
||||
ret = strncmp(name2, "/tmp/tmpnam_", 12);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, -1);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID IT_TEST_MISC_014(VOID)
|
||||
{
|
||||
TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef _IT_POSIX_MEM_H
|
||||
#define _IT_POSIX_MEM_H
|
||||
|
||||
#include "osTest.h"
|
||||
|
||||
#if defined(LOSCFG_USER_TEST_SMOKE)
|
||||
VOID ItPosixMem001(VOID);
|
||||
VOID IT_POSIX_MEM_002(VOID);
|
||||
VOID ItPosixMem003(VOID);
|
||||
#endif
|
||||
|
||||
#endif /* _IT_POSIX_MEM_H */
|
||||
@@ -0,0 +1,41 @@
|
||||
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/testsuites/unittest/config.gni")
|
||||
|
||||
posix_mem_include_dirs = [ "$TEST_UNITTEST_DIR/libc/posix/mem" ]
|
||||
|
||||
posix_mem_sources_entry =
|
||||
[ "$TEST_UNITTEST_DIR/libc/posix/mem/posix_mem_test.cpp" ]
|
||||
|
||||
posix_mem_sources_smoke = [
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mem/smoke/It_posix_mem_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mem/smoke/It_posix_mem_003.cpp",
|
||||
]
|
||||
|
||||
posix_mem_sources_full = []
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "stdio.h"
|
||||
#include <climits>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "It_posix_mem.h"
|
||||
|
||||
|
||||
using namespace testing::ext;
|
||||
namespace OHOS {
|
||||
class PosixMemTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase(void) {}
|
||||
static void TearDownTestCase(void) {}
|
||||
};
|
||||
|
||||
#if defined(LOSCFG_USER_TEST_SMOKE)
|
||||
/* *
|
||||
* @tc.name: IT_POSIX_MEM_001
|
||||
* @tc.desc: function for PosixMemTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(PosixMemTest, ItPosixMem001, TestSize.Level0)
|
||||
{
|
||||
ItPosixMem001();
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.name: IT_POSIX_MEM_003
|
||||
* @tc.desc: function for PosixMemTest
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000EEMQ9
|
||||
*/
|
||||
HWTEST_F(PosixMemTest, ItPosixMem003, TestSize.Level0)
|
||||
{
|
||||
ItPosixMem003();
|
||||
}
|
||||
|
||||
#endif
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_mem.h"
|
||||
|
||||
/* *
|
||||
* @test IT_POSIX_MEMALIGN_001
|
||||
* -@tspec posix_memalign API test
|
||||
* -@ttitle The alignment argument was not a power of two, or was not a multiple of sizeof(void *)
|
||||
* -@tprecon dynamic memory function open
|
||||
* -@tbrief
|
||||
* -#alignment == 0,2,3,7,15,31,63
|
||||
* -@texpect
|
||||
* -#return EINVAL
|
||||
* -#return EINVAL
|
||||
* -@tprior 1
|
||||
* -@tauto TRUE
|
||||
* -@tremark
|
||||
*/
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
int ret;
|
||||
size_t size = 0x100;
|
||||
void *p = nullptr;
|
||||
|
||||
ret = posix_memalign(&p, 0, size);
|
||||
ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
|
||||
ICUNIT_ASSERT_EQUAL(p, nullptr, p);
|
||||
|
||||
ret = posix_memalign(&p, 2, size); // 2, alignment
|
||||
ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
|
||||
ICUNIT_ASSERT_EQUAL(p, nullptr, p);
|
||||
|
||||
for (UINT32 n = 2; n < 7; n++) { // 2, 7, alignment
|
||||
ret = posix_memalign(&p, ((1 << n) - 1), size);
|
||||
ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
|
||||
ICUNIT_ASSERT_EQUAL(p, nullptr, p);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
VOID ItPosixMem001(void)
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_MEM_001", Testcase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_mem.h"
|
||||
|
||||
/* *
|
||||
* @test IT_POSIX_MEMALIGN_003
|
||||
* -@tspec posix_memalign Function test
|
||||
* -@ttitle The alignment argument was a power of two
|
||||
* -@tprecon dynamic memory function open
|
||||
* -@tbrief
|
||||
* -#alignment == 4,8,16,32,64
|
||||
* -@texpect
|
||||
* -#return EINVAL
|
||||
* -#return EINVAL
|
||||
* -@tprior 1
|
||||
* -@tauto TRUE
|
||||
* -@tremark
|
||||
*/
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
int ret;
|
||||
size_t align = sizeof(UINTPTR);
|
||||
size_t size = 0x100;
|
||||
void *p = nullptr;
|
||||
|
||||
for (align = sizeof(UINTPTR); align <= 64; align <<= 1) { // 64, alignment
|
||||
ret = posix_memalign(&p, align, size);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(p, nullptr, p);
|
||||
|
||||
free(p);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID ItPosixMem003(void)
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_MEM_003", Testcase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,278 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef IT_POSIX_QUEUE_H
|
||||
#define IT_POSIX_QUEUE_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <mqueue.h>
|
||||
#include <los_typedef.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <sched.h>
|
||||
#include <signal.h>
|
||||
#include <osTest.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#define MAXMSG5 5
|
||||
#define MSGLEN 10
|
||||
#define MAXMSG 10
|
||||
|
||||
const int MQUEUE_SHORT_ARRAY_LENGTH = 10; // = strlen(MQUEUE_SEND_STRING_TEST)
|
||||
const int MQUEUE_STANDARD_NAME_LENGTH = 50;
|
||||
|
||||
#define MQUEUE_NO_ERROR 0
|
||||
#define MQUEUE_IS_ERROR (-1)
|
||||
#define MQUEUE_PTHREAD_PRIORITY_TEST1 3
|
||||
#define MQUEUE_PTHREAD_PRIORITY_TEST2 4
|
||||
#define MQUEUE_PATH_MAX_TEST PATH_MAX
|
||||
#define MQUEUE_NAME_MAX_TEST NAME_MAX
|
||||
#define MQUEUE_SEND_STRING_TEST "0123456789"
|
||||
#define MQUEUE_PTHREAD_NUM_TEST 5
|
||||
#define MQUEUE_PRIORITY_TEST 0
|
||||
#define MQUEUE_TIMEOUT_TEST 7
|
||||
#define MQUEUE_PRIORITY_NUM_TEST 3
|
||||
#define MQUEUE_MAX_NUM_TEST (LOSCFG_BASE_IPC_QUEUE_CONFIG - QUEUE_EXISTED_NUM)
|
||||
#define MQ_MAX_MSG_NUM 16
|
||||
#define MQ_MAX_MSG_LEN 64
|
||||
#define HWI_NUM_TEST 1
|
||||
#define HWI_NUM_TEST1 2
|
||||
#define LOS_WAIT_FOREVER 0XFFFFFFFF
|
||||
|
||||
typedef VOID (*HWI_PROC_FUNC)(VOID *pParm);
|
||||
|
||||
#define MQ_VALID_MAGIC 0x6db256c1
|
||||
const int LOSCFG_BASE_IPC_QUEUE_CONFIG = 1024;
|
||||
|
||||
#ifdef __LP64__
|
||||
#define PER_ADDED_VALUE 8
|
||||
#else
|
||||
#define PER_ADDED_VALUE 4
|
||||
#endif
|
||||
|
||||
typedef UINT32 TSK_HANDLE_T;
|
||||
using SEM_HANDLE_T = UINT32;
|
||||
extern SEM_HANDLE_T g_mqueueSem;
|
||||
|
||||
static TSK_HANDLE_T g_mqueueTaskPID;
|
||||
extern CHAR g_gqname[MQUEUE_STANDARD_NAME_LENGTH];
|
||||
extern CHAR g_mqueueName[LOSCFG_BASE_IPC_QUEUE_CONFIG + 1][MQUEUE_STANDARD_NAME_LENGTH];
|
||||
extern mqd_t g_mqueueId[LOSCFG_BASE_IPC_QUEUE_CONFIG + 1];
|
||||
|
||||
extern CHAR *g_mqueueMsessage[MQUEUE_SHORT_ARRAY_LENGTH];
|
||||
extern mqd_t g_messageQId;
|
||||
extern mqd_t g_gqueue;
|
||||
|
||||
extern unsigned long MsecsToJiffies(const unsigned int m);
|
||||
|
||||
extern VOID ItSuite_Posix_Mqueue(VOID);
|
||||
extern UINT32 LosCurTaskIDGet();
|
||||
extern int LOS_AtomicInc(const volatile unsigned int *num);
|
||||
extern int LosSemDelete(SEM_HANDLE_T num);
|
||||
extern int LosSemCreate(int num, const SEM_HANDLE_T *hdl);
|
||||
extern UINT32 PosixPthreadInit(pthread_attr_t *attr, int pri);
|
||||
extern void LOS_TaskUnlock();
|
||||
extern void LOS_TaskLock();
|
||||
extern int LosSemPost(SEM_HANDLE_T);
|
||||
extern int LosSemPend(SEM_HANDLE_T hdl, int num);
|
||||
extern int SemPost(SEM_HANDLE_T);
|
||||
extern int SemPend(SEM_HANDLE_T hdl, int num);
|
||||
extern int LOS_HwiCreate(int hwiNum, int hwiPrio, int hwiMode, HWI_PROC_FUNC hwiHandler, int *irqParam);
|
||||
extern UINT64 JiffiesToTick(unsigned long j);
|
||||
extern int HalIrqMask(int num);
|
||||
extern UINT32 PosixPthreadDestroy(pthread_attr_t *attr, pthread_t thread);
|
||||
|
||||
#define LOS_TaskLock()
|
||||
#define LOS_TaskUnlock()
|
||||
#define LOS_AtomicInc(a) (++*(a))
|
||||
#define TEST_TEST_HwiDelete(ID, NULL)
|
||||
|
||||
#if defined(LOSCFG_USER_TEST_SMOKE)
|
||||
VOID ItPosixQueue001(VOID);
|
||||
VOID ItPosixQueue003(VOID);
|
||||
VOID ItPosixQueue028(VOID);
|
||||
VOID ItPosixQueue062(VOID);
|
||||
VOID ItPosixQueue053(VOID);
|
||||
VOID ItPosixQueue144(VOID);
|
||||
#endif
|
||||
|
||||
#if defined(LOSCFG_USER_TEST_FULL)
|
||||
VOID ItPosixQueue002(VOID);
|
||||
VOID ItPosixQueue004(VOID);
|
||||
VOID ItPosixQueue005(VOID);
|
||||
VOID ItPosixQueue007(VOID);
|
||||
VOID ItPosixQueue008(VOID);
|
||||
VOID ItPosixQueue010(VOID);
|
||||
VOID ItPosixQueue011(VOID);
|
||||
VOID ItPosixQueue012(VOID);
|
||||
VOID ItPosixQueue013(VOID);
|
||||
VOID ItPosixQueue014(VOID);
|
||||
VOID ItPosixQueue015(VOID);
|
||||
VOID ItPosixQueue016(VOID);
|
||||
VOID ItPosixQueue017(VOID);
|
||||
VOID ItPosixQueue018(VOID);
|
||||
VOID ItPosixQueue019(VOID);
|
||||
VOID ItPosixQueue020(VOID);
|
||||
VOID ItPosixQueue021(VOID);
|
||||
VOID ItPosixQueue025(VOID);
|
||||
VOID ItPosixQueue026(VOID);
|
||||
VOID ItPosixQueue027(VOID);
|
||||
VOID ItPosixQueue030(VOID);
|
||||
VOID ItPosixQueue031(VOID);
|
||||
VOID ItPosixQueue032(VOID);
|
||||
VOID ItPosixQueue033(VOID);
|
||||
VOID ItPosixQueue036(VOID);
|
||||
VOID ItPosixQueue037(VOID);
|
||||
VOID ItPosixQueue038(VOID);
|
||||
VOID ItPosixQueue039(VOID);
|
||||
VOID ItPosixQueue040(VOID);
|
||||
VOID ItPosixQueue041(VOID);
|
||||
VOID ItPosixQueue042(VOID);
|
||||
VOID ItPosixQueue044(VOID);
|
||||
VOID ItPosixQueue046(VOID);
|
||||
VOID ItPosixQueue047(VOID);
|
||||
VOID ItPosixQueue048(VOID);
|
||||
VOID ItPosixQueue049(VOID);
|
||||
VOID ItPosixQueue050(VOID);
|
||||
VOID ItPosixQueue052(VOID);
|
||||
VOID ItPosixQueue054(VOID);
|
||||
VOID ItPosixQueue055(VOID);
|
||||
VOID ItPosixQueue056(VOID);
|
||||
VOID ItPosixQueue057(VOID);
|
||||
VOID ItPosixQueue058(VOID);
|
||||
VOID ItPosixQueue060(VOID);
|
||||
VOID ItPosixQueue061(VOID);
|
||||
VOID ItPosixQueue063(VOID);
|
||||
VOID ItPosixQueue064(VOID);
|
||||
VOID ItPosixQueue065(VOID);
|
||||
VOID ItPosixQueue066(VOID);
|
||||
VOID ItPosixQueue067(VOID);
|
||||
VOID ItPosixQueue069(VOID);
|
||||
VOID ItPosixQueue070(VOID);
|
||||
VOID ItPosixQueue071(VOID);
|
||||
VOID ItPosixQueue072(VOID);
|
||||
VOID ItPosixQueue073(VOID);
|
||||
VOID ItPosixQueue074(VOID);
|
||||
VOID ItPosixQueue075(VOID);
|
||||
VOID ItPosixQueue076(VOID);
|
||||
VOID ItPosixQueue077(VOID);
|
||||
VOID ItPosixQueue078(VOID);
|
||||
VOID ItPosixQueue079(VOID);
|
||||
VOID ItPosixQueue080(VOID);
|
||||
VOID ItPosixQueue081(VOID);
|
||||
VOID ItPosixQueue082(VOID);
|
||||
VOID ItPosixQueue083(VOID);
|
||||
VOID ItPosixQueue084(VOID);
|
||||
VOID ItPosixQueue085(VOID);
|
||||
VOID ItPosixQueue086(VOID);
|
||||
VOID ItPosixQueue087(VOID);
|
||||
VOID ItPosixQueue088(VOID);
|
||||
VOID ItPosixQueue089(VOID);
|
||||
VOID ItPosixQueue090(VOID);
|
||||
VOID ItPosixQueue091(VOID);
|
||||
VOID ItPosixQueue093(VOID);
|
||||
VOID ItPosixQueue094(VOID);
|
||||
VOID ItPosixQueue095(VOID);
|
||||
VOID ItPosixQueue096(VOID);
|
||||
VOID ItPosixQueue097(VOID);
|
||||
VOID ItPosixQueue098(VOID);
|
||||
VOID ItPosixQueue100(VOID);
|
||||
VOID ItPosixQueue101(VOID);
|
||||
VOID ItPosixQueue102(VOID);
|
||||
VOID ItPosixQueue103(VOID);
|
||||
VOID ItPosixQueue104(VOID);
|
||||
VOID ItPosixQueue106(VOID);
|
||||
VOID ItPosixQueue108(VOID);
|
||||
VOID ItPosixQueue109(VOID);
|
||||
VOID ItPosixQueue110(VOID);
|
||||
VOID ItPosixQueue111(VOID);
|
||||
VOID ItPosixQueue112(VOID);
|
||||
VOID ItPosixQueue113(VOID);
|
||||
VOID ItPosixQueue114(VOID);
|
||||
VOID ItPosixQueue115(VOID);
|
||||
VOID ItPosixQueue116(VOID);
|
||||
VOID ItPosixQueue117(VOID);
|
||||
VOID ItPosixQueue118(VOID);
|
||||
VOID ItPosixQueue119(VOID);
|
||||
VOID ItPosixQueue120(VOID);
|
||||
VOID ItPosixQueue121(VOID);
|
||||
VOID ItPosixQueue122(VOID);
|
||||
VOID ItPosixQueue123(VOID);
|
||||
VOID ItPosixQueue124(VOID);
|
||||
VOID ItPosixQueue125(VOID);
|
||||
VOID ItPosixQueue126(VOID);
|
||||
VOID ItPosixQueue127(VOID);
|
||||
VOID ItPosixQueue128(VOID);
|
||||
VOID ItPosixQueue129(VOID);
|
||||
VOID ItPosixQueue130(VOID);
|
||||
VOID ItPosixQueue133(VOID);
|
||||
VOID ItPosixQueue134(VOID);
|
||||
VOID ItPosixQueue136(VOID);
|
||||
VOID ItPosixQueue143(VOID);
|
||||
VOID ItPosixQueue145(VOID);
|
||||
VOID ItPosixQueue146(VOID);
|
||||
VOID ItPosixQueue147(VOID);
|
||||
VOID ItPosixQueue148(VOID);
|
||||
VOID ItPosixQueue149(VOID);
|
||||
VOID ItPosixQueue150(VOID);
|
||||
VOID ItPosixQueue151(VOID);
|
||||
VOID ItPosixQueue152(VOID);
|
||||
VOID ItPosixQueue153(VOID);
|
||||
VOID ItPosixQueue154(VOID);
|
||||
VOID ItPosixQueue155(VOID);
|
||||
VOID ItPosixQueue156(VOID);
|
||||
VOID ItPosixQueue160(VOID);
|
||||
VOID ItPosixQueue161(VOID);
|
||||
VOID ItPosixQueue162(VOID);
|
||||
VOID ItPosixQueue163(VOID);
|
||||
VOID ItPosixQueue164(VOID);
|
||||
VOID ItPosixQueue165(VOID);
|
||||
VOID ItPosixQueue166(VOID);
|
||||
VOID ItPosixQueue168(VOID);
|
||||
VOID ItPosixQueue169(VOID);
|
||||
VOID ItPosixQueue173(VOID);
|
||||
VOID ItPosixQueue175(VOID);
|
||||
VOID ItPosixQueue176(VOID);
|
||||
VOID ItPosixQueue187(VOID);
|
||||
|
||||
VOID ItPosixQueue200(VOID);
|
||||
VOID ItPosixQueue201(VOID);
|
||||
VOID ItPosixQueue202(VOID);
|
||||
VOID ItPosixQueue203(VOID);
|
||||
VOID ItPosixQueue204(VOID);
|
||||
|
||||
VOID ItPosixQueue205(VOID);
|
||||
VOID ItPosixQueue206(VOID);
|
||||
VOID ItPosixQueue207(VOID);
|
||||
VOID ItPosixQueue208(VOID);
|
||||
VOID ItPosixQueue209(VOID);
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,190 @@
|
||||
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/testsuites/unittest/config.gni")
|
||||
|
||||
posix_mqueue_include_dirs = [ "$TEST_UNITTEST_DIR/libc/posix/mqueue" ]
|
||||
|
||||
posix_mqueue_sources_entry =
|
||||
[ "$TEST_UNITTEST_DIR/libc/posix/mqueue/posix_mqueue_test.cpp" ]
|
||||
|
||||
posix_mqueue_sources_smoke = [
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/smoke/It_posix_queue_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/smoke/It_posix_queue_003.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/smoke/It_posix_queue_028.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/smoke/It_posix_queue_053.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/smoke/It_posix_queue_062.cpp",
|
||||
]
|
||||
|
||||
posix_mqueue_sources_full = [
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_002.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_005.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_008.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_011.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_013.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_014.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_015.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_016.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_018.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_019.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_020.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_021.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_025.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_026.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_027.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_030.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_031.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_032.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_033.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_036.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_038.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_040.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_041.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_042.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_043.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_044.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_046.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_047.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_048.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_049.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_050.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_052.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_054.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_055.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_056.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_057.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_058.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_060.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_061.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_063.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_064.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_065.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_066.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_067.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_069.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_070.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_071.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_072.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_073.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_074.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_075.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_076.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_077.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_078.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_079.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_080.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_081.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_082.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_083.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_084.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_085.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_086.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_087.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_088.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_089.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_090.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_091.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_093.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_094.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_095.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_096.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_097.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_098.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_100.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_101.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_102.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_103.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_104.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_106.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_108.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_109.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_110.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_111.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_112.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_113.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_114.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_115.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_116.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_117.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_118.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_119.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_120.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_121.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_122.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_123.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_124.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_125.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_126.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_127.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_128.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_129.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_130.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_133.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_134.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_136.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_143.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_144.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_145.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_146.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_147.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_148.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_149.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_150.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_151.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_152.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_153.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_154.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_155.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_156.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_157.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_159.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_160.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_161.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_162.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_163.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_164.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_165.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_166.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_168.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_169.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_173.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_175.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_176.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_177.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_187.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_200.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_201.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_202.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_203.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_204.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_205.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_206.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_207.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_208.cpp",
|
||||
"$TEST_UNITTEST_DIR/libc/posix/mqueue/full/It_posix_queue_209.cpp",
|
||||
]
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||
struct mq_attr attr = { 0 };
|
||||
mqd_t mqueue;
|
||||
|
||||
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||
attr.mq_maxmsg = 1;
|
||||
|
||||
snprintf(mqname, MQUEUE_STANDARD_NAME_LENGTH, "/mq002_%d", LosCurTaskIDGet());
|
||||
|
||||
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||
|
||||
ret = mq_send(mqueue, msgptr, strlen(msgptr), 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_receive(mqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_SHORT_ARRAY_LENGTH, ret, EXIT1);
|
||||
ICUNIT_GOTO_STRING_EQUAL(msgrcd, MQUEUE_SEND_STRING_TEST, msgrcd, EXIT1);
|
||||
|
||||
ret = mq_close(mqueue);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
|
||||
return MQUEUE_NO_ERROR;
|
||||
|
||||
EXIT1:
|
||||
mq_close(mqueue);
|
||||
EXIT:
|
||||
mq_unlink(mqname);
|
||||
return MQUEUE_NO_ERROR;
|
||||
}
|
||||
|
||||
VOID ItPosixQueue002(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_QUEUE_002", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
mqd_t mqueue;
|
||||
|
||||
snprintf(mqname, MQUEUE_STANDARD_NAME_LENGTH, "/mq005_%d", LosCurTaskIDGet());
|
||||
mqueue = mq_open(mqname, O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT);
|
||||
ICUNIT_ASSERT_EQUAL(errno, ENOENT, errno);
|
||||
|
||||
return MQUEUE_NO_ERROR;
|
||||
|
||||
EXIT:
|
||||
mq_close(mqueue);
|
||||
mq_unlink(mqname);
|
||||
return MQUEUE_NO_ERROR;
|
||||
}
|
||||
|
||||
VOID ItPosixQueue005(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_QUEUE_005", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
mqd_t roqueue, roqueue2;
|
||||
|
||||
snprintf(mqname, MQUEUE_STANDARD_NAME_LENGTH, "/mq008_%d", LosCurTaskIDGet());
|
||||
|
||||
roqueue = mq_open(mqname, O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_NOT_EQUAL(roqueue, (mqd_t)-1, roqueue, EXIT);
|
||||
|
||||
roqueue2 = mq_open(mqname, O_RDONLY, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_NOT_EQUAL(roqueue2, (mqd_t)-1, roqueue2, EXIT1);
|
||||
|
||||
ret = mq_close(roqueue);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_close(roqueue2);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
|
||||
return MQUEUE_NO_ERROR;
|
||||
EXIT1:
|
||||
mq_close(roqueue2);
|
||||
EXIT:
|
||||
mq_close(roqueue);
|
||||
mq_unlink(mqname);
|
||||
return MQUEUE_NO_ERROR;
|
||||
}
|
||||
|
||||
VOID ItPosixQueue008(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_QUEUE_008", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
CHAR msgrcd2[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||
mqd_t rdwrqueue, rdwrqueue2;
|
||||
struct mq_attr attr = { 0 };
|
||||
|
||||
snprintf(mqname, MQUEUE_STANDARD_NAME_LENGTH, "/mq011_%d", LosCurTaskIDGet());
|
||||
|
||||
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||
attr.mq_maxmsg = MQUEUE_STANDARD_NAME_LENGTH;
|
||||
rdwrqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||
ICUNIT_GOTO_NOT_EQUAL(rdwrqueue, (mqd_t)-1, rdwrqueue, EXIT);
|
||||
|
||||
ret = mq_send(rdwrqueue, msgptr, strlen(msgptr), 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
|
||||
ret = mq_receive(rdwrqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, strlen(msgptr), ret, EXIT);
|
||||
|
||||
rdwrqueue2 = mq_open(mqname, O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||
ICUNIT_GOTO_NOT_EQUAL(rdwrqueue2, (mqd_t)-1, rdwrqueue2, EXIT1);
|
||||
|
||||
ret = mq_send(rdwrqueue2, msgptr, strlen(msgptr), 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_receive(rdwrqueue2, msgrcd2, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, strlen(msgptr), ret, EXIT1);
|
||||
|
||||
ret = mq_close(rdwrqueue2);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||
|
||||
ret = mq_close(rdwrqueue);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
return MQUEUE_NO_ERROR;
|
||||
EXIT1:
|
||||
mq_close(rdwrqueue2);
|
||||
EXIT:
|
||||
mq_close(rdwrqueue);
|
||||
mq_unlink(mqname);
|
||||
return MQUEUE_NO_ERROR;
|
||||
}
|
||||
|
||||
VOID ItPosixQueue011(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_QUEUE_011", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret = 0;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||
mqd_t mqueue1, mqueue2;
|
||||
|
||||
snprintf(mqname, MQUEUE_STANDARD_NAME_LENGTH, "/mq013_%d", LosCurTaskIDGet());
|
||||
|
||||
mqueue1 = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue1, (mqd_t)-1, mqueue1, EXIT1);
|
||||
|
||||
ret = mq_send(mqueue1, msgptr, strlen(msgptr), 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
mqueue2 = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue2, (mqd_t)-1, mqueue2, EXIT2);
|
||||
|
||||
ret = mq_send(mqueue2, msgptr, strlen(msgptr), 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT2);
|
||||
|
||||
ret = mq_close(mqueue1);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT2);
|
||||
|
||||
ret = mq_close(mqueue2);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
|
||||
return MQUEUE_NO_ERROR;
|
||||
EXIT2:
|
||||
mq_close(mqueue2);
|
||||
EXIT1:
|
||||
mq_close(mqueue1);
|
||||
EXIT:
|
||||
mq_unlink(mqname);
|
||||
return MQUEUE_NO_ERROR;
|
||||
}
|
||||
|
||||
VOID ItPosixQueue013(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_QUEUE_013", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
mqd_t mqueue;
|
||||
struct mq_attr attr = { 0 };
|
||||
|
||||
snprintf(mqname, MQUEUE_STANDARD_NAME_LENGTH, "/mq014_%d", LosCurTaskIDGet());
|
||||
|
||||
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||
|
||||
ret = mq_getattr(mqueue, &attr);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
ICUNIT_GOTO_EQUAL(attr.mq_curmsgs, 0, attr.mq_curmsgs, EXIT1);
|
||||
ICUNIT_GOTO_EQUAL(attr.mq_flags, O_CREAT | O_RDWR, attr.mq_flags, EXIT1);
|
||||
ICUNIT_GOTO_EQUAL(attr.mq_maxmsg, MQ_MAX_MSG_NUM, attr.mq_maxmsg, EXIT1);
|
||||
ICUNIT_GOTO_EQUAL(attr.mq_msgsize, MQ_MAX_MSG_LEN, attr.mq_msgsize, EXIT1);
|
||||
|
||||
ret = mq_close(mqueue);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
|
||||
return MQUEUE_NO_ERROR;
|
||||
EXIT1:
|
||||
mq_close(mqueue);
|
||||
EXIT:
|
||||
mq_unlink(mqname);
|
||||
return MQUEUE_NO_ERROR;
|
||||
}
|
||||
|
||||
VOID ItPosixQueue014(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_QUEUE_014", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
mqd_t mqueue;
|
||||
struct mq_attr attr = { 0 };
|
||||
struct mq_attr attrget;
|
||||
|
||||
snprintf(mqname, MQUEUE_STANDARD_NAME_LENGTH, "/mq015_%d", LosCurTaskIDGet());
|
||||
|
||||
attr.mq_maxmsg = MQUEUE_SHORT_ARRAY_LENGTH;
|
||||
attr.mq_msgsize = 5; // 5, queue message size.
|
||||
mqueue = mq_open(mqname, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||
|
||||
ret = mq_getattr(mqueue, &attrget);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
ICUNIT_GOTO_EQUAL(attrget.mq_curmsgs, 0, attrget.mq_curmsgs, EXIT1);
|
||||
ICUNIT_GOTO_EQUAL(attrget.mq_flags, O_CREAT | O_RDWR | O_NONBLOCK, attrget.mq_flags, EXIT1);
|
||||
ICUNIT_GOTO_EQUAL(attrget.mq_maxmsg, attr.mq_maxmsg, attrget.mq_maxmsg, EXIT1);
|
||||
ICUNIT_GOTO_EQUAL(attrget.mq_msgsize, attr.mq_msgsize, attrget.mq_msgsize, EXIT1);
|
||||
|
||||
if (!(attrget.mq_flags & O_NONBLOCK)) {
|
||||
goto EXIT1;
|
||||
}
|
||||
|
||||
ret = mq_close(mqueue);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
|
||||
return MQUEUE_NO_ERROR;
|
||||
EXIT1:
|
||||
mq_close(mqueue);
|
||||
EXIT:
|
||||
mq_unlink(mqname);
|
||||
return MQUEUE_NO_ERROR;
|
||||
}
|
||||
|
||||
VOID ItPosixQueue015(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_QUEUE_015", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
mqd_t mqueue1, mqueue2;
|
||||
|
||||
snprintf(mqname, MQUEUE_STANDARD_NAME_LENGTH, "/mq016_%d", LosCurTaskIDGet());
|
||||
|
||||
mqueue1 = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue1, (mqd_t)-1, mqueue1, EXIT1);
|
||||
|
||||
mqueue2 = mq_open(mqname, O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_EQUAL(mqueue2, (mqd_t)-1, mqueue2, EXIT2);
|
||||
|
||||
ret = mq_close(mqueue1);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
|
||||
return MQUEUE_NO_ERROR;
|
||||
EXIT2:
|
||||
mq_close(mqueue2);
|
||||
EXIT1:
|
||||
mq_close(mqueue1);
|
||||
EXIT:
|
||||
mq_unlink(mqname);
|
||||
return MQUEUE_NO_ERROR;
|
||||
}
|
||||
|
||||
VOID ItPosixQueue016(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_QUEUE_016", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||
mqd_t mqueue;
|
||||
|
||||
snprintf(mqname, MQUEUE_STANDARD_NAME_LENGTH, "/mq018_%d", LosCurTaskIDGet());
|
||||
|
||||
mqueue = mq_open(mqname, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||
|
||||
ret = mq_send(mqueue, msgptr, strlen(msgptr), 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_close(mqueue);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
|
||||
return MQUEUE_NO_ERROR;
|
||||
EXIT1:
|
||||
mq_close(mqueue);
|
||||
EXIT:
|
||||
mq_unlink(mqname);
|
||||
return MQUEUE_NO_ERROR;
|
||||
}
|
||||
|
||||
VOID ItPosixQueue018(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_QUEUE_018", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||
mqd_t mqueue1, mqueue2;
|
||||
struct mq_attr attr = { 0 };
|
||||
|
||||
snprintf(mqname, MQUEUE_STANDARD_NAME_LENGTH, "/mq019_%d", LosCurTaskIDGet());
|
||||
|
||||
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||
attr.mq_maxmsg = MQUEUE_STANDARD_NAME_LENGTH;
|
||||
|
||||
mqueue1 = mq_open(mqname, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue1, (mqd_t)-1, mqueue1, EXIT1);
|
||||
|
||||
ret = mq_receive(mqueue1, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_IS_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_send(mqueue1, msgptr, strlen(msgptr), 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
mqueue2 = mq_open(mqname, O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue1, (mqd_t)-1, mqueue1, EXIT2);
|
||||
|
||||
ret = mq_receive(mqueue1, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, strlen(msgptr), ret, EXIT2);
|
||||
|
||||
ret = mq_close(mqueue1);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT2);
|
||||
|
||||
ret = mq_close(mqueue2);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
|
||||
return MQUEUE_NO_ERROR;
|
||||
|
||||
EXIT2:
|
||||
mq_close(mqueue2);
|
||||
EXIT1:
|
||||
mq_close(mqueue1);
|
||||
EXIT:
|
||||
mq_unlink(mqname);
|
||||
return MQUEUE_NO_ERROR;
|
||||
}
|
||||
|
||||
VOID ItPosixQueue019(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_QUEUE_019", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
mqd_t mqueue;
|
||||
struct sigevent ev;
|
||||
struct sigaction act;
|
||||
|
||||
snprintf(mqname, MQUEUE_STANDARD_NAME_LENGTH, "/mq020_%d", LosCurTaskIDGet());
|
||||
|
||||
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||
|
||||
ret = mq_close(mqueue);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
|
||||
return MQUEUE_NO_ERROR;
|
||||
EXIT1:
|
||||
mq_close(mqueue);
|
||||
EXIT:
|
||||
mq_unlink(mqname);
|
||||
return MQUEUE_NO_ERROR;
|
||||
}
|
||||
|
||||
VOID ItPosixQueue020(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_QUEUE_020", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
mqd_t mqueue;
|
||||
|
||||
snprintf(mqname, MQUEUE_STANDARD_NAME_LENGTH, "/mq021_%d", LosCurTaskIDGet());
|
||||
|
||||
mqueue = mq_open(mqname, O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT);
|
||||
|
||||
return MQUEUE_NO_ERROR;
|
||||
|
||||
EXIT:
|
||||
mq_close(mqueue);
|
||||
mq_unlink(mqname);
|
||||
return MQUEUE_NO_ERROR;
|
||||
}
|
||||
|
||||
VOID ItPosixQueue021(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_QUEUE_021", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
CHAR mqname[MQUEUE_NAME_MAX_TEST * 2];
|
||||
mqd_t mqueue;
|
||||
INT32 i;
|
||||
|
||||
snprintf(mqname, MQUEUE_NAME_MAX_TEST * 2, "/mq025_%d", LosCurTaskIDGet()); // 2, mqname length.
|
||||
|
||||
for (i = 0; i < MQUEUE_NAME_MAX_TEST; i++)
|
||||
strcat(mqname, "0");
|
||||
|
||||
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT);
|
||||
ICUNIT_ASSERT_EQUAL(errno, ENAMETOOLONG, errno);
|
||||
|
||||
return MQUEUE_NO_ERROR;
|
||||
EXIT:
|
||||
mq_close(mqueue);
|
||||
mq_unlink(mqname);
|
||||
return MQUEUE_NO_ERROR;
|
||||
}
|
||||
|
||||
VOID ItPosixQueue025(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_QUEUE_025", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
CHAR qname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
mqd_t queue;
|
||||
|
||||
snprintf(qname, MQUEUE_STANDARD_NAME_LENGTH, "/mq026-1_%d", LosCurTaskIDGet());
|
||||
|
||||
queue = mq_open(qname, O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_EQUAL(queue, (mqd_t)-1, queue, EXIT);
|
||||
ICUNIT_ASSERT_EQUAL(errno, ENOENT, errno);
|
||||
|
||||
return MQUEUE_NO_ERROR;
|
||||
EXIT:
|
||||
mq_close(queue);
|
||||
mq_unlink(qname);
|
||||
return MQUEUE_NO_ERROR;
|
||||
}
|
||||
|
||||
VOID ItPosixQueue026(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_QUEUE_026", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
CHAR qname[50];
|
||||
INT32 ret;
|
||||
mqd_t queue;
|
||||
|
||||
snprintf(qname, MQUEUE_STANDARD_NAME_LENGTH, "/mq027-1_%d", LosCurTaskIDGet());
|
||||
|
||||
queue = mq_open(qname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
if (queue == (mqd_t)-1) {
|
||||
ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue);
|
||||
}
|
||||
|
||||
ret = mq_close(queue);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
|
||||
ret = mq_unlink(qname);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
|
||||
return MQUEUE_NO_ERROR;
|
||||
EXIT:
|
||||
mq_close(queue);
|
||||
mq_unlink(qname);
|
||||
return MQUEUE_NO_ERROR;
|
||||
}
|
||||
|
||||
VOID ItPosixQueue027(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_QUEUE_027", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
ret = mq_close((mqd_t)-1);
|
||||
ICUNIT_GOTO_NOT_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(errno, EBADF, errno);
|
||||
|
||||
return MQUEUE_NO_ERROR;
|
||||
EXIT:
|
||||
mq_close((mqd_t)-1);
|
||||
return MQUEUE_NO_ERROR;
|
||||
}
|
||||
|
||||
VOID ItPosixQueue030(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_QUEUE_030", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret = 0;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||
struct timespec ts;
|
||||
mqd_t mqueue;
|
||||
struct mq_attr attr = { 0 };
|
||||
|
||||
snprintf(mqname, MQUEUE_STANDARD_NAME_LENGTH, "/mq031_%d", LosCurTaskIDGet());
|
||||
|
||||
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||
attr.mq_maxmsg = MQUEUE_SHORT_ARRAY_LENGTH;
|
||||
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||
|
||||
ts.tv_sec = 1;
|
||||
ts.tv_nsec = 0;
|
||||
ret = mq_timedsend(mqueue, msgptr, strlen(msgptr), 0, &ts);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_receive(mqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_SHORT_ARRAY_LENGTH, ret, EXIT1);
|
||||
|
||||
ret = strncmp(msgptr, msgrcd, strlen(msgptr));
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_close(mqueue);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
|
||||
return MQUEUE_NO_ERROR;
|
||||
EXIT1:
|
||||
mq_close(mqueue);
|
||||
EXIT:
|
||||
mq_unlink(mqname);
|
||||
return MQUEUE_NO_ERROR;
|
||||
}
|
||||
|
||||
VOID ItPosixQueue031(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_QUEUE_031", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
mqd_t mqueue;
|
||||
struct sigevent se;
|
||||
|
||||
snprintf(mqname, MQUEUE_STANDARD_NAME_LENGTH, "/mq032_%d", LosCurTaskIDGet());
|
||||
|
||||
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||
|
||||
ret = mq_close(mqueue);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
|
||||
return MQUEUE_NO_ERROR;
|
||||
EXIT1:
|
||||
mq_close(mqueue);
|
||||
EXIT:
|
||||
mq_unlink(mqname);
|
||||
return MQUEUE_NO_ERROR;
|
||||
}
|
||||
|
||||
VOID ItPosixQueue032(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_QUEUE_032", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||
mqd_t mqueue;
|
||||
struct mq_attr attr = { 0 };
|
||||
|
||||
snprintf(mqname, MQUEUE_STANDARD_NAME_LENGTH, "/mq033_%d", LosCurTaskIDGet());
|
||||
|
||||
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||
attr.mq_maxmsg = MQUEUE_SHORT_ARRAY_LENGTH;
|
||||
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||
|
||||
ret = mq_send(mqueue, msgptr, strlen(msgptr), 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_receive(mqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_SHORT_ARRAY_LENGTH, ret, EXIT1);
|
||||
|
||||
ret = strncmp(msgptr, msgrcd, strlen(msgptr));
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_close(mqueue);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
|
||||
return MQUEUE_NO_ERROR;
|
||||
EXIT1:
|
||||
mq_close(mqueue);
|
||||
EXIT:
|
||||
mq_unlink(mqname);
|
||||
return MQUEUE_NO_ERROR;
|
||||
}
|
||||
|
||||
VOID ItPosixQueue033(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_QUEUE_033", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret = 0;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||
struct timespec ts;
|
||||
mqd_t mqueue;
|
||||
|
||||
snprintf(mqname, MQUEUE_STANDARD_NAME_LENGTH, "/mq036_%d", LosCurTaskIDGet());
|
||||
|
||||
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||
|
||||
ts.tv_sec = 1;
|
||||
ts.tv_nsec = 0;
|
||||
ret = mq_timedsend(mqueue, msgptr, strlen(msgptr), MQ_PRIO_MAX + 1, &ts);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_IS_ERROR, ret, EXIT1);
|
||||
ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT1);
|
||||
|
||||
ret = mq_close(mqueue);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
|
||||
return MQUEUE_NO_ERROR;
|
||||
EXIT1:
|
||||
mq_close(mqueue);
|
||||
EXIT:
|
||||
mq_unlink(mqname);
|
||||
return MQUEUE_NO_ERROR;
|
||||
}
|
||||
|
||||
VOID ItPosixQueue036(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_QUEUE_036", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||
mqd_t mqueue;
|
||||
|
||||
snprintf(mqname, MQUEUE_STANDARD_NAME_LENGTH, "/mq038_%d", LosCurTaskIDGet());
|
||||
|
||||
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||
|
||||
ret = mq_send(mqueue, msgptr, strlen(msgptr), MQ_PRIO_MAX);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_IS_ERROR, ret, EXIT1);
|
||||
ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT1);
|
||||
|
||||
ret = mq_close(mqueue);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
|
||||
return MQUEUE_NO_ERROR;
|
||||
EXIT1:
|
||||
mq_close(mqueue);
|
||||
EXIT:
|
||||
mq_unlink(mqname);
|
||||
return MQUEUE_NO_ERROR;
|
||||
}
|
||||
|
||||
VOID ItPosixQueue038(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_QUEUE_038", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
static VOID *PthreadF01(VOID *argument)
|
||||
{
|
||||
INT32 i;
|
||||
INT32 ret;
|
||||
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||
|
||||
g_testCount = 1;
|
||||
|
||||
g_mqueueTaskPID = LosCurTaskIDGet();
|
||||
|
||||
for (i = 0; i < 5 + 1; i++) { // 5, The loop frequency.
|
||||
ret = mq_send(g_gqueue, msgptr, strlen(msgptr), 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
}
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert the g_testCount.
|
||||
|
||||
g_testCount = 2; // 2, Init test count value.
|
||||
|
||||
return NULL;
|
||||
EXIT:
|
||||
g_testCount = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static VOID *PthreadF02(VOID *argument)
|
||||
{
|
||||
INT32 j, ret;
|
||||
|
||||
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
|
||||
g_testCount = 3; // 3, Init test count value.
|
||||
|
||||
ret = mq_receive(g_gqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, strlen(MQUEUE_SEND_STRING_TEST), ret, EXIT);
|
||||
|
||||
ret = mq_close(g_gqueue);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
|
||||
ret = mq_unlink(g_gqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
|
||||
g_testCount = 4; // 4, Init test count value.
|
||||
|
||||
return NULL;
|
||||
EXIT:
|
||||
g_testCount = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_t newTh1, newTh2;
|
||||
UINT32 ret;
|
||||
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||
struct mq_attr attr = { 0 };
|
||||
pthread_attr_t attr1;
|
||||
|
||||
snprintf(g_gqname, MQUEUE_STANDARD_NAME_LENGTH, "/mq040_%d", getpid());
|
||||
|
||||
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||
attr.mq_maxmsg = 5; // 5, queue max message size.
|
||||
|
||||
g_testCount = 0;
|
||||
|
||||
g_gqueue = mq_open(g_gqname, O_CREAT | O_RDWR | O_EXCL, S_IRUSR | S_IWUSR, &attr);
|
||||
ICUNIT_GOTO_NOT_EQUAL(g_gqueue, (mqd_t)-1, g_gqueue, EXIT);
|
||||
|
||||
ret = PosixPthreadInit(&attr1, MQUEUE_PTHREAD_PRIORITY_TEST1);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = pthread_create(&newTh1, &attr1, PthreadF01, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
|
||||
LosTaskDelay(5); // 5, Set delay time.
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT1);
|
||||
|
||||
ret = PosixPthreadInit(&attr1, MQUEUE_PTHREAD_PRIORITY_TEST2);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT2);
|
||||
|
||||
ret = pthread_create(&newTh2, &attr1, PthreadF02, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT2);
|
||||
|
||||
ret = LosTaskDelay(5); // 5, Set delay time.
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT2);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT2); // 4, Here, assert the g_testCount.
|
||||
|
||||
ret = PosixPthreadDestroy(&attr1, newTh2);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT2);
|
||||
|
||||
ret = PosixPthreadDestroy(&attr1, newTh1);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
return MQUEUE_NO_ERROR;
|
||||
|
||||
EXIT2:
|
||||
PosixPthreadDestroy(&attr1, newTh2);
|
||||
EXIT1:
|
||||
PosixPthreadDestroy(&attr1, newTh1);
|
||||
EXIT:
|
||||
mq_close(g_gqueue);
|
||||
mq_unlink(g_gqname);
|
||||
return MQUEUE_NO_ERROR;
|
||||
}
|
||||
|
||||
VOID ItPosixQueue040(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_QUEUE_040", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
static VOID *PthreadF01(VOID *argument)
|
||||
{
|
||||
INT32 i;
|
||||
struct timespec ts;
|
||||
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||
UINT32 ret;
|
||||
|
||||
ts.tv_sec = 0xffff;
|
||||
ts.tv_nsec = 0;
|
||||
|
||||
g_testCount = 1;
|
||||
|
||||
for (i = 0; i < 5 + 1; i++) { // 5, The loop frequency.
|
||||
ret = mq_timedsend(g_gqueue, msgptr, strlen(msgptr), 0, &ts);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
}
|
||||
ICUNIT_ASSERT_EQUAL_NULL(g_testCount, 3, g_testCount); // 3, Here, assert the g_testCount.
|
||||
|
||||
g_testCount = 2; // 2, Init test count value.
|
||||
|
||||
return NULL;
|
||||
EXIT:
|
||||
g_testCount = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static VOID *PthreadF02(VOID *argument)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
|
||||
g_testCount = 3; // 3, Init test count value.
|
||||
|
||||
ret = mq_receive(g_gqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, strlen(MQUEUE_SEND_STRING_TEST), ret, EXIT1);
|
||||
|
||||
TestExtraTaskDelay(2); // 2, Set delay time.
|
||||
ret = mq_close(g_gqueue);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(g_gqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
|
||||
g_testCount = 4; // 4, Init test count value.
|
||||
|
||||
return NULL;
|
||||
EXIT1:
|
||||
mq_close(g_gqueue);
|
||||
EXIT:
|
||||
mq_unlink(g_gqname);
|
||||
g_testCount = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
struct mq_attr attr = { 0 };
|
||||
pthread_attr_t attr1;
|
||||
pthread_t newTh1, newTh2;
|
||||
|
||||
snprintf(g_gqname, MQUEUE_STANDARD_NAME_LENGTH, "/mq041_%d", LosCurTaskIDGet());
|
||||
|
||||
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||
attr.mq_maxmsg = 5; // 5, queue max message size.
|
||||
g_gqueue = mq_open(g_gqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||
ICUNIT_GOTO_NOT_EQUAL(g_gqueue, (mqd_t)-1, g_gqueue, EXIT);
|
||||
|
||||
g_testCount = 0;
|
||||
|
||||
ret = PosixPthreadInit(&attr1, MQUEUE_PTHREAD_PRIORITY_TEST1);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = pthread_create(&newTh1, &attr1, PthreadF01, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
LosTaskDelay(5); // 5, Set delay time.
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT1);
|
||||
|
||||
ret = PosixPthreadInit(&attr1, MQUEUE_PTHREAD_PRIORITY_TEST2);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT2);
|
||||
|
||||
ret = pthread_create(&newTh2, &attr1, PthreadF02, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT2);
|
||||
|
||||
ret = LosTaskDelay(5); // 5, Set delay time.
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT2);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT2); // 4, Here, assert the g_testCount.
|
||||
|
||||
ret = PosixPthreadDestroy(&attr1, newTh2);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT2);
|
||||
|
||||
ret = PosixPthreadDestroy(&attr1, newTh1);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
return MQUEUE_NO_ERROR;
|
||||
|
||||
EXIT2:
|
||||
PosixPthreadDestroy(&attr1, newTh2);
|
||||
EXIT1:
|
||||
PosixPthreadDestroy(&attr1, newTh1);
|
||||
EXIT:
|
||||
mq_close(g_gqueue);
|
||||
mq_unlink(g_gqname);
|
||||
return MQUEUE_NO_ERROR;
|
||||
}
|
||||
|
||||
VOID ItPosixQueue041(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_QUEUE_041", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret, i = 0;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
CHAR msgptr[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
mqd_t mqueue;
|
||||
struct mq_attr attr = { 0 };
|
||||
|
||||
snprintf(mqname, MQUEUE_STANDARD_NAME_LENGTH, "/mq042_%d", LosCurTaskIDGet());
|
||||
|
||||
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||
attr.mq_maxmsg = MQUEUE_SHORT_ARRAY_LENGTH;
|
||||
|
||||
mqueue = mq_open(mqname, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||
|
||||
while (1) {
|
||||
snprintf(msgptr, MQUEUE_STANDARD_NAME_LENGTH, "message %d", i);
|
||||
ret = mq_send(mqueue, msgptr, strlen(msgptr), 0);
|
||||
if (ret == -1) {
|
||||
ICUNIT_GOTO_EQUAL(errno, EAGAIN, errno, EXIT1);
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
ICUNIT_GOTO_EQUAL(i, MQUEUE_SHORT_ARRAY_LENGTH, i, EXIT1);
|
||||
|
||||
i = 0;
|
||||
snprintf(msgptr, MQUEUE_STANDARD_NAME_LENGTH, "message %d", i);
|
||||
ret = mq_receive(mqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, strlen(msgptr), ret, EXIT1);
|
||||
|
||||
ret = strcmp(msgptr, msgrcd);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_close(mqueue);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
|
||||
return MQUEUE_NO_ERROR;
|
||||
EXIT1:
|
||||
mq_close(mqueue);
|
||||
EXIT:
|
||||
mq_unlink(mqname);
|
||||
return MQUEUE_NO_ERROR;
|
||||
}
|
||||
|
||||
VOID ItPosixQueue042(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_QUEUE_042", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||
mqd_t mqueue;
|
||||
struct mq_attr attr = { 0 };
|
||||
|
||||
snprintf(mqname, MQUEUE_STANDARD_NAME_LENGTH, "/mq043_%d", LosCurTaskIDGet());
|
||||
|
||||
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||
attr.mq_maxmsg = MQUEUE_SHORT_ARRAY_LENGTH;
|
||||
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue);
|
||||
|
||||
ret = mq_send(mqueue, msgptr, strlen(msgptr), MQ_PRIO_MAX - 1);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_receive(mqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, strlen(msgptr), ret, EXIT1);
|
||||
ICUNIT_GOTO_STRING_EQUAL(msgrcd, msgptr, msgrcd, EXIT1);
|
||||
|
||||
ret = strncmp(msgptr, msgrcd, strlen(msgptr));
|
||||
ICUNIT_GOTO_NOT_EQUAL(ret, MQUEUE_IS_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_close(mqueue);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
|
||||
return MQUEUE_NO_ERROR;
|
||||
EXIT1:
|
||||
mq_close(mqueue);
|
||||
EXIT:
|
||||
mq_unlink(mqname);
|
||||
return MQUEUE_NO_ERROR;
|
||||
}
|
||||
|
||||
/* *
|
||||
*-@test IT_POSIX_MQUEUE_043
|
||||
*-@tspec The API test for mq_send
|
||||
*-@ttitle Mq_send writes the mqueue while the priority is MQ_PRIO_MAX - 1
|
||||
*-@tprecon The mqueue module is open
|
||||
*-@tbrief
|
||||
1. use the mq_open to create a legal mqueue;
|
||||
2. use the mq_send to write the mqueue while the priority is MQ_PRIO_MAX - 1;
|
||||
3. use the mq_receive to read the mqueue;
|
||||
4. use the mq_close to close the mqueue;
|
||||
5. use the mq_unlink to delete the mqueue.
|
||||
*-@texpect
|
||||
1. Return successed
|
||||
2. Return successed
|
||||
3. Return successed
|
||||
4. Return successed
|
||||
5. Sucessful operation
|
||||
*-@tprior 1
|
||||
*-@tauto TRUE
|
||||
*-@tremark
|
||||
*/
|
||||
VOID ItPosixQueue043(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_QUEUE_043", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret = 0;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||
mqd_t mqueue;
|
||||
struct mq_attr attr = { 0 };
|
||||
|
||||
snprintf(mqname, MQUEUE_STANDARD_NAME_LENGTH, "/mq044_%d", LosCurTaskIDGet());
|
||||
|
||||
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||
attr.mq_maxmsg = MQUEUE_SHORT_ARRAY_LENGTH;
|
||||
mqueue = mq_open(mqname, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||
|
||||
ret = mq_send((mqd_t)(&mqueue + 1), msgptr, strlen(msgptr), 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_IS_ERROR, ret, EXIT1);
|
||||
ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT1);
|
||||
|
||||
ret = mq_receive(mqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_IS_ERROR, ret, EXIT1);
|
||||
ICUNIT_GOTO_EQUAL(errno, EAGAIN, errno, EXIT1);
|
||||
|
||||
ret = strcmp(msgptr, msgrcd);
|
||||
ICUNIT_GOTO_NOT_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_close(mqueue);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
|
||||
|
||||
return MQUEUE_NO_ERROR;
|
||||
EXIT1:
|
||||
mq_close(mqueue);
|
||||
EXIT:
|
||||
mq_unlink(mqname);
|
||||
return MQUEUE_NO_ERROR;
|
||||
}
|
||||
|
||||
VOID ItPosixQueue044(VOID) // IT_Layer_ModuleORFeature_No
|
||||
{
|
||||
TEST_ADD_CASE("IT_POSIX_QUEUE_044", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user