本文整理汇总了C++中ATF_REQUIRE_ERRNO函数的典型用法代码示例。如果您正苦于以下问题:C++ ATF_REQUIRE_ERRNO函数的具体用法?C++ ATF_REQUIRE_ERRNO怎么用?C++ ATF_REQUIRE_ERRNO使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ATF_REQUIRE_ERRNO函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
示例13: ATF_TC_BODY
ATF_TC_BODY(setdomainname_perm, tc)
{
errno = 0;
ATF_REQUIRE_ERRNO(EPERM, setdomainname(domain, sizeof(domain)) == -1);
}
示例14: ATF_TC_BODY
ATF_TC_BODY(sethostname_perm, tc)
{
errno = 0;
ATF_REQUIRE_ERRNO(EPERM, sethostname(host, sizeof(host)) == -1);
}
示例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);
}