提交 56679556 编写于 作者: G ganlan

fix codex about libctest

Signed-off-by: Nganlan <tony.gan@huawei.com>
上级 8086f6b7
......@@ -29,89 +29,105 @@
#define ERREXPECT (-1)
#define ONREXPECT 1
#define EXPECT_TRUE(fun, c) do { \
if (!(c)) \
t_error("[%s] failed\n", fun); \
} while (0)
#define EXPECT_FALSE(fun, c) do { \
if ((c)) \
t_error("[%s] failed \n", fun); \
} while (0)
#define EXPECT_EQ(fun, a, b) do { \
if ((a) != (b)) \
t_error("[%s] failed %d != %d \n", fun, a, b); \
} while (0)
#define EXPECT_LT(fun, a, b) do { \
if ((a) >= (b)) \
t_error("[%s] failed (errno: %s) %d >= %d \n", #fun, strerror(errno), a, b); \
} while(0)
#define EXPECT_MT(fun, a, b) do { \
if ((a) <= (b)) \
t_error("[%s] failed (errno: %s) %d >= %d \n", #fun, strerror(errno), a, b); \
} while(0)
#define EXPECT_NE(fun, a, b) do { \
if ((int)(a) == (int)(b)) \
t_error("[%s] failed %d == %d \n", fun, (a), (b)); \
} while (0)
#define EXPECT_TRUE(fun, c) \
do { \
if (!(c)) \
t_error("[%s] failed\n", fun); \
} while (0)
#define EXPECT_FALSE(fun, c) \
do { \
if ((c)) \
t_error("[%s] failed \n", fun); \
} while (0)
#define EXPECT_EQ(fun, a, b) \
do { \
if ((a) != (b)) \
t_error("[%s] failed %d != %d \n", fun, a, b); \
} while (0)
#define EXPECT_LT(fun, a, b) \
do { \
if ((a) >= (b)) \
t_error("[%s] failed (errno: %s) %d >= %d \n", #fun, strerror(errno), a, b); \
} while (0)
#define EXPECT_MT(fun, a, b) \
do { \
if ((a) <= (b)) \
t_error("[%s] failed (errno: %s) %d >= %d \n", #fun, strerror(errno), a, b); \
} while (0)
#define EXPECT_NE(fun, a, b) \
do { \
if ((int)(a) == (int)(b)) \
t_error("[%s] failed %d == %d \n", fun, (a), (b)); \
} while (0)
/* char*, char[] comparison */
#define EXPECT_STREQ(fun, a, b) do { \
if (strlen(a) != strlen(b) || strcmp((a), (b)) != 0) \
t_error("[%s] failed %s != %s \n", fun, (a), (b)); \
} while (0)
#define EXPECT_STRLT(fun, a, b) do { \
if ((a) >= (b)) \
t_error("[%s] failed (errno: %s) %d >= %d \n", #fun, strerror(errno), a, b); \
} while(0)
#define EXPECT_STRMT(fun, a, b) do { \
if ((a) <= (b)) \
t_error("[%s] failed (errno: %s) %d >= %d \n", #fun, strerror(errno), a, b); \
} while(0)
#define EXPECT_STREQ(fun, a, b) \
do { \
if (strlen(a) != strlen(b) || strcmp((a), (b)) != 0) \
t_error("[%s] failed %s != %s \n", fun, (a), (b)); \
} while (0)
#define EXPECT_STRLT(fun, a, b) \
do { \
if ((a) >= (b)) \
t_error("[%s] failed (errno: %s) %d >= %d \n", #fun, strerror(errno), a, b); \
} while (0)
#define EXPECT_STRMT(fun, a, b) \
do { \
if ((a) <= (b)) \
t_error("[%s] failed (errno: %s) %d >= %d \n", #fun, strerror(errno), a, b); \
} while (0)
/* floating point comparison */
#define FLOAT_EQUAL(fun, a, b) do { \
if (!(fabs((a) - (b)) <= EPS)) \
t_error("[%s] failed %fd != %fd \n", fun, (a), (b)); \
} while (0)
#define EXPECT_PTREQ(fun, a, b) do { \
if ((a) != (b)) { \
t_error("[%s] failed %p != %p \n", fun, a, b); \
} \
} while (0)
#define EXPECT_PTRNE(fun, a, b) do { \
if ((a) == (b)) { \
t_error("[%s] failed %p == %p \n", fun, a, b); \
} \
} while (0)
#define EXPECT_STRNE(fun, a, b) do { \
if (strcmp((a), (b)) == 0) \
t_error("[%s] failed %s == %s \n", fun, (a), (b)); \
} while(0)
#define EXPECT_LONGEQ(fun, a, b) do { \
if ((long)(a) != (long)(b)) \
t_error("[%s] failed %ld != %ld \n", fun, a, b); \
} while(0)
#define EXPECT_LONGLONGEQ(fun, a, b) do { \
if ((long)(a) != (long)(b)) \
t_error("[%s] failed %lld != %lld \n", fun, a, b); \
} while(0)
#define EXPECT_GT(fun, a, b) do { \
if ((a) <= (b)) { \
t_error("[%s] failed %d > %d \n", fun, a, b); \
} \
} while(0)
#define FLOAT_EQUAL(fun, a, b) \
do { \
if (!(fabs((a) - (b)) <= EPS)) \
t_error("[%s] failed %fd != %fd \n", fun, (a), (b)); \
} while (0)
#define EXPECT_PTREQ(fun, a, b) \
do { \
if ((a) != (b)) { \
t_error("[%s] failed %p != %p \n", fun, a, b); \
} \
} while (0)
#define EXPECT_PTRNE(fun, a, b) \
do { \
if ((a) == (b)) { \
t_error("[%s] failed %p == %p \n", fun, a, b); \
} \
} while (0)
#define EXPECT_STRNE(fun, a, b) \
do { \
if (strcmp((a), (b)) == 0) \
t_error("[%s] failed %s == %s \n", fun, (a), (b)); \
} while (0)
#define EXPECT_LONGEQ(fun, a, b) \
do { \
if ((long)(a) != (long)(b)) \
t_error("[%s] failed %ld != %ld \n", fun, a, b); \
} while (0)
#define EXPECT_LONGLONGEQ(fun, a, b) \
do { \
if ((long)(a) != (long)(b)) \
t_error("[%s] failed %lld != %lld \n", fun, a, b); \
} while (0)
#define EXPECT_GT(fun, a, b) \
do { \
if ((a) <= (b)) { \
t_error("[%s] failed %d > %d \n", fun, a, b); \
} \
} while (0)
#endif
\ No newline at end of file
......@@ -84,7 +84,7 @@ void fpathconf_0500(void)
EXPECT_EQ("fpathconf_0500", result, -1);
}
int main()
int main(int argc, char *argv[])
{
fpathconf_0100();
fpathconf_0200();
......
......@@ -13,41 +13,24 @@
* limitations under the License.
*/
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <sys/sysinfo.h>
#include "functionalext.h"
typedef void (*TEST_FUN)();
#include "test.h"
/**
* @tc.name : get_nprocs_0100
* @tc.name : get_avphys_page_0100
* @tc.desc : Verify the total number of pages available for acquisition
* @tc.level : Level 0
*/
void get_nprocs_0100(void)
void get_avphys_page_0100(void)
{
int result;
result = get_avphys_pages();
bool flag = false;
if (result > 0) {
flag = true;
long avail_phys_pages = get_avphys_pages();
if (avail_phys_pages <= 0) {
t_error("%s get_avphys_pages failed\n", __func__);
}
EXPECT_TRUE("fpathconf_0100", true);
}
TEST_FUN G_Fun_Array[] = {
get_nprocs_0100,
};
int main()
int main(int argc, char *argv[])
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
G_Fun_Array[pos]();
}
get_avphys_page_0100();
return t_status;
}
\ No newline at end of file
......@@ -13,15 +13,8 @@
* limitations under the License.
*/
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <sys/sysinfo.h>
#include "functionalext.h"
typedef void (*TEST_FUN)();
#include "test.h"
/**
* @tc.name : get_nprocs_0100
......@@ -30,24 +23,17 @@ typedef void (*TEST_FUN)();
*/
void get_nprocs_0100(void)
{
int result;
result = get_nprocs();
bool flag = false;
if (result > 0) {
flag = true;
int nprocs = get_nprocs();
if (nprocs <= 0) {
t_error("%s get_nprocs failed\n", __func__);
}
if (sysconf(_SC_NPROCESSORS_ONLN) != nprocs) {
t_error("%s get_nprocs invalid\n", __func__);
}
EXPECT_TRUE("fpathconf_0100", true);
}
TEST_FUN G_Fun_Array[] = {
get_nprocs_0100,
};
int main()
int main(int argc, char *argv[])
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
G_Fun_Array[pos]();
}
get_nprocs_0100();
return t_status;
}
\ No newline at end of file
......@@ -13,41 +13,29 @@
* limitations under the License.
*/
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <sys/sysinfo.h>
#include "functionalext.h"
typedef void (*TEST_FUN)();
#include "test.h"
/**
* @tc.name : fpathconf_0100
* @tc.name : get_nprocs_conf_0100
* @tc.desc : Verify the number of CPUs obtained
* @tc.level : Level 0
*/
void get_nprocs_0100(void)
void get_nprocs_conf_0100(void)
{
int result;
result = get_nprocs_conf();
bool flag = false;
if (result > 0) {
flag = true;
int nprocs = get_nprocs();
int nprocs_conf = get_nprocs_conf();
if (nprocs_conf < nprocs) {
t_error("%s nprocs_conf should be greater than nprocs", __func__);
}
if (sysconf(_SC_NPROCESSORS_CONF) != nprocs_conf) {
t_error("%s get_nprocs_conf failed\n", __func__);
}
EXPECT_TRUE("fpathconf_0100", true);
}
TEST_FUN G_Fun_Array[] = {
get_nprocs_0100,
};
int main()
int main(int argc, char *argv[])
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
G_Fun_Array[pos]();
}
get_nprocs_conf_0100();
return t_status;
}
\ No newline at end of file
......@@ -13,41 +13,24 @@
* limitations under the License.
*/
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <sys/sysinfo.h>
#include "functionalext.h"
typedef void (*TEST_FUN)();
#include "test.h"
/**
* @tc.name : get_nprocs_0100
* @tc.name : get_phys_pages_0100
* @tc.desc : Verify the total number of pages fetched in memory
* @tc.level : Level 0
*/
void get_nprocs_0100(void)
void get_phys_pages_0100(void)
{
int result;
result = get_phys_pages();
bool flag = false;
if (result > 0) {
flag = true;
long phys_pages = get_phys_pages();
if (sysconf(_SC_PHYS_PAGES) != phys_pages) {
t_error("%s get_phys_pages failed\n", __func__);
}
EXPECT_TRUE("fpathconf_0100", true);
}
TEST_FUN G_Fun_Array[] = {
get_nprocs_0100,
};
int main()
int main(int argc, char *argv[])
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
G_Fun_Array[pos]();
}
get_phys_pages_0100();
return t_status;
}
\ No newline at end of file
......@@ -14,7 +14,7 @@
functionalext_supplement_conf_test = [
"sysconf",
"fpathconf",
"get_avphys_page",
"get_avphys_pages",
"get_nprocs",
"get_nprocs_conf",
"get_phys_pages",
......
......@@ -66,7 +66,7 @@ TEST_FUN G_Fun_Array[] = {
__ctype_get_mb_cur_max_0300,
};
int main()
int main(int argc, char *argv[])
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
......
......@@ -14,9 +14,6 @@
*/
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include "functionalext.h"
const int32_t COUNT_ZERO = 0;
......@@ -73,11 +70,9 @@ void isalpha_0400(void)
void isalpha_0500(void)
{
int total = 0;
for (int i = 0; i < 128; i++)
{
for (int i = 0; i < 128; i++) {
int ret = isalpha((char)i);
if (ret)
{
if (ret) {
total++;
}
}
......
......@@ -14,14 +14,8 @@
*/
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "functionalext.h"
const int32_t COUJNT_ZERO = 0;
const int32_t COUJNT_SIX = 6;
/*
* @tc.name : isspace_0100
* @tc.desc : Verify that the input character is a space (the parameter is a space)
......@@ -30,7 +24,7 @@ const int32_t COUJNT_SIX = 6;
void isspace_0100(void)
{
int ret = isspace(' ');
EXPECT_NE("isspace_0100", ret, COUJNT_ZERO);
EXPECT_NE("isspace_0100", ret, 0);
}
/*
......@@ -41,7 +35,7 @@ void isspace_0100(void)
void isspace_0200(void)
{
int ret = isspace('\r');
EXPECT_NE("isspace_0200", ret, COUJNT_ZERO);
EXPECT_NE("isspace_0200", ret, 0);
}
/*
......@@ -52,7 +46,7 @@ void isspace_0200(void)
void isspace_0300(void)
{
int ret = isspace('\n');
EXPECT_NE("isspace_0300", ret, COUJNT_ZERO);
EXPECT_NE("isspace_0300", ret, 0);
}
/*
......@@ -63,7 +57,7 @@ void isspace_0300(void)
void isspace_0400(void)
{
int ret = isspace('\v');
EXPECT_NE("isspace_0400", ret, COUJNT_ZERO);
EXPECT_NE("isspace_0400", ret, 0);
}
/*
......@@ -74,7 +68,7 @@ void isspace_0400(void)
void isspace_0500(void)
{
int ret = isspace('\f');
EXPECT_NE("isspace_0500", ret, COUJNT_ZERO);
EXPECT_NE("isspace_0500", ret, 0);
}
/*
......@@ -85,7 +79,7 @@ void isspace_0500(void)
void isspace_0600(void)
{
int ret = isspace('a');
EXPECT_EQ("isspace_0600", ret, COUJNT_ZERO);
EXPECT_EQ("isspace_0600", ret, 0);
}
/*
......@@ -96,7 +90,7 @@ void isspace_0600(void)
void isspace_0700(void)
{
int ret = isspace('6');
EXPECT_EQ("isspace_0700", ret, COUJNT_ZERO);
EXPECT_EQ("isspace_0700", ret, 0);
}
/*
......@@ -107,7 +101,7 @@ void isspace_0700(void)
void isspace_0800(void)
{
int ret = isspace('#');
EXPECT_EQ("isspace_0800", ret, COUJNT_ZERO);
EXPECT_EQ("isspace_0800", ret, 0);
}
/*
......@@ -124,7 +118,7 @@ void isspace_0900(void)
total++;
}
}
EXPECT_EQ("isspace_0900", total, COUJNT_SIX);
EXPECT_EQ("isspace_0900", total, 6);
}
int main(void)
......
......@@ -107,7 +107,7 @@ void iswalhpa_0400()
EXPECT_EQ("iswalhpa_0400", ret, 0);
}
int main()
int main(int argc, char *argv[])
{
iswalhpa_0100();
iswalhpa_0200();
......
......@@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
......@@ -45,7 +46,7 @@ void alphasort_0200(void)
EXPECT_TRUE("alphasort_0100", total < 0);
}
int main()
int main(int argc, char *argv[])
{
alphasort_0100();
alphasort_0200();
......
......@@ -48,7 +48,7 @@ void closedir_0200(void)
EXPECT_EQ("closedir_0200", ret, -1);
}
int main()
int main(int argc, char *argv[])
{
closedir_0100();
closedir_0200();
......
......@@ -55,7 +55,7 @@ void dirfd_0100(void)
closedir(dir_ptr);
}
int main()
int main(int argc, char *argv[])
{
dirfd_0100();
return t_status;
......
......@@ -84,7 +84,7 @@ void fdopendir_0400(void)
system("rm -rf /data/data/test.txt");
}
int main()
int main(int argc, char *argv[])
{
fdopendir_0100();
fdopendir_0200();
......
......@@ -13,14 +13,12 @@
* limitations under the License.
*/
#include <stdbool.h>
#include <errno.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include "functionalext.h"
#include <string.h>
#include "test.h"
typedef void (*TEST_FUN)();
#define MAXPATH 1000
const char *path = "/data";
/*
* @tc.name : opendir_0100
......@@ -29,57 +27,57 @@ typedef void (*TEST_FUN)();
*/
void opendir_0100(void)
{
bool flag = false;
char path[MAXPATH];
DIR *dir_ptr;
char *data = NULL;
data = getcwd(path, MAXPATH);
dir_ptr = opendir(path);
if (dir_ptr != 0) {
flag = true;
DIR *dir = opendir(path);
if (!dir) {
t_error("%s opendir failed\n", __func__);
}
EXPECT_TRUE("opendir_0100", flag);
struct dirent *r = readdir(dir);
if (strcmp(r->d_name, ".")) {
t_error("%s opendir is not right, d_name is %s\n", __func__, r->d_name);
}
closedir(dir);
}
/*
* @tc.name : opendir_0200
* @tc.desc : The verification parameter is invalid, the specified directory cannot be opened
* (name does not exist)
* @tc.desc : When the path is not a folder or not exit, test the return value of the function
* @tc.level : Level 2
*/
void opendir_0200(void)
{
DIR *dir_ptr;
dir_ptr = opendir("/dev/key");
EXPECT_EQ("opendir_0200", dir_ptr, 0);
DIR *dir1 = opendir("/dev/null");
if (dir1) {
t_error("%s dir should be NULL\n", __func__);
}
errno = 0;
DIR *dir2 = opendir("/does/not/exit/folder");
if (dir2) {
t_error("%s dir should be NULL\n", __func__);
}
if (errno != ENOENT) {
t_error("%s errno should be ENOTDIR, but now is %d\n", __func__, errno);
}
}
/*
* @tc.name : opendir_0300
* @tc.desc : The validation parameter is invalid and the specified directory cannot be opened (name is NULL)
* @tc.desc : When the path is NULL, test the return value of the function
* @tc.level : Level 2
*/
void opendir_0300(void)
{
DIR *dir_ptr;
char *path = NULL;
path = getcwd(NULL, 0);
dir_ptr = opendir(NULL);
EXPECT_EQ("opendir_0300", dir_ptr, 0);
DIR *dir = opendir(NULL);
if (dir) {
t_error("%s dir should be NULL\n", __func__);
}
}
TEST_FUN G_Fun_Array[] = {
opendir_0100,
opendir_0200,
opendir_0300,
};
int main()
int main(int argc, char *argv[])
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
G_Fun_Array[pos]();
}
opendir_0100();
opendir_0200();
opendir_0300();
return t_status;
}
\ No newline at end of file
......@@ -46,7 +46,7 @@ void readdir_0200(void)
EXPECT_TRUE("readdir_0200", NULL == ret);
}
int main()
int main(int argc, char *argv[])
{
readdir_0100();
readdir_0200();
......
......@@ -42,7 +42,7 @@ TEST_FUN G_Fun_Array[] = {
aeabi_atexit_0100,
};
int main()
int main(int argc, char *argv[])
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
......
......@@ -13,12 +13,9 @@
* limitations under the License.
*/
#include <stdio.h>
#include <stdlib.h>
#include "functionalext.h"
const int SUCCESS = 0;
const int FAILED = -1;
void f1()
{}
void f2()
......@@ -26,21 +23,21 @@ void f2()
/**
* @tc.name : at_quick_exit_0100
* @tc.desc : Verify that the function pointed to can be registered
* (the number of registrations is less than 32).
* @tc.desc : Verify that the function pointed to can be registered (the number of registrations
* is less than 32).
* @tc.level : Level 0
*/
void at_quick_exit_0100(void)
{
int result = at_quick_exit(f1);
quick_exit(0);
EXPECT_EQ("at_quick_exit_0100", result, SUCCESS);
EXPECT_EQ("at_quick_exit_0100", result, 0);
}
/**
* @tc.name : at_quick_exit_0200
* @tc.desc : Verify that the pointed function cannot be registered
* (the number of registrations is greater than 32).
* @tc.desc : Verify that the pointed function cannot be registered (the number of registrations
* is greater than 32).
* @tc.level : Level 2
*/
void at_quick_exit_0200(void)
......@@ -51,7 +48,7 @@ void at_quick_exit_0200(void)
}
result = at_quick_exit(f2);
quick_exit(0);
EXPECT_EQ("at_quick_exit_0200", result, FAILED);
EXPECT_EQ("at_quick_exit_0200", result, -1);
}
int main(int argc, char *argv[])
......
......@@ -67,7 +67,7 @@ void creat_0300(void)
ptr = NULL;
}
int main()
int main(int argc, char *argv[])
{
creat_0100();
creat_0200();
......
......@@ -14,15 +14,12 @@
*/
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <signal.h>
#include <unistd.h>
#include "functionalext.h"
typedef void (*TEST_FUN)();
const char *path = "/data/test.txt";
/*
* @tc.name : open_0100
* @tc.desc : Verify file open mode is O_RDONLY
......@@ -30,20 +27,17 @@ typedef void (*TEST_FUN)();
*/
void open_0100(void)
{
int fd, size;
char s[] = "test";
char buffer[80] = {0};
fd = open("/data/test.txt", O_RDONLY + O_CREAT);
if (fd == -1) {
fputs("open r is failed\n", stdout);
}
int fd = open(path, O_RDONLY + O_CREAT);
int len = write(fd, s, sizeof(s));
size = read(fd, buffer, sizeof(buffer));
ssize_t size = read(fd, buffer, sizeof(buffer));
EXPECT_EQ("open_0100", fd, 4);
EXPECT_EQ("open_0100", len, -1);
EXPECT_STREQ("open_0100", buffer, "");
close(fd);
remove("/data/test.txt");
remove(path);
}
/*
......@@ -53,148 +47,124 @@ void open_0100(void)
*/
void open_0200(void)
{
int fd;
fd = open("/data/test.txt", O_RDONLY);
int fd = open(path, O_RDONLY);
EXPECT_EQ("open_0200", fd, -1);
close(fd);
}
/*
* @tc.name : open_0300
* @tc.desc : VVerify file open mode is O_WRONLY
* @tc.desc : Verify file open mode is O_WRONLY
* @tc.level : Level 0
*/
void open_0300(void)
{
int fd, size;
char s[] = "test";
char buffer[80] = {0};
fd = open("/data/test.txt", O_WRONLY + O_CREAT);
if (fd == -1) {
fputs("open r is failed\n", stdout);
}
size = read(fd, buffer, sizeof(buffer));
int fd = open(path, O_WRONLY + O_CREAT);
ssize_t size = read(fd, buffer, sizeof(buffer));
EXPECT_EQ("open_0300", fd, 4);
EXPECT_STREQ("open_0300", buffer, "");
int len = write(fd, s, sizeof(s));
EXPECT_EQ("open_0300", len, 5);
close(fd);
remove("/data/test.txt");
remove(path);
}
/*
* @tc.name : open_0400
* @tc.desc : VVerify file open mode is O_WRONLY(file does not exist)
* @tc.desc : Verify file open mode is O_WRONLY(file does not exist)
* @tc.level : Level 2
*/
void open_0400(void)
{
int fd;
fd = open("/data/test.txt", O_WRONLY);
int fd = open(path, O_WRONLY);
EXPECT_EQ("open_0400", fd, -1);
close(fd);
}
/*
* @tc.name : open_0500
* @tc.desc : VVerify file open mode is O_RDWR | O_APPEND
* @tc.desc : Verify file open mode is O_RDWR | O_APPEND
* @tc.level : Level 0
*/
void open_0500(void)
{
int fd, size;
char s[] = "test";
char buffer[80] = {0};
fd = open("/data/test.txt", O_RDWR | O_APPEND + O_CREAT);
if (fd == -1) {
fputs("open r is failed\n", stdout);
}
size = read(fd, buffer, sizeof(buffer));
int fd = open(path, O_RDWR | O_APPEND + O_CREAT);
ssize_t size = read(fd, buffer, sizeof(buffer));
EXPECT_EQ("open_0500", fd, 4);
EXPECT_STREQ("open_0500", buffer, "");
int len = write(fd, s, sizeof(s));
EXPECT_EQ("open_0500", len, 5);
close(fd);
remove("/data/test.txt");
remove(path);
}
/*
* @tc.name : open_0600
* @tc.desc : VVerify file open mode is O_RDWR | O_APPEND(file does not exist)
* @tc.desc : Verify file open mode is O_RDWR | O_APPEND(file does not exist)
* @tc.level : Level 1
*/
void open_0600(void)
{
int fd, size;
char s[] = "test";
char buffer[80] = {0};
fd = open("/data/test.txt", O_RDWR | O_APPEND);
size = read(fd, buffer, sizeof(buffer));
int fd = open(path, O_RDWR | O_APPEND);
ssize_t size = read(fd, buffer, sizeof(buffer));
EXPECT_EQ("open_0600", fd, -1);
EXPECT_STREQ("open_0600", buffer, "");
int len = write(fd, s, sizeof(s));
EXPECT_EQ("open_0600", len, -1);
close(fd);
remove("/data/test.txt");
}
/*
* @tc.name : open_0700
* @tc.desc : VVerify file open mode is O_RDWR | O_APPEND(file pathname is invalid)
* @tc.desc : Verify file open mode is O_RDWR | O_APPEND(file pathname is invalid)
* @tc.level : Level 2
*/
void open_0700(void)
{
int fd;
fd = open("/data/test.txt", O_RDWR | O_APPEND);
int fd = open(path, O_RDWR | O_APPEND);
EXPECT_EQ("open_0700", fd, -1);
close(fd);
}
/*
* @tc.name : open_0800
* @tc.desc : VVerify file open mode is O_RDWR | O_CREAT
* @tc.desc : Verify file open mode is O_RDWR | O_CREAT
* @tc.level : Level 0
*/
void open_0800(void)
{
int fd, size;
char s[] = "test";
char buffer[80] = {0};
fd = open("/data/test.txt", O_RDWR | O_CREAT);
if (fd == -1) {
fputs("open r is failed\n", stdout);
}
size = read(fd, buffer, sizeof(buffer));
int fd = open(path, O_RDWR | O_CREAT);
ssize_t size = read(fd, buffer, sizeof(buffer));
EXPECT_EQ("open_0800", fd, 4);
EXPECT_STREQ("open_0800", buffer, "");
int len = write(fd, s, sizeof(s));
EXPECT_EQ("open_0800", len, 5);
close(fd);
remove("/data/test.txt");
remove(path);
}
/*
* @tc.name : open_0900
* @tc.desc : VVerify file open mode is O_RDWR | O_CLOEXEC
* @tc.desc : Verify file open mode is O_RDWR | O_CLOEXEC
* @tc.level : Level 0
*/
void open_0900(void)
{
int fd, size;
char s[] = "test";
char buffer[80] = {0};
fd = open("/data/test.txt", O_RDWR | O_CLOEXEC + O_CREAT);
if (fd == -1) {
fputs("open r is failed\n", stdout);
}
size = read(fd, buffer, sizeof(buffer));
EXPECT_EQ("open_1000", fd, 4);
EXPECT_STREQ("open_1000", buffer, "");
int fd = open(path, O_RDWR | O_CLOEXEC + O_CREAT);
ssize_t size = read(fd, buffer, sizeof(buffer));
EXPECT_EQ("open_0900", fd, 4);
EXPECT_STREQ("open_0900", buffer, "");
int len = write(fd, s, sizeof(s));
EXPECT_EQ("open_1000", len, 5);
EXPECT_EQ("open_0900", len, 5);
close(fd);
remove("/data/test.txt");
remove(path);
}
TEST_FUN G_Fun_Array[] = {
......@@ -210,7 +180,7 @@ TEST_FUN G_Fun_Array[] = {
};
int main()
int main(int argc, char *argv[])
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
......
......@@ -45,7 +45,7 @@ void dl_iterate_phdr_0100(void)
exit(EXIT_SUCCESS);
}
int main()
int main(int argc, char *argv[])
{
dl_iterate_phdr_0100();
return t_status;
......
......@@ -63,7 +63,7 @@ void dladdr_0200(void)
EXPECT_EQ("dladdr_0200", num, 1);
}
int main()
int main(int argc, char *argv[])
{
dladdr_0100();
dladdr_0200();
......
/**
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <fcntl.h>
#include <unistd.h>
#include "functionalext.h"
......@@ -34,7 +49,7 @@ void daemon_0200(void)
/*
* @tc.name : daemon_0300
* @tc.desc : Verify that the working directory of the daemon cannot be changed
* @tc.desc : Verify that the working directory of the daemon cannot be changed
* (the nochdir parameter has no effect)
* @tc.level : Level 2
*/
......@@ -47,7 +62,7 @@ void daemon_0300(void)
/*
* @tc.name : daemon_0400
* @tc.desc : Verify that the working directory of the daemon cannot be changed
* @tc.desc : Verify that the working directory of the daemon cannot be changed
* (the noclose parameter has no effect)
* @tc.level : Level 2
*/
......@@ -88,7 +103,7 @@ void daemon_0600(void)
EXPECT_EQ("daemon_0600", mode, failed);
}
int main()
int main(int argc, char *argv[])
{
daemon_0100();
daemon_0200();
......
......@@ -37,7 +37,7 @@ void ftw_0100()
EXPECT_NE("ftw_0100", ret, FAIL);
}
int main()
int main(int argc, char *argv[])
{
ftw_0100();
......
......@@ -71,7 +71,7 @@ void futimes_0300(void)
EXPECT_EQ("futimes_0300", ret, FAIL);
}
int main()
int main(int argc, char *argv[])
{
futimes_0100();
futimes_0200();
......
......@@ -29,14 +29,13 @@ void getloadavg_0100(void)
double buf[1024];
int result = -10;
result = getloadavg(buf, 1024);
if (result > 0)
{
if (result > 0) {
flag = true;
}
EXPECT_TRUE("getloadavg_0100", flag);
}
int main()
int main(int argc, char *argv[])
{
getloadavg_0100();
return t_status;
......
......@@ -18,10 +18,6 @@
#include <unistd.h>
#include "functionalext.h"
const int EOK = 0;
const int SUCCESS = 0;
const int FAILED = -1;
/**
* @tc.name : getpagesize_0100
* @tc.desc : The call is successful and the size of the page can be obtained
......@@ -39,7 +35,7 @@ void getpagesize_0100()
remove("/data/1.txt");
}
int main()
int main(int argc, char *argv[])
{
getpagesize_0100();
return t_status;
......
......@@ -13,12 +13,6 @@
* limitations under the License.
*/
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/timex.h>
#include "functionalext.h"
......@@ -48,8 +42,7 @@ void adjtimex_0100(void)
tx.calcnt = 1;
tx.errcnt = 1;
tx.stbcnt = 1;
int result = -1;
result = adjtimex(&tx);
int result = adjtimex(&tx);
EXPECT_NE("adjtimex_0100", result, NUM_NEG);
}
......
......@@ -13,14 +13,14 @@
* limitations under the License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include "functionalext.h"
#include "test.h"
#define MAX 10
void *get_brk()
{
return sbrk(0);
}
/**
* @tc.name : brk_0100
......@@ -29,18 +29,26 @@
*/
void brk_0100(void)
{
int *p, n = 0, max = MAX;
FILE *fp;
int result;
p = (int *)malloc(MAX * sizeof(int));
max++;
result = brk(p);
#ifdef __BSD_SOURCE
EXPECT_EQ("brk_0100", result, 0);
#endif
errno = 0;
void *initial_break = get_brk();
void *new_break = (void *)((uintptr_t)(initial_break) + 1);
int result = brk(new_break);
if (result == -1) {
if (errno != ENOMEM) {
t_error("%s errno should be ENOMEM\n", __func__);
}
} else {
if (result != 0) {
t_error("%s brk failed\n", __func__);
}
if (get_brk() < new_break) {
t_error("%s brk invalid\n", __func__);
}
}
}
int main()
int main(int argc, char *argv[])
{
brk_0100();
return t_status;
......
......@@ -74,7 +74,7 @@ void capget_0300(void)
EXPECT_EQ("capget_0300", result, COUNT_ZERO);
}
int main()
int main(int argc, char *argv[])
{
capget_0100();
capget_0200();
......
......@@ -76,7 +76,7 @@ void capset_0300(void)
EXPECT_EQ("capset_0300", result, COUNT_NEGATIVE);
}
int main()
int main(int argc, char *argv[])
{
capset_0100();
capset_0200();
......
......@@ -64,7 +64,7 @@ void chroot_0400(void)
EXPECT_EQ("chroot_0100", result, -1);
}
int main()
int main(int argc, char *argv[])
{
chroot_0100();
chroot_0200();
......
......@@ -34,8 +34,7 @@ void clock_adjtime_0100(void)
struct timex tx = {0};
int result = -1;
result = clock_adjtime(CLOCK_REALTIME, &tx);
if (result != -1)
{
if (result != -1) {
flag = true;
}
EXPECT_TRUE("clock_adjtime_0100", flag);
......@@ -96,7 +95,7 @@ void clock_adjtime_0500(void)
EXPECT_EQ("clock_adjtime_0500", result, COUNT_NEGATIVE);
}
int main()
int main(int argc, char *argv[])
{
clock_adjtime_0100();
clock_adjtime_0200();
......
......@@ -37,13 +37,12 @@ void clone_0100(void)
{
void *stack = malloc(STACK_SIZE);
int cpid = -1;
cpid = clone((int (*)(void *))test, (char *)stack + STACK_SIZE,
CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, NULL);
cpid = clone((int (*)(void *))test, (char *)stack + STACK_SIZE, CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, NULL);
sleep(1);
EXPECT_NE("clone_0100", cpid, -1);
}
int main()
int main(int argc, char *argv[])
{
clone_0100();
return t_status;
......
......@@ -21,7 +21,7 @@
* @tc.desc : The flags parameter is equal to EFD_SEMAPHORE, which creates an eventfd object.
* @tc.level : Level 0
*/
void eventfd_0100()
void eventfd_0100(void)
{
int ret = eventfd(0, EFD_SEMAPHORE);
EXPECT_TRUE("eventfd_0100", ret > 0);
......@@ -32,7 +32,7 @@ void eventfd_0100()
* @tc.desc : The flags parameter is equal to EFD_CLOEXEC, which creates an eventfd object.
* @tc.level : Level 1
*/
void eventfd_0200()
void eventfd_0200(void)
{
int ret = eventfd(0, EFD_CLOEXEC);
EXPECT_TRUE("eventfd_0200", ret > 0);
......@@ -43,13 +43,13 @@ void eventfd_0200()
* @tc.desc : The flags parameter is equal to EFD_NONBLOCK, which creates an eventfd object.
* @tc.level : Level 1
*/
void eventfd_0300()
void eventfd_0300(void)
{
int ret = eventfd(0, EFD_NONBLOCK);
EXPECT_TRUE("eventfd_0300", ret > 0);
}
int main()
int main(int argc, char *argv[])
{
eventfd_0100();
eventfd_0200();
......
......@@ -14,55 +14,71 @@
*/
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/eventfd.h>
#include <unistd.h>
#include "functionalext.h"
#include "test.h"
/**
* @tc.name : eventfd_read_0100
* @tc.desc : The flags parameter is equal to EFD_SEMAPHORE, which creates an eventfd object.
* @tc.desc : Read the value of event through the file descriptor
* @tc.level : Level 0
*/
void eventfd_read_0100(void)
{
int fd, write_ret, read_ret;
uint64_t value;
fd = eventfd(1, EFD_NONBLOCK);
write_ret = eventfd_write(fd, 20);
read_ret = eventfd_read(fd, &value);
EXPECT_EQ("eventfd_read_0100", read_ret, 0);
unsigned int initial_value = 2;
int fd = eventfd(initial_value, O_NONBLOCK);
if (fd == -1) {
t_error("%s eventfd failed\n", __func__);
}
eventfd_t value = 123;
int result = eventfd_read(fd, &value);
if (result != 0) {
t_error("%s eventfd_read failed\n", __func__);
}
if (value != initial_value) {
t_error("%s eventfd_read value invalid\n", __func__);
}
close(fd);
}
/**
* @tc.name : eventfd_read_0200
* @tc.desc : The flags parameter is equal to EFD_CLOEXEC, which creates an eventfd object.
* @tc.desc : When the file descriptor is invalid, test the return value of this function
* @tc.level : Level 2
*/
void eventfd_read_0200(void)
{
int fd, write_ret, read_ret;
fd = eventfd(1, EFD_NONBLOCK);
write_ret = eventfd_write(fd, 20);
read_ret = eventfd_read(fd, NULL);
EXPECT_EQ("eventfd_read_0200", read_ret, -1);
eventfd_t value = 123;
int result = eventfd_read(-1, &value);
if (result != -1) {
t_error("%s eventfd_read should be failed\n", __func__);
}
}
/**
* @tc.name : eventfd_read_0300
* @tc.desc : The flags parameter is equal to EFD_NONBLOCK, which creates an eventfd object.
* @tc.desc : When the eventfd_t value is invalid, test the return value of this function
* @tc.level : Level 2
*/
void eventfd_read_0300(void)
{
int fd, write_ret, read_ret;
uint64_t value;
read_ret = eventfd_read(-1, &value);
EXPECT_EQ("eventfd_read_0300", read_ret, -1);
unsigned int initial_value = 2;
int fd = eventfd(initial_value, O_NONBLOCK);
if (fd == -1) {
t_error("%s eventfd failed\n", __func__);
}
int result = eventfd_read(fd, NULL);
if (result != -1) {
t_error("%s eventfd_read should be failed\n", __func__);
}
close(fd);
}
int main()
int main(int argc, char *argv[])
{
eventfd_read_0100();
eventfd_read_0200();
......
......@@ -14,55 +14,81 @@
*/
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/eventfd.h>
#include <unistd.h>
#include "functionalext.h"
#include "test.h"
/**
* @tc.name : eventfd_write_0100
* @tc.desc : The flags parameter is equal to EFD_SEMAPHORE, which creates an eventfd object.
* @tc.desc : Write the value through this function
* @tc.level : Level 0
*/
void eventfd_write_0100(void)
{
int fd, write_ret;
uint64_t value;
fd = eventfd(1, EFD_NONBLOCK);
write_ret = eventfd_write(fd, 20);
EXPECT_EQ("eventfd_write_0100", write_ret, 0);
eventfd_t value;
unsigned int initial_value = 0;
int fd = eventfd(initial_value, O_NONBLOCK);
if (fd == -1) {
t_error("%s eventfd failed\n", __func__);
}
int ret = eventfd_write(fd, 1);
if (ret != 0) {
t_error("%s eventfd_write failed\n", __func__);
}
ret = eventfd_write(fd, 1);
if (ret != 0) {
t_error("%s eventfd_write failed\n", __func__);
}
ret = eventfd_write(fd, 1);
if (ret != 0) {
t_error("%s eventfd_write failed\n", __func__);
}
ret = eventfd_read(fd, &value);
if (ret != 0) {
t_error("%s eventfd_read failed\n", __func__);
}
if (value != 3U) {
t_error("%s value is %d, not three\n", __func__);
}
close(fd);
}
/**
* @tc.name : eventfd_write_0200
* @tc.desc : The flags parameter is equal to EFD_CLOEXEC, which creates an eventfd object.
* @tc.desc : When the file descriptor is invalid, test the return value of this function
* @tc.level : Level 2
*/
void eventfd_write_0200(void)
{
int fd, write_ret;
uint64_t value;
fd = eventfd(1, EFD_NONBLOCK);
write_ret = eventfd_write(-1, 20);
EXPECT_EQ("eventfd_write_0200", write_ret, -1);
int ret = eventfd_write(-1, 1);
if (ret != -1) {
t_error("%s eventfd_write should be failed\n", __func__);
}
}
/**
* @tc.name : eventfd_write_0300
* @tc.desc : The flags parameter is equal to EFD_NONBLOCK, which creates an eventfd object.
* @tc.desc : When the eventfd_t value is invalid, test the return value of this function
* @tc.level : Level 2
*/
void eventfd_write_0300(void)
{
int fd, write_ret;
uint64_t value;
fd = eventfd(1, EFD_NONBLOCK);
write_ret = eventfd_write(fd, -1);
EXPECT_EQ("eventfd_write_0300", write_ret, -1);
unsigned int initial_value = 2;
int fd = eventfd(initial_value, O_NONBLOCK);
if (fd == -1) {
t_error("%s eventfd failed\n", __func__);
}
int result = eventfd_write(fd, -1);
if (result != -1) {
t_error("%s eventfd_write should be failed\n", __func__);
}
close(fd);
}
int main()
int main(int argc, char *argv[])
{
eventfd_write_0100();
eventfd_write_0200();
......
......@@ -92,7 +92,7 @@ void fallocate_0400(void)
remove("fatest.txt");
}
int main()
int main(int argc, char *argv[])
{
fallocate_0100();
fallocate_0200();
......
......@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
......@@ -13,63 +13,46 @@
* limitations under the License.
*/
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include "functionalext.h"
typedef void (*TEST_FUN)();
#include <sys/fanotify.h>
#include "test.h"
/**
* @tc.name : dn_skipname_0100
* @tc.desc : Verify that the domain name can be compressed (parameters are valid)
* @tc.name : fanotify_init_0100
* @tc.desc : Initializes a new fanotify group and returns a file descriptor for the event queue associated with
* the group.
* @tc.level : Level 0
*/
void dn_skipname_0100(void)
void fanotify_init_0100(void)
{
unsigned char s[10] = {0, 2, 34, 45, 75, 23, 12, 192, 87, 254};
int result = dn_skipname(&s[0], &s[1]);
EXPECT_EQ("dn_skipname_0100", result, 1);
}
errno = 0;
/**
* @tc.name : dn_skipname_0200
* @tc.desc : Verify that the domain name can be compressed (parameters are valid)
* @tc.level : Level 1
*/
void dn_skipname_0200(void)
{
unsigned char s[10] = {0, 2, 34, 45, 75, 23, 12, 192, 87, 254};
int result = dn_skipname(&s[7], &s[9]);
EXPECT_EQ("dn_skipname_0200", result, 2);
}
int fd = fanotify_init(0, 0);
if (fd < 0) {
switch (errno) {
case ENOSYS:
t_error("%s SKIP: missing support for fanotify (check CONFIG_FANOTIFY=y)\n", __func__);
case EPERM:
t_error("%s SKIP: missing proper permissions for runtime test\n", __func__);
}
/**
* @tc.name : dn_skipname_0300
* @tc.desc : Verify that the domain name cannot be compressed (s and end are equal)
* @tc.level : Level 2
*/
void dn_skipname_0300(void)
{
unsigned char s[10] = {0, 2, 2, 45, 75, 23, 12, 192, 87, 254};
int result = dn_skipname(&s[1], &s[2]);
EXPECT_EQ("dn_skipname_0300", result, -1);
}
t_error("%s fanotify_init failed\n", __func__);
}
TEST_FUN G_Fun_Array[] = {
dn_skipname_0100,
dn_skipname_0200,
dn_skipname_0300,
};
int result = fanotify_mark(fd,
FAN_MARK_ADD | FAN_MARK_MOUNT,
FAN_ACCESS | FAN_MODIFY | FAN_OPEN | FAN_CLOSE | FAN_ONDIR | FAN_EVENT_ON_CHILD,
AT_FDCWD,
".");
int main()
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
G_Fun_Array[pos]();
if (result) {
t_error("%s fanotify_mark (...) failed\n", __func__);
}
}
int main(int argc, char *argv[])
{
// fanotify_init_0100();
return t_status;
}
\ No newline at end of file
}
......@@ -14,10 +14,10 @@
*/
#include <fcntl.h>
#include <stdlib.h>
#include <stdbool.h>
#include "functionalext.h"
#include "sys/xattr.h"
#include <stdio.h>
#include <string.h>
#include <sys/xattr.h>
#include "test.h"
/**
* @tc.name : fgetxattr_0100
......@@ -26,20 +26,27 @@
*/
void fgetxattr_0100(void)
{
int fd = open("fgetxattr.txt", O_RDWR | O_CREAT);
const char *path = "/data/fgetxattr.txt";
char name[] = "user.x";
char value[] = "the past is not dead.";
ssize_t size;
fsetxattr(fd, name, value, strlen(value), 0);
size = fgetxattr(fd, name, value, 1024);
bool flag = false;
if (size >= 0)
{
flag = true;
int fd = open(path, O_RDWR | O_CREAT);
if (fd < 0) {
t_error("%s open failed\n", __func__);
}
int ret = fsetxattr(fd, name, value, strlen(value), 0);
if (ret != 0) {
t_error("%s fsetxattr failed\n", __func__);
}
EXPECT_TRUE("fgetxattr_0100", flag);
ssize_t result = fgetxattr(fd, name, value, 1024);
if (result < 0) {
t_error("%s fgetxattr failed\n", __func__);
}
close(fd);
remove("fgetxattr.txt");
remove(path);
}
int main(int argc, char *argv[])
......
......@@ -14,15 +14,9 @@
*/
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/xattr.h>
#include <stdbool.h>
#include <unistd.h>
#include "functionalext.h"
typedef void (*TEST_FUN)();
/**
* @tc.name : flistxattr_0100
* @tc.desc : Verify that extended attribute names can be listed (each parameter is valid)
......@@ -30,32 +24,24 @@ typedef void (*TEST_FUN)();
*/
void flistxattr_0100(void)
{
bool flag = false;
int fd = open("/data/test.txt", O_CREAT | O_WRONLY, 0667);
const char *path = "/data/test.txt";
char name[] = "user.x";
char value[] = "the past is not dead.";
ssize_t result;
int fd = open(path, O_CREAT | O_WRONLY, 0667);
EXPECT_NE("flistxattr_0100", fd, -1);
fsetxattr(fd, name, value, strlen(value), 0);
result = flistxattr(fd, name, 0);
if (result >= 0)
{
flag = true;
}
EXPECT_TRUE("flistxattr_0100", flag);
ssize_t result = flistxattr(fd, name, 0);
EXPECT_NE("flistxattr_0100", result, -1);
close(fd);
remove("/data/test.txt");
remove(path);
}
TEST_FUN G_Fun_Array[] = {
flistxattr_0100,
};
int main()
int main(int argc, char *argv[])
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos)
{
G_Fun_Array[pos]();
}
flistxattr_0100();
return t_status;
}
\ No newline at end of file
......@@ -38,8 +38,7 @@ void flock_0100()
fd = open("/data/test.txt", O_RDWR | O_CREAT, 0666);
lseek(fd, 2, SEEK_SET);
if (fd < 0) {
printf("open failed!\n");
return;
t_error("%s open failed\n", __func__);
}
result = flock(fd, LOCK_SH);
EXPECT_EQ("flock_0100", result, SUCCESS);
......@@ -59,8 +58,7 @@ void flock_0200()
fd = open("/data/test.txt", O_RDWR | O_CREAT, 0666);
lseek(fd, 2, SEEK_SET);
if (fd < 0) {
printf("open failed!\n");
return;
t_error("%s open failed\n", __func__);
}
result = flock(fd, LOCK_SH | LOCK_NB);
EXPECT_EQ("flock_0200", result, SUCCESS);
......@@ -80,8 +78,7 @@ void flock_0300()
fd = open("/data/test.txt", O_RDWR | O_CREAT, 0666);
lseek(fd, 2, SEEK_SET);
if (fd < 0) {
printf("open failed!\n");
return;
t_error("%s open failed\n", __func__);
}
result = flock(fd, LOCK_EX);
EXPECT_EQ("flock_0300", result, SUCCESS);
......@@ -101,8 +98,7 @@ void flock_0400()
fd = open("/data/test.txt", O_RDWR | O_CREAT, 0666);
lseek(fd, 2, SEEK_SET);
if (fd < 0) {
printf("open failed!\n");
return;
t_error("%s open failed\n", __func__);
}
result = flock(fd, LOCK_EX | LOCK_NB);
EXPECT_EQ("flock_0400", result, SUCCESS);
......@@ -122,8 +118,7 @@ void flock_0500()
fd = open("/data/test.txt", O_RDWR | O_CREAT, 0666);
lseek(fd, 2, SEEK_SET);
if (fd < 0) {
printf("open failed!\n");
return;
t_error("%s open failed\n", __func__);
}
result = flock(fd, LOCK_UN);
EXPECT_EQ("flock_0500", result, SUCCESS);
......@@ -157,8 +152,7 @@ void flock_0700()
fd = open("/data/test.txt", O_RDWR | O_CREAT, 0666);
lseek(fd, 2, SEEK_SET);
if (fd < 0) {
printf("open failed!\n");
return;
t_error("%s open failed\n", __func__);
}
result = flock(fd, 0);
EXPECT_EQ("flock_0700", result, FAILED);
......@@ -166,7 +160,7 @@ void flock_0700()
system("rm -rf /data/test.txt");
}
int main()
int main(int argc, char *argv[])
{
flock_0100();
flock_0200();
......
......@@ -40,7 +40,7 @@ void fremovexattr_0100(void)
remove("/data/test.txt");
}
int main()
int main(int argc, char *argv[])
{
fremovexattr_0100();
return t_status;
......
......@@ -39,7 +39,7 @@ void fsetxattr_0100(void)
remove("/data/test.txt");
}
int main()
int main(int argc, char *argv[])
{
fsetxattr_0100();
return t_status;
......
......@@ -76,7 +76,7 @@ void getdents_0300(void)
EXPECT_EQ("getdents_0300", result, FAILED);
}
int main()
int main(int argc, char *argv[])
{
getdents_0100();
getdents_0200();
......
......@@ -60,7 +60,7 @@ void membarrier_0300(void)
EXPECT_EQ("membarrier_0300", result, COUNT_NEGATIVE);
}
int main()
int main(int argc, char *argv[])
{
membarrier_0100();
membarrier_0200();
......
......@@ -49,7 +49,7 @@ void name_to_handle_at_0100(void)
EXPECT_EQ("name_to_handle_at_0100", result, COUNT_ZERO);
}
int main()
int main(int argc, char *argv[])
{
// name_to_handle_at_0100();
return t_status;
......
......@@ -56,7 +56,7 @@ void open_by_handle_at_0100(void)
EXPECT_TRUE("open_by_handle_at_0100", flag);
}
int main()
int main(int argc, char *argv[])
{
// open_by_handle_at_0100();
return t_status;
......
......@@ -13,13 +13,9 @@
* limitations under the License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/prctl.h>
#include "functionalext.h"
typedef void (*TEST_FUN)();
/*
* @tc.name : prctl_0100
* @tc.desc : Verify that the thread can be given a name and get the name
......@@ -27,24 +23,19 @@ typedef void (*TEST_FUN)();
*/
void prctl_0100(void)
{
char buff[100] = {0};
int prc = prctl(PR_SET_NAME, (unsigned long)"TestThread");
int data = prctl(PR_GET_NAME, (unsigned long)buff);
EXPECT_EQ("prctl_0100", prc, 0);
EXPECT_EQ("prctl_0100", data, 0);
EXPECT_STREQ("prctl_0100", buff, "TestThread");
}
char buf[BUFSIZ];
memset(buf, 0, BUFSIZ);
TEST_FUN G_Fun_Array[] = {
prctl_0100,
};
int result = prctl(PR_SET_NAME, (unsigned long)"TestThread");
EXPECT_EQ("prctl_0100", result, 0);
int main()
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
G_Fun_Array[pos]();
}
result = prctl(PR_GET_NAME, (unsigned long)buf);
EXPECT_EQ("prctl_0100", result, 0);
EXPECT_STREQ("prctl_0100", buf, "TestThread");
}
int main(int argc, char *argv[])
{
prctl_0100();
return t_status;
}
\ No newline at end of file
......@@ -14,18 +14,86 @@
*/
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include "functionalext.h"
#include "test.h"
#define LEN 8192
typedef void (*TEST_FUN)();
const int32_t COUNT_ZERO = 0;
const char *path = "/data/remap_file_pages.txt";
const char *text =
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
/**
* @tc.name : remap_file_pages_0100
......@@ -34,29 +102,78 @@ const int32_t COUNT_ZERO = 0;
*/
void remap_file_pages_0100(void)
{
int i, fd, ret;
char str[LEN] = {0};
char *start = NULL;
fd = open("text", O_RDWR | O_CREAT);
start = mmap(NULL, LEN, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
ret = remap_file_pages(start, LEN >> 1, 0, 1, MAP_SHARED);
if (ret < 0) {
perror("remap file pages failed1");
}
EXPECT_EQ("remap_file_pages_0100", ret, 0);
int fd = open(path, O_RDWR | O_CREAT);
if (fd < 0) {
t_error("%s open failed\n", __func__);
}
int ret = write(fd, text, strlen(text));
if (ret != LEN) {
t_error("%s write failed\n", __func__);
}
close(fd);
remove("text");
}
fd = open(path, O_RDWR);
if (fd < 0) {
t_error("%s open failed\n", __func__);
}
TEST_FUN G_Fun_Array[] = {
// remap_file_pages_0100,
};
char *start = mmap(NULL, LEN, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (start == MAP_FAILED) {
t_error("%s mmap failed\n", __func__);
}
int main()
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
G_Fun_Array[pos]();
memcpy(str, start, 8);
if (strcmp(str, "aaaaaaaa")) {
t_error("%s str should be equal\n", __func__);
}
memcpy(str, start + 4096, 8);
if (strcmp(str, "bbbbbbbb")) {
t_error("%s str should be equal\n", __func__);
}
memcpy(str, start + 4096 - 4, 8);
if (strcmp(str, "aaaabbbb")) {
t_error("%s str should be equal\n", __func__);
}
// Remap the second page of the file to the start position
int result = remap_file_pages(start, LEN >> 1, 0, 1, MAP_SHARED);
if (result < 0) {
munmap(start, LEN);
close(fd);
t_error("%s remap_file_pages failed\n", __func__);
}
// Remap the first page of the file to the position of start+4096
result = remap_file_pages(start + 4096, LEN >> 1, 0, 0, MAP_SHARED);
if (result < 0) {
munmap(start, LEN);
close(fd);
t_error("%s remap_file_pages failed\n", __func__);
}
memcpy(str, start, 8);
if (strcmp(str, "bbbbbbbb")) {
t_error("%s str should be equal\n", __func__);
}
memcpy(str, start + 4096, 8);
if (strcmp(str, "aaaaaaaa")) {
t_error("%s str should be equal\n", __func__);
}
memcpy(str, start + 4096 - 4, 8);
if (strcmp(str, "bbbbaaaa")) {
t_error("%s str should be equal\n", __func__);
}
munmap(start, LEN);
close(fd);
}
int main(int argc, char *argv[])
{
// remap_file_pages_0100();
return t_status;
}
\ No newline at end of file
......@@ -14,7 +14,6 @@
*/
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "test.h"
......
......@@ -79,4 +79,5 @@ functionalext_supplement_linux_test = [
"prlimit",
"quotactl",
"chroot",
"fanotify_init",
]
......@@ -13,12 +13,7 @@
* limitations under the License.
*/
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "functionalext.h"
/**
......@@ -28,13 +23,11 @@
*/
void aligned_alloc_0100(void)
{
bool flag = false;
int pagesize = getpagesize();
int *p1 = (int *)aligned_alloc(pagesize, 1024 * sizeof(int));
if (p1 != 0) {
flag = true;
void *p = aligned_alloc(pagesize, 1024 * sizeof(int));
if (!p) {
t_error("%s aligned_alloc failed\n", __func__);
}
EXPECT_TRUE("aligned_alloc_0100", flag);
}
int main(void)
......
......@@ -125,7 +125,7 @@ void memalign_0500(void)
buff = NULL;
}
int main()
int main(int argc, char *argv[])
{
memalign_0100();
memalign_0200();
......
......@@ -55,7 +55,7 @@ void gethostbyaddre_0200(void)
EXPECT_TRUE("gethostbyaddre_0200", hptr != NULL);
}
int main()
int main(int argc, char *argv[])
{
gethostbyaddre_0100();
gethostbyaddre_0200();
......
......@@ -50,7 +50,7 @@ void gethostbyaddr_r_0200(void)
EXPECT_NE("gethostbyaddr_r_0200", ret, 0);
}
int main()
int main(int argc, char *argv[])
{
gethostbyaddr_r_0100();
gethostbyaddr_r_0200();
......
......@@ -97,7 +97,7 @@ TEST_FUN G_Fun_Array[] = {
gethostbyname2_0400,
};
int main()
int main(int argc, char *argv[])
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
......
......@@ -83,7 +83,7 @@ void gethostbyname2_r_0400(void)
EXPECT_NE("gethostbyname2_r_0400", ret, 0);
}
int main()
int main(int argc, char *argv[])
{
gethostbyname2_r_0100();
gethostbyname2_r_0200();
......
......@@ -73,7 +73,7 @@ TEST_FUN G_Fun_Array[] = {
gethostbyname_r_0200,
};
int main()
int main(int argc, char *argv[])
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
......
......@@ -166,7 +166,7 @@ void getnameinfo_0700()
EXPECT_EQ("getnameinfo_0700", ret, FAMILY_NOTSUPPORTED);
}
int main()
int main(int argc, char *argv[])
{
getnameinfo_0100();
getnameinfo_0200();
......
......@@ -15,15 +15,12 @@
#include <stdio.h>
#include <arpa/inet.h>
#include <ctype.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <stdbool.h>
#include "functionalext.h"
#include <string.h>
#include "test.h"
typedef void (*TEST_FUN)();
const char *path = "/etc/networks";
const char *netinfo = "loopback 127.0.0.1";
/**
* @tc.name : getnetbyaddr_0100
......@@ -32,19 +29,19 @@ typedef void (*TEST_FUN)();
*/
void getnetbyaddr_0100(void)
{
bool flag = false;
char *ptr, **pptr;
char str[INET_ADDRSTRLEN];
struct hostent *hptr;
struct in_addr *addr;
struct sockaddr_in saddr;
inet_aton("127.0.0.1", &saddr.sin_addr);
hptr = gethostbyaddr((void *)&saddr.sin_addr, 4, AF_INET);
if (hptr != NULL) {
flag = true;
FILE *fd = fopen(path, "w+");
if (!fd) {
t_error("%s fopen failed\n", __func__);
}
fwrite(netinfo, sizeof(char), strlen(netinfo), fd);
struct netent *nptr;
uint32_t ip = inet_network("127.0.0.1");
printf("ip: %d\n", ip);
nptr = getnetbyaddr(ip, AF_INET);
if (!nptr) {
t_error("%s getnetbyaddr failed\n", __func__);
}
EXPECT_STREQ("getnetbyaddr_0100", hptr->h_name, "127.0.0.1");
EXPECT_TRUE("getnetbyaddr_0100", flag);
}
/**
......@@ -53,20 +50,7 @@ void getnetbyaddr_0100(void)
* @tc.level : Level 2
*/
void getnetbyaddr_0200(void)
{
bool flag = false;
char *ptr, **pptr;
char str[INET_ADDRSTRLEN];
struct hostent *hptr;
struct in_addr *addr;
struct sockaddr_in saddr;
inet_aton("-128.256.w.1", &saddr.sin_addr);
hptr = gethostbyaddr((void *)&saddr.sin_addr, 0, AF_INET);
if (hptr == NULL) {
flag = true;
}
EXPECT_TRUE("getnetbyaddr_0200", flag);
}
{}
/**
* @tc.name : getnetbyaddr_0300
......@@ -74,20 +58,7 @@ void getnetbyaddr_0200(void)
* @tc.level : Level 0
*/
void getnetbyaddr_0300(void)
{
bool flag = false;
char *ptr, **pptr;
char str[INET_ADDRSTRLEN];
struct hostent *hptr;
struct in_addr *addr;
struct sockaddr_in saddr;
inet_aton("::1", &saddr.sin_addr);
hptr = gethostbyaddr((void *)&saddr.sin_addr, 16, AF_INET6);
if (hptr != NULL) {
flag = true;
}
EXPECT_TRUE("getnetbyaddr_0300", flag);
}
{}
/**
* @tc.name : getnetbyaddr_0400
......@@ -95,33 +66,13 @@ void getnetbyaddr_0300(void)
* @tc.level : Level 2
*/
void getnetbyaddr_0400(void)
{
bool flag = false;
char *ptr, **pptr;
char str[INET_ADDRSTRLEN];
struct hostent *hptr;
struct in_addr *addr;
struct sockaddr_in saddr;
inet_aton("0:-127.w.-256.1", &saddr.sin_addr);
hptr = gethostbyaddr((void *)&saddr.sin_addr, 4, AF_INET6);
if (hptr == NULL) {
flag = true;
}
EXPECT_TRUE("getnetbyaddr_0400", flag);
}
TEST_FUN G_Fun_Array[] = {
getnetbyaddr_0100,
getnetbyaddr_0200,
getnetbyaddr_0300,
getnetbyaddr_0400,
};
{}
int main()
int main(int argc, char *argv[])
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
G_Fun_Array[pos]();
}
getnetbyaddr_0100();
getnetbyaddr_0200();
getnetbyaddr_0300();
getnetbyaddr_0400();
return t_status;
}
\ No newline at end of file
......@@ -34,10 +34,8 @@ void getnetbyname_0100(void)
{
struct netent *Socket = NULL;
Socket = getnetbyname("127.0.0.1");
if (Socket != NULL) {
printf(" name is %s\n", Socket->n_name);
} else {
printf("getnetbyname_0100 is failed\n");
if (!Socket) {
t_error("%s getnetbyname failed\n", __func__);
}
}
......@@ -62,7 +60,7 @@ TEST_FUN G_Fun_Array[] = {
getnetbyname_0200,
};
int main()
int main(int argc, char *argv[])
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
......
......@@ -13,8 +13,8 @@
* limitations under the License.
*/
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <netinet/in.h>
#include <resolv.h>
#include "functionalext.h"
......@@ -99,7 +99,7 @@ TEST_FUN G_Fun_Array[] = {
res_querydomain_0400,
};
int main()
int main(int argc, char *argv[])
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
......
......@@ -14,11 +14,7 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include "functionalext.h"
......@@ -40,7 +36,7 @@ void res_send_0100(void)
EXPECT_TRUE("res_send_0100", flag);
}
int main()
int main(int argc, char *argv[])
{
res_send_0100();
return t_status;
......
......@@ -21,6 +21,5 @@ functionalext_supplement_manual_network_test = [
"gethostbyaddr_r",
"gethostbyname2_r",
"gethostbyaddr",
#"getnetbyname",
"getnetbyname",
]
......@@ -55,7 +55,7 @@ void cnd_broadcast_0100(void)
mtx_destroy(&mtx);
}
int main()
int main(int argc, char *argv[])
{
cnd_broadcast_0100();
return t_status;
......
......@@ -14,18 +14,10 @@
*/
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <stdint.h>
#include <signal.h>
#include <stdint.h>
#include <unistd.h>
#include "functionalext.h"
typedef void (*TEST_FUN)();
const int32_t COUNT_ZERO = 0;
const int32_t COUNT_ONE = 1;
/**
* @tc.name : isatty_0100
......@@ -35,7 +27,7 @@ const int32_t COUNT_ONE = 1;
void isatty_0100()
{
int result = isatty(fileno(stdout));
EXPECT_EQ("isatty_0100", result, COUNT_ONE);
EXPECT_EQ("isatty_0100", result, 1);
}
/**
......@@ -45,11 +37,11 @@ void isatty_0100()
*/
void isatty_0200()
{
int fd = open("readtest.txt", O_RDWR | O_CREAT);
int fd = open("/data/readtest.txt", O_RDWR | O_CREAT);
int result = isatty(fd);
EXPECT_EQ("isatty_0200", result, COUNT_ZERO);
EXPECT_EQ("isatty_0200", result, 0);
close(fd);
remove("readtest.txt");
remove("/data/readtest.txt");
}
TEST_FUN G_Fun_Array[] = {
......@@ -57,7 +49,7 @@ TEST_FUN G_Fun_Array[] = {
isatty_0200,
};
int main()
int main(int argc, char *argv[])
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
......
......@@ -70,8 +70,7 @@ void __fpclassifyf_0400(void)
EXPECT_EQ("__fpclassifyf_0400", ret, FP_ZERO);
}
int main()
int main(int argc, char *argv[])
{
__fpclassifyf_0100();
__fpclassifyf_0200();
......
......@@ -71,7 +71,7 @@ void __fpclassifyl_0400(void)
}
int main()
int main(int argc, char *argv[])
{
__fpclassifyl_0100();
__fpclassifyl_0200();
......
......@@ -62,7 +62,7 @@ TEST_FUN G_Fun_Array[] = {
__signbit_0300,
};
int main()
int main(int argc, char *argv[])
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
......
......@@ -16,9 +16,6 @@
#include <math.h>
#include "functionalext.h"
const int32_t COUNT_ZERO = 0;
const int32_t COUNT_ONE = 1;
/*
* @tc.name : __signbitf_0100
* @tc.desc : The parameter value of float type is 0, and the sign bit of the return parameter is 0.
......@@ -26,24 +23,22 @@ const int32_t COUNT_ONE = 1;
*/
void __signbitf_0100(void)
{
float x = 0;
int result;
result = __signbitf(x);
EXPECT_EQ(" __signbitf_0100", result, COUNT_ZERO);
float x = 0.0f;
int result = __signbitf(x);
EXPECT_EQ("__signbitf_0100", result, 0);
}
/*
* @tc.name : __signbitf_0200
* @tc.desc : The parameter value of type float is a positive number,
* and the sign bit of the returned parameter is 0.
* @tc.desc : The parameter value of type float is a positive number, and the sign bit of the returned
* parameter is 0.
* @tc.level : Level 0
*/
void __signbitf_0200(void)
{
float x = 10;
int result;
result = __signbitf(x);
EXPECT_EQ(" __signbitf_0200", result, COUNT_ZERO);
float x = 3.14f;
int result = __signbitf(x);
EXPECT_EQ("__signbitf_0200", result, 0);
}
/*
......@@ -54,13 +49,12 @@ void __signbitf_0200(void)
*/
void __signbitf_0300(void)
{
float x = -10;
int result;
result = __signbitf(x);
EXPECT_EQ(" __signbitf_0300", result, COUNT_ONE);
float x = -3.14f;
int result = __signbitf(x);
EXPECT_EQ("__signbitf_0300", result, 1);
}
int main()
int main(int argc, char *argv[])
{
__signbitf_0100();
__signbitf_0200();
......
......@@ -28,7 +28,7 @@ const int32_t COUNT_ONE = 1;
*/
void signbitl_0100(void)
{
long double x = 0;
long double x = 0.0L;
int result;
result = __signbitl(x);
EXPECT_EQ("signbitl_0100", result, COUNT_ZERO);
......@@ -41,7 +41,7 @@ void signbitl_0100(void)
*/
void signbitl_0200(void)
{
long double x = 10;
long double x = 3.14;
int result;
result = __signbitl(x);
EXPECT_EQ("signbitl_0200", result, COUNT_ZERO);
......@@ -49,19 +49,18 @@ void signbitl_0200(void)
/**
* @tc.name : signbitl_0300
* @tc.desc : the sign bit of the returned parameter is 1
* (The parameter value of type long is negative)
* @tc.desc : the sign bit of the returned parameter is 1 (The parameter value of type long is negative)
* @tc.level : Level 0
*/
void signbitl_0300(void)
{
long double x = -10;
long double x = -3.14;
int result;
result = __signbitl(x);
EXPECT_EQ("signbitl_0300", result, COUNT_ONE);
}
int main()
int main(int argc, char *argv[])
{
signbitl_0100();
signbitl_0200();
......
......@@ -95,7 +95,7 @@ TEST_FUN G_Fun_Array[] = {
finite_0600,
};
int main()
int main(int argc, char *argv[])
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
......
......@@ -13,15 +13,10 @@
* limitations under the License.
*/
#include <stdlib.h>
#include <stdio.h>
#include <float.h>
#include <math.h>
#include <stdint.h>
#include "functionalext.h"
#include "math.h"
const int32_t NUM_ZERO = 0;
const int32_t NUM_ONE = 1;
/**
* @tc.name : finitef_0100
......@@ -30,8 +25,8 @@ const int32_t NUM_ONE = 1;
*/
void finitef_0100(void)
{
float ret = finitef(0.0);
EXPECT_EQ("finitef_0100", ret, NUM_ONE);
int ret = finitef(0.0);
EXPECT_EQ("finitef_0100", ret, 1);
}
/**
......@@ -41,8 +36,8 @@ void finitef_0100(void)
*/
void finitef_0200(void)
{
float ret = finitef(DBL_MIN / 2);
EXPECT_EQ("finitef_0100", ret, NUM_ONE);
int ret = finitef(DBL_MIN / 2);
EXPECT_EQ("finitef_0100", ret, 1);
}
/**
......@@ -52,8 +47,8 @@ void finitef_0200(void)
*/
void finitef_0300(void)
{
float ret = finitef(NAN);
EXPECT_EQ("finitef_0100", ret, NUM_ZERO);
int ret = finitef(NAN);
EXPECT_EQ("finitef_0100", ret, 0);
}
/**
......@@ -63,8 +58,8 @@ void finitef_0300(void)
*/
void finitef_0400(void)
{
float ret = finitef(INFINITY);
EXPECT_EQ("finitef_0100", ret, NUM_ZERO);
int ret = finitef(INFINITY);
EXPECT_EQ("finitef_0100", ret, 0);
}
/**
......@@ -74,8 +69,8 @@ void finitef_0400(void)
*/
void finitef_0500(void)
{
float ret = finitef(sqrt(-1.0));
EXPECT_EQ("finitef_0100", ret, NUM_ZERO);
int ret = finitef(sqrt(-1.0));
EXPECT_EQ("finitef_0100", ret, 0);
}
/**
......@@ -85,8 +80,8 @@ void finitef_0500(void)
*/
void finitef_0600(void)
{
float ret = finitef(exp(800));
EXPECT_EQ("finitef_0100", ret, NUM_ZERO);
int ret = finitef(exp(800));
EXPECT_EQ("finitef_0100", ret, 0);
}
int main(int argc, char *argv[])
......
......@@ -37,7 +37,7 @@ void endmntent_0100(void)
remove("/data/test.txt");
}
int main()
int main(int argc, char *argv[])
{
endmntent_0100();
return t_status;
......
......@@ -13,9 +13,6 @@
* limitations under the License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "functionalext.h"
/**
......@@ -25,8 +22,7 @@
*/
void ffs_0100(void)
{
int result;
result = ffs(0);
int result = ffs(0);
EXPECT_EQ("ffs_0100", result, 0);
}
......@@ -37,8 +33,7 @@ void ffs_0100(void)
*/
void ffs_0200(void)
{
int result;
result = ffs(1);
int result = ffs(1);
EXPECT_EQ("ffs_0200", result, 1);
}
......@@ -49,8 +44,7 @@ void ffs_0200(void)
*/
void ffs_0300(void)
{
int result;
result = ffs(2);
int result = ffs(2);
EXPECT_EQ("ffs_0300", result, 2);
}
......@@ -61,8 +55,7 @@ void ffs_0300(void)
*/
void ffs_0400(void)
{
int result;
result = ffs(3);
int result = ffs(3);
EXPECT_EQ("ffs_0400", result, 1);
}
......@@ -73,12 +66,11 @@ void ffs_0400(void)
*/
void ffs_0500(void)
{
int result;
result = ffs(128);
int result = ffs(128);
EXPECT_EQ("ffs_0500", result, 8);
}
int main()
int main(int argc, char *argv[])
{
ffs_0100();
ffs_0200();
......
......@@ -57,7 +57,7 @@ void ffsl_0300(void)
EXPECT_EQ("ffsl_0300", result, 16);
}
int main()
int main(int argc, char *argv[])
{
ffsl_0100();
ffsl_0200();
......
......@@ -60,7 +60,7 @@ void ffsll_0300(void)
EXPECT_EQ("ffsll_0300", result, 36);
}
int main()
int main(int argc, char *argv[])
{
ffsll_0100();
ffsll_0200();
......
......@@ -66,7 +66,7 @@ TEST_FUN G_Fun_Array[] = {
forkpty_0100,
};
int main()
int main(int argc, char *argv[])
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
......
......@@ -54,7 +54,7 @@ void getauxval_0300(void)
EXPECT_TRUE("getauxval_0300", result != 0);
}
int main()
int main(int argc, char *argv[])
{
getauxval_0100();
getauxval_0200();
......
......@@ -63,7 +63,7 @@ void getdomainname_0300(void)
EXPECT_EQ("getdomainname_0300", result, FAILED);
}
int main()
int main(int argc, char *argv[])
{
getdomainname_0100();
getdomainname_0200();
......
......@@ -46,7 +46,7 @@ void getentropy_0200(void)
EXPECT_EQ("getentrcopy_0200", result, FAILED);
}
int main()
int main(int argc, char *argv[])
{
getentropy_0100();
getentropy_0200();
......
......@@ -111,7 +111,7 @@ TEST_FUN G_Fun_Array[] = {
getmntent_r_0200,
};
int main()
int main(int argc, char *argv[])
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
......
......@@ -123,7 +123,7 @@ TEST_FUN G_Fun_Array[] = {
ioctl_0200,
};
int main()
int main(int argc, char *argv[])
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
......
......@@ -485,7 +485,7 @@ void mmap_1100(void)
close(fd);
}
int main()
int main(int argc, char *argv[])
{
mmap_0100();
mmap_0200();
......
......@@ -97,7 +97,7 @@ void mprotect_0600(void)
EXPECT_EQ("mprotect_0600", ret, FAILED);
}
int main()
int main(int argc, char *argv[])
{
mprotect_0100();
mprotect_0200();
......
......@@ -13,16 +13,10 @@
* limitations under the License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include "functionalext.h"
typedef void (*TEST_FUN)();
const int32_t COUNT_ZERO = 0;
/*
* @tc.name : munmap_0100
* @tc.desc : Verify that the parameters are valid to unmap the memory
......@@ -33,27 +27,20 @@ void munmap_0100(void)
const char *ptr = "/data/test.txt";
const char str[] = "this is a sample!";
FILE *fptr = fopen(ptr, "w+");
char *p_map;
EXPECT_PTRNE("munmap_0100", fptr, NULL);
struct stat statbuff;
fwrite(str, sizeof(char), strlen(str), fptr);
fseek(fptr, 0L, SEEK_SET);
p_map = mmap(NULL, sizeof(char) * 10, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(fptr), 0);
char *p_map = mmap(NULL, sizeof(char) * 10, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(fptr), 0);
fclose(fptr);
int data = munmap(p_map, sizeof(char) * 10);
EXPECT_EQ("munmap_0100", data, COUNT_ZERO);
EXPECT_EQ("munmap_0100", data, 0);
remove(ptr);
}
TEST_FUN G_Fun_Array[] = {
munmap_0100,
};
int main()
int main(int argc, char *argv[])
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
G_Fun_Array[pos]();
}
munmap_0100();
return t_status;
}
\ No newline at end of file
......@@ -13,161 +13,158 @@
* limitations under the License.
*/
#include <uchar.h>
#include <wchar.h>
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <locale.h>
#include "functionalext.h"
mbstate_t state;
#include <string.h>
#include <uchar.h>
#include "test.h"
/**
* @tc.name : c16rtomb_0100
* @tc.desc : Verify that the 16-bit wide character representation is converted to a narrow multibyte character
* @tc.desc : Converts a variable-length 16-bit wide character representation to its narrow multibyte character
* representation.
* @tc.level : Level 0
*/
void c16rtomb_0100(void)
{
wchar_t str[] = L"test";
size_t in_sz = sizeof str / sizeof *str;
int rc = 0;
char out[MB_CUR_MAX * in_sz];
char *p = out;
for (size_t n = 0; n < in_sz; ++n) {
rc = c16rtomb(p, str[n], &state);
p += rc;
}
EXPECT_EQ("c16rtomb_0100", rc, 1);
char bytes[MB_LEN_MAX];
memset(bytes, 0, sizeof(bytes));
size_t result = c16rtomb(bytes, L'h', NULL);
if (result != 1U) {
t_error("%s c16rtomb failed, result is %d\n", __func__, result);
}
if (bytes[0] != 'h') {
t_error("%s bytes[0] is %c, not \'h\'\n", bytes[0]);
}
char *ret = setlocale(LC_CTYPE, "C.UTF-8");
if (strcmp(ret, "C.UTF-8")) {
t_error("%s setlocale failed\n", __func__);
}
uselocale(LC_GLOBAL_LOCALE);
// 1-byte UTF-8.
memset(bytes, 0, sizeof(bytes));
result = c16rtomb(bytes, L'h', NULL);
if (result != 1U) {
t_error("%s c16rtomb failed, result is %d\n", __func__, result);
}
if (bytes[0] != 'h') {
t_error("%s bytes[0] is %c, not \'h\'\n", bytes[0]);
}
// 2-byte UTF-8.
memset(bytes, 0, sizeof(bytes));
result = c16rtomb(bytes, 0x00a2, NULL);
if (result != 2U) {
t_error("%s c16rtomb failed, result is %d\n", __func__, result);
}
if (bytes[0] != '\xc2') {
t_error("%s bytes[0] is %c, not \'\\xc2\'\n", bytes[0]);
}
if (bytes[1] != '\xa2') {
t_error("%s bytes[0] is %c, not \'\\xa2\'\n", bytes[1]);
}
// 3-byte UTF-8.
memset(bytes, 0, sizeof(bytes));
result = c16rtomb(bytes, 0x20ac, NULL);
if (result != 3U) {
t_error("%s c16rtomb failed, result is %d\n", __func__, result);
}
if (bytes[0] != '\xe2') {
t_error("%s bytes[0] is %c, not \'\\xe2\'\n", bytes[0]);
}
if (bytes[1] != '\x82') {
t_error("%s bytes[0] is %c, not \'\\x82\'\n", bytes[1]);
}
if (bytes[2] != '\xac') {
t_error("%s bytes[0] is %c, not \'\\xac\'\n", bytes[2]);
}
}
/**
* @tc.name : c16rtomb_0200
* @tc.desc : Verify that the 16-bit wide character representation is converted to a narrow multibyte character
* representation(s parameter NULL). representation.
* @tc.desc : When the s parameter is invalid, test the return value of the function.
* @tc.level : Level 1
*/
void c16rtomb_0200(void)
{
wchar_t str[] = L"";
size_t in_sz = sizeof str / sizeof *str;
int rc = 0;
char out[MB_CUR_MAX * in_sz];
char *p = out;
for (size_t n = 0; n < in_sz; ++n) {
rc = c16rtomb(p, str[n], &state);
p += rc;
}
EXPECT_EQ("c16rtomb_0200", rc, 1);
size_t result = c16rtomb(NULL, L'\0', NULL);
if (result != 1U) {
t_error("%s c16rtomb failed, result is %d\n", __func__, result);
}
result = c16rtomb(NULL, L'h', NULL);
if (result != 1U) {
t_error("%s c16rtomb failed, result is %d\n", __func__, result);
}
}
/**
* @tc.name : c16rtomb_0300
* @tc.desc : Verify that the 16-bit wide character representation cannot be converted to a narrow multibyte
* character representation (s parameter NULL).
* @tc.level : Level 2
* @tc.desc : Test the return value of this function when c16 is equal to 0xdbea.
* @tc.leve : Level 1
*/
void c16rtomb_0300(void)
{
wchar_t str[] = L"";
size_t in_sz = sizeof str / sizeof *str;
int rc = 0;
char out[MB_CUR_MAX * in_sz];
char *p = out;
size_t n = 0;
rc = c16rtomb(p, 0xE000u, NULL);
EXPECT_EQ("c16rtomb_0300", rc, -1);
char bytes[MB_LEN_MAX];
memset(bytes, 0, sizeof(bytes));
size_t result = c16rtomb(bytes, 0xdbea, NULL);
if (result != 0U) {
t_error("%s c16rtomb failed\n", __func__);
}
}
/**
* @tc.name : c16rtomb_0400
* @tc.desc : Verify that the 16-bit wide character representation is converted to a narrow multibyte character
* representation(c16 is 0xD800u,ps parameter NULL).
* @tc.desc : Test the return value of this function when c16 is equal to 0xdfcd.
* @tc.leve : Level 1
*/
void c16rtomb_0400(void)
{
wchar_t str[] = L"test";
size_t in_sz = sizeof str / sizeof *str;
int rc = 0;
char out[MB_CUR_MAX * in_sz];
char *p = out;
for (size_t n = 0; n < in_sz; ++n) {
rc = c16rtomb(p, 0xD800u, NULL);
p += rc;
}
EXPECT_EQ("c16rtomb_0400", rc, 0);
}
char bytes[MB_LEN_MAX];
memset(bytes, 0, sizeof(bytes));
size_t result = c16rtomb(bytes, 0xdfcd, NULL);
if (result != 4U) {
t_error("%s c16rtomb failed\n", __func__);
}
/**
* @tc.name : c16rtomb_0500
* @tc.desc : Verify that the 16-bit wide character representation is converted to a narrow multibyte character
* representation (c16 is 0xDC00u,s parameter NULL).
* @tc.leve : Level 1
*/
void c16rtomb_0500(void)
{
wchar_t str[] = L"test";
size_t in_sz = sizeof str / sizeof *str;
int rc = 0;
char out[MB_CUR_MAX * in_sz];
char *p = out;
for (size_t n = 0; n < in_sz; n++) {
rc = c16rtomb(p, 0xdc00u, NULL);
p += rc;
}
EXPECT_EQ("c16rtomb_0500", rc, -1);
if (bytes[0] != '\xf4') {
t_error("%s bytes[0] is %c, not \'\\xf4\'\n", bytes[0]);
}
if (bytes[1] != '\x8a') {
t_error("%s bytes[0] is %c, not \'\\x8a\'\n", bytes[1]);
}
if (bytes[2] != '\xaf') {
t_error("%s bytes[0] is %c, not \'\\xaf\'\n", bytes[2]);
}
if (bytes[3] != '\x8d') {
t_error("%s bytes[0] is %c, not \'\\x8d\'\n", bytes[3]);
}
}
/**
* @tc.name : c16rtomb_0600
* @tc.desc : Verify that the 16-bit wide character representation cannot be converted to a narrow multibyte
* character representation (c16 is 0xE000u).
* @tc.name : c16rtomb_0500
* @tc.desc : Test the return value of this function when c16 is equal to 0xdfcd.
* @tc.leve : Level 2
*/
void c16rtomb_0600(void)
{
wchar_t str[] = L"test";
size_t in_sz = sizeof str / sizeof *str;
int rc = 0;
char out[MB_CUR_MAX * in_sz];
char *p = out;
for (size_t n = 0; n < in_sz; ++n) {
rc = c16rtomb(p, 0xE000u, &state);
p += rc;
}
EXPECT_EQ("c16rtomb_0600", rc, -1);
}
/**
* @tc.name : c16rtomb_0700
* @tc.desc : Verify that the 16-bit wide character representation is converted to a narrow multibyte character
* representation (c16 is 0xDFFFu).
* @tc.leve : Level 1
*/
void c16rtomb_0700(void)
void c16rtomb_0500(void)
{
wchar_t str[] = L"test";
size_t in_sz = sizeof str / sizeof *str;
int rc = 0;
char out[MB_CUR_MAX * in_sz];
char *p = out;
for (size_t n = 0; n < in_sz; ++n) {
rc = c16rtomb(p, 0xDFFFu, &state);
p += rc;
}
EXPECT_EQ("c16rtomb_0700", rc, 1);
char bytes[MB_LEN_MAX];
memset(bytes, 0, sizeof(bytes));
size_t result = c16rtomb(bytes, 0xdfcd, NULL);
if (result != (size_t)-1) {
t_error("%s c16rtomb failed\n", __func__);
}
}
int main()
int main(int argc, char *argv[])
{
c16rtomb_0100();
c16rtomb_0200();
c16rtomb_0300();
c16rtomb_0400();
c16rtomb_0500();
c16rtomb_0600();
c16rtomb_0700();
return t_status;
}
\ No newline at end of file
......@@ -13,37 +13,153 @@
* limitations under the License.
*/
#include <uchar.h>
#include <wchar.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <limits.h>
#include <locale.h>
#include "functionalext.h"
mbstate_t state;
#include <string.h>
#include <uchar.h>
#include "test.h"
/**
* @tc.name : c32rtomb_0100
* @tc.desc : Verify that the 32-bit wide character representation is converted to a narrow multibyte character
* representation.
* @tc.desc :
* @tc.leve : Level 0
*/
void c32rtomb_0100(void)
{
wchar_t str[] = L"test";
size_t in_sz = sizeof str / sizeof *str;
int rc = 0;
char out[MB_CUR_MAX * in_sz];
char *p = out;
for (size_t n = 0; n < in_sz; ++n) {
rc = c32rtomb(p, str[n], &state);
p += rc;
}
EXPECT_EQ("c32rtomb_0100", rc, 1);
size_t result = c32rtomb(NULL, L'\0', NULL);
if (result != 1U) {
t_error("%s c32rtomb failed\n", __func__);
}
result = c32rtomb(NULL, L'h', NULL);
if (result != 1U) {
t_error("%s c32rtomb failed\n", __func__);
}
}
/**
* @tc.name : c32rtomb_0200
* @tc.desc :
* @tc.leve : Level 0
*/
void c32rtomb_0200(void)
{
char bytes[MB_LEN_MAX];
memset(bytes, 1, sizeof(bytes));
size_t result = c32rtomb(bytes, L'\0', NULL);
if (result != 1U) {
t_error("%s c32rtomb failed\n", __func__);
}
if (bytes[0] != '\0') {
t_error("%s bytes[0] failed\n", __func__);
}
if (bytes[1] != '\x01') {
t_error("%s bytes[1] failed\n", __func__);
}
memset(bytes, 0, sizeof(bytes));
result = c32rtomb(bytes, L'h', NULL);
if (result != 1U) {
t_error("%s c32rtomb failed\n", __func__);
}
if (bytes[0] != 'h') {
t_error("%s bytes[0] failed\n", __func__);
}
}
/**
* @tc.name : c32rtomb_0300
* @tc.desc :
* @tc.leve : Level 0
*/
void c32rtomb_0300(void)
{
char bytes[MB_LEN_MAX];
char *ret = setlocale(LC_CTYPE, "C.UTF-8");
if (strcmp(ret, "C.UTF-8")) {
t_error("%s setlocale failed\n", __func__);
}
uselocale(LC_GLOBAL_LOCALE);
// 1-byte UTF-8.
memset(bytes, 0, sizeof(bytes));
size_t result = c32rtomb(bytes, L'h', NULL);
if (result != 1U) {
t_error("%s c32rtomb failed\n", __func__);
}
if (bytes[0] != 'h') {
t_error("%s bytes[0] failed\n", __func__);
}
// 2-byte UTF-8.
memset(bytes, 0, sizeof(bytes));
result = c32rtomb(bytes, 0x00a2, NULL);
if (result != 2U) {
t_error("%s c32rtomb failed\n", __func__);
}
if (bytes[0] != '\xc2') {
t_error("%s bytes[0] failed\n", __func__);
}
if (bytes[1] != '\xa2') {
t_error("%s bytes[1] failed\n", __func__);
}
// 3-byte UTF-8.
memset(bytes, 0, sizeof(bytes));
result = c32rtomb(bytes, 0x20ac, NULL);
if (result != 3U) {
t_error("%s c32rtomb failed\n", __func__);
}
if (bytes[0] != '\xe2') {
t_error("%s bytes[0] failed\n", __func__);
}
if (bytes[1] != '\x82') {
t_error("%s bytes[1] failed\n", __func__);
}
if (bytes[2] != '\xac') {
t_error("%s bytes[2] failed\n", __func__);
}
// 4-byte UTF-8.
memset(bytes, 0, sizeof(bytes));
result = c32rtomb(bytes, 0x24b62, NULL);
if (result != 4U) {
t_error("%s c32rtomb failed\n", __func__);
}
if (bytes[0] != '\xf0') {
t_error("%s bytes[0] failed\n", __func__);
}
if (bytes[1] != '\xa4') {
t_error("%s bytes[1] failed\n", __func__);
}
if (bytes[2] != '\xad') {
t_error("%s bytes[2] failed\n", __func__);
}
if (bytes[3] != '\xa2') {
t_error("%s bytes[3] failed\n", __func__);
}
}
/**
* @tc.name : c32rtomb_0400
* @tc.desc :
* @tc.leve : Level 2
*/
void c32rtomb_0400(void)
{
char bytes[MB_LEN_MAX];
memset(bytes, 0, sizeof(bytes));
size_t result = c32rtomb(bytes, 0xffffffff, NULL);
if (result != (size_t)-1) {
t_error("%s c32rtomb should be failed\n", __func__);
}
}
int main()
int main(int argc, char *argv[])
{
c32rtomb_0100();
c32rtomb_0200();
c32rtomb_0300();
c32rtomb_0400();
return t_status;
}
\ No newline at end of file
......@@ -380,7 +380,7 @@ void accept4_0600(void)
ret = pthread_barrier_destroy(&g_barrier);
EXPECT_EQ("accept4_0600", SUCCESS, ret);
}
int main()
int main(int argc, char *argv[])
{
accept4_0100();
accept4_0200();
......
......@@ -61,8 +61,7 @@ void dn_comp_0300(void)
{
int result;
char name[1024];
for (int i = 0; i < 260; i++)
{
for (int i = 0; i < 260; i++) {
name[i] = 'w';
}
unsigned char buf[1024] = "\0";
......@@ -112,7 +111,7 @@ void dn_comp_0600(void)
EXPECT_EQ("dn_comp_0600", result, COUNT_FAILED);
}
int main()
int main(int argc, char *argv[])
{
dn_comp_0100();
dn_comp_0200();
......
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <netdb.h>
#include <stdio.h>
#include "test.h"
/**
* @tc.name : freeaddrinfo_0100
* @tc.desc : Frees the memory that was allocated for the dynamically allocated linked list res
* @tc.level : Level 0
*/
void freeaddrinfo_0100(void)
{
char *host = "127.0.0.1";
struct addrinfo *ai;
if (getaddrinfo(host, NULL, NULL, &ai) != 0) {
t_error("%s getaddrinfo failed\n", __func__);
}
if (!ai->ai_flags) {
freeaddrinfo(ai);
while (ai->ai_next) {
if (!ai->ai_flags) {
t_error("%s freeaddrinfo failed\n", __func__);
}
ai = ai->ai_next;
}
} else {
t_error("%s hint is NULL, so ai->ai_flags should be 0, but now is %d\n", __func__, ai->ai_flags);
}
}
int main(int argc, char *argv[])
{
freeaddrinfo_0100();
return t_status;
}
......@@ -30,14 +30,13 @@ void freeifaddrs_0100(void)
freeifaddrs(ifaddr);
ifaddr = NULL;
bool flag = false;
if (ifaddr == NULL)
{
if (ifaddr == NULL) {
flag = true;
}
EXPECT_TRUE("freeifaddrs_0100", flag);
}
int main()
int main(int argc, char *argv[])
{
freeifaddrs_0100();
return t_status;
......
......@@ -21,7 +21,7 @@
* @tc.desc : Verify that the corresponding error message can be returned (parameter is EAI_BADFLAGS)
* @tc.level : Level 0
*/
void gai_strerror_0100()
void gai_strerror_0100(void)
{
const char *result = gai_strerror(EAI_BADFLAGS);
EXPECT_TRUE(gai_strerror_0100, strcmp(result, "Invalid flags\0") == 0);
......@@ -32,7 +32,7 @@ void gai_strerror_0100()
* @tc.desc : Verify that the corresponding error message can be returned (parameter is EAI_NONAME)
* @tc.level : Level 0
*/
void gai_strerror_0200()
void gai_strerror_0200(void)
{
const char *result = gai_strerror(EAI_NONAME);
EXPECT_TRUE(gai_strerror_0200, strcmp(result, "Name does not resolve\0") == 0);
......@@ -43,7 +43,7 @@ void gai_strerror_0200()
* @tc.desc : Verify that the corresponding error message can be returned (parameter is EAI_AGAIN)
* @tc.level : Level 0
*/
void gai_strerror_0300()
void gai_strerror_0300(void)
{
const char *result = gai_strerror(EAI_AGAIN);
EXPECT_TRUE(gai_strerror_0300, strcmp(result, "Try again\0") == 0);
......@@ -54,7 +54,7 @@ void gai_strerror_0300()
* @tc.desc : Verify that the corresponding error message can be returned (parameter is EAI_FAIL)
* @tc.level : Level 0
*/
void gai_strerror_0400()
void gai_strerror_0400(void)
{
const char *result = gai_strerror(EAI_FAIL);
EXPECT_TRUE(gai_strerror_0400, strcmp(result, "Non-recoverable error\0") == 0);
......@@ -65,7 +65,7 @@ void gai_strerror_0400()
* @tc.desc : Verify that the corresponding error message can be returned (parameter is -5)
* @tc.level : Level 1
*/
void gai_strerror_0500()
void gai_strerror_0500(void)
{
const char *result = gai_strerror(-5);
EXPECT_TRUE(gai_strerror_0500, strcmp(result, "Unknown error\0") == 0);
......@@ -76,7 +76,7 @@ void gai_strerror_0500()
* @tc.desc : Verify that the corresponding error message can be returned (parameter is EAI_FAMILY)
* @tc.level : Level 0
*/
void gai_strerror_0600()
void gai_strerror_0600(void)
{
const char *result = gai_strerror(EAI_FAMILY);
EXPECT_TRUE(gai_strerror_0600, strcmp(result, "Unrecognized address family or invalid length\0") == 0);
......@@ -87,7 +87,7 @@ void gai_strerror_0600()
* @tc.desc : Verify that the corresponding error message can be returned (parameter is EAI_SOCKTYPE)
* @tc.level : Level 0
*/
void gai_strerror_0700()
void gai_strerror_0700(void)
{
const char *result = gai_strerror(EAI_SOCKTYPE);
EXPECT_TRUE(gai_strerror_0700, strcmp(result, "Unrecognized socket type\0") == 0);
......@@ -98,7 +98,7 @@ void gai_strerror_0700()
* @tc.desc : Verify that the corresponding error message can be returned (parameter is EAI_SERVICE)
* @tc.level : Level 0
*/
void gai_strerror_0800()
void gai_strerror_0800(void)
{
const char *result = gai_strerror(EAI_SERVICE);
EXPECT_TRUE(gai_strerror_0800, strcmp(result, "Unrecognized service\0") == 0);
......@@ -109,7 +109,7 @@ void gai_strerror_0800()
* @tc.desc : Verify that the corresponding error message can be returned (parameter is -9)
* @tc.level : Level 1
*/
void gai_strerror_0900()
void gai_strerror_0900(void)
{
const char *result = gai_strerror(-9);
EXPECT_TRUE(gai_strerror_0900, strcmp(result, "Unknown error\0") == 0);
......@@ -120,7 +120,7 @@ void gai_strerror_0900()
* @tc.desc : Verify that the corresponding error message can be returned (parameter is EAI_MEMORY)
* @tc.level : Level 0
*/
void gai_strerror_1000()
void gai_strerror_1000(void)
{
const char *result = gai_strerror(EAI_MEMORY);
EXPECT_TRUE(gai_strerror_1000, strcmp(result, "Out of memory\0") == 0);
......@@ -131,7 +131,7 @@ void gai_strerror_1000()
* @tc.desc : Verify that the corresponding error message can be returned (parameter is EAI_SYSTEM)
* @tc.level : Level 0
*/
void gai_strerror_1100()
void gai_strerror_1100(void)
{
const char *result = gai_strerror(EAI_SYSTEM);
EXPECT_TRUE(gai_strerror_1100, strcmp(result, "System error\0") == 0);
......@@ -142,7 +142,7 @@ void gai_strerror_1100()
* @tc.desc : Verify that the corresponding error message can be returned (parameter is EAI_OVERFLOW)
* @tc.level : Level 0
*/
void gai_strerror_1200()
void gai_strerror_1200(void)
{
const char *result = gai_strerror(EAI_OVERFLOW);
EXPECT_TRUE(gai_strerror_1200, strcmp(result, "Overflow\0") == 0);
......@@ -153,13 +153,13 @@ void gai_strerror_1200()
* @tc.desc : Verify that the corresponding error message can be returned (parameter is -13)
* @tc.level : Level 1
*/
void gai_strerror_1300()
void gai_strerror_1300(void)
{
const char *result = gai_strerror(-13);
EXPECT_TRUE(gai_strerror_1300, strcmp(result, "Unknown error\0") == 0);
}
int main()
int main(int argc, char *argv[])
{
gai_strerror_0100();
gai_strerror_0200();
......
......@@ -339,7 +339,7 @@ void getaddrinfo_1500(void)
EXPECT_EQ("getaddrinfo_1500", ret, SOCKTYPE_NOTSUPPORTED);
}
int main()
int main(int argc, char *argv[])
{
getaddrinfo_0100();
getaddrinfo_0200();
......
......@@ -33,7 +33,7 @@ void gethostent_0100(void)
endhostent();
}
int main()
int main(int argc, char *argv[])
{
gethostent_0100();
return t_status;
......
......@@ -32,7 +32,7 @@ void getifaddrs_0100(void)
ifaddr = NULL;
}
int main()
int main(int argc, char *argv[])
{
getifaddrs_0100();
return t_status;
......
......@@ -31,7 +31,7 @@ void getnetent_0100(void)
ret = NULL;
}
int main()
int main(int argc, char *argv[])
{
getnetent_0100();
return t_status;
......
......@@ -120,7 +120,7 @@ void getpeername_0100()
}
TEST_FUN G_Fun_Array[] = {getpeername_0100};
int main()
int main(int argc, char *argv[])
{
int num = sizeof(G_Fun_Array) / sizeof(TEST_FUN);
for (int pos = 0; pos < num; ++pos) {
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册