lib/replace/test/testsuite.c

ソースコードを見る。

関数

static int test_ftruncate (void)
static int test_strlcpy (void)
static int test_strlcat (void)
static int test_mktime (void)
static int test_initgroups (void)
static int test_memmove (void)
static int test_strdup (void)
static int test_setlinebuf (void)
static int test_vsyslog (void)
static int test_timegm (void)
static int test_setenv (void)
static int test_strndup (void)
static int test_strnlen (void)
static int test_waitpid (void)
static int test_seteuid (void)
static int test_setegid (void)
static int test_asprintf (void)
static int test_snprintf (void)
static int test_vasprintf (void)
static int test_vsnprintf (void)
static int test_opendir (void)
int test_readdir_os2_delete (void)
static int test_readdir (void)
static int test_telldir (void)
static int test_seekdir (void)
static int test_dlopen (void)
static int test_chroot (void)
static int test_bzero (void)
static int test_strerror (void)
static int test_errno (void)
static int test_mkdtemp (void)
static int test_mkstemp (void)
static int test_pread (void)
static int test_pwrite (void)
static int test_getpass (void)
static int test_inet_ntoa (void)
static int test_strtoll (void)
static int test_strtoull (void)
static int test_va_copy (void)
static int test_FUNCTION (void)
static int test_MIN (void)
static int test_MAX (void)
static int test_socketpair (void)
int libreplace_test_strptime (void)
static int test_strptime (void)
bool torture_local_replace (struct torture_context *ctx)
int main (void)


関数

static int test_ftruncate ( void   )  [static]

testsuite.c56 行で定義されています。

参照先 errnofdprintf()sizestrerror().

参照元 torture_local_replace().

00057 {
00058         struct stat st;
00059         int fd;
00060         const int size = 1234;
00061         printf("test: ftruncate\n");
00062         unlink(TESTFILE);
00063         fd = open(TESTFILE, O_RDWR|O_CREAT, 0600);
00064         if (fd == -1) {
00065                 printf("failure: ftruncate [\n"
00066                            "creating '%s' failed - %s\n]\n", TESTFILE, strerror(errno));
00067                 return false;
00068         }
00069         if (ftruncate(fd, size) != 0) {
00070                 printf("failure: ftruncate [\n%s\n]\n", strerror(errno));
00071                 return false;
00072         }
00073         if (fstat(fd, &st) != 0) {
00074                 printf("failure: ftruncate [\nfstat failed - %s\n]\n", strerror(errno));
00075                 return false;
00076         }
00077         if (st.st_size != size) {
00078                 printf("failure: ftruncate [\ngave wrong size %d - expected %d\n]\n",
00079                        (int)st.st_size, size);
00080                 return false;
00081         }
00082         unlink(TESTFILE);
00083         printf("success: ftruncate\n");
00084         return true;
00085 }

static int test_strlcpy ( void   )  [static]

testsuite.c91 行で定義されています。

参照先 bufprintf()resultstrlcpy()tests.

参照元 torture_local_replace().

00092 {
00093         char buf[4];
00094         const struct {
00095                 const char *src;
00096                 size_t result;
00097         } tests[] = {
00098                 { "abc", 3 },
00099                 { "abcdef", 6 },
00100                 { "abcd", 4 },
00101                 { "", 0 },
00102                 { NULL, 0 }
00103         };
00104         int i;
00105         printf("test: strlcpy\n");
00106         for (i=0;tests[i].src;i++) {
00107                 if (strlcpy(buf, tests[i].src, sizeof(buf)) != tests[i].result) {
00108                         printf("failure: strlcpy [\ntest %d failed\n]\n", i);
00109                         return false;
00110                 }
00111         }
00112         printf("success: strlcpy\n");
00113         return true;
00114 }

static int test_strlcat ( void   )  [static]

testsuite.c116 行で定義されています。

参照先 printf()strlcat()strlcpy().

参照元 torture_local_replace().

00117 {
00118         char tmp[10];
00119         printf("test: strlcat\n");
00120         strlcpy(tmp, "", sizeof(tmp));
00121         if (strlcat(tmp, "bla", 3) != 3) {
00122                 printf("failure: strlcat [\ninvalid return code\n]\n");
00123                 return false;
00124         }
00125         if (strcmp(tmp, "bl") != 0) {
00126                 printf("failure: strlcat [\nexpected \"bl\", got \"%s\"\n]\n", 
00127                            tmp);
00128                 return false;
00129         }
00130 
00131         strlcpy(tmp, "da", sizeof(tmp));
00132         if (strlcat(tmp, "me", 4) != 4) {
00133                 printf("failure: strlcat [\nexpected \"dam\", got \"%s\"\n]\n",
00134                            tmp);
00135                 return false;
00136         }
00137 
00138         printf("success: strlcat\n");
00139         return true;
00140 }

static int test_mktime ( void   )  [static]

testsuite.c142 行で定義されています。

参照元 torture_local_replace().

00143 {
00144         /* FIXME */
00145         return true;
00146 }

static int test_initgroups ( void   )  [static]

testsuite.c148 行で定義されています。

参照元 torture_local_replace().

00149 {
00150         /* FIXME */
00151         return true;
00152 }

static int test_memmove ( void   )  [static]

testsuite.c154 行で定義されています。

参照元 torture_local_replace().

00155 {
00156         /* FIXME */
00157         return true;
00158 }

static int test_strdup ( void   )  [static]

testsuite.c160 行で定義されています。

参照先 printf()strdup().

参照元 torture_local_replace().

00161 {
00162         char *x;
00163         printf("test: strdup\n");
00164         x = strdup("bla");
00165         if (strcmp("bla", x) != 0) {
00166                 printf("failure: strdup [\nfailed: expected \"bla\", got \"%s\"\n]\n",
00167                            x);
00168                 return false;
00169         }
00170         free(x);
00171         printf("success: strdup\n");
00172         return true;
00173 }       

static int test_setlinebuf ( void   )  [static]

testsuite.c175 行で定義されています。

参照先 printf().

参照元 torture_local_replace().

00176 {
00177         printf("test: setlinebuf\n");
00178         setlinebuf(stdout);
00179         printf("success: setlinebuf\n");
00180         return true;
00181 }

static int test_vsyslog ( void   )  [static]

