ref: db3d99c72d9ae5d3d30357bba2251db3008f71ef
parent: e2fe38d6738c7d231fd926a36a0b1e173af7f2d2
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Feb 19 13:04:16 EST 2018
[tests/ar] Fix multiple problems in tests
--- a/tests/ar/execute/00-test-q.sh
+++ b/tests/ar/execute/00-test-q.sh
@@ -49,7 +49,7 @@
#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
--- a/tests/ar/execute/10-test-d.sh
+++ b/tests/ar/execute/10-test-d.sh
@@ -70,7 +70,7 @@
#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 @@
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
--- a/tests/ar/execute/20-test-p.sh
+++ b/tests/ar/execute/20-test-p.sh
@@ -7,10 +7,8 @@
tmp1=`mktemp`
tmp2=`mktemp`
-trap "rm -f file.a" 0 2 3
+trap "rm -f file.a $tmp1 $tmp2" 0 2 3
-echo tmp1=$tmp1 and tmp2=$tmp2
-
############################################################################
#print 1st member
@@ -32,6 +30,22 @@
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.
--- a/tests/ar/execute/chktest.sh
+++ b/tests/ar/execute/chktest.sh
@@ -13,17 +13,17 @@
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.