3 # This program tests that simultaneous input and output to a single
4 # file properly coexist, with the output atomically replacing the
7 TEMPDIR=/tmp/pspp-tst-$$
8 TESTFILE=$TEMPDIR/`basename $0`.sps
10 # ensure that top_builddir are absolute
11 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
12 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
13 top_builddir=`cd $top_builddir; pwd`
14 PSPP=$top_builddir/src/ui/terminal/pspp
16 # ensure that top_srcdir is absolute
17 top_srcdir=`cd $top_srcdir; pwd`
19 STAT_CONFIG_PATH=$top_srcdir/config
20 export STAT_CONFIG_PATH
57 activity="create data file"
65 if [ $? -ne 0 ] ; then no_result ; fi
67 activity="create program 1"
69 DATA LIST FILE='foo.data' /X 1.
70 SAVE OUTFILE='foo.sav'.
71 EXPORT OUTFILE='foo.por'.
73 if [ $? -ne 0 ] ; then no_result ; fi
75 activity="run program 1"
76 $SUPERVISOR $PSPP --testing-mode $TESTFILE
77 if [ $? -ne 0 ] ; then no_result ; fi
79 activity="check and save copy of output files"
80 # Check that the files are nonzero length.
81 test -s foo.data || fail
82 test -s foo.sav || fail
83 test -s foo.por || fail
84 # Save copies of them.
85 cp foo.data foo.data.backup || fail
86 cp foo.sav foo.sav.backup || fail
87 cp foo.por foo.por.backup || fail
90 activity="create program 2"
94 XSAVE OUTFILE='foo.sav'.
95 XEXPORT OUTFILE='foo.por'.
96 PRINT OUTFILE='foo.data'.
97 HOST kill -TERM \$PPID
99 if [ $? -ne 0 ] ; then no_result ; fi
101 activity="run program 2"
102 { $SUPERVISOR $PSPP --testing-mode $TESTFILE -e /dev/null; } >/dev/null 2>&1
103 # PSPP should have terminated with a signal. POSIX requires that the exit
104 # status of a process terminated by a signal be greater than 128.
105 if [ $? -le 128 ] ; then no_result ; fi
107 activity="check for remaining temporary files"
108 if test -e *.tmp*; then fail; fi
110 activity="compare output 1"
111 cmp foo.sav foo.sav.backup
112 if [ $? -ne 0 ] ; then fail ; fi
114 activity="compare output 2"
115 cmp foo.por foo.por.backup
116 if [ $? -ne 0 ] ; then fail ; fi
118 activity="compare output 3"
119 cmp foo.data foo.data.backup
120 if [ $? -ne 0 ] ; then fail ; fi
123 activity="create program 3"
124 cat > $TESTFILE <<EOF
125 DATA LIST NOTABLE LIST FILE='foo.data'/X.
127 PRINT OUTFILE='foo.data'/X Y.
132 SAVE OUTFILE='foo.sav'.
136 EXPORT OUTFILE='foo.por'.
138 if [ $? -ne 0 ] ; then no_result ; fi
140 activity="run program 3"
141 $SUPERVISOR $PSPP --testing-mode $TESTFILE -e /dev/null
142 if [ $? -ne 0 ] ; then no_result ; fi
144 activity="check for remaining temporary files"
145 if test -e *.tmp*; then fail; fi
147 activity="create program 4"
148 cat > $TESTFILE <<EOF
149 DATA LIST LIST NOTABLE FILE='foo.data'/X Y.
158 if [ $? -ne 0 ] ; then no_result ; fi
160 activity="run program 4"
161 $SUPERVISOR $PSPP --testing-mode $TESTFILE -e /dev/null
162 if [ $? -ne 0 ] ; then no_result ; fi
164 activity="compare output"
165 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
166 diff -b pspp.list - << EOF
189 if [ $? -ne 0 ] ; then fail ; fi