testsuite.c183 行で定義されています。

参照元 torture_local_replace().

00184 {
00185         /* FIXME */
00186         return true;
00187 }

static int test_timegm ( void   )  [static]

testsuite.c189 行で定義されています。

参照元 torture_local_replace().

00190 {
00191         /* FIXME */
00192         return true;
00193 }

static int test_setenv ( void   )  [static]

testsuite.c195 行で定義されています。

参照先 printf().

参照元 torture_local_replace().

00196 {
00197 #define TEST_SETENV(key, value, overwrite, result) do { \
00198         int _ret; \
00199         char *_v; \
00200         _ret = setenv(key, value, overwrite); \
00201         if (_ret != 0) { \
00202                 printf("failure: setenv [\n" \
00203                         "setenv(%s, %s, %d) failed\n" \
00204                         "]\n", \
00205                         key, value, overwrite); \
00206                 return false; \
00207         } \
00208         _v=getenv(key); \
00209         if (!_v) { \
00210                 printf("failure: setenv [\n" \
00211                         "getenv(%s) returned NULL\n" \
00212                         "]\n", \
00213                         key); \
00214                 return false; \
00215         } \
00216         if (strcmp(result, _v) != 0) { \
00217                 printf("failure: setenv [\n" \
00218                         "getenv(%s): '%s' != '%s'\n" \
00219                         "]\n", \
00220                         key, result, _v); \
00221                 return false; \
00222         } \
00223 } while(0)
00224 
00225 #define TEST_UNSETENV(key) do { \
00226         char *_v; \
00227         unsetenv(key); \
00228         _v=getenv(key); \
00229         if (_v) { \
00230                 printf("failure: setenv [\n" \
00231                         "getenv(%s): NULL != '%s'\n" \
00232                         "]\n", \
00233                         SETENVTEST_KEY, _v); \
00234                 return false; \
00235         } \
00236 } while (0)
00237 
00238 #define SETENVTEST_KEY "SETENVTESTKEY"
00239 #define SETENVTEST_VAL "SETENVTESTVAL"
00240 
00241         printf("test: setenv\n");
00242         TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"1", 0, SETENVTEST_VAL"1");
00243         TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"2", 0, SETENVTEST_VAL"1");
00244         TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"3", 1, SETENVTEST_VAL"3");
00245         TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"4", 1, SETENVTEST_VAL"4");
00246         TEST_UNSETENV(SETENVTEST_KEY);
00247         TEST_UNSETENV(SETENVTEST_KEY);
00248         TEST_SETENV(SETENVTEST_KEY, SETENVTEST_VAL"5", 0, SETENVTEST_VAL"5");
00249         TEST_UNSETENV(SETENVTEST_KEY);
00250         TEST_UNSETENV(SETENVTEST_KEY);
00251         printf("success: setenv\n");
00252         return true;
00253 }

static int test_strndup ( void   )  [static]

testsuite.c255 行で定義されています。

参照先 printf().

参照元 torture_local_replace().

00256 {
00257         char *x;
00258         printf("test: strndup\n");
00259         x = strndup("bla", 0);
00260         if (strcmp(x, "") != 0) {
00261                 printf("failure: strndup [\ninvalid\n]\n");
00262                 return false;
00263         }
00264         free(x);
00265         x = strndup("bla", 2);
00266         if (strcmp(x, "bl") != 0) {
00267                 printf("failure: strndup [\ninvalid\n]\n");
00268                 return false;
00269         }
00270         free(x);
00271         x = strndup("bla", 10);
00272         if (strcmp(x, "bla") != 0) {
00273                 printf("failure: strndup [\ninvalid\n]\n");
00274                 return false;
00275         }
00276         free(x);
00277         printf("success: strndup\n");
00278         return true;
00279 }

static int test_strnlen ( void   )  [static]

testsuite.c281 行で定義されています。

参照先 printf().

参照元 torture_local_replace().

00282 {
00283         printf("test: strnlen\n");
00284         if (strnlen("bla", 2) != 2) {
00285                 printf("failure: strnlen [\nunexpected length\n]\n");
00286                 return false;
00287         }
00288 
00289         if (strnlen("some text\n", 0) != 0) {
00290                 printf("failure: strnlen [\nunexpected length\n]\n");
00291                 return false;
00292         }
00293 
00294         if (strnlen("some text", 20) != 9) {
00295                 printf("failure: strnlen [\nunexpected length\n]\n");
00296                 return false;
00297         }
00298 
00299         printf("success: strnlen\n");
00300         return true;
00301 }

static int test_waitpid ( void   )  [static]

testsuite.c303 行で定義されています。

参照元 torture_local_replace().

00304 {
00305         /* FIXME */
00306         return true;
00307 }

static int test_seteuid ( void   )  [static]

testsuite.c309 行で定義されています。

参照元 torture_local_replace().

00310 {
00311         /* FIXME */
00312         return true;
00313 }

static int test_setegid ( void   )  [static]

testsuite.c315 行で定義されています。

参照元 torture_local_replace().

00316 {
00317         /* FIXME */
00318         return true;
00319 }

static int test_asprintf ( void   )  [static]

testsuite.c321 行で定義されています。

参照先 asprintf()printf().

参照元 torture_local_replace().

00322 {
00323         char *x;
00324         printf("test: asprintf\n");
00325         if (asprintf(&x, "%d", 9) != 1) {
00326                 printf("failure: asprintf [\ngenerate asprintf\n]\n");
00327                 return false;
00328         }
00329         if (strcmp(x, "9") != 0) {
00330                 printf("failure: asprintf [\ngenerate asprintf\n]\n");
00331                 return false;
00332         }
00333         if (asprintf(&x, "dat%s", "a") != 4) {
00334                 printf("failure: asprintf [\ngenerate asprintf\n]\n");
00335                 return false;
00336         }
00337         if (strcmp(x, "data") != 0) {
00338                 printf("failure: asprintf [\ngenerate asprintf\n]\n");
00339                 return false;
00340         }
00341         printf("success: asprintf\n");
00342         return true;
00343 }

static int test_snprintf ( void   )  [static]

testsuite.c345 行で定義されています。

参照先 printf()snprintf().

参照元 torture_local_replace().

