scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit 80c896c4423e018e92c600d9d5e6803095876e90
parent eb80c90a72ca9b4cd2f035c98897332f9181f661
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 19 Feb 2018 08:57:47 +0000

[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.

Diffstat:
Mtests/ar/execute/chktest.sh | 107+++++++++++--------------------------------------------------------------------
Atests/ar/execute/test-q.sh | 93+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 107 insertions(+), 93 deletions(-)

diff --git a/tests/ar/execute/chktest.sh b/tests/ar/execute/chktest.sh @@ -1,93 +1,14 @@ -#!/bin/sh -x - -set -e - -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 +#!/bin/sh + +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 + +for i in test*.sh +do + printf "%s\t" $i + ./$i && echo [OK] || echo [FAIL] +done diff --git a/tests/ar/execute/test-q.sh b/tests/ar/execute/test-q.sh @@ -0,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