1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
#!/bin/sh
#
# This is a simple script that tests autoclass
#
# install as: /usr/lib/debian-test/tests/autoclass
# or else as: /usr/lib/debian-test/tests/autoclass/test-1
# In the latter case, /usr/lib/debian-test/tests/autoclass/ can contain
# other file with test data and/or other scripts named test-2, test-3, etc.
#
# You can run this script with the command
# sh debian/tests
# After installation, you can run it with the commands
# /usr/lib/debian-test/tests/autoclass
# or
# debian-test -v autoclass
# see debian-test(1)
. ${DEBIANTEST_LIB:-/usr/lib/debian-test/lib}/functions.sh
if [ -f my-data-file ]; then
TESTDIR=`pwd`;
else
TESTDIR=/usr/lib/debian-test/tests/autoclass;
fi
## we need a scratch directory in which to execute
TMP=/tmp/autoclass-test.$$
test -e $TMP && rm -rf $TMP
mkdir $TMP
cd $TMP
trap "rm -rf $TMP" EXIT
test1(){
RESULT=0
cp /usr/share/doc/autoclass/examples/simple* .
# use autoclass to separate observations into two groups
if [ ! -f simple.db2 ]; then gunzip *.gz; fi
# use autoclass to find the groups
autoclass -search simple.db2 simple.hd2 simple.model simple.s-params
# ask autoclass to generate reports
autoclass -reports simple.results simple.search simple.r-params
## FIXME
# copy the oservations into two files,
# depending on the group assigned by autoclass
awk '
/^[0-9]/{
group_number=$2;
getline data < "simple.db2";
print data > "group" group_number;
}' simple.case-data-1
# display the original data (under X windows)
gnuplot -persist <<EOF
set key bottom
set title "original data"
plot "simple.db2"
EOF
# display the two groups in different colors (under X windows)
cat simple.influ-o-data-1 | awk '
BEGIN{
FS="[ ()]+";
printf("set key bottom\n");
printf("set title \"groups found by AutoClass\"\n");
printf("set parametric; set trange [0:6.28]\n");
printf("plot \\\n");
}
/^[0-9][0-9]/{
if ($5~/latitude/) {latmean=$7; latsd=$8; ++data}
if ($5~/longitude/) {lonmean=$7; lonsd=$8; ++data}
if (data == 2) {
if (group) printf(",\\\n");
printf("%s+2.45*%s*sin(t),%s+2.45*%s*cos(t) title \"group %d 95%% contour\",\\\n",
lonmean, lonsd, latmean, latsd, group);
printf(" \"group%d\" title \"group %d members\"", group, group);
data=0; group++;
}
}
END { printf("\n");}' | gnuplot -persist
# execute autoclass against first test case
# in case of failure, set the shell variable RESULT like this:
RESULT=1
return $RESULT
}
test2(){
RESULT=0
# execute autoclass against second test case,
# OR test for a different bug which has been reported in autoclass
# OR test a different binary supplied by autoclass.
# in case of failure, set the shell variable RESULT like this:
RESULT=1
return $RESULT
}
runtest "first test case" test1
runtest "second test case" test2
# extend as necessary...
|