Lines Matching +defs:file +defs:tests

43 #include <linux/ext2_fs.h>      /* for Linux file flags */
46 #include <ext2fs/ext2_fs.h> /* Linux file flags, broken on Cygwin */
105 * try to minimize conditionals by grouping platform-specific tests in
278 * Each test has to specify if a file or a directory symlink
350 const wchar_t * function, const wchar_t * file,
357 (void)file;
371 /* Default is to remove temp dirs and log data for successful tests. */
373 /* Default is to run the specified tests once and report errors. */
443 * Copy arguments into file-local variables.
463 assertion_count(const char *file, int line)
465 (void)file; /* UNUSED */
471 /* Uncomment to print file:line after every assertion.
473 /* printf("Checked %s:%d\n", file, line); */
477 * For each test source file, we remember how many times each
507 /* Log file:line header for this failure */
528 /* Complete reporting of failed tests. */
583 assertion_assert(const char *file, int line, int value,
586 assertion_count(file, line);
588 failure_start(file, line, "Assertion failed: %s", condition);
596 assertion_chdir(const char *file, int line, const char *pathname)
598 assertion_count(file, line);
601 failure_start(file, line, "chdir(\"%s\")", pathname);
607 /* change file/directory permissions and errors if it fails */
609 assertion_chmod(const char *file, int line, const char *pathname, int mode)
611 assertion_count(file, line);
614 failure_start(file, line, "chmod(\"%s\", %4.o)", pathname, mode);
622 assertion_equal_int(const char *file, int line,
625 assertion_count(file, line);
628 failure_start(file, line, "%s != %s", e1, e2);
637 assertion_equal_address(const char *file, int line,
640 assertion_count(file, line);
643 failure_start(file, line, "%s != %s", e1, e2);
799 assertion_equal_string(const char *file, int line,
806 assertion_count(file, line);
809 failure_start(file, line, "%s != %s", e1, e2);
861 assertion_equal_wstring(const char *file, int line,
866 assertion_count(file, line);
871 failure_start(file, line, "%s != %s", e1, e2);
922 assertion_equal_mem(const char *file, int line,
931 assertion_count(file, line);
937 failure_start(file, line, "%s != %s", e1, e2);
960 assertion_memory_filled_with(const char *file, int line,
970 assertion_count(file, line);
980 failure_start(file, line, "%s (size %d) not filled with %s", vd, (int)l, bd);
986 /* Verify that the named file exists and is empty. */
1022 /* Verify that the named file exists and is not empty. */
1084 /* Verify that the named file does exist. */
1102 /* Verify that the named file doesn't exist. */
1120 /* Compare the contents of a file to a block of memory. */
1145 logprintf(" file=\"%s\"\n", fn);
1157 /* Check the contents of a text file, being tolerant of line endings. */
1202 logprintf(" file=\"%s\"\n", fn);
1216 /* Verify that a text file contains the specified lines, regardless of order */
1221 assertion_file_contains_lines_any_order(const char *file, int line,
1232 assertion_count(file, line);
1236 failure_start(pathname, line, "Can't read file: %s", pathname);
1242 * file size. */
1263 /* Break the file into lines */
1317 failure_start(file, line, "File doesn't match: %s", pathname);
1342 /* Verify that a text file does not contains the specified strings */
1344 assertion_file_contains_no_invalid_strings(const char *file, int line,
1352 failure_start(file, line, "Can't read file: %s", pathname);
1359 failure_start(file, line, "Invalid string in %s: %s", pathname,
1371 /* Test that two paths point to the same file. */
1374 is_hardlink(const char *file, int line,
1381 assertion_count(file, line);
1384 failure_start(file, line, "File %s can't be inspected?", path1);
1390 failure_start(file, line, "File %s can't be inspected?", path2);
1401 assertion_count(file, line);
1404 failure_start(file, line, "File should exist: %s", path1);
1410 failure_start(file, line, "File should exist: %s", path2);
1419 assertion_is_hardlink(const char *file, int line,
1422 if (is_hardlink(file, line, path1, path2))
1424 failure_start(file, line,
1431 assertion_is_not_hardlink(const char *file, int line,
1434 if (!is_hardlink(file, line, path1, path2))
1436 failure_start(file, line,
1445 assertion_file_time(const char *file, int line,
1459 assertion_count(file, line);
1461 * a directory file. If not, CreateFile() will fail when
1466 failure_start(file, line, "Can't access %s\n", pathname);
1478 failure_start(file, line, "Can't GetFileTime %s\n", pathname);
1490 assertion_count(file, line);
1493 failure_start(file, line, "Can't stat %s\n", pathname);
1501 default: fprintf(stderr, "INTERNAL: Bad type %c for file time", type);
1515 default: fprintf(stderr, "INTERNAL: Bad type %c for file time", type);
1533 failure_start(file, line,
1540 failure_start(file, line,
1551 assertion_file_atime(const char *file, int line,
1554 return assertion_file_time(file, line, pathname, t, nsec, 'a', 0);
1559 assertion_file_atime_recent(const char *file, int line, const char *pathname)
1561 return assertion_file_time(file, line, pathname, 0, 0, 'a', 1);
1566 assertion_file_birthtime(const char *file, int line,
1569 return assertion_file_time(file, line, pathname, t, nsec, 'b', 0);
1574 assertion_file_birthtime_recent(const char *file, int line,
1577 return assertion_file_time(file, line, pathname, 0, 0, 'b', 1);
1582 assertion_file_mode(const char *file, int line, const char *pathname, int expected_mode)
1587 assertion_count(file, line);
1589 failure_start(file, line, "assertFileMode not yet implemented for Windows");
1602 failure_start(file, line, "File %s has mode %o, expected %o",
1611 assertion_file_mtime(const char *file, int line,
1614 return assertion_file_time(file, line, pathname, t, nsec, 'm', 0);
1619 assertion_file_mtime_recent(const char *file, int line, const char *pathname)
1621 return assertion_file_time(file, line, pathname, 0, 0, 'm', 1);
1626 assertion_file_nlinks(const char *file, int line,
1633 assertion_count(file, line);
1637 failure_start(file, line, "File %s has %jd links, expected %d",
1645 assertion_count(file, line);
1649 failure_start(file, line, "File %s has %jd links, expected %d",
1658 assertion_file_size(const char *file, int line, const char *pathname, long size)
1663 assertion_count(file, line);
1679 failure_start(file, line, "File %s has size %ld, expected %ld",
1687 assertion_is_dir(const char *file, int line, const char *pathname, int mode)
1695 assertion_count(file, line);
1698 failure_start(file, line, "Dir should exist: %s", pathname);
1703 failure_start(file, line, "%s is not a dir", pathname);
1709 * so just ignore the mode tests. */
1712 failure_start(file, line, "Dir %s has wrong mode", pathname);
1722 /* Verify that 'pathname' is a regular file. If 'mode' is >= 0,
1725 assertion_is_reg(const char *file, int line, const char *pathname, int mode)
1733 assertion_count(file, line);
1736 failure_start(file, line, "File should exist: %s", pathname);
1742 * so just ignore the mode tests. */
1745 failure_start(file, line, "File %s has wrong mode", pathname);
1759 * On platforms with directory symlinks, set isdir to 0 to test for a file
1764 is_symlink(const char *file, int line,
1784 failure_start(file, line, "Can't allocate memory");
1800 failure_start(file, line, "Can't access %s\n", pathname);
1806 failure_start(file, line,
1810 failure_start(file, line,
1816 failure_start(file, line,
1823 failure_start(file, line,
1824 "Not a file symlink: %s", pathname);
1839 failure_start(file, line,
1849 failure_start(file, line,
1896 assertion_count(file, line);
1899 failure_start(file, line,
1910 failure_start(file, line, "Can't read symlink %s", pathname);
1923 assertion_is_symlink(const char *file, int line,
1926 if (is_symlink(file, line, path, contents, isdir))
1929 failure_start(file, line, "File %s is not a symlink to %s",
1932 failure_start(file, line, "File %s is not a symlink", path);
1940 assertion_make_dir(const char *file, int line, const char *dirname, int mode)
1942 assertion_count(file, line);
1950 assertion_file_mode(file, line, dirname, mode);
1955 failure_start(file, line, "Could not create directory %s", dirname);
1960 /* Create a file with the specified contents and report any failures. */
1962 assertion_make_file(const char *file, int line,
1966 /* TODO: Rework this to set file mode as well. */
1969 assertion_count(file, line);
1972 failure_start(file, line, "Could not create file %s", path);
1985 failure_start(file, line,
1986 "Could not write file %s", path);
1995 assertion_count(file, line);
1998 failure_start(file, line, "Could not create %s", path);
2008 failure_start(file, line, "Could not chmod %s", path);
2022 failure_start(file, line,
2030 assertion_file_mode(file, line, path, mode);
2037 assertion_make_hardlink(const char *file, int line,
2042 assertion_count(file, line);
2052 failure_start(file, line, "Could not create hardlink");
2065 assertion_make_symlink(const char *file, int line,
2069 assertion_count(file, line);
2074 assertion_count(file, line);
2080 failure_start(file, line, "Could not create symlink");
2089 assertion_umask(const char *file, int line, int mask)
2091 assertion_count(file, line);
2092 (void)file; /* UNUSED */
2100 assertion_utimes(const char *file, int line, const char *pathname,
2113 assertion_count(file, line);
2118 failure_start(file, line, "Can't access %s\n", pathname);
2143 failure_start(file, line, "Can't SetFileTime %s\n", pathname);
2160 failure_start(file, line, "Can't stat %s\n", pathname);
2194 failure_start(file, line, "Can't utimes %s\n", pathname);
2202 /* Compare file flags */
2204 assertion_compare_fflags(const char *file, int line, const char *patha,
2210 assertion_count(file, line);
2217 failure_start(file, line, "File flags should be identical: "
2224 failure_start(file, line, "File flags should be different: "
2236 assertion_count(file, line);
2239 failure_start(file, line, "Can't open %s\n", patha);
2252 failure_start(file, line, "Can't get flags %s\n", patha);
2258 failure_start(file, line, "Can't open %s\n", pathb);
2271 failure_start(file, line, "Can't get flags %s\n", pathb);
2276 failure_start(file, line, "File flags should be identical: "
2282 failure_start(file, line, "File flags should be different: "
2291 assertion_count(file, line);
2298 assertion_set_nodump(const char *file, int line, const char *pathname)
2303 assertion_count(file, line);
2306 failure_start(file, line, "Can't set nodump %s\n", pathname);
2316 assertion_count(file, line);
2319 failure_start(file, line, "Can't open %s\n", pathname);
2331 failure_start(file, line, "Can't get flags %s\n", pathname);
2349 failure_start(file, line, "Can't set nodump %s\n", pathname);
2356 assertion_count(file, line);
2474 * UTILITIES for use by tests.
2480 * for tests to use in deciding whether to bother testing symlink
3110 * Slurp a file into memory for ease of comparison and testing.
3111 * Returns size of file in 'sizep' if non-NULL, null-terminates
3131 /* Note: No error; non-existent file is okay here. */
3136 logprintf("Can't stat file %s\n", filename);
3142 logprintf("Can't allocate %ld bytes of memory to read file %s\n",
3149 logprintf("Can't read file %s\n", filename);
3162 * Slurp a file into memory for ease of comparison and testing.
3163 * Returns size of file in 'sizep' if non-NULL, null-terminates
3174 logprintf("Can't open file %s for writing\n", filename);
3179 logprintf("Can't write file %s\n", filename);
3183 /* Read a uuencoded file from the reference directory, decode, and
3195 failure("Couldn't open reference file %s", buff);
3254 failure("Couldn't open reference file %s", buff);
3272 is_LargeInode(const char *file)
3278 r = my_GetFileInformationByName(file, &bhfi);
3286 if (stat(file, &st) < 0)
3303 assertion_entry_set_acls(const char *file, int line, struct archive_entry *ae,
3308 assertion_count(file, line);
3318 failure_start(file, line, "type=%#010x, "
3364 assertion_entry_compare_acls(const char *file, int line,
3374 assertion_count(file, line);
3388 failure_start(file, line, "No ACL's to compare, type mask: %d",
3407 failure_start(file, line, "No match for "
3413 failure_start(file, line, "USER_OBJ permset "
3422 failure_start(file, line, "No match for "
3428 failure_start(file, line, "GROUP_OBJ permset "
3437 failure_start(file, line, "No match for "
3443 failure_start(file, line, "OTHER permset "
3450 failure_start(file, line, "Could not find match for "
3458 failure_start(file, line, "Should not exit before EOF");
3464 failure_start(file, line, "Mode (%02o) and entry mode (%02o) "
3470 failure_start(file, line, "Could not find match for ACL "
3508 /* Use "list.h" to create a list of all tests (functions and names). */
3511 static struct test_list_t tests[] = {
3540 /* Clear the failure history for the next file. */
3565 printf("%3d: %-64s", i, tests[i].name);
3569 printf("%3d: %s\n", i, tests[i].name);
3578 /* Create a log file for this test. */
3579 snprintf(logfilename, sizeof(logfilename), "%s.log", tests[i].name);
3581 fprintf(logfile, "%s\n\n", tests[i].name);
3583 snprintf(workdir, sizeof(workdir), "%s/%s", tmpdir, tests[i].name);
3598 (*tests[i].func)();
3614 tests[i].failures = failures - failures_before;
3615 test_summarize(tests[i].failures, skips - skips_before);
3616 /* Close the per-test log file. */
3620 if (tests[i].failures == 0) {
3624 * Sometimes a processing of closing files used by tests
3632 r = systemf("rmdir /S /Q %s", tests[i].name);
3638 systemf("rm -rf %s", tests[i].name);
3644 return (tests[i].failures);
3658 static const int limit = nitems(tests);
3662 printf("Default is to run all tests.\n");
3663 printf("Otherwise, specify the numbers of the tests you wish to run.\n");
3667 printf(" Default: temp files for successful tests deleted.\n");
3675 printf(" -u Keep running specifies tests until one fails.\n");
3677 printf("Available tests:\n");
3679 printf(" %d: %s\n", i, tests[i].name);
3728 /* Look for a known file. */
3774 printf("Unable to locate known reference file %s\n", KNOWNREF);
3793 /* Filter tests against a glob pattern. Returns non-zero if test matches
3844 /* Default: Run all tests. */
3879 const char *name = tests[start].name;
3890 static const int limit = nitems(tests);
3891 int test_set[nitems(tests)];
4134 * Create a temp directory for the following tests.
4135 * Include the time the tests started as part of the name,
4136 * to make it easier to track the results of multiple tests.
4179 printf("If tests fail or crash, details will be in:\n");
4185 printf("Running tests on: %s\n", testprog);
4196 * Run some or all of the individual tests.
4225 /* Must be freed after all tests run */
4244 printf("Failing tests:\n");
4246 if (tests[i].failures)
4248 tests[i].name, tests[i].failures);
4251 printf("Details for failing tests: %s\n", tmpdir);
4256 printf("%d tests passed, no failures\n", tests_run);
4262 /* This should be the usual case when all tests succeed. */