aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-03-30 20:29:09 +0200
committerMattias Andrée <maandree@kth.se>2016-03-30 20:29:09 +0200
commit8e47c389e81dd32e020d3739a3d9439beaad37d6 (patch)
treef13c99b666fa8f8236ff88de10d211c80bc2142b
parentadd printenv test (diff)
downloadbase-util-tests-8e47c389e81dd32e020d3739a3d9439beaad37d6.tar.gz
base-util-tests-8e47c389e81dd32e020d3739a3d9439beaad37d6.tar.bz2
base-util-tests-8e47c389e81dd32e020d3739a3d9439beaad37d6.tar.xz
some improvements
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--README3
-rwxr-xr-x__xsum/__test26
-rwxr-xr-xbase16-test/test2
-rwxr-xr-xbase32-test/test2
-rwxr-xr-xbase64-test/test2
-rwxr-xr-xbasename-test/test10
-rwxr-xr-xcat-test/test7
-rwxr-xr-xcksum-test/test6
-rwxr-xr-xecho-test/test2
-rwxr-xr-xfalse-test/test28
-rwxr-xr-xpatch-test/__test6
-rwxr-xr-xprintenv-test/test2
-rwxr-xr-xrev-test/test2
-rwxr-xr-xtac-test/test2
-rwxr-xr-xuniq-test/test2
15 files changed, 60 insertions, 42 deletions
diff --git a/README b/README
index 7dc896d..7507b12 100644
--- a/README
+++ b/README
@@ -46,4 +46,5 @@ NOTES FOR PATCH-TEST
to the path and flags for patch(1) that runs patch(1)
qwithout asking questions. If the path is relative,
it is relative to a direct subdiretory of ./patch-test/
- (../../ prefix.)
+ (../../ prefix.) You may also have to change some
+ strings in ./patct-test/__test.
diff --git a/__xsum/__test b/__xsum/__test
index ef42b6c..749d955 100755
--- a/__xsum/__test
+++ b/__xsum/__test
@@ -18,8 +18,8 @@ report ()
multiple_files_order ()
{
- $s $(seq 1 $N) | tr '[A-F]' '[a-f]' | sed -e 's/[\t ]*/ /' | cut -d ' ' -f 2 > tmp1
- < $algo sed -e 's/ */ /' | cut -d ' ' -f 2 > tmp2
+ $s $(seq $N) | tr '[A-F]' '[a-f]' | sed 's/[\t ]*/ /' | cut -d ' ' -f 2 > tmp1
+ < $algo sed 's/ */ /' | cut -d ' ' -f 2 > tmp2
diff tmp1 tmp2 > /dev/null
report $? "multiple_files_order"
rm tmp1 tmp2
@@ -27,8 +27,8 @@ multiple_files_order ()
multiple_files_delim ()
{
- $s $(seq 1 $N) | tr '[A-F]' '[a-f]' | sed -e 's/^[0-9a-f]*//' | sort > tmp1
- seq 1 $N | sed -e 's/^/ /' | sort > tmp2
+ $s $(seq $N) | tr '[A-F]' '[a-f]' | sed 's/^[0-9a-f]*//' | sort > tmp1
+ seq $N | sed 's/^/ /' | sort > tmp2
diff tmp1 tmp2 > /dev/null
report $? "multiple_files_delim"
rm tmp1 tmp2
@@ -36,7 +36,7 @@ multiple_files_delim ()
multiple_files_sum ()
{
- $s $(seq 1 $N) | tr '[A-F]' '[a-f]' | sed -e 's/\t/ /' | cut -d ' ' -f 1 | sort > tmp1
+ $s $(seq $N) | tr '[A-F]' '[a-f]' | sed 's/\t/ /' | cut -d ' ' -f 1 | sort > tmp1
< $algo cut -d ' ' -f 1 | sort > tmp2
diff tmp1 tmp2 > /dev/null
report $? "multiple_files_sum"
@@ -45,7 +45,7 @@ multiple_files_sum ()
multiple_files ()
{
- $s $(seq 1 $N) | tr '[A-F]' '[a-f]' > tmp1
+ $s $(seq $N) | tr '[A-F]' '[a-f]' > tmp1
diff tmp1 $algo > /dev/null
report $? "multiple_files"
rm tmp1
@@ -80,7 +80,7 @@ dash ()
check_file_match ()
{
- $s $(seq 1 $N) > tmp1
+ $s $(seq $N) > tmp1
$s -c tmp1 > /dev/null
report $? "check_file_match"
rm tmp1
@@ -88,7 +88,7 @@ check_file_match ()
check_stdin_match ()
{
- $s $(seq 1 $N) > tmp1
+ $s $(seq $N) > tmp1
$s -c < tmp1 > /dev/null
report $? "check_stdin_match"
rm tmp1
@@ -96,7 +96,7 @@ check_stdin_match ()
check_dash_match ()
{
- $s $(seq 1 $N) > tmp1
+ $s $(seq $N) > tmp1
$s -c - < tmp1 > /dev/null
report $? "check_dash_match"
rm tmp1
@@ -104,7 +104,7 @@ check_dash_match ()
check_file_mismatch ()
{
- $s $(seq 1 $N) | tr '[a-f]' '[1-6]' | tr '[A-F]' '[1-6]' > tmp1
+ $s $(seq $N) | tr '[a-f]' '[1-6]' | tr '[A-F]' '[1-6]' > tmp1
! $s -c tmp1 > /dev/null 2> /dev/null
report $? "check_file_mismatch"
rm tmp1
@@ -112,7 +112,7 @@ check_file_mismatch ()
check_stdin_mismatch ()
{
- $s $(seq 1 $N) | tr '[a-f]' '[1-6]' | tr '[A-F]' '[1-6]' > tmp1
+ $s $(seq $N) | tr '[a-f]' '[1-6]' | tr '[A-F]' '[1-6]' > tmp1
! $s -c < tmp1 > /dev/null 2> /dev/null
report $? "check_stdin_mismatch"
rm tmp1
@@ -120,7 +120,7 @@ check_stdin_mismatch ()
check_dash_mismatch ()
{
- $s $(seq 1 $N) | tr '[a-f]' '[1-6]' | tr '[A-F]' '[1-6]' > tmp1
+ $s $(seq $N) | tr '[a-f]' '[1-6]' | tr '[A-F]' '[1-6]' > tmp1
! $s -c - < tmp1 > /dev/null 2> /dev/null
report $? "check_dash_mismatch"
rm tmp1
@@ -128,7 +128,7 @@ check_dash_mismatch ()
check_case ()
{
- $s $(seq 1 $N) | tr '[A-F]' '[a-f]' > tmp1
+ $s $(seq $N) | tr '[A-F]' '[a-f]' > tmp1
tr '[a-f]' '[A-F]' < tmp1 > tmp2
$s -c tmp1 > /dev/null && $s -c tmp2 > /dev/null
report $? "check_case"
diff --git a/base16-test/test b/base16-test/test
index b0945e4..735eb35 100755
--- a/base16-test/test
+++ b/base16-test/test
@@ -98,7 +98,7 @@ iflag ()
iflagless ()
{
- ! printf "$foo" | sed 's/./\%&/g' | $b -d >/dev/null 2>/dev/null
+ ! printf "$foo" | sed 's/./\%&/g' | $b -d > /dev/null 2> /dev/null
report_np $? "iflagless -d"
}
diff --git a/base32-test/test b/base32-test/test
index 40ae172..96f8551 100755
--- a/base32-test/test
+++ b/base32-test/test
@@ -96,7 +96,7 @@ iflag ()
iflagless ()
{
- ! printf "$foo" | sed 's/./\%&/g' | $b -d >/dev/null 2>/dev/null
+ ! printf "$foo" | sed 's/./\%&/g' | $b -d > /dev/null 2> /dev/null
report_np $? "iflagless -d"
}
diff --git a/base64-test/test b/base64-test/test
index 0097bdd..8f9b71f 100755
--- a/base64-test/test
+++ b/base64-test/test
@@ -96,7 +96,7 @@ iflag ()
iflagless ()
{
- ! printf "$foo" | sed 's/./\%&/g' | $b -d >/dev/null 2>/dev/null
+ ! printf "$foo" | sed 's/./\%&/g' | $b -d > /dev/null 2> /dev/null
report_np $? "iflagless -d"
}
diff --git a/basename-test/test b/basename-test/test
index 8cab7a3..3e0d210 100755
--- a/basename-test/test
+++ b/basename-test/test
@@ -73,31 +73,31 @@ step_4_5 ()
step_6 ()
{
- test "$($b a.b b)" = a. &&
+ test "$($b a.b b)" = a.
report $? "step_6"
}
step_6_4 ()
{
- test "$($b a.b/ b)" = a. &&
+ test "$($b a.b/ b)" = a.
report $? "step_6.4"
}
step_6_full ()
{
- test "$($b a.b a.b)" = a.b &&
+ test "$($b a.b a.b)" = a.b
report $? "step_6_full"
}
step_6_mismatch ()
{
- test "$($b a.b c)" = a.b &&
+ test "$($b a.b c)" = a.b
report $? "step_6_mismatch"
}
step_6_longer ()
{
- test "$($b a.b cccccccccccccccccc)" = a.b &&
+ test "$($b a.b cccccccccccccccccc)" = a.b
report $? "step_6_longer"
}
diff --git a/cat-test/test b/cat-test/test
index 1a3d3b3..9005dd1 100755
--- a/cat-test/test
+++ b/cat-test/test
@@ -72,7 +72,10 @@ uflag ()
touch tmp2; rm tmp2
(
printf 123
- sleep 0.1
+ python3 <<EOF
+import time
+time.sleep(0.1)
+EOF
cat tmp > tmp1
) | $c -u > tmp
printf 123 > tmp2
@@ -84,7 +87,7 @@ uflag ()
if test $# = 0; then
- set $(printf 'file_%i\n' $(seq 1 $N)) dash dash_many file_one file_many file_dash ddash uflag
+ set $(printf 'file_%i\n' $(seq $N)) dash dash_many file_one file_many file_dash ddash uflag
fi
(
for f in $@; do
diff --git a/cksum-test/test b/cksum-test/test
index 8387145..7a17fd0 100755
--- a/cksum-test/test
+++ b/cksum-test/test
@@ -19,7 +19,7 @@ report ()
multiple_files_order ()
{
- $s $(seq 1 $N) | sed -e 's/[\t ]\+/ /g' | cut -d ' ' -f 3 > tmp1
+ $s $(seq $N) | sed -e 's/[\t ]\+/ /g' | cut -d ' ' -f 3 > tmp1
< $algo cut -d ' ' -f 3 > tmp2
diff tmp1 tmp2 > /dev/null
report $? "multiple_files_order"
@@ -28,7 +28,7 @@ multiple_files_order ()
multiple_files_sum ()
{
- $s $(seq 1 $N) | sed -e 's/[\t ]\+/ /g' | cut -d ' ' -f 1,2 | sort > tmp1
+ $s $(seq $N) | sed -e 's/[\t ]\+/ /g' | cut -d ' ' -f 1,2 | sort > tmp1
< $algo cut -d ' ' -f 1,2 | sort > tmp2
diff tmp1 tmp2 > /dev/null
report $? "multiple_files_sum"
@@ -37,7 +37,7 @@ multiple_files_sum ()
multiple_files ()
{
- $s $(seq 1 $N) > tmp1
+ $s $(seq $N) > tmp1
diff tmp1 $algo > /dev/null
report $? "multiple_files"
rm tmp1
diff --git a/echo-test/test b/echo-test/test
index 508ad78..574cd26 100755
--- a/echo-test/test
+++ b/echo-test/test
@@ -17,7 +17,7 @@ report ()
}
if test $# = 0; then
- set $(seq 1 $N)
+ set $(seq $N)
fi
(
for f in $@; do
diff --git a/false-test/test b/false-test/test
index c3e1432..a4f38fd 100755
--- a/false-test/test
+++ b/false-test/test
@@ -15,53 +15,65 @@ report ()
fi
}
+F ()
+{
+ touch tmp1 tmp2; rm tmp1 tmp2
+ ! $t "$@" 2> tmp1 >&2
+ ret=$?
+ < tmp1 tee /dev/stderr | grep -v '^==[0-9]*==' > tmp2
+ test $ret = 0 && test ! -s tmp2
+ ret=$?
+ rm tmp1 tmp2
+ return $ret
+}
+
args0 ()
{
- ! $t
+ F
report $? "args0"
}
args1 ()
{
- ! $t 1
+ F 1
report $? "args1"
}
args2 ()
{
- ! $t 1 2
+ F 1 2
report $? "args2"
}
args3 ()
{
- ! $t 1 2 3
+ F 1 2 3
report $? "args3"
}
dash ()
{
- ! $t -
+ F -
report $? "dash"
}
opt ()
{
- ! $t -h
+ F -h
report $? "opt"
}
ddash ()
{
- ! $t --
+ F --
report $? "ddash"
}
long ()
{
- ! $t --hello
+ F --hello
report $? "long"
}
diff --git a/patch-test/__test b/patch-test/__test
index 82605f1..20d1258 100755
--- a/patch-test/__test
+++ b/patch-test/__test
@@ -80,10 +80,12 @@ run ()
fi
val=$?
if test $val = $x && test $2 = fuzzy; then
- grep 'ward fuzz' < tmp >/dev/null
+ grep -i 'ward fuzz' < tmp > /dev/null ||
+ grep -i 'hunk #1 succeeded .*offset' < tmp > /dev/null
val=$?
elif test $val = $x && test $2 = applied; then
- grep 'hunk number 2 of 2' < tmp >/dev/null
+ grep -i 'hunk number 2 of 2' < tmp > /dev/null ||
+ grep -i 'hunk #2 failed' < tmp > /dev/null
val=$?
fi
diff --git a/printenv-test/test b/printenv-test/test
index db0d4f6..272f524 100755
--- a/printenv-test/test
+++ b/printenv-test/test
@@ -60,7 +60,7 @@ nonexistent ()
failure ()
{
$p >&- 2>/dev/null
- test $? = 2
+ test $? -ge 2
report_np $? "failure"
}
diff --git a/rev-test/test b/rev-test/test
index 4cff0bc..8ae234a 100755
--- a/rev-test/test
+++ b/rev-test/test
@@ -89,7 +89,7 @@ combining ()
if test $# = 0; then
- set $(printf 'file_%i\n' $(seq 1 $N)) dash nolf utf8 file_one file_many file_dash ddash combining
+ set $(printf 'file_%i\n' $(seq $N)) dash nolf utf8 file_one file_many file_dash ddash combining
fi
(
for f in $@; do
diff --git a/tac-test/test b/tac-test/test
index db4e121..fa6b7ac 100755
--- a/tac-test/test
+++ b/tac-test/test
@@ -61,7 +61,7 @@ ddash ()
if test $# = 0; then
- set $(printf 'file_%i\n' $(seq 1 $N)) dash file_one file_many file_dash ddash
+ set $(printf 'file_%i\n' $(seq $N)) dash file_one file_many file_dash ddash
fi
(
for f in $@; do
diff --git a/uniq-test/test b/uniq-test/test
index 74692ef..be5dadd 100755
--- a/uniq-test/test
+++ b/uniq-test/test
@@ -128,7 +128,7 @@ dash_out ()
if test $# = 0; then
- set $(printf 'file_%i\n' $(seq 1 $N)) dflag uflag cflag sflag_excess \
+ set $(printf 'file_%i\n' $(seq $N)) dflag uflag cflag sflag_excess \
sflag f0flag fflag_excess fflag fsflag file_in dash_in file_out \
dash_out
fi