qse/ase/test/awk/regress.sh

118 lines
1.7 KiB
Bash
Raw Normal View History

2006-11-19 07:28:33 +00:00
#!/bin/sh
2006-12-04 03:08:37 +00:00
run_script_for_init()
{
script="$1"
data="$2"
output=`echo $script | sed 's/\.awk$/.out/g'`
./awk "$script" "$data" > "$output"
}
2006-11-29 03:55:57 +00:00
run_init()
2006-11-19 07:45:46 +00:00
{
for script in emp-???.awk
do
2006-12-04 03:08:37 +00:00
run_script_for_init "$script" "emp-en.data"
done
for script in cou-???.awk
do
run_script_for_init "$script" "cou-en.data"
2006-11-19 07:45:46 +00:00
done
}
2006-12-04 03:08:37 +00:00
run_script_for_test()
{
script="$1"
data="$2"
output=`echo $script | sed 's/\.awk$/.out/g'`
2006-12-04 07:23:19 +00:00
echo ">> RUNNING $script"
2007-02-03 10:52:36 +00:00
./awk -f "$script" "$data" > "$output.$pid"
2006-12-04 03:08:37 +00:00
2006-12-26 10:25:19 +00:00
#diff -y "$output" "$output.$pid"
diff "$output" "$output.$pid"
2006-12-04 03:08:37 +00:00
if [ $? -ne 0 ]
then
rm -f "$output.$pid"
return 1
fi
rm -f "$output.$pid"
return 0
}
2006-11-29 03:55:57 +00:00
run_test()
2006-11-19 07:45:46 +00:00
{
pid=$$
for script in emp-???.awk
do
2006-12-04 03:08:37 +00:00
run_script_for_test "$script" "emp-en.data"
2006-11-19 07:45:46 +00:00
if [ $? -ne 0 ]
then
echo "###################################"
echo "PROBLEM(S) DETECTED IN $script.".
echo "###################################"
2006-12-24 16:07:13 +00:00
echo "Do you want to abort? [y/n]"
read ans
if [ "$ans" = "y" -o "$ans" = "Y" ]
then
return 1
fi
2006-11-19 07:45:46 +00:00
fi
2006-12-04 03:08:37 +00:00
done
2006-11-19 07:45:46 +00:00
2006-12-04 03:08:37 +00:00
for script in cou-???.awk
do
run_script_for_test "$script" "cou-en.data"
if [ $? -ne 0 ]
then
echo "###################################"
echo "PROBLEM(S) DETECTED IN $script.".
echo "###################################"
2006-12-24 16:07:13 +00:00
echo "Do you want to abort? [y/n]"
read ans
if [ "$ans" = "y" -o "$ans" = "Y" ]
then
return 1
fi
2006-12-04 03:08:37 +00:00
fi
2006-11-19 07:45:46 +00:00
done
2006-12-23 06:33:47 +00:00
return 0
2006-11-19 07:45:46 +00:00
}
#--------#
# main #
#--------#
2006-11-19 09:28:55 +00:00
if [ ! -x ./awk ]
then
echo "Error: cannot locate a relevant awk interpreter"
exit 1;
fi
2006-11-19 07:45:46 +00:00
if [ $# -ne 1 ]
then
echo "Usage: $0 init"
echo " $0 test"
exit 1
fi
if [ "$1" = "init" ]
then
2006-11-29 03:55:57 +00:00
run_init
2006-11-19 07:45:46 +00:00
elif [ "$1" = "test" ]
then
2006-11-29 03:55:57 +00:00
run_test
2006-11-19 07:45:46 +00:00
else
echo "Usage: $0 init"
echo " $0 test"
exit 1
fi
2006-11-19 07:28:33 +00:00