]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Speed up test_archive_matching_time by stopping making reference files for each
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Wed, 25 Jan 2012 05:41:15 +0000 (00:41 -0500)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Wed, 25 Jan 2012 05:41:15 +0000 (00:41 -0500)
tests, wich take time to make sure those files have different ctime. And
make common reference files instead.

SVN-Revision: 4206

libarchive/test/test_archive_matching_time.c

index 27ded2d9f101f3c29b0aab328e800dae46fd8387..2c5efbf9f9d7c2b5d7b1d85dffedeb3f2afdc237 100644 (file)
@@ -96,15 +96,6 @@ test_newer_mtime_than_file_mbs(void)
                return;
        }
 
-       assertMakeDir("test_newer_mtime_than_file_mbs", 0777);
-       assertChdir("test_newer_mtime_than_file_mbs");
-
-       assertMakeFile("old", 0666, "old");
-       sleepUntilAfter(time(NULL));
-       assertMakeFile("mid", 0666, "mid");
-       sleepUntilAfter(time(NULL));
-       assertMakeFile("new", 0666, "new");
-
        /*
         * Test 'newer mtime than'.
         */
@@ -136,7 +127,6 @@ test_newer_mtime_than_file_mbs(void)
        assertEqualInt(0, archive_matching_time_excluded(m, ae));
        assertEqualInt(0, archive_matching_excluded(m, ae));
 
-       assertChdir("..");
        /* Clean up. */
        archive_read_free(a);
        archive_entry_free(ae);
@@ -162,18 +152,6 @@ test_newer_ctime_than_file_mbs(void)
                return;
        }
 
-       assertMakeDir("test_newer_ctime_than_file_mbs", 0777);
-       assertChdir("test_newer_ctime_than_file_mbs");
-
-       assertMakeFile("old", 0666, "old");
-       assertUtimes("old", 10002, 0, 10002, 0);
-       sleepUntilAfter(time(NULL));
-       assertMakeFile("mid", 0666, "mid");
-       assertUtimes("mid", 10001, 0, 10001, 0);
-       sleepUntilAfter(time(NULL));
-       assertMakeFile("new", 0666, "new");
-       assertUtimes("new", 10000, 0, 10000, 0);
-
        /*
         * Test 'newer ctime than'.
         */
@@ -206,7 +184,6 @@ test_newer_ctime_than_file_mbs(void)
        assertEqualInt(0, archive_matching_time_excluded(m, ae));
        assertEqualInt(0, archive_matching_excluded(m, ae));
 
-       assertChdir("..");
        /* Clean up. */
        archive_read_free(a);
        archive_entry_free(ae);
@@ -232,15 +209,6 @@ test_newer_mtime_than_file_wcs(void)
                return;
        }
 
-       assertMakeDir("test_newer_mtime_than_file_wcs", 0777);
-       assertChdir("test_newer_mtime_than_file_wcs");
-
-       assertMakeFile("old", 0666, "old");
-       sleepUntilAfter(time(NULL));
-       assertMakeFile("mid", 0666, "mid");
-       sleepUntilAfter(time(NULL));
-       assertMakeFile("new", 0666, "new");
-
        /*
         * Test 'newer mtime than'.
         */
@@ -272,7 +240,6 @@ test_newer_mtime_than_file_wcs(void)
        assertEqualInt(0, archive_matching_time_excluded(m, ae));
        assertEqualInt(0, archive_matching_excluded(m, ae));
 
-       assertChdir("..");
        /* Clean up. */
        archive_read_free(a);
        archive_entry_free(ae);
@@ -298,18 +265,6 @@ test_newer_ctime_than_file_wcs(void)
                return;
        }
 
-       assertMakeDir("test_newer_ctime_than_file_wcs", 0777);
-       assertChdir("test_newer_ctime_than_file_wcs");
-
-       assertMakeFile("old", 0666, "old");
-       assertUtimes("old", 10002, 0, 10002, 0);
-       sleepUntilAfter(time(NULL));
-       assertMakeFile("mid", 0666, "mid");
-       assertUtimes("mid", 10001, 0, 10001, 0);
-       sleepUntilAfter(time(NULL));
-       assertMakeFile("new", 0666, "new");
-       assertUtimes("new", 10000, 0, 10000, 0);
-
        /*
         * Test 'newer ctime than'.
         */
@@ -342,7 +297,6 @@ test_newer_ctime_than_file_wcs(void)
        assertEqualInt(0, archive_matching_time_excluded(m, ae));
        assertEqualInt(0, archive_matching_excluded(m, ae));
 
-       assertChdir("..");
        /* Clean up. */
        archive_read_free(a);
        archive_entry_free(ae);
@@ -419,15 +373,6 @@ test_older_mtime_than_file_mbs(void)
                return;
        }
 
