• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ATF_REQUIRE函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ATF_REQUIRE函数的典型用法代码示例。如果您正苦于以下问题:C++ ATF_REQUIRE函数的具体用法?C++ ATF_REQUIRE怎么用?C++ ATF_REQUIRE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ATF_REQUIRE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: ATF_TC_BODY

ATF_TC_BODY(hexadecimal_rounding, tc)
{

    ATF_REQUIRE(setlocale(LC_NUMERIC, "C"));

    fesetround(FE_TOWARDZERO);
    testfmt("0X1.23456789ABCP+0", "%.11A", 0x1.23456789abcdep0);
    testfmt("-0x1.23456p+0", "%.5a", -0x1.23456789abcdep0);
    testfmt("0x1.23456p+0", "%.5a", 0x1.23456789abcdep0);
    testfmt("0x1.234567p+0", "%.6a", 0x1.23456789abcdep0);
    testfmt("-0x1.234566p+0", "%.6a", -0x1.23456689abcdep0);

    fesetround(FE_DOWNWARD);
    testfmt("0X1.23456789ABCP+0", "%.11A", 0x1.23456789abcdep0);
    testfmt("-0x1.23457p+0", "%.5a", -0x1.23456789abcdep0);
    testfmt("0x1.23456p+0", "%.5a", 0x1.23456789abcdep0);
    testfmt("0x1.234567p+0", "%.6a", 0x1.23456789abcdep0);
    testfmt("-0x1.234567p+0", "%.6a", -0x1.23456689abcdep0);

    fesetround(FE_UPWARD);
    testfmt("0X1.23456789ABDP+0", "%.11A", 0x1.23456789abcdep0);
    testfmt("-0x1.23456p+0", "%.5a", -0x1.23456789abcdep0);
    testfmt("0x1.23457p+0", "%.5a", 0x1.23456789abcdep0);
    testfmt("0x1.234568p+0", "%.6a", 0x1.23456789abcdep0);
    testfmt("-0x1.234566p+0", "%.6a", -0x1.23456689abcdep0);

    fesetround(FE_TONEAREST);
    testfmt("0x1.23456789abcdep+4", "%a", 0x1.23456789abcdep4);
    testfmt("0X1.23456789ABDP+0", "%.11A", 0x1.23456789abcdep0);
    testfmt("-0x1.23456p+0", "%.5a", -0x1.23456789abcdep0);
    testfmt("0x1.23456p+0", "%.5a", 0x1.23456789abcdep0);
    testfmt("0x1.234568p+0", "%.6a", 0x1.23456789abcdep0);
    testfmt("-0x1.234567p+0", "%.6a", -0x1.23456689abcdep0);
    testfmt("0x1.00p-1029", "%.2a", 0x1.fffp-1030);
    testfmt("0x1.00p-1026", "%.2a", 0xf.fffp-1030);
    testfmt("0x1.83p+0", "%.2a", 1.51);
}
开发者ID:jaredmcneill,项目名称:freebsd,代码行数:37,代码来源:printfloat_test.c


示例2: ATF_TC_BODY

ATF_TC_BODY(current_path__enoent, tc)
{
    char* previous;
    ATF_REQUIRE(!kyua_error_is_set(kyua_fs_current_path(&previous)));

    ATF_REQUIRE(mkdir("root", 0755) != -1);
    ATF_REQUIRE(chdir("root") != -1);
    ATF_REQUIRE(rmdir("../root") != -1);
    char* cwd = (char*)0xdeadbeef;
    kyua_error_t error = kyua_fs_current_path(&cwd);
    ATF_REQUIRE(kyua_error_is_set(error));
    ATF_REQUIRE(kyua_error_is_type(error, "libc"));
    ATF_REQUIRE_EQ(ENOENT, kyua_libc_error_errno(error));
    ATF_REQUIRE_EQ((char*)0xdeadbeef, cwd);
    kyua_error_free(error);

    free(previous);
}
开发者ID:phoatfreebsd,项目名称:kyua,代码行数:18,代码来源:fs_test.c


示例3: ATF_TC_BODY