00346 {
00347         char tmp[10];
00348         printf("test: snprintf\n");
00349         if (snprintf(tmp, 3, "foo%d", 9) != 4) {
00350                 printf("failure: snprintf [\nsnprintf return code failed\n]\n");
00351                 return false;
00352         }
00353 
00354         if (strcmp(tmp, "fo") != 0) {
00355                 printf("failure: snprintf [\nsnprintf failed\n]\n");
00356                 return false;
00357         }
00358 
00359         printf("success: snprintf\n");
00360         return true;
00361 }

static int test_vasprintf ( void   )  [static]

testsuite.c363 行で定義されています。

参照元 torture_local_replace().

00364 {
00365         /* FIXME */
00366         return true;
00367 }

static int test_vsnprintf ( void   )  [static]

testsuite.c369 行で定義されています。

参照元 torture_local_replace().

00370 {
00371         /* FIXME */
00372         return true;
00373 }

static int test_opendir ( void   )  [static]

testsuite.c375 行で定義されています。

参照元 torture_local_replace().

00376 {
00377         /* FIXME */
00378         return true;
00379 }

int test_readdir_os2_delete ( void   ) 

os2_delete.c80 行で定義されています。

参照先 cleanup()closedir()create_files()errnofprintf()opendir()os2_delete()readdir()test_readdir_os2_delete_rettotal_deleted.

参照元 test_readdir().

00081 {
00082         int total_deleted = 0;
00083         DIR *d;
00084         struct dirent *de;
00085 
00086         test_readdir_os2_delete_ret = 0;
00087 
00088         cleanup();
00089         create_files();
00090 
00091         d = opendir(TESTDIR "/test0.txt");
00092         if (d != NULL) FAILED("opendir() on file succeed");
00093         if (errno != ENOTDIR) FAILED("opendir() on file didn't give ENOTDIR");
00094 
00095         d = opendir(TESTDIR);
00096 
00097         /* skip past . and .. */
00098         de = readdir(d);
00099         strcmp(de->d_name, ".") == 0 || FAILED("match .");
00100         de = readdir(d);
00101         strcmp(de->d_name, "..") == 0 || FAILED("match ..");
00102 
00103         while (1) {
00104                 int n = os2_delete(d);
00105                 if (n == 0) break;
00106                 total_deleted += n;
00107         }
00108         closedir(d);
00109 
00110         fprintf(stderr, "Deleted %d files of %d\n", total_deleted, NUM_FILES);
00111 
00112         rmdir(TESTDIR) == 0 || FAILED("rmdir");
00113 
00114         system("rm -rf " TESTDIR);
00115 
00116         return test_readdir_os2_delete_ret;
00117 }

static int test_readdir ( void   )  [static]

testsuite.c383 行で定義されています。

参照先 printf()test_readdir_os2_delete().

参照元 torture_local_replace().

00384 {
00385         printf("test: readdir\n");
00386         if (test_readdir_os2_delete() != 0) {
00387                 return false;
00388         }
00389         printf("success: readdir\n");
00390         return true;
00391 }

static int test_telldir ( void   )  [static]

testsuite.c393 行で定義されています。

参照元 torture_local_replace().

00394 {
00395         /* FIXME */
00396         return true;
00397 }

static int test_seekdir ( void   )  [static]

testsuite.c399 行で定義されています。

参照元 torture_local_replace().

00400 {
00401         /* FIXME */
00402         return true;
00403 }

static int test_dlopen ( void   )  [static]

testsuite.c405 行で定義されています。

参照元 torture_local_replace().

00406 {
00407         /* FIXME: test dlopen, dlsym, dlclose, dlerror */
00408         return true;
00409 }

static int test_chroot ( void   )  [static]

testsuite.c412 行で定義されています。

参照元 torture_local_replace().

00413 {
00414         /* FIXME: chroot() */
00415         return true;
00416 }

static int test_bzero ( void   )  [static]

testsuite.c418 行で定義されています。

参照元 torture_local_replace().

00419 {
00420         /* FIXME: bzero */
00421         return true;
00422 }

static int test_strerror ( void   )  [static]

testsuite.c424 行で定義されています。

参照元 torture_local_replace().

00425 {
00426         /* FIXME */
00427         return true;
00428 }

static int test_errno ( void   )  [static]

testsuite.c430 行で定義されています。

参照先 errnoprintf().

参照元 torture_local_replace().

00431 {
00432         printf("test: errno\n");
00433         errno = 3;
00434         if (errno != 3) {
00435                 printf("failure: errno [\nerrno failed\n]\n");
00436                 return false;
00437         }
00438 
00439         printf("success: errno\n");
00440         return true;
00441 }

static int test_mkdtemp ( void   )  [static]

testsuite.c443 行で定義されています。

参照元 torture_local_replace().

00444 {
00445         /* FIXME */
00446         return true;
00447 }

static int test_mkstemp ( void   )  [static]

testsuite.c449 行で定義されています。

参照元 torture_local_replace().

00450 {
00451         /* FIXME */
00452         return true;
00453 }

static int test_pread ( void   )  [static]

testsuite.c455 行で定義されています。

参照元 torture_local_replace().

00456 {
00457         /* FIXME */
00458         return true;
00459 }

static int test_pwrite ( void   )  [static]

testsuite.c461 行で定義されています。

参照元 torture_local_replace().

00462 {
00463         /* FIXME */
00464         return true;
00465 }

static int test_getpass ( void   )  [static]

testsuite.c467 行で定義されています。

参照元 torture_local_replace().

00468 {
00469         /* FIXME */
00470         return true;
00471 }

static int test_inet_ntoa ( void   )  [static]

testsuite.c473 行で定義されています。

参照元 torture_local_replace().

00474 {
00475         /* FIXME */
00476         return true;
00477 }

static int test_strtoll ( void   )  [static]

testsuite.c519 行で定義されています。

参照先 printf().

参照元 torture_local_replace().

