本文整理汇总了C++中do_one_test函数的典型用法代码示例。如果您正苦于以下问题:C++ do_one_test函数的具体用法?C++ do_one_test怎么用?C++ do_one_test使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了do_one_test函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int
main (void)
{
size_t i;
int ret = 0;
mtrace ();
for (i = 0; i < sizeof (tests) / sizeof (tests[0]); ++i)
{
if (setlocale (LC_ALL, "de_DE.ISO-8859-1") == NULL)
{
puts ("setlocale de_DE.ISO-8859-1 failed");
ret = 1;
}
ret |= do_one_test (&tests[i], "");
if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)
{
puts ("setlocale de_DE.UTF-8 failed");
ret = 1;
}
ret |= do_one_test (&tests[i], "UTF-8 ");
ret |= do_mb_tests (&tests[i]);
}
return ret;
}
示例2: do_test_limit
static void
do_test_limit (size_t align1, size_t align2, size_t len, size_t n, int max_char,
int exp_result)
{
size_t i, align_n;
char *s1, *s2;
if (n == 0)
{
s1 = (char*)(buf1 + page_size);
s2 = (char*)(buf2 + page_size);
printf ("Length %d/%d:", len, n);
FOR_EACH_IMPL (impl, 0)
do_one_test (impl, s1, s2, n, 0);
putchar ('\n');
return;
}
align1 &= 15;
align2 &= 15;
align_n = (page_size - n) & 15;
s1 = (char*)(buf1 + page_size - n);
s2 = (char*)(buf2 + page_size - n);
if (align1 < align_n)
s1 -= (align_n - align1);
if (align2 < align_n)
s2 -= (align_n - align2);
for (i = 0; i < n; i++)
s1[i] = s2[i] = 1 + 23 * i % max_char;
if (len < n)
{
s1[len] = 0;
s2[len] = 0;
if (exp_result < 0)
s2[len] = 32;
else if (exp_result > 0)
s1[len] = 64;
}
printf ("Length %d/%d, alignment %d/%d:", len, n, align1, align2);
FOR_EACH_IMPL (impl, 0)
do_one_test (impl, s1, s2, n, exp_result);
putchar ('\n');
}
示例3: do_test
static void
do_test (size_t align1, size_t align2, size_t len, int max_char)
{
size_t i;
CHAR *s1, *s2;
/* For wcscpy: align1 and align2 here mean alignment not in bytes,
but in wchar_ts, in bytes it will equal to align * (sizeof (wchar_t))
len for wcschr here isn't in bytes but it's number of wchar_t symbols. */
align1 &= 7;
if ((align1 + len) * sizeof(CHAR) >= page_size)
return;
align2 &= 7;
if ((align2 + len) * sizeof(CHAR) >= page_size)
return;
s1 = (CHAR *) (buf1) + align1;
s2 = (CHAR *) (buf2) + align2;
for (i = 0; i < len; i++)
s1[i] = 32 + 23 * i % (max_char - 32);
s1[len] = 0;
printf ("Length %4zd, alignments in bytes %2zd/%2zd:", len, align1 * sizeof(CHAR), align2 * sizeof(CHAR));
FOR_EACH_IMPL (impl, 0)
do_one_test (impl, s2, s1, len);
putchar ('\n');
}
示例4: do_test
static void
do_test (size_t align1, size_t align2, size_t len)
{
size_t i, j;
char *s1, *s2;
align1 &= 63;
if (align1 + len >= page_size)
return;
align2 &= 63;
if (align2 + len >= page_size)
return;
s1 = (char *) (buf1 + align1);
s2 = (char *) (buf2 + align2);
for (i = 0, j = 1; i < len; i++, j += 23)
s1[i] = j;
printf ("Length %4zd, alignment %d/%d:", len, align1, align2);
FOR_EACH_IMPL (impl, 0)
do_one_test (impl, s2, (char *) (buf2 + align1), s1, len);
putchar ('\n');
}
示例5: do_test
static void
do_test (size_t align1, size_t align2, size_t len, int exp_result)
{
size_t i;
CHAR *s1, *s2;
if (len == 0)
return;
align1 &= 63;
if (align1 + (len + 1) * CHARBYTES >= page_size)
return;
align2 &= 63;
if (align2 + (len + 1) * CHARBYTES >= page_size)
return;
s1 = (CHAR *) (buf1 + align1);
s2 = (CHAR *) (buf2 + align2);
for (i = 0; i < len; i++)
s1[i] = s2[i] = 1 + (23 << ((CHARBYTES - 1) * 8)) * i % CHAR__MAX;
s1[len] = align1;
s2[len] = align2;
s2[len - 1] -= exp_result;
printf ("Length %4zd, alignment %2zd/%2zd:", len, align1, align2);
FOR_EACH_IMPL (impl, 0)
do_one_test (impl, s1, s2, len, exp_result);
putchar ('\n');
}
示例6: do_random_tests
static void
do_random_tests (void)
{
for (size_t n = 0; n < ITERATIONS; ++n)
{
char tmpbuf[32];
size_t shift = random () % 11;
size_t rel = random () % ((2 << (shift + 1)) * 64);
size_t idx = MIN ((2 << shift) * 64 + rel, BUF1PAGES * page_size - 2);
size_t len = random () % (sizeof (tmpbuf) - 1) + 1;
len = MIN (len, BUF1PAGES * page_size - idx - 1);
memcpy (tmpbuf, buf1 + idx, len);
for (size_t i = random () % len / 2 + 1; i > 0; --i)
{
size_t off = random () % len;
char ch = '0' + random () % 10;
buf1[idx + off] = ch;
}
printf ("String %.*s, offset %zd:", (int) len, buf1 + idx, idx);
FOR_EACH_IMPL (impl, 0)
do_one_test (impl, buf1, BUF1PAGES * page_size, buf1 + idx, len,
buf1 + idx);
putchar ('\n');
memcpy (buf1 + idx, tmpbuf, len);
}
}
示例7: do_test
static void
do_test (size_t align1, size_t align2, size_t len, size_t dlen, int max_char)
{
size_t i;
char *s1, *s2;
align1 &= 7;
if (align1 + len >= page_size)
return;
align2 &= 7;
if (align2 + len >= page_size)
return;
s1 = (char *) buf1 + align1;
s2 = (char *) buf2 + align2;
for (i = 0; i < len; i++)
s1[i] = 32 + 23 * i % (max_char - 32);
s1[len] = 0;
if (dlen > len)
printf ("Length %4zd, alignment %2zd/%2zd:", len, align1, align2);
FOR_EACH_IMPL (impl, 0)
do_one_test (impl, s2, s1, len, dlen);
if (dlen > len)
putchar ('\n');
}
示例8: do_test
static void
do_test (size_t align1, size_t align2, int c, size_t len, size_t n,
int max_char)
{
size_t i;
char *s1, *s2;
align1 &= 7;
if (align1 + len >= page_size)
return;
align2 &= 7;
if (align2 + len >= page_size)
return;
s1 = (char *) (buf1 + align1);
s2 = (char *) (buf2 + align2);
for (i = 0; i < len - 1; ++i)
{
s1[i] = 32 + 23 * i % (max_char - 32);
if (s1[i] == (char) c)
--s1[i];
}
s1[len - 1] = c;
for (i = len; i + align1 < page_size && i < len + 64; ++i)
s1[i] = 32 + 32 * i % (max_char - 32);
printf ("Length %4zd, n %4zd, char %d, alignment %2zd/%2zd:", len, n, c, align1, align2);
FOR_EACH_IMPL (impl, 0)
do_one_test (impl, s2, s1, c, len, n);
putchar ('\n');
}
示例9: do_test
static void
do_test (size_t align1, size_t align2, size_t len, size_t n, int max_char)
{
size_t i;
CHAR *s1, *s2;
/* For wcsncpy: align1 and align2 here mean alignment not in bytes,
but in wchar_ts, in bytes it will equal to align * (sizeof (wchar_t)). */
align1 &= 7;
if ((align1 + len) * sizeof (CHAR) >= page_size)
return;
align2 &= 7;
if ((align2 + len) * sizeof (CHAR) >= page_size)
return;
s1 = (CHAR *) (buf1) + align1;
s2 = (CHAR *) (buf2) + align2;
for (i = 0; i < len; ++i)
s1[i] = 32 + 23 * i % (max_char - 32);
s1[len] = 0;
for (i = len + 1; (i + align1) * sizeof (CHAR) < page_size && i < len + 64;
++i)
s1[i] = 32 + 32 * i % (max_char - 32);
printf ("Length %4zd, n %4zd, alignment %2zd/%2zd:", len, n, align1, align2);
FOR_EACH_IMPL (impl, 0)
do_one_test (impl, s2, s1, len, n);
putchar ('\n');
}
示例10: do_test
static void
do_test (size_t align, size_t pos, size_t len, int seek_char)
{
size_t i;
char *result;
align &= 7;
if (align + len >= page_size)
return;
for (i = 0; i < len; ++i)
{
buf1[align + i] = 1 + 23 * i % 127;
if (buf1[align + i] == seek_char)
buf1[align + i] = seek_char + 1;
}
buf1[align + len] = 0;
assert (pos < len);
buf1[align + pos] = seek_char;
buf1[align + len] = -seek_char;
result = (char *) (buf1 + align + pos);
if (HP_TIMING_AVAIL)
printf ("Length %4zd, alignment %2zd:", pos, align);
FOR_EACH_IMPL (impl, 0)
do_one_test (impl, (char *) (buf1 + align), seek_char, result);
if (HP_TIMING_AVAIL)
putchar ('\n');
}
示例11: do_test
static void
do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len)
{
size_t i, j;
char *s1, *s2;
align1 &= 63;
if (align1 + len >= page_size)
return;
align2 &= 63;
if (align2 + len >= page_size)
return;
s1 = (char *) (buf2 + align1);
s2 = (char *) (buf2 + align2);
for (i = 0, j = 1; i < len; i++, j += 23)
s1[i] = j;
json_element_object_begin (json_ctx);
json_attr_uint (json_ctx, "length", (double) len);
json_attr_uint (json_ctx, "align1", (double) align1);
json_attr_uint (json_ctx, "align2", (double) align2);
json_array_begin (json_ctx, "timings");
FOR_EACH_IMPL (impl, 0)
do_one_test (json_ctx, impl, s2, s1, len);
json_array_end (json_ctx);
json_element_object_end (json_ctx);
}
示例12: do_test
static void
do_test (size_t align1, size_t align2, size_t len, size_t n, int max_char)
{
size_t i;
char *s1, *s2;
align1 &= 7;
if (align1 + len >= page_size)
return;
align2 &= 7;
if (align2 + len >= page_size)
return;
s1 = (char *) (buf1 + align1);
s2 = (char *) (buf2 + align2);
for (i = 0; i < len; ++i)
s1[i] = 32 + 23 * i % (max_char - 32);
s1[len] = 0;
for (i = len + 1; i + align1 < page_size && i < len + 64; ++i)
s1[i] = 32 + 32 * i % (max_char - 32);
if (HP_TIMING_AVAIL)
printf ("Length %4zd, n %4zd, alignment %2zd/%2zd:", len, n, align1, align2);
FOR_EACH_IMPL (impl, 0)
do_one_test (impl, s2, s1, len, n);
if (HP_TIMING_AVAIL)
putchar ('\n');
}
示例13: do_test
static int
do_test (void)
{
int mode, ret = 0;
for (mode = 0; mode <= 4; mode++)
ret |= do_one_test (mode);
return ret;
}
示例14: do_test
static void
do_test (size_t align, size_t pos, size_t len)
{
size_t i;
int c;
RES_TYPE result;
char *rej, *s;
align &= 7;
if (align + pos + 10 >= page_size || len > 240)
return;
rej = (char *) (buf2 + (random () & 255));
s = (char *) (buf1 + align);
for (i = 0; i < len; ++i)
{
rej[i] = random () & 255;
if (!rej[i])
rej[i] = random () & 255;
if (!rej[i])
rej[i] = 1 + (random () & 127);
}
rej[len] = '\0';
for (c = 1; c <= 255; ++c)
if (strchr (rej, c) == NULL)
break;
for (i = 0; i < pos; ++i)
{
s[i] = random () & 255;
if (strchr (rej, s[i]))
{
s[i] = random () & 255;
if (strchr (rej, s[i]))
s[i] = c;
}
}
s[pos] = rej[random () % (len + 1)];
if (s[pos])
{
for (i = pos + 1; i < pos + 10; ++i)
s[i] = random () & 255;
s[i] = '\0';
}
result = STRPBRK_RESULT (s, pos);
if (HP_TIMING_AVAIL)
printf ("Length %4zd, alignment %2zd, rej len %2zd:", pos, align, len);
FOR_EACH_IMPL (impl, 0)
do_one_test (impl, s, rej, result);
if (HP_TIMING_AVAIL)
putchar ('\n');
}
示例15: do_test
static int
do_test (void)
{
struct passwd *pwd = getpwnam ("nobody");
if (pwd == NULL)
{
puts ("User nobody doesn't exist");
return 0;
}
nobody_uid = pwd->pw_uid;
nobody_gid = pwd->pw_gid;
if (getresuid (&prev_ruid, &prev_euid, &prev_suid) < 0)
{
printf ("getresuid failed: %m\n");
exit (1);
}
if (getresgid (&prev_rgid, &prev_egid, &prev_sgid) < 0)
{
printf ("getresgid failed: %m\n");
exit (1);
}
if (prev_ruid == nobody_uid || prev_euid == nobody_uid
|| prev_suid == nobody_uid)
{
puts ("already running as user nobody, skipping tests");
exit (0);
}
if (prev_rgid == nobody_gid || prev_egid == nobody_gid
|| prev_sgid == nobody_gid)
{
puts ("already running as group nobody, skipping tests");
exit (0);
}
if (pthread_barrier_init (&b3, NULL, 3) != 0)
{
puts ("barrier_init failed");
exit (1);
}
if (pthread_barrier_init (&b4, NULL, 4) != 0)
{
puts ("barrier_init failed");
exit (1);
}
for (unsigned long int testno = 0;
testno < sizeof (setuid_tests) / sizeof (setuid_tests[0]);
++testno)
do_one_test (testno);
return 0;
}