From 5f7faac453633820837ff32f9534af81ca5e82a9 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 7 Sep 2022 15:04:02 -0500 Subject: [PATCH] Remove leftover uses of SKIPNEXT, indent skip groups so they're more visually obvious, use a SKIP value that looks intentional and not like file permissions, have skipnot() return whether or not test succeeded. --- scripts/runtest.sh | 4 +- tests/lsattr.test | 12 ++--- tests/tar.test | 123 +++++++++++++++++++++++---------------------- 3 files changed, 72 insertions(+), 67 deletions(-) diff --git a/scripts/runtest.sh b/scripts/runtest.sh index 467f8b82..11799400 100644 --- a/scripts/runtest.sh +++ b/scripts/runtest.sh @@ -92,11 +92,11 @@ skipnot() { if verbose_has quiet then - eval "$@" 2>/dev/null + eval "$@" >/dev/null 2>&1 else eval "$@" fi - [ $? -eq 0 ] || ((++SKIP)) + [ $? -eq 0 ] || { ((++SKIP)); return 1; } } # Skip this test (rest of command line) when not running toybox. diff --git a/tests/lsattr.test b/tests/lsattr.test index 63d9ee9c..f2beef56 100644 --- a/tests/lsattr.test +++ b/tests/lsattr.test @@ -31,12 +31,12 @@ NOSPACE=1 testing "-v file" "lsattr -v file | clean" "_ $_A file\n" "" "" NOSPACE=1 testing "-lv file" "lsattr -lv file | clean" "_ file No_Atime\n" "" "" # You need at least Linux 4.5 plus file system support for project ids. -lsattr -p file >/dev/null 2>&1 || SKIPNEXT=1 -NOSPACE=1 testing "-p file" "lsattr -p file | clean" "_ $_A file\n" "" "" -lsattr -p file >/dev/null 2>&1 || SKIPNEXT=1 -NOSPACE=1 testing "-lp file" "lsattr -lp file | clean" "_ file No_Atime\n" "" "" -lsattr -p file >/dev/null 2>&1 || SKIPNEXT=1 -NOSPACE=1 testing "-vp file" "lsattr -vp file | clean" "_ _ $_A file\n" "" "" +lsattr -p file >/dev/null 2>&1 || SKIP=999 + NOSPACE=1 testing "-p file" "lsattr -p file | clean" "_ $_A file\n" "" "" + NOSPACE=1 testing "-lp file" "lsattr -lp file | clean" "_ file No_Atime\n" \ + "" "" + NOSPACE=1 testing "-vp file" "lsattr -vp file | clean" "_ _ $_A file\n" "" "" +SKIP=0 chattr -AacDdijsStTu file && cd .. rm -rf dir diff --git a/tests/tar.test b/tests/tar.test index 9facfe4d..4c87f210 100755 --- a/tests/tar.test +++ b/tests/tar.test @@ -109,30 +109,30 @@ testing "create long fname" "$TAR dir/${LONG:1:97} dir/${LONG:1:96} | SUM 3" \ "d70018505fa5df19ae73498cfc74d0281601e42e\n" "" "" # MacOS X has different symlink permissions, skip these tests there -[ "$(uname)" == Darwin ] && SKIP=666 +[ "$(uname)" == Darwin ] && SKIP=999 -# / and .. only stripped from name, not symlink target. -ln -s ../name.././.. dir/link -testing "create symlink" "$TAR dir/link | SUM 3" \ - "f841bf9d757c655c5d37f30be62acb7ae24f433c\n" "" "" + # / and .. only stripped from name, not symlink target. + ln -s ../name.././.. dir/link + testing "create symlink" "$TAR dir/link | SUM 3" \ + "f841bf9d757c655c5d37f30be62acb7ae24f433c\n" "" "" -ln dir/link dir/hlink -testing "create hardlink to symlink" "$TAR dir/link dir/hlink | SUM 3" \ - "de571a6dbf09e1485e513ad13a178b1729267452\n" "" "" + ln dir/link dir/hlink + testing "create hardlink to symlink" "$TAR dir/link dir/hlink | SUM 3" \ + "de571a6dbf09e1485e513ad13a178b1729267452\n" "" "" -ln -s dir/${LONG:1:96} dir/lshort -ln -s dir/${LONG:1:97} dir/llong -testing "create long symlink" "$TAR dir/lshort dir/llong | SUM 3" \ - "07eaf397634b5443dbf2d3ec38a4302150fcfe82\n" "" "" + ln -s dir/${LONG:1:96} dir/lshort + ln -s dir/${LONG:1:97} dir/llong + testing "create long symlink" "$TAR dir/lshort dir/llong | SUM 3" \ + "07eaf397634b5443dbf2d3ec38a4302150fcfe82\n" "" "" -ln -s $LONG dir/${LONG:5} -testing "create long->long" "$TAR dir/${LONG:5} | SUM 7" \ - "b9e24f53e27496c5125445230d201b4a36ff7398\n" "" "" -# absolute and relative link names, broken and not + ln -s $LONG dir/${LONG:5} + testing "create long->long" "$TAR dir/${LONG:5} | SUM 7" \ + "b9e24f53e27496c5125445230d201b4a36ff7398\n" "" "" -ln -s file dir/linkok -testing "create symlink" "$TAR dir/linkok | SUM 3" \ - "f5669cfd179ddcdd5ca9f8a1561a99e11e0a08b1\n" "" "" + # absolute and relative link names, broken and not + ln -s file dir/linkok + testing "create symlink" "$TAR dir/linkok | SUM 3" \ + "f5669cfd179ddcdd5ca9f8a1561a99e11e0a08b1\n" "" "" SKIP=0 # End of tests that don't match MacOS symlink permissions @@ -195,7 +195,7 @@ testing "ownership" "$TAR dir/file | SUM 3" \ mkdir -p dd/sub/blah && tar cf test.tar dd/sub/blah && rm -rf dd/sub && -ln -s ../.. dd/sub || SKIPNEXT=1 +skipnot ln -s ../.. dd/sub toyonly testing "symlink out of cwd" \ "tar xf test.tar 2> /dev/null || echo yes ; [ ! -e dd/sub/blah ] && echo yes" \ "yes\nyes\n" "" "" @@ -234,45 +234,50 @@ testing "autodetect falls back to gzip -d when no zcat" \ rm -rf path # Tests that don't produce the same results on MacOS X as Linux -[ "$(uname)" == Darwin ] && SKIP=666 - -yes | head -n $((1<<18)) > bang -{ dd bs=$((1<<16)) count=1 status=none; dd bs=8192 seek=14 count=1 status=none; dd bs=4096 seek=64 count=5 status=none; } < bang > fweep -testing "sparse without overflow" "$TAR --sparse fweep | SUM 3" \ - "50dc56c3c7eed163f0f37c0cfc2562852a612ad0\n" "" "" -rm bang fweep - -for i in 1 3 5 7 9 14 27 36 128 256 300 304 -do - dd if=/dev/zero of=fweep bs=65536 seek=$i count=1 2>/dev/null -done -testing "sparse single overflow" "$TAR --sparse fweep | SUM 6" \ - "81d59c3a7470201f92d60e63a43318ddde893f6d\n" "" "" -rm fweep - -for i in $(seq 8 3 200) -do - dd if=/dev/zero of=fweep bs=65536 seek=$i count=1 2>/dev/null - dd if=/dev/zero of=fweep2 bs=65536 seek=$i count=1 2>/dev/null -done -truncate -s 20m fweep2 -testing "sparse double overflow" "$TAR --sparse fweep | SUM 7" \ - "024aacd955e45f89bafedb3f37c8d39b4d556471\n" "" "" - -tar c --sparse fweep > fweep.tar -rm fweep -testing "sparse extract" "tar xf fweep.tar && $TAR --sparse fweep | SUM 4" \ - "b949d3a3b4c6457c873f1ea9918fd9029c5ed4b3\n" "" "" -testing "sparse tvf" "tar tvf fweep.tar | grep -wq 13172736 && echo right size"\ - "right size\n" "" "" -rm fweep fweep.tar - -tar c --sparse fweep2 > fweep2.tar -rm fweep2 -testing "sparse extract hole at end" \ - "tar xf fweep2.tar && $TAR --sparse fweep2 | SUM 4" \ - "807664bcad0e827793318ff742991d6f006b2127\n" "" "" -rm fweep2 fweep2.tar +[ "$(uname)" == Darwin ] && SKIP=999 + + yes | head -n $((1<<18)) > bang + { + dd bs=$((1<<16)) count=1 status=none + dd bs=8192 seek=14 count=1 status=none + dd bs=4096 seek=64 count=5 status=none + } < bang > fweep + testing "sparse without overflow" "$TAR --sparse fweep | SUM 3" \ + "50dc56c3c7eed163f0f37c0cfc2562852a612ad0\n" "" "" + rm bang fweep + + for i in 1 3 5 7 9 14 27 36 128 256 300 304 + do + dd if=/dev/zero of=fweep bs=65536 seek=$i count=1 2>/dev/null + done + testing "sparse single overflow" "$TAR --sparse fweep | SUM 6" \ + "81d59c3a7470201f92d60e63a43318ddde893f6d\n" "" "" + rm fweep + + for i in $(seq 8 3 200) + do + dd if=/dev/zero of=fweep bs=65536 seek=$i count=1 2>/dev/null + dd if=/dev/zero of=fweep2 bs=65536 seek=$i count=1 2>/dev/null + done + truncate -s 20m fweep2 + testing "sparse double overflow" "$TAR --sparse fweep | SUM 7" \ + "024aacd955e45f89bafedb3f37c8d39b4d556471\n" "" "" + + tar c --sparse fweep > fweep.tar + rm fweep + testing "sparse extract" "tar xf fweep.tar && $TAR --sparse fweep | SUM 4" \ + "b949d3a3b4c6457c873f1ea9918fd9029c5ed4b3\n" "" "" + testing "sparse tvf" \ + "tar tvf fweep.tar | grep -wq 13172736 && echo right size" "right size\n" \ + "" "" + rm fweep fweep.tar + + tar c --sparse fweep2 > fweep2.tar + rm fweep2 + testing "sparse extract hole at end" \ + "tar xf fweep2.tar && $TAR --sparse fweep2 | SUM 4" \ + "807664bcad0e827793318ff742991d6f006b2127\n" "" "" + rm fweep2 fweep2.tar SKIP=0 # End of tests that don't work on MacOS X -- 2.39.2