00520 {
00521         printf("test: strtoll\n");
00522 
00523 #define TEST_STRTOLL(str,base,res,diff,errnoo) TEST_STRTO_X(int64_t, "%lld", strtoll,str,base,res,diff,errnoo)
00524 
00525         TEST_STRTOLL("15",      10,     15LL,   2, 0);
00526         TEST_STRTOLL("  15",    10,     15LL,   4, 0);
00527         TEST_STRTOLL("15",      0,      15LL,   2, 0);
00528         TEST_STRTOLL(" 15 ",    0,      15LL,   3, 0);
00529         TEST_STRTOLL("+15",     10,     15LL,   3, 0);
00530         TEST_STRTOLL("  +15",   10,     15LL,   5, 0);
00531         TEST_STRTOLL("+15",     0,      15LL,   3, 0);
00532         TEST_STRTOLL(" +15 ",   0,      15LL,   4, 0);
00533         TEST_STRTOLL("-15",     10,     -15LL,  3, 0);
00534         TEST_STRTOLL("  -15",   10,     -15LL,  5, 0);
00535         TEST_STRTOLL("-15",     0,      -15LL,  3, 0);
00536         TEST_STRTOLL(" -15 ",   0,      -15LL,  4, 0);
00537         TEST_STRTOLL("015",     10,     15LL,   3, 0);
00538         TEST_STRTOLL("  015",   10,     15LL,   5, 0);
00539         TEST_STRTOLL("015",     0,      13LL,   3, 0);
00540         TEST_STRTOLL("  015",   0,      13LL,   5, 0);
00541         TEST_STRTOLL("0x15",    10,     0LL,    1, 0);
00542         TEST_STRTOLL("  0x15",  10,     0LL,    3, 0);
00543         TEST_STRTOLL("0x15",    0,      21LL,   4, 0);
00544         TEST_STRTOLL("  0x15",  0,      21LL,   6, 0);
00545 
00546         TEST_STRTOLL("10",      16,     16LL,   2, 0);
00547         TEST_STRTOLL("  10 ",   16,     16LL,   4, 0);
00548         TEST_STRTOLL("0x10",    16,     16LL,   4, 0);
00549         TEST_STRTOLL("0x10",    0,      16LL,   4, 0);
00550         TEST_STRTOLL(" 0x10 ",  0,      16LL,   5, 0);
00551         TEST_STRTOLL("+10",     16,     16LL,   3, 0);
00552         TEST_STRTOLL("  +10 ",  16,     16LL,   5, 0);
00553         TEST_STRTOLL("+0x10",   16,     16LL,   5, 0);
00554         TEST_STRTOLL("+0x10",   0,      16LL,   5, 0);
00555         TEST_STRTOLL(" +0x10 ", 0,      16LL,   6, 0);
00556         TEST_STRTOLL("-10",     16,     -16LL,  3, 0);
00557         TEST_STRTOLL("  -10 ",  16,     -16LL,  5, 0);
00558         TEST_STRTOLL("-0x10",   16,     -16LL,  5, 0);
00559         TEST_STRTOLL("-0x10",   0,      -16LL,  5, 0);
00560         TEST_STRTOLL(" -0x10 ", 0,      -16LL,  6, 0);
00561         TEST_STRTOLL("010",     16,     16LL,   3, 0);
00562         TEST_STRTOLL("  010 ",  16,     16LL,   5, 0);
00563         TEST_STRTOLL("-010",    16,     -16LL,  4, 0);
00564 
00565         TEST_STRTOLL("11",      8,      9LL,    2, 0);
00566         TEST_STRTOLL("011",     8,      9LL,    3, 0);
00567         TEST_STRTOLL("011",     0,      9LL,    3, 0);
00568         TEST_STRTOLL("-11",     8,      -9LL,   3, 0);
00569         TEST_STRTOLL("-011",    8,      -9LL,   4, 0);
00570         TEST_STRTOLL("-011",    0,      -9LL,   4, 0);
00571 
00572         TEST_STRTOLL("011",     8,      9LL,    3, 0);
00573         TEST_STRTOLL("011",     0,      9LL,    3, 0);
00574         TEST_STRTOLL("-11",     8,      -9LL,   3, 0);
00575         TEST_STRTOLL("-011",    8,      -9LL,   4, 0);
00576         TEST_STRTOLL("-011",    0,      -9LL,   4, 0);
00577 
00578         TEST_STRTOLL("Text",    0,      0LL,    0, 0);
00579 
00580         TEST_STRTOLL("9223372036854775807",     10,     9223372036854775807LL,  19, 0);
00581         TEST_STRTOLL("9223372036854775807",     0,      9223372036854775807LL,  19, 0);
00582         TEST_STRTOLL("9223372036854775808",     0,      9223372036854775807LL,  19, ERANGE);
00583         TEST_STRTOLL("9223372036854775808",     10,     9223372036854775807LL,  19, ERANGE);
00584         TEST_STRTOLL("0x7FFFFFFFFFFFFFFF",      0,      9223372036854775807LL,  18, 0);
00585         TEST_STRTOLL("0x7FFFFFFFFFFFFFFF",      16,     9223372036854775807LL,  18, 0);
00586         TEST_STRTOLL("7FFFFFFFFFFFFFFF",        16,     9223372036854775807LL,  16, 0);
00587         TEST_STRTOLL("0x8000000000000000",      0,      9223372036854775807LL,  18, ERANGE);
00588         TEST_STRTOLL("0x8000000000000000",      16,     9223372036854775807LL,  18, ERANGE);
00589         TEST_STRTOLL("80000000000000000",       16,     9223372036854775807LL,  17, ERANGE);
00590         TEST_STRTOLL("0777777777777777777777",  0,      9223372036854775807LL,  22, 0);
00591         TEST_STRTOLL("0777777777777777777777",  8,      9223372036854775807LL,  22, 0);
00592         TEST_STRTOLL("777777777777777777777",   8,      9223372036854775807LL,  21, 0);
00593         TEST_STRTOLL("01000000000000000000000", 0,      9223372036854775807LL,  23, ERANGE);
00594         TEST_STRTOLL("01000000000000000000000", 8,      9223372036854775807LL,  23, ERANGE);
00595         TEST_STRTOLL("1000000000000000000000",  8,      9223372036854775807LL,  22, ERANGE);
00596 
00597         TEST_STRTOLL("-9223372036854775808",    10,     -9223372036854775807LL -1,      20, 0);
00598         TEST_STRTOLL("-9223372036854775808",    0,      -9223372036854775807LL -1,      20, 0);
00599         TEST_STRTOLL("-9223372036854775809",    0,      -9223372036854775807LL -1,      20, ERANGE);
00600         TEST_STRTOLL("-9223372036854775809",    10,     -9223372036854775807LL -1,      20, ERANGE);
00601         TEST_STRTOLL("-0x8000000000000000",     0,      -9223372036854775807LL -1,      19, 0);
00602         TEST_STRTOLL("-0x8000000000000000",     16,     -9223372036854775807LL -1,      19, 0);
00603         TEST_STRTOLL("-8000000000000000",       16,     -9223372036854775807LL -1,      17, 0);
00604         TEST_STRTOLL("-0x8000000000000001",     0,      -9223372036854775807LL -1,      19, ERANGE);
00605         TEST_STRTOLL("-0x8000000000000001",     16,     -9223372036854775807LL -1,      19, ERANGE);
00606         TEST_STRTOLL("-80000000000000001",      16,     -9223372036854775807LL -1,      18, ERANGE);
00607         TEST_STRTOLL("-01000000000000000000000",0,      -9223372036854775807LL -1,      24, 0);
00608         TEST_STRTOLL("-01000000000000000000000",8,      -9223372036854775807LL -1,      24, 0);
00609         TEST_STRTOLL("-1000000000000000000000", 8,      -9223372036854775807LL -1,      23, 0);
00610         TEST_STRTOLL("-01000000000000000000001",0,      -9223372036854775807LL -1,      24, ERANGE);
00611         TEST_STRTOLL("-01000000000000000000001",8,      -9223372036854775807LL -1,      24, ERANGE);
00612         TEST_STRTOLL("-1000000000000000000001", 8,      -9223372036854775807LL -1,      23, ERANGE);
00613 
00614         printf("success: strtoll\n");
00615         return true;
00616 }

