本文整理汇总了C++中ATF_REQUIRE_EQ函数的典型用法代码示例。如果您正苦于以下问题:C++ ATF_REQUIRE_EQ函数的具体用法?C++ ATF_REQUIRE_EQ怎么用?C++ ATF_REQUIRE_EQ使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ATF_REQUIRE_EQ函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ATF_TC_BODY
ATF_TC_BODY(msgget_success, tc)
{
FILE *pipefd = setup(fds, auclass);
/* Create a message queue and obtain the corresponding identifier */
ATF_REQUIRE((msqid = msgget(IPC_PRIVATE, IPC_CREAT | S_IRUSR)) != -1);
/* Check the presence of message queue ID in audit record */
snprintf(ipcregex, sizeof(ipcregex),
"msgget.*return,success,%d", msqid);
check_audit(fds, ipcregex, pipefd);
/* Destroy the message queue with ID = msqid */
ATF_REQUIRE_EQ(0, msgctl(msqid, IPC_RMID, NULL));
}
示例2: attachversion
/*
* Individual unit tests
*/
static void
attachversion(isc_assertioncallback_t callback) {
isc_result_t result;
dns_dbversion_t *v = NULL;
result = dns_test_begin(NULL, ISC_FALSE);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
setup_db();
isc_assertion_setcallback(callback);
dns_db_attachversion(db1, VERSION(callback), &v);
if (callback != NULL)
atf_tc_fail("dns_db_attachversion did not assert");
ATF_REQUIRE_EQ(v, v1);
dns_db_closeversion(db1, &v, ISC_FALSE);
ATF_REQUIRE_EQ(v, NULL);
close_db();
dns_test_end();
}
示例3: create_two_events
/*
* Create two devd events. The easiest way I know of, that requires no special
* hardware, is to create md(4) devices.
*/
static void
create_two_events(void)
{
FILE *create_stdout;
FILE *destroy_stdout;
char mdname[80];
char destroy_cmd[80];
char *error;
create_stdout = popen("mdconfig -a -s 64 -t null", "r");
ATF_REQUIRE(create_stdout != NULL);
error = fgets(mdname, sizeof(mdname), create_stdout);
ATF_REQUIRE(error != NULL);
/* We only expect one line of output */
ATF_REQUIRE_EQ(0, pclose(create_stdout));
snprintf(destroy_cmd, nitems(destroy_cmd), "mdconfig -d -u %s", mdname);
destroy_stdout = popen(destroy_cmd, "r");
ATF_REQUIRE(destroy_stdout != NULL);
/* We expect no output */
ATF_REQUIRE_EQ(0, pclose(destroy_stdout));
}
示例4: test_context_setup
static test_context_t *
test_context_setup(void) {
test_context_t *ctx;
isc_result_t result;
size_t i;
ctx = isc_mem_get(mctx, sizeof(*ctx));
ATF_REQUIRE(ctx != NULL);
ctx->rbt = NULL;
result = dns_rbt_create(mctx, delete_data, NULL, &ctx->rbt);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
ctx->rbt_distances = NULL;
result = dns_rbt_create(mctx, delete_data, NULL, &ctx->rbt_distances);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
for (i = 0; i < domain_names_count; i++) {
size_t *n;
dns_fixedname_t fname;
dns_name_t *name;
build_name_from_str(domain_names[i], &fname);
name = dns_fixedname_name(&fname);
n = isc_mem_get(mctx, sizeof(size_t));
*n = i + 1;
result = dns_rbt_addname(ctx->rbt, name, n);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
n = isc_mem_get(mctx, sizeof(size_t));
*n = node_distances[i];
result = dns_rbt_addname(ctx->rbt_distances, name, n);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
}
return (ctx);
}
示例5: addrdataset
static void
addrdataset(isc_assertioncallback_t callback) {
isc_result_t result;
dns_rdataset_t rdataset;
dns_fixedname_t fixed;
dns_dbnode_t *node = NULL;
dns_rdatalist_t rdatalist;
result = dns_test_begin(NULL, ISC_FALSE);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
setup_db();
dns_rdataset_init(&rdataset);
dns_rdatalist_init(&rdatalist);
dns_fixedname_init(&fixed);
rdatalist.rdclass = dns_rdataclass_in;
result = dns_rdatalist_tordataset(&rdatalist, &rdataset);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
result = dns_db_findnode(db1, dns_rootname, ISC_FALSE, &node);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
isc_assertion_setcallback(callback);
result = dns_db_addrdataset(db1, node, VERSION(callback), 0, &rdataset,
0, NULL);
if (callback != NULL)
atf_tc_fail("dns_db_adddataset did not assert");
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
dns_db_detachnode(db1, &node);
ATF_REQUIRE_EQ(node, NULL);
close_db();
dns_test_end();
}
示例6: ATF_TC_BODY
ATF_TC_BODY(wait__ok, tc)
{
const pid_t control = fork();
ATF_REQUIRE(control != -1);
if (control == 0)
fork_and_wait(123, "Some output\n", "Some error\n");
else {
int status;
ATF_REQUIRE(waitpid(control, &status, 0) != -1);
ATF_REQUIRE(WIFEXITED(status));
ATF_REQUIRE_EQ(EXIT_SUCCESS, WEXITSTATUS(status));
}
}
示例7: ATF_TC_BODY
ATF_TC_BODY(bufsize, tc)
{
union {
int int_val;
unsigned char space[256];
} buf;
size_t len;
for (len = 0; len < sizeof(buf); len++) {
size_t oldlen = len;
int r;
memset(&buf, 0xFF, sizeof(buf));
r = sysctlbyname("kern.job_control", &buf, &oldlen, 0, (size_t) 0);
if (len < sizeof(int)) {
ATF_REQUIRE_EQ(r, -1);
ATF_REQUIRE_EQ(errno, ENOMEM);
} else {
ATF_REQUIRE_EQ(r, 0);
ATF_REQUIRE_EQ(buf.int_val, 1);
ATF_REQUIRE_EQ(oldlen, sizeof(int));
}
}
}
示例8: verify_bkpt
/*
* Wait for the specified process to hit a breakpoint at the specified symbol.
*/
static void
verify_bkpt(struct proc_handle *phdl, GElf_Sym *sym, const char *symname,
const char *mapname)
{
char mapbname[MAXPATHLEN], *name;
GElf_Sym tsym;
prmap_t *map;
size_t namesz;
u_long addr;
int error, state;
state = proc_wstatus(phdl);
ATF_REQUIRE_EQ_MSG(state, PS_STOP, "process has state %d", state);
/* Get the program counter and decrement it. */
error = proc_regget(phdl, REG_PC, &addr);
ATF_REQUIRE_EQ_MSG(error, 0, "failed to obtain PC for '%s'",
target_prog_file);
proc_bkptregadj(&addr);
/*
* Make sure the PC matches the expected value obtained from the symbol
* definition we looked up earlier.
*/
ATF_CHECK_EQ_MSG(addr, sym->st_value,
"program counter 0x%lx doesn't match expected value 0x%jx",
addr, (uintmax_t)sym->st_value);
/*
* Ensure we can look up the r_debug_state symbol using its starting
* address and that the resulting symbol matches the one we found using
* a name lookup.
*/
namesz = strlen(symname) + 1;
name = malloc(namesz);
ATF_REQUIRE(name != NULL);
error = proc_addr2sym(phdl, addr, name, namesz, &tsym);
ATF_REQUIRE_EQ_MSG(error, 0, "failed to look up symbol at 0x%lx", addr);
ATF_REQUIRE_EQ(memcmp(sym, &tsym, sizeof(*sym)), 0);
ATF_REQUIRE_EQ_MSG(strcmp(symname, name), 0,
"expected symbol name '%s' doesn't match '%s'", symname, name);
free(name);
map = proc_addr2map(phdl, addr);
ATF_REQUIRE_MSG(map != NULL, "failed to look up map for address 0x%lx",
addr);
basename_r(map->pr_mapname, mapbname);
ATF_REQUIRE_EQ_MSG(strcmp(mapname, mapbname), 0,
"expected map name '%s' doesn't match '%s'", mapname, mapbname);
}
示例9: h_wctomb
static void
h_wctomb(const struct test *t, char tc)
{
wchar_t wcs[16 + 2];
char buf[128];
char cs[MB_LEN_MAX];
const char *pcs;
char *str;
mbstate_t st;
mbstate_t *stp = NULL;
size_t sz, ret, i;
ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C");
ATF_REQUIRE(setlocale(LC_CTYPE, t->locale) != NULL);
(void)strvis(buf, t->data, VIS_WHITE | VIS_OCTAL);
(void)printf("Checking sequence: \"%s\"\n", buf);
ATF_REQUIRE((str = setlocale(LC_ALL, NULL)) != NULL);
(void)printf("Using locale: %s\n", str);
if (tc == TC_WCRTOMB_ST) {
(void)memset(&st, 0, sizeof(st));
stp = &st;
}
wcs[t->wclen] = L'X'; /* poison */
pcs = t->data;
sz = mbsrtowcs(wcs, &pcs, t->wclen + 2, NULL);
ATF_REQUIRE_EQ_MSG(sz, t->wclen, "mbsrtowcs() returned: "
"%zu, expected: %zu", sz, t->wclen);
ATF_REQUIRE_EQ(wcs[t->wclen], 0);
for (i = 0; i < t->wclen + 1; i++) {
if (tc == TC_WCTOMB)
ret = wctomb(cs, wcs[i]);
else
ret = wcrtomb(cs, wcs[i], stp);
if (ret == t->mblen[i])
continue;
(void)printf("At position %zd:\n", i);
(void)printf(" expected: %zd\n", t->mblen[i]);
(void)printf(" got : %zd\n", ret);
atf_tc_fail("Test failed");
/* NOTREACHED */
}
(void)printf("Ok.\n");
}
示例10: ATF_TC_BODY
ATF_TC_BODY(seqpacket, tc)
{
int s;
int error;
struct sockaddr_un devd_addr;
bool got_create_event = false;
bool got_destroy_event = false;
const char create_pat[] =
"!system=DEVFS subsystem=CDEV type=CREATE cdev=md";
const char destroy_pat[] =
"!system=DEVFS subsystem=CDEV type=DESTROY cdev=md";
memset(&devd_addr, 0, sizeof(devd_addr));
devd_addr.sun_family = PF_LOCAL;
strlcpy(devd_addr.sun_path, "/var/run/devd.seqpacket.pipe",
sizeof(devd_addr.sun_path));
s = socket(PF_LOCAL, SOCK_SEQPACKET, 0);
ATF_REQUIRE(s >= 0);
error = connect(s, (struct sockaddr*)&devd_addr, SUN_LEN(&devd_addr));
ATF_REQUIRE_EQ(0, error);
create_two_events();
/*
* Loop until both events are detected on _different_ reads
* There may be extra events due to unrelated system activity
* If we never get both events, then the test will timeout.
*/
while (!(got_create_event && got_destroy_event)) {
int cmp;
ssize_t len;
char event[1024];
/* Read 1 less than sizeof(event) to allow space for NULL */
len = recv(s, event, sizeof(event) - 1, MSG_WAITALL);
ATF_REQUIRE(len != -1);
/* NULL terminate the result */
event[len] = '\0';
printf("%s", event);
cmp = strncmp(event, create_pat, sizeof(create_pat) - 1);
if (cmp == 0)
got_create_event = true;
cmp = strncmp(event, destroy_pat, sizeof(destroy_pat) - 1);
if (cmp == 0)
got_destroy_event = true;
}
close(s);
}
示例11: ATF_TC_BODY
ATF_TC_BODY(large_blk, tc)
{
char buf[128];
char cmpbuf[128];
ssize_t n;
int rv, tfd;
/*
* mount mfs. it would be nice if this would not be required,
* but a) tmpfs doesn't "support" sparse files b) we don't really
* know what fs atf workdir is on anyway.
*/
if (mkdir("mfsdir", 0777) == -1)
atf_tc_fail_errno("mkdir failed");
if (system("mount_mfs -s 64m -o nosuid,nodev mfs mfsdir") != 0)
atf_tc_skip("could not mount mfs");
/* create a 8TB sparse file */
rv = system("dd if=/dev/zero of=" IMG_ON_MFS " bs=1 count=1 seek=8t");
ATF_REQUIRE_EQ(rv, 0);
/*
* map it and issue write at 6TB, then unmap+remap and check
* we get the same stuff back
*/
rump_init();
ATF_REQUIRE_EQ(rump_pub_etfs_register(TESTPATH1, IMG_ON_MFS,
RUMP_ETFS_BLK), 0);
tfd = rump_sys_open(TESTPATH1, O_RDWR);
ATF_REQUIRE(tfd != -1);
memset(buf, 12, sizeof(buf));
n = rump_sys_pwrite(tfd, buf, sizeof(buf), 6*1024*1024*1024ULL*1024ULL);
ATF_REQUIRE_EQ(n, sizeof(buf));
ATF_REQUIRE_EQ(rump_sys_close(tfd), 0);
ATF_REQUIRE_EQ(rump_pub_etfs_remove(TESTPATH1), 0);
ATF_REQUIRE_EQ(rump_pub_etfs_register(TESTPATH2, IMG_ON_MFS,
RUMP_ETFS_BLK), 0);
tfd = rump_sys_open(TESTPATH2, O_RDWR);
ATF_REQUIRE(tfd != -1);
memset(buf, 0, sizeof(buf));
n = rump_sys_pread(tfd, buf, sizeof(buf), 6*1024*1024*1024ULL*1024ULL);
ATF_REQUIRE_EQ(n, sizeof(buf));
memset(cmpbuf, 12, sizeof(cmpbuf));
ATF_REQUIRE_EQ(memcmp(cmpbuf, buf, 128), 0);
}
示例12: extendbody
static void
extendbody(const atf_tc_t *tc, off_t seekcnt)
{
char buf[TESTSZ+1];
struct stat sb;
int fd;
FSTEST_ENTER();
RL(fd = rump_sys_open("testfile",
O_CREAT | O_RDWR | (seekcnt ? O_APPEND : 0)));
RL(rump_sys_ftruncate(fd, seekcnt));
RL(rump_sys_fstat(fd, &sb));
ATF_REQUIRE_EQ(sb.st_size, seekcnt);
ATF_REQUIRE_EQ(rump_sys_write(fd, TESTSTR, TESTSZ), TESTSZ);
ATF_REQUIRE_EQ(rump_sys_pread(fd, buf, TESTSZ, seekcnt), TESTSZ);
ATF_REQUIRE_STREQ(buf, TESTSTR);
RL(rump_sys_fstat(fd, &sb));
ATF_REQUIRE_EQ(sb.st_size, (off_t)TESTSZ + seekcnt);
RL(rump_sys_close(fd));
FSTEST_EXIT();
}
示例13: ATF_TC_BODY
ATF_TC_BODY(emsgsize_nonblocking, tc)
{
int s;
int sv[2];
const size_t sndbufsize = 8192;
const size_t rcvbufsize = 8192;
const size_t pktsize = (sndbufsize + rcvbufsize) * 2;
char sndbuf[pktsize];
char recv_buf[pktsize];
ssize_t ssize, rsize;
/* setup the socket pair */
do_socketpair_nonblocking(sv);
/* Setup the buffers */
ATF_REQUIRE_EQ(0, setsockopt(sv[0], SOL_SOCKET, SO_SNDBUF, &sndbufsize,
sizeof(sndbufsize)));
ATF_REQUIRE_EQ(0, setsockopt(sv[1], SOL_SOCKET, SO_RCVBUF, &rcvbufsize,
sizeof(rcvbufsize)));
ssize = send(sv[0], sndbuf, pktsize, MSG_EOR);
ATF_CHECK_EQ(EMSGSIZE, errno);
ATF_CHECK_EQ(-1, ssize);
}
示例14: pkgdict_init
static prop_dictionary_t
pkgdict_init(void)
{
prop_array_t a;
prop_dictionary_t d;
d = prop_dictionary_create();
ATF_REQUIRE(d != NULL);
a = provides_init();
ATF_REQUIRE_EQ(prop_dictionary_set(d, "provides", a), true);
return d;
}
示例15: ATF_TC_BODY
ATF_TC_BODY(proc3, tc)
{
pid_t pid = 0;
int kq, status;
struct kevent ke;
struct timespec timeout;
RL(kq = kqueue());
EV_SET(&ke, (uintptr_t)getpid(), EVFILT_PROC, EV_ADD, NOTE_TRACK, 0, 0);
RL(kevent(kq, &ke, 1, NULL, 0, NULL));
RL(pid = fork());
if (pid == 0) {
_exit(EXIT_SUCCESS);
/* NOTREACHED */
}
RL(waitpid(pid, &status, 0));
ATF_REQUIRE(WIFEXITED(status));
ATF_REQUIRE_EQ(WEXITSTATUS(status), EXIT_SUCCESS);
timeout.tv_sec = 0;
timeout.tv_nsec = 0;
ke.ident = 0;
ke.fflags = 0;
ke.flags = EV_ENABLE;
RL(kevent(kq, NULL, 0, &ke, 1, &timeout));
RL(close(kq));
ATF_REQUIRE(ke.fflags & NOTE_CHILD);
ATF_REQUIRE((ke.fflags & NOTE_TRACKERR) == 0);
ATF_REQUIRE_EQ((pid_t)ke.ident, pid);
}