]> git.gag.com Git - debian/tar/commitdiff
Fix the testsuite
authorSergey Poznyakoff <gray@gnu.org>
Sat, 19 Mar 2016 20:32:34 +0000 (22:32 +0200)
committerSergey Poznyakoff <gray@gnu.org>
Sun, 20 Mar 2016 21:11:27 +0000 (23:11 +0200)
* tests/sparse05.at: Use autom4te magic to generate mapfile,
instead of the shell command seq, which is not always available.
* tests/listed03.at: Skip the test if xgetcwd fails.
* tests/ckmtime.c: New file.
* tests/Makefile.am: Build ckmtime
* tests/testsuite.at (AT_CHECK_TIMESTAMP): Check whether newly created
files have timestamps consistent with the creation time.  Skip the test
if not.
* tests/incr01.at: Use AT_CHECK_TIMESTAMP
* tests/incr02.at: Likewise.
* tests/incr03.at: Likewise.
* tests/incr04.at: Likewise.
* tests/incr05.at: Likewise.
* tests/incr06.at: Likewise.
* tests/incr07.at: Likewise.
* tests/incr08.at: Likewise.
* tests/incr09.at: Likewise.
* tests/incr10.at: Likewise.
* tests/incr11.at: Likewise.
* tests/incremental.at: Likewise.
* tests/listed01.at: Likewise.
* tests/listed02.at: Likewise.
* tests/listed04.at: Likewise.
* tests/listed05.at: Likewise.

22 files changed:
tests/.gitignore
tests/Makefile.am
tests/ckmtime.c [new file with mode: 0644]
tests/incr01.at
tests/incr02.at
tests/incr03.at
tests/incr04.at
tests/incr05.at
tests/incr06.at
tests/incr07.at
tests/incr08.at
tests/incr09.at
tests/incr10.at
tests/incr11.at
tests/incremental.at
tests/listed01.at
tests/listed02.at
tests/listed03.at
tests/listed04.at
tests/listed05.at
tests/sparse05.at
tests/testsuite.at

index 2a721ba6c10c2a35fb3969720e7fa4d1e769aba2..9c0103d3d1bb10f0e94855add3e4bbf572221127 100644 (file)
@@ -11,3 +11,4 @@ genfile
 download
 ttyemu
 checkseekhole
+ckmtime
index ee7a1d34ad3f2b3498d14d509db6b85c208a6b48..02a3d7906b1ab174ea8d0d1b71f80d3666c9b89c 100644 (file)
@@ -281,7 +281,7 @@ installcheck-local: $(check_PROGRAMS)
 ## genfile      ##
 ## ------------ ##
 
-check_PROGRAMS = genfile checkseekhole
+check_PROGRAMS = genfile checkseekhole ckmtime
 
 if TAR_COND_GRANTPT
 check_PROGRAMS += ttyemu