static int test_strtoull ( void   )  [static]

testsuite.c618 行で定義されています。

参照先 printf().

参照元 torture_local_replace().

00619 {
00620         printf("test: strtoull\n");
00621 
00622 #define TEST_STRTOULL(str,base,res,diff,errnoo) TEST_STRTO_X(uint64_t,"%llu",strtoull,str,base,res,diff,errnoo)
00623 
00624         TEST_STRTOULL("15",     10,     15LLU,  2, 0);
00625         TEST_STRTOULL("  15",   10,     15LLU,  4, 0);
00626         TEST_STRTOULL("15",     0,      15LLU,  2, 0);
00627         TEST_STRTOULL(" 15 ",   0,      15LLU,  3, 0);
00628         TEST_STRTOULL("+15",    10,     15LLU,  3, 0);
00629         TEST_STRTOULL("  +15",  10,     15LLU,  5, 0);
00630         TEST_STRTOULL("+15",    0,      15LLU,  3, 0);
00631         TEST_STRTOULL(" +15 ",  0,      15LLU,  4, 0);
00632         TEST_STRTOULL("-15",    10,     18446744073709551601LLU,        3, 0);
00633         TEST_STRTOULL("  -15",  10,     18446744073709551601LLU,        5, 0);
00634         TEST_STRTOULL("-15",    0,      18446744073709551601LLU,        3, 0);
00635         TEST_STRTOULL(" -15 ",  0,      18446744073709551601LLU,        4, 0);
00636         TEST_STRTOULL("015",    10,     15LLU,  3, 0);
00637         TEST_STRTOULL("  015",  10,     15LLU,  5, 0);
00638         TEST_STRTOULL("015",    0,      13LLU,  3, 0);
00639         TEST_STRTOULL("  015",  0,      13LLU,  5, 0);
00640         TEST_STRTOULL("0x15",   10,     0LLU,   1, 0);
00641         TEST_STRTOULL("  0x15", 10,     0LLU,   3, 0);
00642         TEST_STRTOULL("0x15",   0,      21LLU,  4, 0);
00643         TEST_STRTOULL("  0x15", 0,      21LLU,  6, 0);
00644 
00645         TEST_STRTOULL("10",     16,     16LLU,  2, 0);
00646         TEST_STRTOULL("  10 ",  16,     16LLU,  4, 0);
00647         TEST_STRTOULL("0x10",   16,     16LLU,  4, 0);
00648         TEST_STRTOULL("0x10",   0,      16LLU,  4, 0);
00649         TEST_STRTOULL(" 0x10 ", 0,      16LLU,  5, 0);
00650         TEST_STRTOULL("+10",    16,     16LLU,  3, 0);
00651         TEST_STRTOULL("  +10 ", 16,     16LLU,  5, 0);
00652         TEST_STRTOULL("+0x10",  16,     16LLU,  5, 0);
00653         TEST_STRTOULL("+0x10",  0,      16LLU,  5, 0);
00654         TEST_STRTOULL(" +0x10 ",        0,      16LLU,  6, 0);
00655         TEST_STRTOULL("-10",    16,     -16LLU, 3, 0);
00656         TEST_STRTOULL("  -10 ", 16,     -16LLU, 5, 0);
00657         TEST_STRTOULL("-0x10",  16,     -16LLU, 5, 0);
00658         TEST_STRTOULL("-0x10",  0,      -16LLU, 5, 0);
00659         TEST_STRTOULL(" -0x10 ",        0,      -16LLU, 6, 0);
00660         TEST_STRTOULL("010",    16,     16LLU,  3, 0);
00661         TEST_STRTOULL("  010 ", 16,     16LLU,  5, 0);
00662         TEST_STRTOULL("-010",   16,     -16LLU, 4, 0);
00663 
00664         TEST_STRTOULL("11",     8,      9LLU,   2, 0);
00665         TEST_STRTOULL("011",    8,      9LLU,   3, 0);
00666         TEST_STRTOULL("011",    0,      9LLU,   3, 0);
00667         TEST_STRTOULL("-11",    8,      -9LLU,  3, 0);
00668         TEST_STRTOULL("-011",   8,      -9LLU,  4, 0);
00669         TEST_STRTOULL("-011",   0,      -9LLU,  4, 0);
00670 
00671         TEST_STRTOULL("011",    8,      9LLU,   3, 0);
00672         TEST_STRTOULL("011",    0,      9LLU,   3, 0);
00673         TEST_STRTOULL("-11",    8,      -9LLU,  3, 0);
00674         TEST_STRTOULL("-011",   8,      -9LLU,  4, 0);
00675         TEST_STRTOULL("-011",   0,      -9LLU,  4, 0);
00676 
00677         TEST_STRTOULL("Text",   0,      0LLU,   0, 0);
00678 
00679         TEST_STRTOULL("9223372036854775807",    10,     9223372036854775807LLU, 19, 0);
00680         TEST_STRTOULL("9223372036854775807",    0,      9223372036854775807LLU, 19, 0);
00681         TEST_STRTOULL("9223372036854775808",    0,      9223372036854775808LLU, 19, 0);
00682         TEST_STRTOULL("9223372036854775808",    10,     9223372036854775808LLU, 19, 0);
00683         TEST_STRTOULL("0x7FFFFFFFFFFFFFFF",     0,      9223372036854775807LLU, 18, 0);
00684         TEST_STRTOULL("0x7FFFFFFFFFFFFFFF",     16,     9223372036854775807LLU, 18, 0);
00685         TEST_STRTOULL("7FFFFFFFFFFFFFFF",       16,     9223372036854775807LLU, 16, 0);
00686         TEST_STRTOULL("0x8000000000000000",     0,      9223372036854775808LLU, 18, 0);
00687         TEST_STRTOULL("0x8000000000000000",     16,     9223372036854775808LLU, 18, 0);
00688         TEST_STRTOULL("8000000000000000",       16,     9223372036854775808LLU, 16, 0);
00689         TEST_STRTOULL("0777777777777777777777", 0,      9223372036854775807LLU, 22, 0);
00690         TEST_STRTOULL("0777777777777777777777", 8,      9223372036854775807LLU, 22, 0);
00691         TEST_STRTOULL("777777777777777777777",  8,      9223372036854775807LLU, 21, 0);
00692         TEST_STRTOULL("01000000000000000000000",0,      9223372036854775808LLU, 23, 0);
00693         TEST_STRTOULL("01000000000000000000000",8,      9223372036854775808LLU, 23, 0);
00694         TEST_STRTOULL("1000000000000000000000", 8,      9223372036854775808LLU, 22, 0);
00695 
00696         TEST_STRTOULL("-9223372036854775808",   10,     9223372036854775808LLU, 20, 0);
00697         TEST_STRTOULL("-9223372036854775808",   0,      9223372036854775808LLU, 20, 0);
00698         TEST_STRTOULL("-9223372036854775809",   0,      9223372036854775807LLU, 20, 0);
00699         TEST_STRTOULL("-9223372036854775809",   10,     9223372036854775807LLU, 20, 0);
00700         TEST_STRTOULL("-0x8000000000000000",    0,      9223372036854775808LLU, 19, 0);
00701         TEST_STRTOULL("-0x8000000000000000",    16,     9223372036854775808LLU, 19, 0);
00702         TEST_STRTOULL("-8000000000000000",      16,     9223372036854775808LLU, 17, 0);
00703         TEST_STRTOULL("-0x8000000000000001",    0,      9223372036854775807LLU, 19, 0);
00704         TEST_STRTOULL("-0x8000000000000001",    16,     9223372036854775807LLU, 19, 0);
00705         TEST_STRTOULL("-8000000000000001",      16,     9223372036854775807LLU, 17, 0);
00706         TEST_STRTOULL("-01000000000000000000000",0,     9223372036854775808LLU, 24, 0);
00707         TEST_STRTOULL("-01000000000000000000000",8,     9223372036854775808LLU, 24, 0);
00708         TEST_STRTOULL("-1000000000000000000000",8,      9223372036854775808LLU, 23, 0);
00709         TEST_STRTOULL("-01000000000000000000001",0,     9223372036854775807LLU, 24, 0);
00710         TEST_STRTOULL("-01000000000000000000001",8,     9223372036854775807LLU, 24, 0);
00711         TEST_STRTOULL("-1000000000000000000001",8,      9223372036854775807LLU, 23, 0);
00712 
00713         TEST_STRTOULL("18446744073709551615",   0,      18446744073709551615LLU,        20, 0);
00714         TEST_STRTOULL("18446744073709551615",   10,     18446744073709551615LLU,        20, 0);
00715         TEST_STRTOULL("18446744073709551616",   0,      18446744073709551615LLU,        20, ERANGE);
00716         TEST_STRTOULL("18446744073709551616",   10,     18446744073709551615LLU,        20, ERANGE);
00717         TEST_STRTOULL("0xFFFFFFFFFFFFFFFF",     0,      18446744073709551615LLU,        18, 0);
00718         TEST_STRTOULL("0xFFFFFFFFFFFFFFFF",     16,     18446744073709551615LLU,        18, 0);
00719         TEST_STRTOULL("FFFFFFFFFFFFFFFF",       16,     18446744073709551615LLU,        16, 0);
00720         TEST_STRTOULL("0x10000000000000000",    0,      18446744073709551615LLU,        19, ERANGE);
00721         TEST_STRTOULL("0x10000000000000000",    16,     18446744073709551615LLU,        19, ERANGE);
00722         TEST_STRTOULL("10000000000000000",      16,     18446744073709551615LLU,        17, ERANGE);
00723         TEST_STRTOULL("01777777777777777777777",0,      18446744073709551615LLU,        23, 0);
00724         TEST_STRTOULL("01777777777777777777777",8,      18446744073709551615LLU,        23, 0);
00725         TEST_STRTOULL("1777777777777777777777", 8,      18446744073709551615LLU,        22, 0);
00726         TEST_STRTOULL("02000000000000000000000",0,      18446744073709551615LLU,        23, ERANGE);
00727         TEST_STRTOULL("02000000000000000000000",8,      18446744073709551615LLU,        23, ERANGE);
00728         TEST_STRTOULL("2000000000000000000000", 8,      18446744073709551615LLU,        22, ERANGE);
00729 
00730         TEST_STRTOULL("-18446744073709551615",  0,      1LLU,                           21, 0);
00731         TEST_STRTOULL("-18446744073709551615",  10,     1LLU,                           21, 0);
00732         TEST_STRTOULL("-18446744073709551616",  0,      18446744073709551615LLU,        21, ERANGE);
00733         TEST_STRTOULL("-18446744073709551616",  10,     18446744073709551615LLU,        21, ERANGE);
00734         TEST_STRTOULL("-0xFFFFFFFFFFFFFFFF",    0,      1LLU,                           19, 0);
00735         TEST_STRTOULL("-0xFFFFFFFFFFFFFFFF",    16,     1LLU,                           19, 0);
00736         TEST_STRTOULL("-FFFFFFFFFFFFFFFF",      16,     1LLU,                           17, 0);
00737         TEST_STRTOULL("-0x10000000000000000",   0,      18446744073709551615LLU,        20, ERANGE);
00738         TEST_STRTOULL("-0x10000000000000000",   16,     18446744073709551615LLU,        20, ERANGE);
00739         TEST_STRTOULL("-10000000000000000",     16,     18446744073709551615LLU,        18, ERANGE);
00740         TEST_STRTOULL("-01777777777777777777777",0,     1LLU,                           24, 0);
00741         TEST_STRTOULL("-01777777777777777777777",8,     1LLU,                           24, 0);
00742         TEST_STRTOULL("-1777777777777777777777",8,      1LLU,                           23, 0);
00743         TEST_STRTOULL("-02000000000000000000000",0,     18446744073709551615LLU,        24, ERANGE);
00744         TEST_STRTOULL("-02000000000000000000000",8,     18446744073709551615LLU,        24, ERANGE);
00745         TEST_STRTOULL("-2000000000000000000000",8,      18446744073709551615LLU,        23, ERANGE);
00746 
00747         printf("success: strtuoll\n");
00748         return true;
00749 }