ATF_TC_BODY(setlogin_perm, tc)
{
	char *name;
	pid_t pid;
	int sta;

	pid = fork();
	ATF_REQUIRE(pid >= 0);

	if (pid == 0) {

		(void)setsid();

		errno = 0;

		if (setlogin("foobar") != -1)
			_exit(EXIT_FAILURE);

		if (errno != EPERM)
			_exit(EXIT_FAILURE);

		name = getlogin();

		if (name == NULL)
			_exit(EXIT_FAILURE);

		if (strcmp(name, "foobar") == 0)
			_exit(EXIT_FAILURE);

		_exit(EXIT_SUCCESS);
	}

	(void)wait(&sta);

	if (WIFEXITED(sta) == 0 || WEXITSTATUS(sta) != EXIT_SUCCESS)
		atf_tc_fail("login name was set as an unprivileged user");
}
开发者ID:2asoft,项目名称:freebsd,代码行数:37,代码来源:t_getlogin.c


示例4: ATF_TC_BODY

ATF_TC_BODY(require_errno, tc)
{
    struct test {
        void (*head)(atf_tc_t *);
        void (*body)(const atf_tc_t *);
        bool ok;
        const char *exp_regex;
    } *t, tests[] = {
        { H_REQUIRE_ERRNO_HEAD_NAME(no_error),
          H_REQUIRE_ERRNO_BODY_NAME(no_error),
          false, "Expected true value in errno_ok_stub\\(\\) == -1" },
        { H_REQUIRE_ERRNO_HEAD_NAME(errno_ok),
          H_REQUIRE_ERRNO_BODY_NAME(errno_ok),
          true, NULL },
        { H_REQUIRE_ERRNO_HEAD_NAME(errno_fail),
          H_REQUIRE_ERRNO_BODY_NAME(errno_fail),
          false, "Expected errno 3, got 4, in errno_fail_stub\\(4\\) == -1" },
        { NULL, NULL, false, NULL }
    };

    for (t = &tests[0]; t->head != NULL; t++) {
        init_and_run_h_tc("h_require_errno", t->head, t->body);

        ATF_REQUIRE(exists("before"));
        if (t->ok) {
            ATF_REQUIRE(atf_utils_grep_file("^passed", "result"));
            ATF_REQUIRE(exists("after"));
        } else {
            ATF_REQUIRE(atf_utils_grep_file(
                "^failed: .*macros_test.c:[0-9]+: %s$", "result",
                t->exp_regex));
            ATF_REQUIRE(!exists("after"));
        }

        ATF_REQUIRE(unlink("before") != -1);
        if (t->ok)
            ATF_REQUIRE(unlink("after") != -1);
    }
}
开发者ID:Henauxg,项目名称:minix,代码行数:39,代码来源:macros_test.c


示例5: ATF_TC_BODY

ATF_TC_BODY(config, tcin)
{
    atf_tc_t tc;
    const char *const config[] = { "test-var", "test-value", NULL };

    RE(atf_tc_init(&tc, "test1", ATF_TC_HEAD_NAME(empty),
                   ATF_TC_BODY_NAME(empty), NULL, NULL));
    ATF_REQUIRE(!atf_tc_has_config_var(&tc, "test-var"));
    ATF_REQUIRE(!atf_tc_has_md_var(&tc, "test-var"));
    atf_tc_fini(&tc);

    RE(atf_tc_init(&tc, "test1", ATF_TC_HEAD_NAME(empty),
                   ATF_TC_BODY_NAME(empty), NULL, config));
    ATF_REQUIRE(atf_tc_has_config_var(&tc, "test-var"));
    ATF_REQUIRE(strcmp(atf_tc_get_config_var(&tc, "test-var"),
                     "test-value") == 0);
    ATF_REQUIRE(!atf_tc_has_md_var(&tc, "test-var"));
    ATF_REQUIRE(!atf_tc_has_config_var(&tc, "test-var2"));
    ATF_REQUIRE(strcmp(atf_tc_get_config_var_wd(&tc, "test-var2", "def-value"),
                     "def-value") == 0);
    atf_tc_fini(&tc);
}
开发者ID:jaredmcneill,项目名称:netbsd-src,代码行数:22,代码来源:tc_test.c


示例6: ATF_TC_BODY

