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

C++ ATF_REQUIRE_ERRNO函数代码示例

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

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



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

示例1: ATF_TC_BODY

ATF_TC_BODY(msgctl_err, tc)
{
	const int cmd[] = { IPC_STAT, IPC_SET, IPC_RMID };
	struct msqid_ds msgds;
	size_t i;
	int id;

	(void)memset(&msgds, 0, sizeof(struct msqid_ds));

	id = msgget(MSG_KEY, IPC_CREAT | 0600);
	ATF_REQUIRE(id != -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(EINVAL, msgctl(id, INT_MAX, &msgds) == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(EFAULT, msgctl(id, IPC_STAT, (void *)-1) == -1);

	for (i = 0; i < __arraycount(cmd); i++) {
		errno = 0;
		ATF_REQUIRE_ERRNO(EINVAL, msgctl(-1, cmd[i], &msgds) == -1);
	}

	ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0);
}
开发者ID:Stichting-MINIX-Research-Foundation,项目名称:minix,代码行数:25,代码来源:t_msgctl.c


示例2: ATF_TC_BODY

ATF_TC_BODY(key, tc)
{

	RZ(rump_init());

	RL(open("hostfile", O_RDWR | O_CREAT, 0777));

	RZ(rump_pub_etfs_register("/key", "hostfile", RUMP_ETFS_REG));
	ATF_REQUIRE_EQ(rump_pub_etfs_register("key", "hostfile", RUMP_ETFS_REG),
	    EINVAL);

	RL(rump_sys_open("/key", O_RDONLY));
	RL(rump_sys_open("////////key", O_RDONLY));

	RZ(rump_pub_etfs_register("////key//with/slashes", "hostfile",
	    RUMP_ETFS_REG));

	RL(rump_sys_open("/key//with/slashes", O_RDONLY));
	RL(rump_sys_open("key//with/slashes", O_RDONLY));
	ATF_REQUIRE_ERRNO(ENOENT,
	    rump_sys_open("/key/with/slashes", O_RDONLY) == -1);

	RL(rump_sys_mkdir("/a", 0777));
	ATF_REQUIRE_ERRNO(ENOENT,
	    rump_sys_open("/a/key//with/slashes", O_RDONLY) == -1);
}
开发者ID:2asoft,项目名称:freebsd,代码行数:26,代码来源:t_etfs.c


示例3: ATF_TC_BODY

ATF_TC_BODY(mkfifo_err, tc)
{
	char buf[PATH_MAX + 1];

	support();

	(void)memset(buf, 'x', sizeof(buf));
	ATF_REQUIRE(mkfifo(path, 0600) == 0);

	errno = 0;
	ATF_REQUIRE_ERRNO(EFAULT, mkfifo((char *)-1, 0600) == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(EEXIST, mkfifo("/etc/passwd", 0600) == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(EEXIST, mkfifo(path, 0600) == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(ENAMETOOLONG, mkfifo(buf, 0600) == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(ENOENT, mkfifo("/a/b/c/d/e/f/g", 0600) == -1);

	ATF_REQUIRE(unlink(path) == 0);
}
开发者ID:2asoft,项目名称:freebsd,代码行数:26,代码来源:t_mkfifo.c


示例4: ATF_TC_BODY

ATF_TC_BODY(write_err, tc)
{
	char rbuf[3] = { 'a', 'b', 'c' };
	char wbuf[3] = { 'x', 'y', 'z' };
	int fd;

	errno = 0;
	ATF_REQUIRE_ERRNO(EBADF, write(-1, wbuf, sizeof(wbuf)) == -1);

	fd = open(path, O_RDWR | O_CREAT);

	if (fd >= 0) {

		errno = 0;
		ATF_REQUIRE_ERRNO(0, write(fd, wbuf, 3) == 3);

		errno = 0;
		ATF_REQUIRE_ERRNO(EINVAL, write(fd, wbuf, SIZE_MAX) == -1);

		errno = 0;
		ATF_REQUIRE_ERRNO(EFAULT, write(fd, (void *)-1, 1) == -1);

		/*
		 * Check that the above bogus write(2)
		 * calls did not corrupt the file.
		 */
		ATF_REQUIRE(lseek(fd, 0, SEEK_SET) == 0);
		ATF_REQUIRE(read(fd, rbuf, 3) == 3);
		ATF_REQUIRE(memcmp(rbuf, wbuf, 3) == 0);

		(void)close(fd);
		(void)unlink(path);
	}
}
开发者ID:Hooman3,项目名称:minix,代码行数:34,代码来源:t_write.c


示例5: ATF_TC_BODY

ATF_TC_BODY(mknod_err, tc)
{
    char buf[PATH_MAX + 1];

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

#ifndef __FreeBSD__
    /*
     * As of FreeBSD 6.0 device nodes may be created in regular file systems but
     * such nodes cannot be used to access devices. As a result an invalid dev
     * argument is unchecked.
     */
    errno = 0;
    ATF_REQUIRE_ERRNO(EINVAL, mknod(path, S_IFCHR, -1) == -1);
#endif

    errno = 0;
    ATF_REQUIRE_ERRNO(ENAMETOOLONG, mknod(buf, S_IFCHR, 0) == -1);

    errno = 0;
    ATF_REQUIRE_ERRNO(EFAULT, mknod((char *)-1, S_IFCHR, 0) == -1);

    errno = 0;
    ATF_REQUIRE_ERRNO(ENOENT, mknod("/a/b/c/d/e/f/g", S_IFCHR, 0) == -1);
}
开发者ID:cyrilmagsuci,项目名称:freebsd,代码行数:25,代码来源:t_mknod.c


示例6: ATF_TC_BODY

ATF_TC_BODY(bigenough, tc)
{
	struct stat sb;

	RZ(system("rump_server " RUMPSERV));
	RL(setenv("RUMP_SERVER", RUMPSERV, 1));

	RL(dup2(0, 10));
	RL(dup2(1, 11));
	RL(dup2(2, 12));

	RL(close(0));
	RL(close(1));
	RL(close(2));

	RL(rumpclient_init());
	RL(rump_sys_getpid());

	ATF_REQUIRE_ERRNO(EBADF, fstat(0, &sb) == -1);
	ATF_REQUIRE_ERRNO(EBADF, fstat(1, &sb) == -1);
	ATF_REQUIRE_ERRNO(EBADF, fstat(2, &sb) == -1);

	RL(rump_sys_getpid());

	/* restore these.  does it help? */
	dup2(10, 0);
	dup2(11, 1);
	dup2(12, 2);
}
开发者ID:2asoft,项目名称:freebsd,代码行数:29,代码来源:t_fd.c


示例7: ATF_TC_BODY

ATF_TC_BODY(msgsnd_err, tc)
{
	struct msg msg = { MSG_MTYPE_1, { 'a', 'b', 'c' } };
	int id;

	id = msgget(MSG_KEY, IPC_CREAT | 0600);
	ATF_REQUIRE(id != -1);

	errno = 0;

	ATF_REQUIRE_ERRNO(EFAULT, msgsnd(id, (void *)-1,
		sizeof(struct msg), IPC_NOWAIT) == -1);

	errno = 0;

	ATF_REQUIRE_ERRNO(EINVAL, msgsnd(-1, &msg,
		sizeof(struct msg), IPC_NOWAIT) == -1);

	errno = 0;

	ATF_REQUIRE_ERRNO(EINVAL, msgsnd(-1, &msg,
		SSIZE_MAX, IPC_NOWAIT) == -1);

	errno = 0;
	msg.mtype = 0;

	ATF_REQUIRE_ERRNO(EINVAL, msgsnd(id, &msg,
		sizeof(struct msg), IPC_NOWAIT) == -1);

	ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0);
}
开发者ID:Lxg1582,项目名称:freebsd,代码行数:31,代码来源:t_msgsnd.c


示例8: ATF_TC_BODY

ATF_TC_BODY(fopen_perm, tc)
{

	errno = 0;
	ATF_REQUIRE_ERRNO(EACCES, fopen("/bin/ls", "a+") == NULL);

	errno = 0;
	ATF_REQUIRE_ERRNO(EACCES, fopen("/bin/ls", "w+") == NULL);
}
开发者ID:Hooman3,项目名称:minix,代码行数:9,代码来源:t_fopen.c


示例9: ATF_TC_BODY

ATF_TC_BODY(stat_err, tc)
{
	char buf[NAME_MAX + 1];
	struct stat st;

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

	errno = 0;
	ATF_REQUIRE_ERRNO(EBADF, fstat(-1, &st) == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(ENAMETOOLONG, stat(buf, &st) == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(ENAMETOOLONG, lstat(buf, &st) == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(EFAULT, stat((void *)-1, &st) == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(EFAULT, lstat((void *)-1, &st) == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(EFAULT, stat("/etc/passwd", (void *)-1) == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(EFAULT, lstat("/etc/passwd", (void *)-1) == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(ENOENT, stat("/a/b/c/d/e/f/g/h/i/j/k", &st) == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(ENOENT, lstat("/a/b/c/d/e/f/g/h/i/j/k", &st) == -1);
}
开发者ID:Lxg1582,项目名称:freebsd,代码行数:34,代码来源:t_stat.c


示例10: ATF_TC_BODY

ATF_TC_BODY(getitimer_err, tc)
{
	struct itimerval it;

	errno = 0;
	ATF_REQUIRE_ERRNO(EINVAL, getitimer(-1, &it) == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(EINVAL, getitimer(INT_MAX, &it) == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(EFAULT, getitimer(ITIMER_REAL, (void *)-1) == -1);
}
开发者ID:2asoft,项目名称:freebsd,代码行数:13,代码来源:t_getitimer.c


示例11: ATF_TC_BODY

ATF_TC_BODY(rfork, tc)
{
	struct stat sb;
	struct lwp *l, *l2;
	int fd;

	RZ(rump_init());

	ATF_REQUIRE_EQ(rump_pub_lwproc_rfork(RUMP_RFFDG|RUMP_RFCFDG), EINVAL);

	RZ(rump_pub_lwproc_rfork(0));
	l = rump_pub_lwproc_curlwp();

	RL(fd = rump_sys_open("/file", O_RDWR | O_CREAT, 0777));

	/* ok, first check rfork(RUMP_RFCFDG) does *not* preserve fd's */
	RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG));
	ATF_REQUIRE_ERRNO(EBADF, rump_sys_write(fd, &fd, sizeof(fd)) == -1);

	/* then check that rfork(0) does */
	rump_pub_lwproc_switch(l);
	RZ(rump_pub_lwproc_rfork(0));
	ATF_REQUIRE_EQ(rump_sys_write(fd, &fd, sizeof(fd)), sizeof(fd));
	RL(rump_sys_fstat(fd, &sb));
	l2 = rump_pub_lwproc_curlwp();

	/*
	 * check that the shared fd table is really shared by
	 * closing fd in parent
	 */
	rump_pub_lwproc_switch(l);
	RL(rump_sys_close(fd));
	rump_pub_lwproc_switch(l2);
	ATF_REQUIRE_ERRNO(EBADF, rump_sys_fstat(fd, &sb) == -1);

	/* redo, this time copying the fd table instead of sharing it */
	rump_pub_lwproc_releaselwp();
	rump_pub_lwproc_switch(l);
	RL(fd = rump_sys_open("/file", O_RDWR, 0777));
	RZ(rump_pub_lwproc_rfork(RUMP_RFFDG));
	ATF_REQUIRE_EQ(rump_sys_write(fd, &fd, sizeof(fd)), sizeof(fd));
	RL(rump_sys_fstat(fd, &sb));
	l2 = rump_pub_lwproc_curlwp();

	/* check that the fd table is copied */
	rump_pub_lwproc_switch(l);
	RL(rump_sys_close(fd));
	rump_pub_lwproc_switch(l2);
	RL(rump_sys_fstat(fd, &sb));
	ATF_REQUIRE_EQ(sb.st_size, sizeof(fd));
}
开发者ID:Stichting-MINIX-Research-Foundation,项目名称:minix,代码行数:51,代码来源:t_lwproc.c


示例12: ATF_TC_BODY

ATF_TC_BODY(ftruncate_err, tc)
{
	int fd;

	fd = open("/etc/passwd", O_RDONLY, 0400);
	ATF_REQUIRE(fd >= 0);

	errno = 0;
	ATF_REQUIRE_ERRNO(EBADF, ftruncate(-1, 999) == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(EINVAL, ftruncate(fd, 999) == -1);

	(void)close(fd);
}
开发者ID:2asoft,项目名称:freebsd,代码行数:15,代码来源:t_truncate.c


示例13: ATF_TC_BODY

ATF_TC_BODY(setdomainname_perm, tc)
{

	errno = 0;

	ATF_REQUIRE_ERRNO(EPERM, setdomainname(domain, sizeof(domain)) == -1);
}
开发者ID:Lxg1582,项目名称:freebsd,代码行数:7,代码来源:t_setdomainname.c


示例14: ATF_TC_BODY

ATF_TC_BODY(sethostname_perm, tc)
{

	errno = 0;

	ATF_REQUIRE_ERRNO(EPERM, sethostname(host, sizeof(host)) == -1);
}
开发者ID:Hooman3,项目名称:minix,代码行数:7,代码来源:t_sethostname.c


示例15: ATF_TC_BODY

ATF_TC_BODY(t_exect_null, tc)
{
	struct sigaction act;

	/*
	 * Currently exect(3) is misdesigned -- see PR port-amd64/51700 and it
	 * needs to be redone from scratch.
	 *
	 * This test affects amd64 releng machines causing tests to hang or
	 * fail. As there is little point to test interface that is still not,
	 * designed and implemented and is breaking tests - skip it
	 * unconditionally for all ports.
	 */
	/* Prevent static analysis from requiring t_exec_null to be __dead. */
	if (!caught) 
		atf_tc_skip("exect(3) misdesigned and hangs - PR port-amd64/51700");

	ATF_REQUIRE(sigemptyset(&act.sa_mask) == 0);
	act.sa_sigaction = sigtrap_handler;
	act.sa_flags = SA_SIGINFO;

	ATF_REQUIRE(sigaction(SIGTRAP, &act, 0) == 0);

	ATF_REQUIRE_ERRNO(EFAULT, exect(NULL, NULL, NULL) == -1);

	ATF_REQUIRE_EQ_MSG(caught, 1, "expected caught (1) != received (%d)",
	    (int)caught);
}
开发者ID:2trill2spill,项目名称:freebsd,代码行数:28,代码来源:t_exect.c


示例16: read_after_unlink

static void
read_after_unlink(const atf_tc_t *tc, const char *mp)
{
	char buf[TBSIZE], buf2[TBSIZE];
	int fd;

	FSTEST_ENTER();

	/* create file and put some content into it */
	RL(fd = rump_sys_open("file", O_RDWR|O_CREAT, 0666));
	memset(buf, 'D', TBSIZE);
	ATF_REQUIRE_EQ(rump_sys_write(fd, buf, TBSIZE), TBSIZE);
	rump_sys_close(fd);

	/* flush buffers from UBC to file system */
	ATF_REQUIRE_ERRNO(EBUSY, rump_sys_unmount(mp, 0) == -1);

	RL(fd = rump_sys_open("file", O_RDWR));
	RL(rump_sys_unlink("file"));

	ATF_REQUIRE_EQ(rump_sys_read(fd, buf2, TBSIZE), TBSIZE);
	ATF_REQUIRE_EQ(memcmp(buf, buf2, TBSIZE), 0);
	rump_sys_close(fd);

	FSTEST_EXIT();
}
开发者ID:Stichting-MINIX-Research-Foundation,项目名称:minix,代码行数:26,代码来源:t_io.c


示例17: dir_rmdirdotdot

static void
dir_rmdirdotdot(const atf_tc_t *tc, const char *mp)
{
	char pb[MAXPATHLEN];
	int xerrno;

	USES_DIRS;

	FSTEST_ENTER();
	RL(rump_sys_mkdir("test", 0777));
	RL(rump_sys_chdir("test"));

	RL(rump_sys_mkdir("subtest", 0777));
	RL(rump_sys_chdir("subtest"));

	md(pb, mp, "test/subtest");
	RL(rump_sys_rmdir(pb));
	md(pb, mp, "test");
	RL(rump_sys_rmdir(pb));

	if (FSTYPE_NFS(tc))
		xerrno = ESTALE;
	else
		xerrno = ENOENT;
	ATF_REQUIRE_ERRNO(xerrno, rump_sys_chdir("..") == -1);
	FSTEST_EXIT();
}
开发者ID:anuragpeshne,项目名称:minix,代码行数:27,代码来源:t_vnops.c


示例18: ATF_TC_BODY

ATF_TC_BODY(bad_big5_wprintf, tc)
{
	/* XXX implementation detail knowledge (wchar_t encoding) */
	wchar_t ibuf[] = { 0xcf10, 0 };
	setlocale(LC_CTYPE, "zh_TW.Big5");
	ATF_REQUIRE_ERRNO(EILSEQ, wprintf(L"%ls\n", ibuf) < 0);
	ATF_REQUIRE(ferror(stdout));
}
开发者ID:2trill2spill,项目名称:freebsd,代码行数:8,代码来源:t_io.c


示例19: ATF_TC_BODY

ATF_TC_BODY(mlock_err, tc)
{
#ifdef __NetBSD__
	unsigned long vmin = 0;
	size_t len = sizeof(vmin);
#endif
	void *invalid_ptr;
	int null_errno = ENOMEM;	/* error expected for NULL */

#ifdef __FreeBSD__
#ifdef VM_MIN_ADDRESS
	if ((uintptr_t)VM_MIN_ADDRESS > 0)
		null_errno = EINVAL;	/* NULL is not inside user VM */
#endif
	/* Set max_wired really really high to avoid EAGAIN */
	set_vm_max_wired(INT_MAX);
#else
	if (sysctlbyname("vm.minaddress", &vmin, &len, NULL, 0) != 0)
		atf_tc_fail("failed to read vm.minaddress");

	if (vmin > 0)
		null_errno = EINVAL;	/* NULL is not inside user VM */
#endif

	errno = 0;
	ATF_REQUIRE_ERRNO(null_errno, mlock(NULL, page) == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(null_errno, mlock((char *)0, page) == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(EINVAL, mlock((char *)-1, page) == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(null_errno, munlock(NULL, page) == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(null_errno, munlock((char *)0, page) == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(EINVAL, munlock((char *)-1, page) == -1);

	/*
	 * Try to create a pointer to an unmapped page - first after current
	 * brk will likely do.
	 */
	invalid_ptr = (void*)(((uintptr_t)sbrk(0)+page) & ~(page-1));
	printf("testing with (hopefully) invalid pointer %p\n", invalid_ptr);

	errno = 0;
	ATF_REQUIRE_ERRNO(ENOMEM, mlock(invalid_ptr, page) == -1);

	errno = 0;
	ATF_REQUIRE_ERRNO(ENOMEM, munlock(invalid_ptr, page) == -1);
}
开发者ID:Digital-Chaos,项目名称:freebsd,代码行数:55,代码来源:t_mlock.c


示例20: ATF_TC_BODY

ATF_TC_BODY(unlink_fifo, tc)
{

	ATF_REQUIRE(mkfifo(path, 0666) == 0);
	ATF_REQUIRE(unlink(path) == 0);

	errno = 0;
	ATF_REQUIRE_ERRNO(ENOENT, open(path, O_RDONLY) == -1);
}
开发者ID:2trill2spill,项目名称:freebsd,代码行数:9,代码来源:t_unlink.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ ATF_REQUIRE_MSG函数代码示例发布时间:2022-05-30
下一篇:
C++ ATF_REQUIRE_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