diff --git a/tests/ckmtime.c b/tests/ckmtime.c
new file mode 100644 (file)
index 0000000..75b9e6c
--- /dev/null
@@ -0,0 +1,48 @@
+/* Check if filesystem timestamps are consistent with the system time.
+   Copyright (C) 2016 Free Software Foundation, Inc.
+      
+   This program is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by the
+   Free Software Foundation; either version 3, or (at your option) any later
+   version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+   Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#include <config.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stat-time.h>
+#include <timespec.h>
+
+int
+main (int argc, char **argv)
+{
+  FILE *fp;
+  struct timeval tv;
+  struct stat st;
+  struct timespec ts;
+  
+  assert (gettimeofday (&tv, NULL) == 0);
+  ts.tv_sec = tv.tv_sec;
+  ts.tv_nsec = tv.tv_usec * 1000;
+  
+  fp = tmpfile ();
+  assert (fp != NULL);
+  assert (fstat (fileno (fp), &st) == 0);
+  fclose (fp);
+  if (timespec_cmp (get_stat_mtime (&st), ts) >= 0)
+    {
+      fprintf (stderr, "file timestamp unreliable\n");
+      return 1;
+    }
+  return 0;
+}
index 0b8623ecdc2e895ec14f02a3423c42703a8a2512..1af6ec601305d08697d9314e7883eef185e4e4d1 100644 (file)
@@ -28,6 +28,8 @@ AT_SETUP([restore broken symlinks from incremental])
 AT_KEYWORDS([incremental incr01])
 
 AT_TAR_CHECK([
+AT_CHECK_TIMESTAMP
+
 mkdir directory
 $as_ln_s foo directory/bar
 
index 12c6cda83caa0d1c5e7be6c7dc277640db85cace..7396f6cad6c045f30d55eace75644eba52605a53 100644 (file)
@@ -33,6 +33,7 @@ AT_SETUP([restoring timestamps from incremental])
 AT_KEYWORDS([incremental timestamp restore incr02])
 
 AT_TAR_CHECK([
+AT_CHECK_TIMESTAMP
 # Create directory structure
 mkdir dir
 mkdir dir/subdir1
index c9df3e37c7cad5d731fd09f8bdd55c482d8b20cf..d6301a7c17066f5c3c41cb513f547cd18c02b617 100644 (file)
@@ -30,6 +30,7 @@ AT_SETUP([renamed files in incrementals])
 AT_KEYWORDS([incremental incr03 rename])
 
 AT_TAR_CHECK([
+AT_CHECK_TIMESTAMP
 AT_SORT_PREREQ
 mkdir directory
 genfile --file=directory/x
index bf8a17b1c8b61b2e7704f6d952ce5d42cea897e1..0d1305d0e9ede00e8fa987d6d5984b5447801bce 100644 (file)
@@ -33,6 +33,7 @@ AT_KEYWORDS([incremental incr04 icontents])
 m4_pushdef([NAME_PREFIX],[a/b/one_31_chars_long_file_name_])
 
 AT_TAR_CHECK([
+AT_CHECK_TIMESTAMP
 AT_TAR_MKHIER(a/b)
 awk 'BEGIN {
   for (i=1;i<=142;i++)
index 0347933cc920e7aa475a53caabb90e813ec82982..fbb4ac4c3b003f7caa784e2944c75bc4730dab8c 100644 (file)
@@ -22,6 +22,7 @@ AT_SETUP([incremental dumps with -C])
 AT_KEYWORDS([incremental incr05])
 
 AT_TAR_CHECK([
+AT_CHECK_TIMESTAMP
 mkdir dir
 mkdir dir/sub
 genfile --file dir/file1
index 2711f3b7b4ab52d7c1e567d63602d6de4d2ec33f..2509461f064a5f96572ed78b9251c587e06d0c86 100644 (file)
@@ -22,6 +22,7 @@ AT_SETUP([incremental dumps of nested directories])
 AT_KEYWORDS([incremental incr06])
 
 AT_TAR_CHECK([
+AT_CHECK_TIMESTAMP
 mkdir dir
 mkdir dir/sub
 mkdir dir/sub/a
index 51e0949da76077572622c8f6d9adc86a515a0337..a5b886730e2fce4f2a8bdb168fe19735bdd4da99 100644 (file)
@@ -38,6 +38,7 @@ AT_KEYWORDS([incremental extract incr07])
 #             http://lists.gnu.org/archive/html/bug-tar/2013-03/msg00044.html
 
 AT_TAR_CHECK([
+AT_CHECK_TIMESTAMP
 mkdir dirA
 echo 'a' > dirA/a
 echo 'a' > dirA/b
index 0d6b826d9da9b2cf01a3f9891d9b1cb4f6515deb..e74be3d54cb8fbe09822876b01b28ad4ce9195fe 100644 (file)
@@ -39,6 +39,7 @@ AT_SETUP([filename normalization])
 AT_KEYWORDS([incremental create incr08])
 
 AT_TAR_CHECK([
+AT_CHECK_TIMESTAMP
 AT_SORT_PREREQ
 mkdir tartest
 cd tartest
index c3c8f9ac65b99774188ba11e7bb162f875cc8680..983bdc2475abd7ff8228ff9ed930d8803be6adca 100644 (file)
@@ -27,6 +27,7 @@ AT_SETUP([incremental with alternating -C])
 AT_KEYWORDS([incremental create incr09])
 
 AT_TAR_CHECK([
+AT_CHECK_TIMESTAMP
 AT_SORT_PREREQ
 mkdir foo bar middle
 echo foo/foo_file > foo/foo_file
index 45d00286d99ed0f9feee37876129a708a3b64ca0..cc77d499648e8cd1b3b98767d1b99303390af7e0 100644 (file)
@@ -26,6 +26,7 @@ AT_KEYWORDS([incremental concat cat incr10])
 #             http://lists.gnu.org/archive/html/bug-tar/2015-04/msg00003.html
 
 AT_TAR_CHECK([
+AT_CHECK_TIMESTAMP
 mkdir in
 mkdir in/dir
 decho Level 0
index 0ac923f3f2616dfad590205c1635ec1378f152ae..061a8db083640edff7f4ec181fca12f83eb0301f 100644 (file)
@@ -26,6 +26,7 @@ AT_SETUP([concatenated incremental archives (renames)])
 AT_KEYWORDS([incremental concat cat incr11])
 
 AT_TAR_CHECK([
+AT_CHECK_TIMESTAMP
 AT_SORT_PREREQ
 AT_TAR_MKHIER([data/dir],[file])
 decho Level 0
index 2c3f48036323d88f3243be90f4df1752ced56bfe..0b8a977905b111da6406efd5b0833868ab35393b 100644 (file)
@@ -24,6 +24,8 @@ AT_SETUP([incremental])
 AT_KEYWORDS([incremental listed incr00])
 
 AT_TAR_CHECK([
+AT_CHECK_TIMESTAMP
+
 mkdir structure
 echo x >structure/file
 
index 7fabc7c727f6e4365e55fc02a18dc05e433a854f..fc0a356e3dea688371ea96430b60be05df5f7782 100644 (file)
@@ -28,6 +28,8 @@ AT_SETUP([--listed for individual files])
 AT_KEYWORDS([listed incremental listed01])
 
 AT_TAR_CHECK([
+AT_CHECK_TIMESTAMP
+
 mkdir directory
 genfile --length 10240 --pattern zeros --file directory/file1
 # Let the things settle
index 58a020c81d77c452a5b85a25c4cbe4df88e806bc..153644ba574d49d66f84ab9361341b863cd686fe 100644 (file)
@@ -30,6 +30,7 @@ AT_SETUP([working --listed])
 AT_KEYWORDS([listed incremental listed02])
 
 AT_TAR_CHECK([
+AT_CHECK_TIMESTAMP
 AT_SORT_PREREQ
 echo Create directories
 
index d40525703c737325f66868c7211aa61c16cd83af..07bd1c8e9854d12a5293aac3b2ee73a007c34e41 100644 (file)
@@ -25,6 +25,7 @@ AT_SETUP([incremental dump when the parent directory is unreadable])
 AT_KEYWORDS([listed incremental listed03])
 
 AT_TAR_CHECK([
+AT_CHECK_TIMESTAMP
 AT_UNPRIVILEGED_PREREQ
 
 mkdir dir
@@ -34,9 +35,13 @@ genfile --file dir/sub/a/file
 cd dir/sub
 
 chmod a-r ..
-tar -c -f archive.tar --listed-incremental=db.1 -v a
+tar -c -f archive.tar --listed-incremental=db.1 -v a 2>err
 status=$?
 chmod a+r ..
+if test $status -eq 2; then
+  grep '^tar: \.: Cannot getcwd' err >/dev/null 2>&1 && AT_SKIP_TEST
+fi
+cat err >&2
 exit $status
 ],
 [0],
index 8dd6542747bcab320b72e14e5e5cd84591001a07..ea8450f344341065dd5f7d10f81567d6f13852a6 100644 (file)
@@ -27,7 +27,7 @@ AT_SETUP([--listed-incremental and --one-file-system])
 AT_KEYWORDS([listed incremental listed04])
 
 AT_TAR_CHECK([
-
+AT_CHECK_TIMESTAMP
 mkdir dir
 echo a >dir/a
 echo b >dir/b
index 3cb19665af2af214c0418edf21c24d28821455d3..13ac42acefa963476430bac5cf0a81d60a4e5dfa 100644 (file)
@@ -34,6 +34,7 @@ AT_SETUP([--listed-incremental and remounted directories])
 AT_KEYWORDS([listed incremental listed05])
 
 AT_TAR_CHECK([
+AT_CHECK_TIMESTAMP
 AT_PRIVILEGED_PREREQ
 options="-C tartest --create --one-file-system --verbose"
 rm -rf archive-[01].snar archive-[01].tar tartest subdir
index e358d1f5ecf8a6f599df4178118eb4c1eee11521..0c7a03738ff634e9187e859d656ec02438e47812 100644 (file)
@@ -29,10 +29,11 @@ AT_KEYWORDS([sparse sparse05])
 #             http://lists.gnu.org/archive/html/bug-tar/2013-01/msg00001.html
 
 AT_TAR_CHECK([
-(echo 0 =2560
-for i in `seq 1 999`; do
-    echo 10M =2560
-done) | genfile --sparse --file BIGFILE --block-size 4K - || AT_SKIP_TEST
+AT_DATA([mapfile],
+[0 =2560
+m4_for([i], 1, 999, 1, [10M =2560
+])])
+genfile --sparse --file BIGFILE --block-size 4K - < mapfile || AT_SKIP_TEST
 tar -f - -c --sparse --posix BIGFILE | tar tvf - | awk '{ print $3, $(NF) }'
 ],
 [0],
index 2e4a0679cd8abea5b2999667defa252f16c22d0c..0b37fa302bfafc801e0a775685c6cf5c6e926869 100644 (file)
@@ -188,6 +188,10 @@ m4_define([AT_ACLS_PREREQ],[
   fi
 ])
 
+dnl Check whether a newly created file has timestamp consistent with the
+dnl local time.  Skip the test if not.
+m4_define([AT_CHECK_TIMESTAMP],[ckmtime || AT_SKIP_TEST])
+
 m4_include([sparsemvp.at])
 
 AT_INIT