本文整理汇总了C++中ATF_REQUIRE_STREQ函数的典型用法代码示例。如果您正苦于以下问题:C++ ATF_REQUIRE_STREQ函数的具体用法?C++ ATF_REQUIRE_STREQ怎么用?C++ ATF_REQUIRE_STREQ使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ATF_REQUIRE_STREQ函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ATF_TC_BODY
ATF_TC_BODY(fork, tc)
{
fprintf(stdout, "Should not get into child\n");
fprintf(stderr, "Should not get into child\n");
pid_t pid = atf_utils_fork();
if (pid == 0) {
fprintf(stdout, "Child stdout\n");
fprintf(stderr, "Child stderr\n");
exit(EXIT_SUCCESS);
}
int status;
ATF_REQUIRE(waitpid(pid, &status, 0) != -1);
ATF_REQUIRE(WIFEXITED(status));
ATF_REQUIRE_EQ(EXIT_SUCCESS, WEXITSTATUS(status));
atf_dynstr_t out_name;
RE(atf_dynstr_init_fmt(&out_name, "atf_utils_fork_%d_out.txt", (int)pid));
atf_dynstr_t err_name;
RE(atf_dynstr_init_fmt(&err_name, "atf_utils_fork_%d_err.txt", (int)pid));
char buffer[1024];
read_file(atf_dynstr_cstring(&out_name), buffer, sizeof(buffer));
ATF_REQUIRE_STREQ("Child stdout\n", buffer);
read_file(atf_dynstr_cstring(&err_name), buffer, sizeof(buffer));
ATF_REQUIRE_STREQ("Child stderr\n", buffer);
atf_dynstr_fini(&err_name);
atf_dynstr_fini(&out_name);
}
示例2: ATF_TC_BODY
ATF_TC_BODY(pkgdb_get_virtualpkg_test, tc)
{
xbps_dictionary_t pkgd;
struct xbps_handle xh;
const char *tcsdir, *pkgver;
/* get test source dir */
tcsdir = atf_tc_get_config_var(tc, "srcdir");
memset(&xh, 0, sizeof(xh));
strncpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
strncpy(xh.metadir, tcsdir, sizeof(xh.metadir));
xh.flags = XBPS_FLAG_DEBUG;
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
pkgd = xbps_pkgdb_get_virtualpkg(&xh, "mixed");
ATF_REQUIRE_EQ(xbps_object_type(pkgd), XBPS_TYPE_DICTIONARY);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
ATF_REQUIRE_STREQ(pkgver, "virtual-mixed-0.1_1");
pkgd = xbps_pkgdb_get_virtualpkg(&xh, "mixed>0");
ATF_REQUIRE_EQ(xbps_object_type(pkgd), XBPS_TYPE_DICTIONARY);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
ATF_REQUIRE_STREQ(pkgver, "virtual-mixed-0.1_1");
pkgd = xbps_pkgdb_get_virtualpkg(&xh, "mixed<2");
ATF_REQUIRE_EQ(xbps_object_type(pkgd), XBPS_TYPE_DICTIONARY);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
ATF_REQUIRE_STREQ(pkgver, "virtual-mixed-0.1_1");
pkgd = xbps_pkgdb_get_virtualpkg(&xh, "mixed-0.1_1");
ATF_REQUIRE_EQ(xbps_object_type(pkgd), XBPS_TYPE_DICTIONARY);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
ATF_REQUIRE_STREQ(pkgver, "virtual-mixed-0.1_1");
}
示例3: ATF_TC_BODY
ATF_TC_BODY(sdl_print, tc)
{
char buf[1024];
char res[1024];
int r, e;
size_t l = sizeof(buf);
struct sockaddr_dl sdl;
memset(&sdl, 0, sizeof(sdl));
for (size_t i = 0; i < __arraycount(tst); i++) {
memcpy(&sdl.sdl_addr, &tst[i].ia, sizeof(sdl.sdl_addr));
sdl.sdl_index = (uint16_t)i;
r = sdl_print(buf, l, &sdl);
e = snprintf(res, l, "[%s]:%zu", tst[i].str, i);
ATF_REQUIRE_STREQ(buf, res);
ATF_REQUIRE_EQ(r, e);
}
l = 8;
for (size_t i = 0; i < __arraycount(tst); i++) {
memcpy(&sdl.sdl_addr, &tst[i].ia, sizeof(sdl.sdl_addr));
sdl.sdl_index = (uint16_t)i;
r = sdl_print(buf, l, &sdl);
e = snprintf(res, l, "[%s]:%zu", tst[i].str, i);
ATF_REQUIRE_STREQ(buf, res);
ATF_REQUIRE_EQ(r, e);
}
}
示例4: ATF_TC_BODY
ATF_TC_BODY(reregister_reg, tc)
{
char buf[1024];
int localfd, etcfd;
ssize_t n;
int tfd;
etcfd = open("/etc/passwd", O_RDONLY);
ATF_REQUIRE(etcfd != -1);
localfd = open("./testfile", O_RDWR | O_CREAT, 0666);
ATF_REQUIRE(localfd != -1);
ATF_REQUIRE_EQ(write(localfd, TESTSTR1, TESTSTR1SZ), TESTSTR1SZ);
/* testfile now contains test string */
rump_init();
ATF_REQUIRE_EQ(rump_pub_etfs_register(TESTPATH1, "/etc/passwd",
RUMP_ETFS_REG), 0);
tfd = rump_sys_open(TESTPATH1, O_RDONLY);
ATF_REQUIRE(tfd != -1);
ATF_REQUIRE(rump_sys_read(tfd, buf, sizeof(buf)) > 0);
rump_sys_close(tfd);
rump_pub_etfs_remove(TESTPATH1);
ATF_REQUIRE_EQ(rump_pub_etfs_register(TESTPATH2, "./testfile",
RUMP_ETFS_REG), 0);
tfd = rump_sys_open(TESTPATH2, O_RDWR);
ATF_REQUIRE(tfd != -1);
memset(buf, 0, sizeof(buf));
ATF_REQUIRE((n = rump_sys_read(tfd, buf, sizeof(buf))) > 0);
/* check that we have what we expected */
ATF_REQUIRE_STREQ(buf, TESTSTR1);
/* ... while here, check that writing works too */
ATF_REQUIRE_EQ(rump_sys_lseek(tfd, 0, SEEK_SET), 0);
ATF_REQUIRE(TESTSTR1SZ <= TESTSTR2SZ);
ATF_REQUIRE_EQ(rump_sys_write(tfd, TESTSTR2, TESTSTR2SZ), TESTSTR2SZ);
memset(buf, 0, sizeof(buf));
ATF_REQUIRE_EQ(lseek(localfd, 0, SEEK_SET), 0);
ATF_REQUIRE(read(localfd, buf, sizeof(buf)) > 0);
ATF_REQUIRE_STREQ(buf, TESTSTR2);
close(etcfd);
close(localfd);
}
示例5: ATF_TC_BODY
ATF_TC_BODY(find_all_orphans_test, tc)
{
struct xbps_handle xh;
xbps_array_t res;
xbps_dictionary_t pkgd;
xbps_string_t pstr;
const char *pkgver, *tcsdir;
unsigned int i;
/* get test source dir */
tcsdir = atf_tc_get_config_var(tc, "srcdir");
memset(&xh, 0, sizeof(xh));
xbps_strlcpy(xh.rootdir, tcsdir, sizeof(xh.rootdir));
xbps_strlcpy(xh.metadir, tcsdir, sizeof(xh.metadir));
ATF_REQUIRE_EQ(xbps_init(&xh), 0);
pstr = xbps_string_create();
res = xbps_find_pkg_orphans(&xh, NULL);
for (i = 0; i < xbps_array_count(res); i++) {
pkgd = xbps_array_get(res, i);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
xbps_string_append_cstring(pstr, pkgver);
xbps_string_append_cstring(pstr, "\n");
}
printf("%s", xbps_string_cstring_nocopy(pstr));
ATF_REQUIRE_STREQ(xbps_string_cstring_nocopy(pstr), expected_output_all);
}
示例6: ATF_TC_BODY
ATF_TC_BODY(vprintf__empty, tc)
{
char* buffer;
kyua_error_t error = call_vprintf(&buffer, "%s", "");
ATF_REQUIRE(!kyua_error_is_set(error));
ATF_REQUIRE_STREQ("", buffer);
}
示例7: ATF_TC_BODY
ATF_TC_BODY(mbsnrtowcs, tc)
{
size_t i;
const struct test *t;
mbstate_t state;
wchar_t buf[64];
const char *src;
size_t len;
for (i = 0; i < __arraycount(tests); ++i) {
t = &tests[i];
ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C");
ATF_REQUIRE(setlocale(LC_CTYPE, t->locale) != NULL);
memset(&state, 0, sizeof(state));
src = t->data;
len = mbsnrtowcs(buf, &src, t->limit,
__arraycount(buf), &state);
ATF_REQUIRE_EQ(src, t->data + t->limit);
ATF_REQUIRE_EQ(len, t->output1_len);
ATF_REQUIRE(wmemcmp(t->output1, buf, len) == 0);
len = mbsnrtowcs(buf, &src, strlen(src) + 1,
__arraycount(buf), &state);
ATF_REQUIRE_EQ(len, strlen(t->data) - t->limit);
ATF_REQUIRE(wmemcmp(t->output2, buf, len + 1) == 0);
ATF_REQUIRE_EQ(src, NULL);
}
}
示例8: ATF_TC_BODY
ATF_TC_BODY(concat__two, tc)
{
char* path;
ATF_REQUIRE(!kyua_error_is_set(kyua_fs_concat(&path, "foo", "bar", NULL)));
ATF_REQUIRE_STREQ("foo/bar", path);
free(path);
}
示例9: ATF_TC_BODY
ATF_TC_BODY(usage_error_format__args, tc)
{
kyua_error_t error = kyua_usage_error_new("%s message %d", "A", 123);
char buffer[1024];
kyua_error_format(error, buffer, sizeof(buffer));
ATF_REQUIRE_STREQ("A message 123", buffer);
kyua_error_free(error);
}
示例10: h_mbtowc
static void
h_mbtowc(const char *locale, const char *illegal, const char *legal)
{
char buf[64];
size_t stateful, ret;
char *str;
ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C");
#ifdef __NetBSD__
ATF_REQUIRE(setlocale(LC_CTYPE, locale) != NULL);
#else
if (setlocale(LC_CTYPE, locale) == NULL) {
fprintf(stderr, "Locale %s not found.\n", locale);
return;
}
#endif
ATF_REQUIRE((str = setlocale(LC_ALL, NULL)) != NULL);
(void)printf("Using locale: %s\n", str);
stateful = wctomb(NULL, L'\0');
(void)printf("Locale is state-%sdependent\n",
stateful ? "in" : "");
/* initialize internal state */
ret = mbtowc(NULL, NULL, 0);
ATF_REQUIRE(stateful ? ret : !ret);
(void)strvis(buf, illegal, VIS_WHITE | VIS_OCTAL);
(void)printf("Checking illegal sequence: \"%s\"\n", buf);
ret = mbtowc(NULL, illegal, strlen(illegal));
(void)printf("mbtowc() returned: %zd\n", ret);
ATF_REQUIRE_EQ(ret, (size_t)-1);
(void)printf("errno: %s\n", strerror(errno));
ATF_REQUIRE_EQ(errno, EILSEQ);
/* if this is stateless encoding, this re-initialization is not required. */
if (stateful) {
/* re-initialize internal state */
ret = mbtowc(NULL, NULL, 0);
ATF_REQUIRE(stateful ? ret : !ret);
}
/* valid multibyte sequence case */
(void)strvis(buf, legal, VIS_WHITE | VIS_OCTAL);
(void)printf("Checking legal sequence: \"%s\"\n", buf);
errno = 0;
ret = mbtowc(NULL, legal, strlen(legal));
(void)printf("mbtowc() returned: %zd\n", ret);
ATF_REQUIRE(ret != (size_t)-1);
(void)printf("errno: %s\n", strerror(errno));
ATF_REQUIRE_EQ(errno, 0);
(void)printf("Ok.\n");
}
示例11: ATF_TC_BODY
ATF_TC_BODY(check_files, tc)
{
FILE *f;
unsigned char *sum;
f = fopen("foo", "w");
fprintf(f, "bar\n");
fclose(f);
sum = pkg_checksum_file("foo", PKG_HASH_TYPE_SHA256_HEX);
ATF_REQUIRE_STREQ(sum, "7d865e959b2466918c9863afca942d0fb89d7c9ac0c99bafc3749504ded97730");
ATF_CHECK(pkg_checksum_validate_file("foo", "7d865e959b2466918c9863afca942d0fb89d7c9ac0c99bafc3749504ded97730") == 0);
free(sum);
sum=pkg_checksum_generate_file("foo", PKG_HASH_TYPE_SHA256_HEX);
ATF_REQUIRE_STREQ(sum, "1$7d865e959b2466918c9863afca942d0fb89d7c9ac0c99bafc3749504ded97730");
}
示例12: ATF_TC_BODY
ATF_TC_BODY(run_params_init__defaults, tc)
{
kyua_run_params_t run_params;
kyua_run_params_init(&run_params);
ATF_REQUIRE_EQ(60, run_params.timeout_seconds);
ATF_REQUIRE_EQ(getuid(), run_params.unprivileged_user);
ATF_REQUIRE_EQ(getgid(), run_params.unprivileged_group);
ATF_REQUIRE_STREQ(".", run_params.work_directory);
}
示例13: ATF_TC_BODY
ATF_TC_BODY(fork, tc)
{
fprintf(stdout, "Should not get into child\n");
fprintf(stderr, "Should not get into child\n");
pid_t pid = atf_utils_fork();
if (pid == 0) {
fprintf(stdout, "Child stdout\n");
fprintf(stderr, "Child stderr\n");
exit(EXIT_SUCCESS);
}
int status;
ATF_REQUIRE(waitpid(pid, &status, 0) != -1);
ATF_REQUIRE(WIFEXITED(status));
ATF_REQUIRE_EQ(EXIT_SUCCESS, WEXITSTATUS(status));
char buffer[1024];
read_file("atf_utils_fork_out.txt", buffer, sizeof(buffer));
ATF_REQUIRE_STREQ("Child stdout\n", buffer);
read_file("atf_utils_fork_err.txt", buffer, sizeof(buffer));
ATF_REQUIRE_STREQ("Child stderr\n", buffer);
}