static int test_va_copy ( void   )  [static]

testsuite.c767 行で定義されています。

参照元 torture_local_replace().

00768 {
00769         /* FIXME */
00770         return true;
00771 }

static int test_FUNCTION ( void   )  [static]

testsuite.c773 行で定義されています。

参照先 printf().

参照元 torture_local_replace().

00774 {
00775         printf("test: FUNCTION\n");
00776         if (strcmp(__FUNCTION__, "test_FUNCTION") != 0) {
00777                 printf("failure: FAILURE [\nFAILURE invalid\n]\n");
00778                 return false;
00779         }
00780         printf("success: FUNCTION\n");
00781         return true;
00782 }

static int test_MIN ( void   )  [static]

testsuite.c784 行で定義されています。

参照先 printf().

参照元 torture_local_replace().

00785 {
00786         printf("test: MIN\n");
00787         if (MIN(20, 1) != 1) {
00788                 printf("failure: MIN [\nMIN invalid\n]\n");
00789                 return false;
00790         }
00791         if (MIN(1, 20) != 1) {
00792                 printf("failure: MIN [\nMIN invalid\n]\n");
00793                 return false;
00794         }
00795         printf("success: MIN\n");
00796         return true;
00797 }

static int test_MAX ( void   )  [static]

testsuite.c799 行で定義されています。

