commit 37924c4d0f4e809d000f05aebe81aebba20c895f
parent c0889d3bb72e1975c8d7f4cfbb873f0dacf06004
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Mon, 19 Feb 2018 18:04:16 +0000
[tests/ar] Fix multiple problems in tests
Diffstat:
4 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/tests/ar/execute/00-test-q.sh b/tests/ar/execute/00-test-q.sh
@@ -49,7 +49,7 @@ awk '$0 != NR-1 ".tst" {
#empty file list
rm -f file.a
ar -qv file.a
-if !test -f file.a
+if ! test -f file.a
then
echo "ar -q didn't generated empty archive" >&2
exit 1
diff --git a/tests/ar/execute/10-test-d.sh b/tests/ar/execute/10-test-d.sh
@@ -70,7 +70,7 @@ fi
#no members
cp master.a file.a
-last=`stat -c %Y file.a`
+last=`ls -l file.a | awk '{print $6,$7,$8}'`
if ! ar -dv file.a
then
@@ -78,7 +78,8 @@ then
exit 1
fi
-if test `stat -c %Y file.a` -ne $last
+now=`ls -l file.a | awk '{print $6,$7,$8}'`
+if test "$now" != "$last"
then
echo empty ar -d modified the archive >&2
exit 1
diff --git a/tests/ar/execute/20-test-p.sh b/tests/ar/execute/20-test-p.sh
@@ -7,9 +7,7 @@ set -e
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f file.a" 0 2 3
-
-echo tmp1=$tmp1 and tmp2=$tmp2
+trap "rm -f file.a $tmp1 $tmp2" 0 2 3
############################################################################
#print 1st member
@@ -32,6 +30,22 @@ cmp $tmp1 $tmp2
ar -p file.a file3 > $tmp1
cat <<! > $tmp2
+and at the end, this is the last file
+that should go at the end of the file,
+thus it should go in the third position.
+!
+
+cmp $tmp1 $tmp2
+
+############################################################################
+#print 2nd member with verbose
+
+ar -pv file.a file2 >$tmp1
+
+cat <<! > $tmp2
+
+<file2>
+
But this other one is the second one,
and it shouldn't go in the first position
because it should go in the second position.
diff --git a/tests/ar/execute/chktest.sh b/tests/ar/execute/chktest.sh
@@ -13,17 +13,17 @@ gid=`id -g`
cat <<EOF >master.a
!<arch>
-file1 315532800 $uid $gid 100644 79 \`
+file1 315532800 `printf "%-6d" $uid``printf "%-6d" $gid`100644 79 \`
This is the first file,
and it should go in the
first position in the archive.
-file2 315532800 $uid $gid 100644 125 \`
+file2 315532800 `printf "%-6d" $uid``printf "%-6d" $gid`100644 125 \`
But this other one is the second one,
and it shouldn't go in the first position
because it should go in the second position.
-file3 315532800 $uid $gid 100644 118 \`
+file3 315532800 `printf "%-6d" $uid``printf "%-6d" $gid`100644 118 \`
and at the end, this is the last file
that should go at the end of the file,
thus it should go in the third position.