ATF_TC_BODY(sigio, tc)
{
	struct sockaddr_in sin;
	int ls;
	int cs;
	int fl;
	int sc;

	signal(SIGIO, gotsig);
	RZ(system("rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet "
	    RUMPSERV));
	RL(setenv("RUMP_SERVER", RUMPSERV, 1));

	RL(rumpclient_init());
	RL(ls = rump_sys_socket(PF_INET, SOCK_STREAM, 0));

	RL(rump_sys_fcntl(ls, F_SETOWN, rump_sys_getpid()));
	RL(fl = rump_sys_fcntl(ls, F_GETFL));
	RL(rump_sys_fcntl(ls, F_SETFL, fl | O_ASYNC));

	memset(&sin, 0, sizeof(sin));
	sin.sin_len = sizeof(sin);
	sin.sin_family = AF_INET;
	sin.sin_port = htons(12345);
	RL(rump_sys_bind(ls, (struct sockaddr *)&sin, sizeof(sin)));
	RL(rump_sys_listen(ls, 5));

	RL(cs = rump_sys_socket(PF_INET, SOCK_STREAM, 0));
	sin.sin_addr.s_addr = inet_addr("127.0.0.1");

	ATF_REQUIRE_EQ(sigcnt, 0);
	RL(rump_sys_connect(cs, (struct sockaddr *)&sin, sizeof(sin)));
	sc = sigcnt;
	printf("sigcnt after connect: %d\n", sc);
	ATF_REQUIRE(sc >= 1);
}
开发者ID:2asoft,项目名称:freebsd,代码行数:36,代码来源:t_fd.c


示例7: ATF_TC_BODY

ATF_TC_BODY(fpclassify_float, tc)
{
	float d0, d1, d2, f, ip;
	int e, i;

	d0 = FLT_MIN;
	ATF_REQUIRE_EQ(fpclassify(d0), FP_NORMAL);
	f = frexpf(d0, &e);
	ATF_REQUIRE_EQ(e, FLT_MIN_EXP);
	ATF_REQUIRE_EQ(f, 0.5);
	d1 = d0;

	/* shift a "1" bit through the mantissa (skip the implicit bit) */
	for (i = 1; i < FLT_MANT_DIG; i++) {
		d1 /= 2;
		ATF_REQUIRE_EQ(fpclassify(d1), FP_SUBNORMAL);
		ATF_REQUIRE(d1 > 0 && d1 < d0);

		d2 = ldexpf(d0, -i);
		ATF_REQUIRE_EQ(d2, d1);

		d2 = modff(d1, &ip);
		ATF_REQUIRE_EQ(d2, d1);
		ATF_REQUIRE_EQ(ip, 0);

		f = frexpf(d1, &e);
		ATF_REQUIRE_EQ(e, FLT_MIN_EXP - i);
		ATF_REQUIRE_EQ(f, 0.5);
	}

	d1 /= 2;
	ATF_REQUIRE_EQ(fpclassify(d1), FP_ZERO);
	f = frexpf(d1, &e);
	ATF_REQUIRE_EQ(e, 0);
	ATF_REQUIRE_EQ(f, 0);
}
开发者ID:2asoft,项目名称:freebsd,代码行数:36,代码来源:t_fpclassify.c


示例8: ATF_TC_BODY

ATF_TC_BODY(check_parsing, tc)
{
    struct pkg_dep_formula *f;
    const char *cases[] = {
        "name",
        "name = 1.0",
        "name >= 1.0,1",
        "name1, name2",
        "name1 | name2, name3",
        "name1 = 1.0 | name2 != 1.0, name3 > 1.0 < 2.0 != 1.5",
        "name1 = 1.0 | name2 != 1.0, name3 > 1.0 < 2.0 != 1.5, name4 +opt1 -opt2"
    };
    char *r;
    int i;

    for (i = 0; i < sizeof(cases) / sizeof(cases[0]); i ++) {
        f = pkg_deps_parse_formula(cases[i]);
        ATF_REQUIRE(f != NULL);
        r = pkg_deps_formula_tostring(f);
        ATF_REQUIRE_STREQ(r, cases[i]);
        free(r);
        pkg_deps_formula_free(f);
    }
}
开发者ID:neirbowj,项目名称:pkg,代码行数:24,代码来源:deps_formula.c


示例9: ATF_TC_BODY

