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$EXEEXT
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
25 if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then
26 echo "NOT cleaning $TEMPDIR"
61 activity="create data file"
69 if [ $? -ne 0 ] ; then no_result ; fi
71 activity="create program 1"
73 DATA LIST FILE='foo.data' /X 1.
74 SAVE OUTFILE='foo.sav'.
75 EXPORT OUTFILE='foo.por'.
77 if [ $? -ne 0 ] ; then no_result ; fi
79 activity="run program 1"
80 $SUPERVISOR $PSPP -o pspp.csv $TESTFILE
81 if [ $? -ne 0 ] ; then no_result ; fi
83 activity="check and save copy of output files"
84 # Check that the files are nonzero length.
85 test -s foo.data || fail
86 test -s foo.sav || fail
87 test -s foo.por || fail
88 # Save copies of them.
89 cp foo.data foo.data.backup || fail
90 cp foo.sav foo.sav.backup || fail
91 cp foo.por foo.por.backup || fail
94 activity="create program 2"
98 XSAVE OUTFILE='foo.sav'.
99 XEXPORT OUTFILE='foo.por'.
100 PRINT OUTFILE='foo.data'.
101 HOST COMMAND=['kill -TERM \$PPID'].
103 if [ $? -ne 0 ] ; then no_result ; fi
105 activity="run program 2"
106 { $SUPERVISOR $PSPP -o pspp.csv $TESTFILE -e /dev/null; } >/dev/null 2>&1
107 # PSPP should have terminated with a signal. POSIX requires that the exit
108 # status of a process terminated by a signal be greater than 128.
109 if [ $? -le 128 ] ; then no_result ; fi
111 activity="check for remaining temporary files"
112 if test -e *.tmp*; then fail; fi
114 activity="compare output 1"
115 cmp foo.sav foo.sav.backup
116 if [ $? -ne 0 ] ; then fail ; fi
118 activity="compare output 2"
119 cmp foo.por foo.por.backup
120 if [ $? -ne 0 ] ; then fail ; fi
122 activity="compare output 3"
123 cmp foo.data foo.data.backup
124 if [ $? -ne 0 ] ; then fail ; fi
127 activity="create program 3"
128 cat > $TESTFILE <<EOF
129 DATA LIST NOTABLE LIST FILE='foo.data'/X.
131 PRINT OUTFILE='foo.data'/X Y.
136 SAVE OUTFILE='foo.sav'.
140 EXPORT OUTFILE='foo.por'.
142 if [ $? -ne 0 ] ; then no_result ; fi
144 activity="run program 3"
145 $SUPERVISOR $PSPP -o pspp.csv $TESTFILE -e /dev/null
146 if [ $? -ne 0 ] ; then no_result ; fi
148 activity="check for remaining temporary files"
149 if test -e *.tmp*; then fail; fi
151 activity="create program 4"
152 cat > $TESTFILE <<EOF
153 DATA LIST LIST NOTABLE FILE='foo.data'/X Y.
162 if [ $? -ne 0 ] ; then no_result ; fi
164 activity="run program 4"
165 $SUPERVISOR $PSPP -o pspp.csv $TESTFILE -e /dev/null
166 if [ $? -ne 0 ] ; then no_result ; fi
168 activity="compare output"
169 diff -c pspp.csv - << EOF
194 if [ $? -ne 0 ] ; then fail ; fi