-       assertMakeDir("test_older_mtime_than_file_mbs", 0777);
-       assertChdir("test_older_mtime_than_file_mbs");
-
-       assertMakeFile("old", 0666, "old");
-       sleepUntilAfter(time(NULL));
-       assertMakeFile("mid", 0666, "mid");
-       sleepUntilAfter(time(NULL));
-       assertMakeFile("new", 0666, "new");
-
        /*
         * Test 'older mtime than'.
         */
@@ -459,7 +404,6 @@ test_older_mtime_than_file_mbs(void)
        assertEqualInt(1, archive_matching_time_excluded(m, ae));
        assertEqualInt(1, archive_matching_excluded(m, ae));
 
-       assertChdir("..");
        /* Clean up. */
        archive_read_free(a);
        archive_entry_free(ae);
@@ -485,18 +429,6 @@ test_older_ctime_than_file_mbs(void)
                return;
        }
 
-       assertMakeDir("test_older_ctime_than_file_mbs", 0777);
-       assertChdir("test_older_ctime_than_file_mbs");
-
-       assertMakeFile("old", 0666, "old");
-       assertUtimes("old", 10002, 0, 10002, 0);
-       sleepUntilAfter(time(NULL));
-       assertMakeFile("mid", 0666, "mid");
-       assertUtimes("mid", 10001, 0, 10001, 0);
-       sleepUntilAfter(time(NULL));
-       assertMakeFile("new", 0666, "new");
-       assertUtimes("new", 10000, 0, 10000, 0);
-
        /*
         * Test 'older ctime than'.
         */
@@ -529,7 +461,6 @@ test_older_ctime_than_file_mbs(void)
        assertEqualInt(1, archive_matching_time_excluded(m, ae));
        assertEqualInt(1, archive_matching_excluded(m, ae));
 
-       assertChdir("..");
        /* Clean up. */
        archive_read_free(a);
        archive_entry_free(ae);
@@ -555,15 +486,6 @@ test_older_mtime_than_file_wcs(void)
                return;
        }
 
-       assertMakeDir("test_older_mtime_than_file_wcs", 0777);
-       assertChdir("test_older_mtime_than_file_wcs");
-
-       assertMakeFile("old", 0666, "old");
-       sleepUntilAfter(time(NULL));
-       assertMakeFile("mid", 0666, "mid");
-       sleepUntilAfter(time(NULL));
-       assertMakeFile("new", 0666, "new");
-
        /*
         * Test 'older mtime than'.
         */
@@ -595,7 +517,6 @@ test_older_mtime_than_file_wcs(void)
        assertEqualInt(1, archive_matching_time_excluded(m, ae));
        assertEqualInt(1, archive_matching_excluded(m, ae));
 
-       assertChdir("..");
        /* Clean up. */
        archive_read_free(a);
        archive_entry_free(ae);
@@ -621,18 +542,6 @@ test_older_ctime_than_file_wcs(void)
                return;
        }
 
-       assertMakeDir("test_older_ctime_than_file_wcs", 0777);
-       assertChdir("test_older_ctime_than_file_wcs");
-
-       assertMakeFile("old", 0666, "old");
-       assertUtimes("old", 10002, 0, 10002, 0);
-       sleepUntilAfter(time(NULL));
-       assertMakeFile("mid", 0666, "mid");
-       assertUtimes("mid", 10001, 0, 10001, 0);
-       sleepUntilAfter(time(NULL));
-       assertMakeFile("new", 0666, "new");
-       assertUtimes("new", 10000, 0, 10000, 0);
-
        /*
         * Test 'older ctime than'.
         */
@@ -665,7 +574,6 @@ test_older_ctime_than_file_wcs(void)
        assertEqualInt(1, archive_matching_time_excluded(m, ae));
        assertEqualInt(1, archive_matching_excluded(m, ae));
 
-       assertChdir("..");
        /* Clean up. */
        archive_read_free(a);
        archive_entry_free(ae);
@@ -779,10 +687,24 @@ DEFINE_TEST(test_archive_matching_time)
 {
        test_newer_time();
        test_older_time();
+
+       assertMakeFile("old", 0666, "old");
+       sleepUntilAfter(time(NULL));
+       assertMakeFile("mid", 0666, "mid");
+       sleepUntilAfter(time(NULL));
+       assertMakeFile("new", 0666, "new");
+
        test_newer_mtime_than_file_mbs();
        test_newer_mtime_than_file_wcs();
        test_older_mtime_than_file_mbs();
        test_older_mtime_than_file_wcs();
+
+       assertUtimes("old", 10002, 0, 10002, 0);
+       sleepUntilAfter(time(NULL));
+       assertUtimes("mid", 10001, 0, 10001, 0);
+       sleepUntilAfter(time(NULL));
+       assertUtimes("new", 10000, 0, 10000, 0);
+
        test_newer_ctime_than_file_mbs();
        test_newer_ctime_than_file_wcs();
        test_older_ctime_than_file_mbs();