ATF_TC_BODY(pkg_current_state_remote, tc)
{
	struct pkg     *package;

	package = gen_pkg(PKG_REMOTE);
	ATF_REQUIRE(package != NULL);

	/* Old version newer -> available */
	pkg_set(package, PKG_OLD_VERSION, "1.2.3");
	ATF_CHECK_EQ(pkgutils_pkg_current_state(package),
	    PK_INFO_ENUM_AVAILABLE);

	/* Old version the same -> installed */
	pkg_set(package, PKG_OLD_VERSION, "1.1.4");
	ATF_CHECK_EQ(pkgutils_pkg_current_state(package),
	    PK_INFO_ENUM_INSTALLED);

	/* Old version older -> available */
	pkg_set(package, PKG_OLD_VERSION, "1.0.0");
	ATF_CHECK_EQ(pkgutils_pkg_current_state(package),
	    PK_INFO_ENUM_AVAILABLE);

	pkg_free(package);
}
开发者ID:CaptainHayashi,项目名称:pkgng-packagekit,代码行数:24,代码来源:pkgutils_test.c


示例10: symlink_len

/*
 * Test creating a symlink whose length is "len" bytes, not including
 * the terminating NUL.
 */
static void
symlink_len(const atf_tc_t *tc, const char *mp, size_t len)
{
	char *buf;
	int r;

	USES_SYMLINKS;

	RL(rump_sys_chdir(mp));

	buf = malloc(len + 1);
	ATF_REQUIRE(buf);
	memset(buf, 'a', len);
	buf[len] = '\0';
	r = rump_sys_symlink(buf, "afile");
	if (r == -1) {
		ATF_REQUIRE_ERRNO(ENAMETOOLONG, r);
	} else {
		RL(rump_sys_unlink("afile"));
	}
	free(buf);

	RL(rump_sys_chdir("/"));
}
开发者ID:2asoft,项目名称:freebsd,代码行数:28,代码来源:t_vnops.c


示例11: ATF_TC_BODY

ATF_TC_BODY(inet_addr_err, tc)
{
	static const char *addrs[] = {
		". . . .", "1.2.3.", "0.0.0.256", "255.255.255.256",
		"................................................",
		"a.b.c.d", "0x0.0x1.0x2.0x3", "-1.-1.-1.-1", "", " "};

	struct in_addr ia;
	const char *ian;
	in_addr_t addr;
	size_t i;

	for (i = 0; i < __arraycount(addrs); i++) {

		(void)fprintf(stderr, "checking %s\n", addrs[i]);;

		addr = inet_addr(addrs[i]);
		ia.s_addr = addr;
		ian = inet_ntoa(ia);

		ATF_REQUIRE(ian != NULL);
		ATF_CHECK(strcmp(ian, addrs[i]) != 0);
	}
}
开发者ID:2trill2spill,项目名称:freebsd,代码行数:24,代码来源:t_inet_addr.c


示例12: ATF_TC_BODY

ATF_TC_BODY(mmap_loan, tc)
{
	char buf[BUFSIZE];
	char *vp, *vp2;
	int fd;

	fd = open(path, O_RDWR | O_CREAT, 0600);
	ATF_REQUIRE(fd >= 0);

	(void)memset(buf, 'x', sizeof(buf));
	(void)write(fd, buf, sizeof(buf));

	vp = mmap(NULL, BUFSIZE, PROT_READ | PROT_WRITE,
	    MAP_FILE | MAP_PRIVATE, fd, 0);

	ATF_REQUIRE(vp != MAP_FAILED);

	vp2 = vp;

	testloan(vp, vp2, 'A', 0);
	testloan(vp, vp2, 'B', 1);

	ATF_REQUIRE(munmap(vp, BUFSIZE) == 0);

	vp = mmap(NULL, BUFSIZE, PROT_READ | PROT_WRITE,
	    MAP_FILE | MAP_SHARED, fd, 0);

	vp2 = mmap(NULL, BUFSIZE, PROT_READ | PROT_WRITE,
	    MAP_FILE | MAP_SHARED, fd, 0);

	ATF_REQUIRE(vp != MAP_FAILED);
	ATF_REQUIRE(vp2 != MAP_FAILED);

	testloan(vp, vp2, 'E', 1);

	ATF_REQUIRE(munmap(vp, BUFSIZE) == 0);
	ATF_REQUIRE(munmap(vp2, BUFSIZE) == 0);
}
开发者ID:jaredmcneill,项目名称:freebsd,代码行数:38,代码来源:t_mmap.c


