}
/*
- * Test 'newer mtime than'.
+ * Test: newer mtime than a file specified in MBS file name.
*/
- assertEqualIntA(m, 0, archive_matching_newer_mtime_than(m, "mid"));
+ assertEqualIntA(m, 0,
+ archive_matching_newer_mtime_than(m, "mid_mtime"));
- /* Verify 'old' file. */
- archive_entry_copy_pathname(ae, "old");
+ /* Verify 'old_mtime' file. */
+ archive_entry_copy_pathname(ae, "old_mtime");
assertEqualIntA(a, ARCHIVE_OK,
archive_read_disk_entry_from_file(a, ae, -1, NULL));
- failure("It should not be excluded");
- assertEqualInt(0, archive_matching_time_excluded(m, ae));
- assertEqualInt(0, archive_matching_excluded(m, ae));
+ failure("old_mtime should be excluded");
+ assertEqualInt(1, archive_matching_time_excluded(m, ae));
+ assertEqualInt(1, archive_matching_excluded(m, ae));
- /* Verify 'mid' file. */
+ /* Verify 'mid_mtime' file. */
archive_entry_clear(ae);
- archive_entry_copy_pathname(ae, "mid");
+ archive_entry_copy_pathname(ae, "mid_mtime");
assertEqualIntA(a, ARCHIVE_OK,
archive_read_disk_entry_from_file(a, ae, -1, NULL));
- failure("It should be excluded");
+ failure("mid_mtime should be excluded");
assertEqualInt(1, archive_matching_time_excluded(m, ae));
assertEqualInt(1, archive_matching_excluded(m, ae));
- /* Verify 'new' file. */
+ /* Verify 'new_mtime' file. */
archive_entry_clear(ae);
- archive_entry_copy_pathname(ae, "new");
+ archive_entry_copy_pathname(ae, "new_mtime");
assertEqualIntA(a, ARCHIVE_OK,
archive_read_disk_entry_from_file(a, ae, -1, NULL));
- failure("It should be excluded");
- assertEqualInt(1, archive_matching_time_excluded(m, ae));
- assertEqualInt(1, archive_matching_excluded(m, ae));
+ failure("new_mtime should not be excluded");
+ assertEqualInt(0, archive_matching_time_excluded(m, ae));
+ assertEqualInt(0, archive_matching_excluded(m, ae));
/* Clean up. */
archive_read_free(a);
}
/*
- * Test 'newer ctime than'.
+ * Test: newer ctime than a file specified in MBS file name.
*/
- assertEqualIntA(m, 0, archive_matching_newer_ctime_than(m, "mid"));
+ assertEqualIntA(m, 0,
+ archive_matching_newer_ctime_than(m, "mid_ctime"));
- /* Verify 'old' file. */
- archive_entry_clear(ae);
- archive_entry_copy_pathname(ae, "old");
+ /* Verify 'old_ctime' file. */
+ archive_entry_copy_pathname(ae, "old_ctime");
assertEqualIntA(a, ARCHIVE_OK,
archive_read_disk_entry_from_file(a, ae, -1, NULL));
- failure("It should be excluded");
+ failure("old_ctime should be excluded");
assertEqualInt(1, archive_matching_time_excluded(m, ae));
assertEqualInt(1, archive_matching_excluded(m, ae));
- /* Verify 'mid' file. */
+ /* Verify 'mid_ctime' file. */
archive_entry_clear(ae);
- archive_entry_copy_pathname(ae, "mid");
+ archive_entry_copy_pathname(ae, "mid_ctime");
assertEqualIntA(a, ARCHIVE_OK,
archive_read_disk_entry_from_file(a, ae, -1, NULL));
- failure("It should be excluded");
+ failure("mid_ctime should be excluded");
assertEqualInt(1, archive_matching_time_excluded(m, ae));
assertEqualInt(1, archive_matching_excluded(m, ae));
- /* Verify 'new' file. */
+ /* Verify 'new_ctime' file. */
archive_entry_clear(ae);
- archive_entry_copy_pathname(ae, "new");
+ archive_entry_copy_pathname(ae, "new_ctime");
assertEqualIntA(a, ARCHIVE_OK,
archive_read_disk_entry_from_file(a, ae, -1, NULL));
- failure("It should not be excluded");
+ failure("new_ctime should not be excluded");
assertEqualInt(0, archive_matching_time_excluded(m, ae));
assertEqualInt(0, archive_matching_excluded(m, ae));
}
/*
- * Test 'newer mtime than'.
+ * Test: newer mtime than a file specified in WCS file name.
*/
- assertEqualIntA(m, 0, archive_matching_newer_mtime_than_w(m, L"mid"));
+ assertEqualIntA(m, 0,
+ archive_matching_newer_mtime_than_w(m, L"mid_mtime"));
- /* Verify 'old' file. */
- archive_entry_copy_pathname(ae, "old");
+ /* Verify 'old_mtime' file. */
+ archive_entry_copy_pathname(ae, "old_mtime");
assertEqualIntA(a, ARCHIVE_OK,
archive_read_disk_entry_from_file(a, ae, -1, NULL));
- failure("It should not be excluded");
- assertEqualInt(0, archive_matching_time_excluded(m, ae));
- assertEqualInt(0, archive_matching_excluded(m, ae));
+ failure("old_mtime should be excluded");
+ assertEqualInt(1, archive_matching_time_excluded(m, ae));
+ assertEqualInt(1, archive_matching_excluded(m, ae));
- /* Verify 'mid' file. */
+ /* Verify 'mid_mtime' file. */
archive_entry_clear(ae);
- archive_entry_copy_pathname(ae, "mid");
+ archive_entry_copy_pathname(ae, "mid_mtime");
assertEqualIntA(a, ARCHIVE_OK,
archive_read_disk_entry_from_file(a, ae, -1, NULL));
- failure("It should be excluded");
+ failure("mid_mtime should be excluded");
assertEqualInt(1, archive_matching_time_excluded(m, ae));
assertEqualInt(1, archive_matching_excluded(m, ae));
- /* Verify 'new' file. */
+ /* Verify 'new_mtime' file. */
archive_entry_clear(ae);
- archive_entry_copy_pathname(ae, "new");
+ archive_entry_copy_pathname(ae, "new_mtime");
assertEqualIntA(a, ARCHIVE_OK,
archive_read_disk_entry_from_file(a, ae, -1, NULL));
- failure("It should be excluded");
- assertEqualInt(1, archive_matching_time_excluded(m, ae));
- assertEqualInt(1, archive_matching_excluded(m, ae));
+ failure("new_mtime should not be excluded");
+ assertEqualInt(0, archive_matching_time_excluded(m, ae));
+ assertEqualInt(0, archive_matching_excluded(m, ae));
/* Clean up. */
archive_read_free(a);
}
/*
- * Test 'newer ctime than'.
+ * Test: newer ctime than a file specified in WCS file name.
*/
- assertEqualIntA(m, 0, archive_matching_newer_ctime_than_w(m, L"mid"));
+ assertEqualIntA(m, 0,
+ archive_matching_newer_ctime_than_w(m, L"mid_ctime"));
- /* Verify 'old' file. */
+ /* Verify 'old_ctime' file. */
archive_entry_clear(ae);
- archive_entry_copy_pathname(ae, "old");
+ archive_entry_copy_pathname(ae, "old_ctime");
assertEqualIntA(a, ARCHIVE_OK,
archive_read_disk_entry_from_file(a, ae, -1, NULL));
- failure("It should be excluded");
+ failure("old_ctime should be excluded");
assertEqualInt(1, archive_matching_time_excluded(m, ae));
assertEqualInt(1, archive_matching_excluded(m, ae));
- /* Verify 'mid' file. */
+ /* Verify 'mid_ctime' file. */
archive_entry_clear(ae);
- archive_entry_copy_pathname(ae, "mid");
+ archive_entry_copy_pathname(ae, "mid_ctime");
assertEqualIntA(a, ARCHIVE_OK,
archive_read_disk_entry_from_file(a, ae, -1, NULL));
- failure("It should be excluded");
+ failure("mid_ctime should be excluded");
assertEqualInt(1, archive_matching_time_excluded(m, ae));
assertEqualInt(1, archive_matching_excluded(m, ae));
- /* Verify 'new' file. */
+ /* Verify 'new_ctime' file. */
archive_entry_clear(ae);
- archive_entry_copy_pathname(ae, "new");
+ archive_entry_copy_pathname(ae, "new_ctime");
assertEqualIntA(a, ARCHIVE_OK,
archive_read_disk_entry_from_file(a, ae, -1, NULL));
- failure("It should not be excluded");
+ failure("new_ctime should not be excluded");
assertEqualInt(0, archive_matching_time_excluded(m, ae));
assertEqualInt(0, archive_matching_excluded(m, ae));
}
/*
- * Test 'older mtime than'.
+ * Test: older mtime than a file specified in MBS file name.
*/
- assertEqualIntA(m, 0, archive_matching_older_mtime_than(m, "mid"));
+ assertEqualIntA(m, 0,
+ archive_matching_older_mtime_than(m, "mid_mtime"));
- /* Verify 'old' file. */
- archive_entry_copy_pathname(ae, "old");
+ /* Verify 'old_mtime' file. */
+ archive_entry_copy_pathname(ae, "old_mtime");
assertEqualIntA(a, ARCHIVE_OK,
archive_read_disk_entry_from_file(a, ae, -1, NULL));
- failure("It should be excluded");
- assertEqualInt(1, archive_matching_time_excluded(m, ae));
- assertEqualInt(1, archive_matching_excluded(m, ae));
+ failure("old_mtime should not be excluded");
+ assertEqualInt(0, archive_matching_time_excluded(m, ae));
+ assertEqualInt(0, archive_matching_excluded(m, ae));
- /* Verify 'mid' file. */
+ /* Verify 'mid_mtime' file. */
archive_entry_clear(ae);
- archive_entry_copy_pathname(ae, "mid");
+ archive_entry_copy_pathname(ae, "mid_mtime");
assertEqualIntA(a, ARCHIVE_OK,
archive_read_disk_entry_from_file(a, ae, -1, NULL));
- failure("It should be excluded");
+ failure("mid_mtime should be excluded");
assertEqualInt(1, archive_matching_time_excluded(m, ae));
assertEqualInt(1, archive_matching_excluded(m, ae));
- /* Verify 'new' file. */
+ /* Verify 'new_mtime' file. */
archive_entry_clear(ae);
- archive_entry_copy_pathname(ae, "new");
+ archive_entry_copy_pathname(ae, "new_mtime");
assertEqualIntA(a, ARCHIVE_OK,
archive_read_disk_entry_from_file(a, ae, -1, NULL));
- failure("It should not be excluded");
- assertEqualInt(0, archive_matching_time_excluded(m, ae));
- assertEqualInt(0, archive_matching_excluded(m, ae));
+ failure("new_mtime should be excluded");
+ assertEqualInt(1, archive_matching_time_excluded(m, ae));
+ assertEqualInt(1, archive_matching_excluded(m, ae));
/* Clean up. */
archive_read_free(a);
}
/*
- * Test 'older ctime than'.
+ * Test: older ctime than a file specified in MBS file name.
*/
- assertEqualIntA(m, 0, archive_matching_older_ctime_than(m, "mid"));
+ assertEqualIntA(m, 0,
+ archive_matching_older_ctime_than(m, "mid_ctime"));
- /* Verify 'old' file. */
+ /* Verify 'old_ctime' file. */
archive_entry_clear(ae);
- archive_entry_copy_pathname(ae, "old");
+ archive_entry_copy_pathname(ae, "old_ctime");
assertEqualIntA(a, ARCHIVE_OK,
archive_read_disk_entry_from_file(a, ae, -1, NULL));
- failure("It should not be excluded");
+ failure("old_ctime should not be excluded");
assertEqualInt(0, archive_matching_time_excluded(m, ae));
assertEqualInt(0, archive_matching_excluded(m, ae));
- /* Verify 'mid' file. */
+ /* Verify 'mid_ctime' file. */
archive_entry_clear(ae);
- archive_entry_copy_pathname(ae, "mid");
+ archive_entry_copy_pathname(ae, "mid_ctime");
assertEqualIntA(a, ARCHIVE_OK,
archive_read_disk_entry_from_file(a, ae, -1, NULL));
- failure("It should be excluded");
+ failure("mid_ctime should be excluded");
assertEqualInt(1, archive_matching_time_excluded(m, ae));
assertEqualInt(1, archive_matching_excluded(m, ae));
- /* Verify 'new' file. */
+ /* Verify 'new_ctime' file. */
archive_entry_clear(ae);
- archive_entry_copy_pathname(ae, "new");
+ archive_entry_copy_pathname(ae, "new_ctime");
assertEqualIntA(a, ARCHIVE_OK,
archive_read_disk_entry_from_file(a, ae, -1, NULL));
- failure("It should be excluded");
+ failure("new_ctime should be excluded");
assertEqualInt(1, archive_matching_time_excluded(m, ae));
assertEqualInt(1, archive_matching_excluded(m, ae));
}
/*
- * Test 'older mtime than'.
+ * Test: older mtime than a file specified in WCS file name.
*/
- assertEqualIntA(m, 0, archive_matching_older_mtime_than_w(m, L"mid"));
+ assertEqualIntA(m, 0,
+ archive_matching_older_mtime_than_w(m, L"mid_mtime"));
- /* Verify 'old' file. */
- archive_entry_copy_pathname(ae, "old");
+ /* Verify 'old_mtime' file. */
+ archive_entry_copy_pathname(ae, "old_mtime");
assertEqualIntA(a, ARCHIVE_OK,
archive_read_disk_entry_from_file(a, ae, -1, NULL));
- failure("It should be excluded");
- assertEqualInt(1, archive_matching_time_excluded(m, ae));
- assertEqualInt(1, archive_matching_excluded(m, ae));
+ failure("old_mtime should not be excluded");
+ assertEqualInt(0, archive_matching_time_excluded(m, ae));
+ assertEqualInt(0, archive_matching_excluded(m, ae));
- /* Verify 'mid' file. */
+ /* Verify 'mid_mtime' file. */
archive_entry_clear(ae);
- archive_entry_copy_pathname(ae, "mid");
+ archive_entry_copy_pathname(ae, "mid_mtime");
assertEqualIntA(a, ARCHIVE_OK,
archive_read_disk_entry_from_file(a, ae, -1, NULL));
- failure("It should be excluded");
+ failure("mid_mtime should be excluded");
assertEqualInt(1, archive_matching_time_excluded(m, ae));
assertEqualInt(1, archive_matching_excluded(m, ae));
- /* Verify 'new' file. */
+ /* Verify 'new_mtime' file. */
archive_entry_clear(ae);
- archive_entry_copy_pathname(ae, "new");
+ archive_entry_copy_pathname(ae, "new_mtime");
assertEqualIntA(a, ARCHIVE_OK,
archive_read_disk_entry_from_file(a, ae, -1, NULL));
- failure("It should not be excluded");
- assertEqualInt(0, archive_matching_time_excluded(m, ae));
- assertEqualInt(0, archive_matching_excluded(m, ae));
+ failure("new_mtime should be excluded");
+ assertEqualInt(1, archive_matching_time_excluded(m, ae));
+ assertEqualInt(1, archive_matching_excluded(m, ae));
/* Clean up. */
archive_read_free(a);
}
/*
- * Test 'older ctime than'.
+ * Test: older ctime than a file specified in WCS file name.
*/
- assertEqualIntA(m, 0, archive_matching_older_ctime_than_w(m, L"mid"));
+ assertEqualIntA(m, 0,
+ archive_matching_older_ctime_than_w(m, L"mid_ctime"));
- /* Verify 'old' file. */
+ /* Verify 'old_ctime' file. */
archive_entry_clear(ae);
- archive_entry_copy_pathname(ae, "old");
+ archive_entry_copy_pathname(ae, "old_ctime");
assertEqualIntA(a, ARCHIVE_OK,
archive_read_disk_entry_from_file(a, ae, -1, NULL));
- failure("It should not be excluded");
+ failure("old_ctime should not be excluded");
assertEqualInt(0, archive_matching_time_excluded(m, ae));
assertEqualInt(0, archive_matching_excluded(m, ae));
- /* Verify 'mid' file. */
+ /* Verify 'mid_ctime' file. */
archive_entry_clear(ae);
- archive_entry_copy_pathname(ae, "mid");
+ archive_entry_copy_pathname(ae, "mid_ctime");
assertEqualIntA(a, ARCHIVE_OK,
archive_read_disk_entry_from_file(a, ae, -1, NULL));
- failure("It should be excluded");
+ failure("mid_ctime should be excluded");
assertEqualInt(1, archive_matching_time_excluded(m, ae));
assertEqualInt(1, archive_matching_excluded(m, ae));
- /* Verify 'new' file. */
+ /* Verify 'new_ctime' file. */
archive_entry_clear(ae);
- archive_entry_copy_pathname(ae, "new");
+ archive_entry_copy_pathname(ae, "new_ctime");
assertEqualIntA(a, ARCHIVE_OK,
archive_read_disk_entry_from_file(a, ae, -1, NULL));
- failure("It should be excluded");
+ failure("new_ctime should be excluded");
assertEqualInt(1, archive_matching_time_excluded(m, ae));
assertEqualInt(1, archive_matching_excluded(m, ae));
{
struct stat st;
+ /* Test: matching newer times. */
test_newer_time();
+ /* Test: matching older times. */
test_older_time();
- assertMakeFile("old", 0666, "old");
- assertUtimes("old", 10002, 0, 10002, 0);
- assertEqualInt(0, stat("old", &st));
+ /*
+ * Create sample files for tests matching mtime.
+ * ctimes of those files may be all the same or the ctime of
+ * new_mtime may be older than old_mtime.
+ */
+ assertMakeFile("new_mtime", 0666, "new");
+ assertUtimes("new_mtime", 10002, 0, 10002, 0);
+ assertMakeFile("mid_mtime", 0666, "mid");
+ assertUtimes("mid_mtime", 10001, 0, 10001, 0);
+ assertMakeFile("old_mtime", 0666, "old");
+ assertUtimes("old_mtime", 10000, 0, 10000, 0);
+
+ /*
+ * Create sample files for tests matching ctime.
+ * the mtime of mid_ctime is older than old_ctime and also the mtime
+ * of new_ctime is older than both mid_ctime and old_ctime.
+ */
+ assertMakeFile("old_ctime", 0666, "old");
+ assertUtimes("old_ctime", 10002, 0, 10002, 0);
+ assertEqualInt(0, stat("old_ctime", &st));
sleepUntilAfter(st.st_ctime);
- assertMakeFile("mid", 0666, "mid");
- assertUtimes("mid", 10001, 0, 10001, 0);
- assertEqualInt(0, stat("mid", &st));
+ assertMakeFile("mid_ctime", 0666, "mid");
+ assertUtimes("mid_ctime", 10001, 0, 10001, 0);
+ assertEqualInt(0, stat("mid_ctime", &st));
sleepUntilAfter(st.st_ctime);
- assertMakeFile("new", 0666, "new");
- assertUtimes("new", 10000, 0, 10000, 0);
+ assertMakeFile("new_ctime", 0666, "new");
+ assertUtimes("new_ctime", 10000, 0, 10000, 0);
+ /*
+ * Test: matching mtime which indicated by files on the disk.
+ */
test_newer_mtime_than_file_mbs();
test_newer_mtime_than_file_wcs();
test_older_mtime_than_file_mbs();
test_older_mtime_than_file_wcs();
+ /*
+ * Test: matching ctime which indicated by files on the disk.
+ */
test_newer_ctime_than_file_mbs();
test_newer_ctime_than_file_wcs();
test_older_ctime_than_file_mbs();
test_older_ctime_than_file_wcs();
+ /* Test: matching both pathname and mtime. */
test_pathname_newer_mtime();
}