参照先 printf().

参照元 torture_local_replace().

00800 {
00801         printf("test: MAX\n");
00802         if (MAX(20, 1) != 20) {
00803                 printf("failure: MAX [\nMAX invalid\n]\n");
00804                 return false;
00805         }
00806         if (MAX(1, 20) != 20) {
00807                 printf("failure: MAX [\nMAX invalid\n]\n");
00808                 return false;
00809         }
00810         printf("success: MAX\n");
00811         return true;
00812 }

static int test_socketpair ( void   )  [static]

testsuite.c814 行で定義されています。

参照先 buferrnoprintf()strerror().

参照元 torture_local_replace().

00815 {
00816         int sock[2];
00817         char buf[20];
00818 
00819         printf("test: socketpair\n");
00820 
00821         if (socketpair(AF_UNIX, SOCK_STREAM, 0, sock) == -1) {
00822                 printf("failure: socketpair [\n"
00823                            "socketpair() failed\n"
00824                            "]\n");
00825                 return false;
00826         }
00827 
00828         if (write(sock[1], "automatisch", 12) == -1) {
00829                 printf("failure: socketpair [\n"
00830                            "write() failed: %s\n"
00831                            "]\n", strerror(errno));
00832                 return false;
00833         }
00834 
00835         if (read(sock[0], buf, 12) == -1) {
00836                 printf("failure: socketpair [\n"
00837                            "read() failed: %s\n"
00838                            "]\n", strerror(errno));
00839                 return false;
00840         }
00841 
00842         if (strcmp(buf, "automatisch") != 0) {
00843                 printf("failure: socketpair [\n"
00844                            "expected: automatisch, got: %s\n"
00845                            "]\n", buf);
00846                 return false;
00847         }
00848 
00849         printf("success: socketpair\n");
00850 
00851         return true;
00852 }

int libreplace_test_strptime ( void   ) 

strptime.c25 行で定義されています。

参照先 printf().

参照元 main()test_strptime().

