From 143dc63ffa179c8a1804c0079a2fd576e259d66a Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Sat, 19 Mar 2016 22:32:34 +0200 Subject: [PATCH] Fix the testsuite * 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. --- tests/.gitignore | 1 + tests/Makefile.am | 2 +- tests/ckmtime.c | 48 ++++++++++++++++++++++++++++++++++++++++++++ tests/incr01.at | 2 ++ tests/incr02.at | 1 + tests/incr03.at | 1 + tests/incr04.at | 1 + tests/incr05.at | 1 + tests/incr06.at | 1 + tests/incr07.at | 1 + tests/incr08.at | 1 + tests/incr09.at | 1 + tests/incr10.at | 1 + tests/incr11.at | 1 + tests/incremental.at | 2 ++ tests/listed01.at | 2 ++ tests/listed02.at | 1 + tests/listed03.at | 7 ++++++- tests/listed04.at | 2 +- tests/listed05.at | 1 + tests/sparse05.at | 9 +++++---- tests/testsuite.at | 4 ++++ 22 files changed, 84 insertions(+), 7 deletions(-) create mode 100644 tests/ckmtime.c diff --git a/tests/.gitignore b/tests/.gitignore index 2a721ba6..9c0103d3 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -11,3 +11,4 @@ genfile download ttyemu checkseekhole +ckmtime diff --git a/tests/Makefile.am b/tests/Makefile.am index ee7a1d34..02a3d790 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 00000000..75b9e6c3 --- /dev/null +++ b/tests/ckmtime.c @@ -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 . +*/ +#include +#include +#include +#include +#include +#include +#include +#include + +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; +} diff --git a/tests/incr01.at b/tests/incr01.at index 0b8623ec..1af6ec60 100644 --- a/tests/incr01.at +++ b/tests/incr01.at @@ -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 diff --git a/tests/incr02.at b/tests/incr02.at index 12c6cda8..7396f6ca 100644 --- a/tests/incr02.at +++ b/tests/incr02.at @@ -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 diff --git a/tests/incr03.at b/tests/incr03.at index c9df3e37..d6301a7c 100644 --- a/tests/incr03.at +++ b/tests/incr03.at @@ -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 diff --git a/tests/incr04.at b/tests/incr04.at index bf8a17b1..0d1305d0 100644 --- a/tests/incr04.at +++ b/tests/incr04.at @@ -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++) diff --git a/tests/incr05.at b/tests/incr05.at index 0347933c..fbb4ac4c 100644 --- a/tests/incr05.at +++ b/tests/incr05.at @@ -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 diff --git a/tests/incr06.at b/tests/incr06.at index 2711f3b7..2509461f 100644 --- a/tests/incr06.at +++ b/tests/incr06.at @@ -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 diff --git a/tests/incr07.at b/tests/incr07.at index 51e0949d..a5b88673 100644 --- a/tests/incr07.at +++ b/tests/incr07.at @@ -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 diff --git a/tests/incr08.at b/tests/incr08.at index 0d6b826d..e74be3d5 100644 --- a/tests/incr08.at +++ b/tests/incr08.at @@ -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 diff --git a/tests/incr09.at b/tests/incr09.at index c3c8f9ac..983bdc24 100644 --- a/tests/incr09.at +++ b/tests/incr09.at @@ -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 diff --git a/tests/incr10.at b/tests/incr10.at index 45d00286..cc77d499 100644 --- a/tests/incr10.at +++ b/tests/incr10.at @@ -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 diff --git a/tests/incr11.at b/tests/incr11.at index 0ac923f3..061a8db0 100644 --- a/tests/incr11.at +++ b/tests/incr11.at @@ -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 diff --git a/tests/incremental.at b/tests/incremental.at index 2c3f4803..0b8a9779 100644 --- a/tests/incremental.at +++ b/tests/incremental.at @@ -24,6 +24,8 @@ AT_SETUP([incremental]) AT_KEYWORDS([incremental listed incr00]) AT_TAR_CHECK([ +AT_CHECK_TIMESTAMP + mkdir structure echo x >structure/file diff --git a/tests/listed01.at b/tests/listed01.at index 7fabc7c7..fc0a356e 100644 --- a/tests/listed01.at +++ b/tests/listed01.at @@ -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 diff --git a/tests/listed02.at b/tests/listed02.at index 58a020c8..153644ba 100644 --- a/tests/listed02.at +++ b/tests/listed02.at @@ -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 diff --git a/tests/listed03.at b/tests/listed03.at index d4052570..07bd1c8e 100644 --- a/tests/listed03.at +++ b/tests/listed03.at @@ -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], diff --git a/tests/listed04.at b/tests/listed04.at index 8dd65427..ea8450f3 100644 --- a/tests/listed04.at +++ b/tests/listed04.at @@ -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 diff --git a/tests/listed05.at b/tests/listed05.at index 3cb19665..13ac42ac 100644 --- a/tests/listed05.at +++ b/tests/listed05.at @@ -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 diff --git a/tests/sparse05.at b/tests/sparse05.at index e358d1f5..0c7a0373 100644 --- a/tests/sparse05.at +++ b/tests/sparse05.at @@ -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], diff --git a/tests/testsuite.at b/tests/testsuite.at index 2e4a0679..0b37fa30 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -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 -- 2.47.2