示例13: ATF_TC_BODY

ATF_TC_BODY(error_new, tc)
{
    atf_error_t err;
    int data;

    err = atf_error_new("test_error", NULL, 0, NULL);
    ATF_REQUIRE(atf_error_is(err, "test_error"));
    ATF_REQUIRE(!atf_error_is(err, "unknown_error"));
    ATF_REQUIRE(atf_error_data(err) == NULL);
    atf_error_free(err);

    data = 5;
    err = atf_error_new("test_data_error", &data, sizeof(data), NULL);
    ATF_REQUIRE(atf_error_is(err, "test_data_error"));
    ATF_REQUIRE(!atf_error_is(err, "unknown_error"));
    ATF_REQUIRE(atf_error_data(err) != NULL);
    ATF_REQUIRE_EQ(*((const int *)atf_error_data(err)), 5);
    atf_error_free(err);
}
开发者ID:Stichting-MINIX-Research-Foundation,项目名称:minix,代码行数:19,代码来源:error_test.c


示例14: ATF_TC_BODY

ATF_TC_BODY(fdopen_seek, tc)
{
	FILE *f;
	int fd;

	/*
	 * Verify that the file position associated
	 * with the stream corresponds with the offset
	 * set earlier for the file descriptor.
	 */
	fd = open(path, O_RDWR | O_CREAT);

	ATF_REQUIRE(fd >= 0);
	ATF_REQUIRE(write(fd, "garbage", 7) == 7);
	ATF_REQUIRE(lseek(fd, 3, SEEK_SET) == 3);

	f = fdopen(fd, "r+");

	ATF_REQUIRE(f != NULL);
	ATF_REQUIRE(ftell(f) == 3);
	ATF_REQUIRE(fclose(f) == 0);
	ATF_REQUIRE(unlink(path) == 0);
}
开发者ID:Hooman3,项目名称:minix,代码行数:23,代码来源:t_fopen.c


示例15: ATF_TC_BODY

ATF_TC_BODY(strtod_hex, tc)
{
	const char *str;
	char *end;
	volatile double d;

	str = "-0x0";
	d = strtod(str, &end);	/* -0.0 */

	ATF_REQUIRE(end == str + 4);
	ATF_REQUIRE(signbit(d) != 0);
	ATF_REQUIRE(fabs(d) < SMALL_NUM);

	str = "-0x";
	d = strtod(str, &end);	/* -0.0 */

	ATF_REQUIRE(end == str + 2);
	ATF_REQUIRE(signbit(d) != 0);
	ATF_REQUIRE(fabs(d) < SMALL_NUM);
}
开发者ID:Stichting-MINIX-Research-Foundation,项目名称:minix,代码行数:20,代码来源:t_strtod.c


示例16: ATF_TC_BODY

ATF_TC_BODY(t_parser_test2, tc)
{
	saslc_t *ctx;
	saslc_sess_t *sess;
	const char *val;

	ATF_REQUIRE(ctx = saslc_alloc());
	ATF_CHECK_EQ(saslc_init(ctx, "test2", NULL), 0);
	ATF_REQUIRE((sess = saslc_sess_init(ctx, "ANONYMOUS", NULL)));
	ATF_REQUIRE(val = saslc_sess_getprop(sess, "TEST"));
	ATF_CHECK_STREQ(val, "one");
	ATF_REQUIRE(val = saslc_sess_getprop(sess, "TEST2"));
	ATF_CHECK_STREQ(val, "one two");
	ATF_REQUIRE(val = saslc_sess_getprop(sess, "TEST3"));
	ATF_CHECK_STREQ(val, "one two three");
	ATF_REQUIRE(val = saslc_sess_getprop(sess, "ID"));
	ATF_CHECK_STREQ(val, "6669");
	saslc_sess_end(sess);
	ATF_REQUIRE_EQ(saslc_end(ctx), 0);
}
开发者ID:Henauxg,项目名称:minix,代码行数:20,代码来源:t_parser.c


示例17: ATF_TC_BODY