00026 {
00027         const char *s = "20070414101546Z";
00028         char *ret;
00029         struct tm t, t2;
00030 
00031         memset(&t, 0, sizeof(t));
00032         memset(&t2, 0, sizeof(t2));
00033 
00034         printf("test: strptime\n");
00035 
00036         ret = strptime(s, "%Y%m%d%H%M%S", &t);
00037         if ( ret == NULL ) {
00038                 printf("failure: strptime [\n"
00039                        "returned NULL\n"
00040                        "]\n");
00041                 return false;
00042         }
00043 
00044         if ( *ret != 'Z' ) {
00045                 printf("failure: strptime [\n"
00046                        "ret doesn't point to 'Z'\n"
00047                        "]\n");
00048                 return false;
00049         }
00050 
00051         ret = strptime(s, "%Y%m%d%H%M%SZ", &t2);
00052         if ( ret == NULL ) {
00053                 printf("failure: strptime [\n"
00054                        "returned NULL with Z\n"
00055                        "]\n");
00056                 return false;
00057         }
00058 
00059         if ( *ret != '\0' ) {
00060                 printf("failure: strptime [\n"
00061                        "ret doesn't point to '\\0'\n"
00062                        "]\n");
00063                 return false;
00064         }
00065 
00066 #define CMP_TM_ELEMENT(t1,t2,elem) \
00067         if (t1.elem != t2.elem) { \
00068                 printf("failure: strptime [\n" \
00069                        "result differs if the format string has a 'Z' at the end\n" \
00070                        "element: %s %d != %d\n" \
00071                        "]\n", \
00072                        __STRING(elen), t1.elem, t2.elem); \
00073                 return false; \
00074         }
00075 
00076         CMP_TM_ELEMENT(t,t2,tm_sec);
00077         CMP_TM_ELEMENT(t,t2,tm_min);
00078         CMP_TM_ELEMENT(t,t2,tm_hour);
00079         CMP_TM_ELEMENT(t,t2,tm_mday);
00080         CMP_TM_ELEMENT(t,t2,tm_mon);
00081         CMP_TM_ELEMENT(t,t2,tm_year);
00082         CMP_TM_ELEMENT(t,t2,tm_wday);
00083         CMP_TM_ELEMENT(t,t2,tm_yday);
00084         CMP_TM_ELEMENT(t,t2,tm_isdst);
00085 
00086         if (t.tm_sec != 46) {
00087                 printf("failure: strptime [\n"
00088                        "tm_sec: expected: 46, got: %d\n"
00089                        "]\n",
00090                        t.tm_sec);
00091                 return false;
00092         }
00093 
00094         if (t.tm_min != 15) {
00095                 printf("failure: strptime [\n"
00096                        "tm_min: expected: 15, got: %d\n"
00097                        "]\n",
00098                        t.tm_min);
00099                 return false;
00100         }
00101 
00102         if (t.tm_hour != 10) {
00103                 printf("failure: strptime [\n"
00104                        "tm_hour: expected: 10, got: %d\n"
00105                        "]\n",
00106                        t.tm_hour);
00107                 return false;
00108         }
00109 
00110         if (t.tm_mday != 14) {
00111                 printf("failure: strptime [\n"
00112                        "tm_mday: expected: 14, got: %d\n"
00113                        "]\n",
00114                        t.tm_mday);
00115                 return false;
00116         }
00117 
00118         if (t.tm_mon != 3) {
00119                 printf("failure: strptime [\n"
00120                        "tm_mon: expected: 3, got: %d\n"
00121                        "]\n",
00122                        t.tm_mon);
00123                 return false;
00124         }
00125 
00126         if (t.tm_year != 107) {
00127                 printf("failure: strptime [\n"
00128                        "tm_year: expected: 107, got: %d\n"
00129                        "]\n",
00130                        t.tm_year);
00131                 return false;
00132         }
00133 
00134         if (t.tm_wday != 6) { /* saturday */
00135                 printf("failure: strptime [\n"
00136                        "tm_wday: expected: 6, got: %d\n"
00137                        "]\n",
00138                        t.tm_wday);
00139                 return false;
00140         }
00141 
00142         if (t.tm_yday != 103) {
00143                 printf("failure: strptime [\n"
00144                        "tm_yday: expected: 103, got: %d\n"
00145                        "]\n",
00146                        t.tm_yday);
00147                 return false;
00148         }
00149 
00150         /* we don't test this as it depends on the host configuration
00151         if (t.tm_isdst != 0) {
00152                 printf("failure: strptime [\n"
00153                        "tm_isdst: expected: 0, got: %d\n"
00154                        "]\n",
00155                        t.tm_isdst);
00156                 return false;
00157         }*/
00158 
00159         printf("success: strptime\n");
00160 
00161         return true;
00162 }

static int test_strptime ( void   )  [static]

testsuite.c856 行で定義されています。

参照先 libreplace_test_strptime().

参照元 torture_local_replace().

00857 {
00858         return libreplace_test_strptime();
00859 }

bool torture_local_replace ( struct torture_context *  ctx  ) 

testsuite.c862 行で定義されています。

参照先 test_asprintf()test_bzero()test_chroot()test_dlopen()test_errno()test_ftruncate()test_FUNCTION()test_getpass()test_inet_ntoa()test_initgroups()test_MAX()test_memmove()test_MIN()test_mkdtemp()test_mkstemp()test_mktime()test_opendir()test_pread()test_pwrite()test_readdir()test_seekdir()test_setegid()test_setenv()test_seteuid()test_setlinebuf()test_snprintf()test_socketpair()test_strdup()test_strerror()test_strlcat()test_strlcpy()test_strndup()test_strnlen()test_strptime()test_strtoll()test_strtoull()test_telldir()test_timegm()test_va_copy()test_vasprintf()test_vsnprintf()test_vsyslog()test_waitpid().

参照元 main().

00863 {
00864         bool ret = true;
00865         ret &= test_ftruncate();
00866         ret &= test_strlcpy();
00867         ret &= test_strlcat();
00868         ret &= test_mktime();
00869         ret &= test_initgroups();
00870         ret &= test_memmove();
00871         ret &= test_strdup();
00872         ret &= test_setlinebuf();
00873         ret &= test_vsyslog();
00874         ret &= test_timegm();
00875         ret &= test_setenv();
00876         ret &= test_strndup();
00877         ret &= test_strnlen();
00878         ret &= test_waitpid();
00879         ret &= test_seteuid();
00880         ret &= test_setegid();
00881         ret &= test_asprintf();
00882         ret &= test_snprintf();
00883         ret &= test_vasprintf();
00884         ret &= test_vsnprintf();
00885         ret &= test_opendir();
00886         ret &= test_readdir();
00887         ret &= test_telldir();
00888         ret &= test_seekdir();
00889         ret &= test_dlopen();
00890         ret &= test_chroot();
00891         ret &= test_bzero();
00892         ret &= test_strerror();
00893         ret &= test_errno();
00894         ret &= test_mkdtemp();
00895         ret &= test_mkstemp();
00896         ret &= test_pread();
00897         ret &= test_pwrite();
00898         ret &= test_getpass();
00899         ret &= test_inet_ntoa();
00900         ret &= test_strtoll();
00901         ret &= test_strtoull();
00902         ret &= test_va_copy();
00903         ret &= test_FUNCTION();
00904         ret &= test_MIN();
00905         ret &= test_MAX();
00906         ret &= test_socketpair();
00907         ret &= test_strptime();
00908 
00909         return ret;
00910 }

int main ( void   ) 

testsuite.c913 行で定義されています。

参照先 torture_local_replace().

00914 {
00915         bool ret = torture_local_replace(NULL);
00916         if (ret) 
00917                 return 0;
00918         return -1;
00919 }


Sambaに対してSat Aug 29 21:23:37 2009に生成されました。  doxygen 1.4.7