ref: 81d81dcd58880aadd230a6e23e916daaaeaa01af
parent: a5c68edfb2f68719d8558ca293b43387d6a5a9ab
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Feb 19 03:57:47 EST 2018
[tests/ar] Create test-q.sh It is better to have a shell script by every key that we want to test. In this way, chktest.sh is in charge of calling every one of the test script and prints a message about the exit status of every script.
--- a/tests/ar/execute/chktest.sh
+++ b/tests/ar/execute/chktest.sh
@@ -1,93 +1,14 @@
-#!/bin/sh -x
+#!/bin/sh
-set -e
+ttyflags=`stty -g`
+trap "stty $ttyflags;tabs -8;rm -f a.out; exit 1" 0 2 3 15
+stty tabs
+tabs 40
+ulimit -c 40
+rm -f test.log
-TZ=UTC
-tmp1=`mktemp`
-tmp2=`mktemp`
-
-#trap "rm -f $tmp1 $tmp2" 0 2 3
-
-rm -f test.a
-
-############################################################################
-#create the test files
-mkdir -p files
-cd files
-
-cat <<! >file1
-This is the first file,
-and it should go in the
-first position in the archive.
-!
-
-cat <<! >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.
-!
-
-cat <<! >file3
-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.
-!
-
-cat <<! >file4
-Ok, we can add a new file
-and see what happens
-!
-
-touch -t 198001010000 file?
-
-############################################################################
-#generate the archive with the members in files
-ar -qv ../test.a file1 file2
-ar -qv ../test.a file3
-cd ..
-
-############################################################################
-#verify that the output of ar -t is correct
-
-ar -t test.a > $tmp1
-cat <<! > $tmp2
-file1
-file2
-file3
-!
-
-cmp $tmp1 $tmp2
-
-############################################################################
-#and now check that -tv doesn't break the code
-
-ar -tv test.a >$tmp1
-cat <<! >$tmp2
-rw-r--r-- 1000/100 Tue Jan 1 00:00:00 1980 file1
-rw-r--r-- 1000/100 Tue Jan 1 00:00:00 1980 file2
-rw-r--r-- 1000/100 Tue Jan 1 00:00:00 1980 file3
-!
-
-cmp $tmp1 $tmp2
-
-############################################################################
-#extract the files
-ar -xv test.a file1 file2 file3
-
-cmp file1 files/file1
-cmp file2 files/file2
-cmp file3 files/file3
-
-rm -f file1 file2 file3
-
-############################################################################
-#delete the 2nd file
-ar -dv test.a file2
-
-ar -tv test.a >$tmp1
-cat <<! >$tmp2
-rw-r--r-- 1000/100 Tue Jan 1 00:00:00 1980 file1
-rw-r--r-- 1000/100 Tue Jan 1 00:00:00 1980 file3
-!
-
-cmp $tmp1 $tmp2
+for i in test*.sh
+do
+ printf "%s\t" $i
+ ./$i && echo [OK] || echo [FAIL]
+done
--- /dev/null
+++ b/tests/ar/execute/test-q.sh
@@ -1,0 +1,93 @@
+#!/bin/sh
+
+exec >> test.log
+exec 2>> test.log
+
+set -e
+
+TZ=UTC
+tmp1=`mktemp`
+tmp2=`mktemp`
+pwd=$PWD
+
+trap "cd $pwd && rm -rf $tmp1 $tmp2 file*" 0 2 3
+
+rm -f file.a
+
+############################################################################
+#create the test files
+mkdir -p files
+cd files
+
+cat <<! >file1
+This is the first file,
+and it should go in the
+first position in the archive.
+!
+
+cat <<! >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.
+!
+
+cat <<! >file3
+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.
+!
+
+cat <<! >file4
+Ok, we can add a new file
+and see what happens
+!
+
+touch -t 198001010000 file?
+
+############################################################################
+#generate the archive with the members in files
+ar -qv ../file.a file1 file2
+ar -qv ../file.a file3
+cd ..
+
+############################################################################
+#verify that the output of ar -t is correct
+
+ar -t file.a > $tmp1
+cat <<! > $tmp2
+file1
+file2
+file3
+!
+
+cmp $tmp1 $tmp2
+
+############################################################################
+#and now check that -tv doesn't break the code
+
+ar -tv file.a >$tmp1
+cat <<! >$tmp2
+rw-r--r-- 1000/100 Tue Jan 1 00:00:00 1980 file1
+rw-r--r-- 1000/100 Tue Jan 1 00:00:00 1980 file2
+rw-r--r-- 1000/100 Tue Jan 1 00:00:00 1980 file3
+!
+
+cmp $tmp1 $tmp2
+
+############################################################################
+#extract the files
+ar -xv file.a file1 file2 file3
+
+cmp file1 files/file1
+cmp file2 files/file2
+cmp file3 files/file3
+
+rm -f file1 file2 file3
+
+############################################################################
+#stress quick append
+
+for i in `awk '{for (i=0; i <999; ++i) print $i}``
+do
+ ar -qv file.a $i
+done