ATF_TC_BODY(closefrom_basic, tc)
{
	int fd, cur1, cur2;

	(void)closefrom(STDERR_FILENO + 1);

	fd = open(path, O_RDONLY | O_CREAT, 0400);
	ATF_REQUIRE(fd >= 0);

	cur1 = fcntl(0, F_MAXFD);

	ATF_REQUIRE(cur1 == STDERR_FILENO + 1);
	ATF_REQUIRE(closefrom(cur1) == 0);

	cur2 = fcntl(0, F_MAXFD);

	ATF_REQUIRE(cur1 - 1 == cur2);
	ATF_REQUIRE(close(fd) == -1);
	ATF_REQUIRE(unlink(path) == 0);
}
开发者ID:2asoft,项目名称:freebsd,代码行数:20,代码来源:t_closefrom.c


示例18: ATF_TC_BODY

ATF_TC_BODY(stat_chflags, tc)
{
	struct stat sa, sb;
	int fd;

	(void)memset(&sa, 0, sizeof(struct stat));
	(void)memset(&sb, 0, sizeof(struct stat));

	fd = open(path, O_RDONLY | O_CREAT);

	ATF_REQUIRE(fd != -1);
	ATF_REQUIRE(stat(path, &sa) == 0);
	ATF_REQUIRE(chflags(path, UF_NODUMP) == 0);
	ATF_REQUIRE(stat(path, &sb) == 0);

	if (sa.st_flags == sb.st_flags)
		atf_tc_fail("stat(2) did not detect chflags(2)");

	ATF_REQUIRE(close(fd) == 0);
	ATF_REQUIRE(unlink(path) == 0);
}
开发者ID:Lxg1582,项目名称:freebsd,代码行数:21,代码来源:t_stat.c


示例19: ATF_TC_BODY

ATF_TC_BODY(link_err, tc)
{
	char buf[MAXPATHLEN + 1];
	int fd;

	(void)memset(buf, 'x', sizeof(buf));

	pathl = getpath();
	fd = open(path, O_RDWR | O_CREAT, 0600);

	ATF_REQUIRE(fd >= 0);
	ATF_REQUIRE(pathl != NULL);

	errno = 0;
	ATF_REQUIRE(link(path, pathl) == 0);
	ATF_REQUIRE_ERRNO(EEXIST, link(path, pathl) == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(ENAMETOOLONG, link(buf, "xxx") == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(ENOENT, link(path, "/d/c/b/a") == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(ENOENT, link("/a/b/c/d", path) == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(ENOENT, link("/a/b/c/d", "/d/c/b/a") == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(EFAULT, link(path, (const char *)-1) == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(EFAULT, link((const char *)-1, "xxx") == -1);

	ATF_REQUIRE(close(fd) == 0);
	ATF_REQUIRE(unlink(path) == 0);
	ATF_REQUIRE(unlink(pathl) == 0);
}
开发者ID:Stichting-MINIX-Research-Foundation,项目名称:minix,代码行数:39,代码来源:t_link.c


示例20: clone_group

static void
clone_group(struct group *dest, struct group const *src)
{
	ATF_REQUIRE(dest != NULL);
	ATF_REQUIRE(src != NULL);

	char **cp;
	int members_num;

	memset(dest, 0, sizeof(struct group));

	if (src->gr_name != NULL) {
		dest->gr_name = strdup(src->gr_name);
		ATF_REQUIRE(dest->gr_name != NULL);
	}

	if (src->gr_passwd != NULL) {
		dest->gr_passwd = strdup(src->gr_passwd);
		ATF_REQUIRE(dest->gr_passwd != NULL);
	}
	dest->gr_gid = src->gr_gid;

	if (src->gr_mem != NULL) {
		members_num = 0;
		for (cp = src->gr_mem; *cp; ++cp)
			++members_num;

		dest->gr_mem = calloc(1, (members_num + 1) * sizeof(char *));
		ATF_REQUIRE(dest->gr_mem != NULL);

		for (cp = src->gr_mem; *cp; ++cp) {
			dest->gr_mem[cp - src->gr_mem] = strdup(*cp);
			ATF_REQUIRE(dest->gr_mem[cp - src->gr_mem] != NULL);
		}
	}
}
开发者ID:2asoft,项目名称:freebsd,代码行数:36,代码来源:getgr_test.c



注:本文中的ATF_REQUIRE函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ATF_REQUIRE_EQ函数代码示例发布时间:2022-05-30
下一篇:
C++ ATF_CHECK_EQ函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap