Fixed some buglets in the tests
[pspp] / tests / command / sys-info.sh
1 #!/bin/sh
2
3 # This program tests the SYSFILE INFO command
4
5 TEMPDIR=/tmp/pspp-tst-$$
6
7 here=`pwd`;
8
9 # ensure that top_srcdir is absolute
10 cd $top_srcdir; top_srcdir=`pwd`
11
12 export STAT_CONFIG_PATH=$top_srcdir/config
13
14
15 cleanup()
16 {
17      rm -rf $TEMPDIR
18 }
19
20
21 fail()
22 {
23     echo $activity
24     echo FAILED
25     cleanup;
26     exit 1;
27 }
28
29
30 no_result()
31 {
32     echo $activity
33     echo NO RESULT;
34     cleanup;
35     exit 2;
36 }
37
38 pass()
39 {
40     cleanup;
41     exit 0;
42 }
43
44 mkdir -p $TEMPDIR
45
46 cd $TEMPDIR
47
48 activity="create program 1"
49 cat > $TEMPDIR/save.stat << EOF
50 data list /x 1-2.
51 begin data.
52 3
53 34
54 2
55 98
56 end data.
57 save 'foo.save'.
58 display $JDATE.
59 finish.
60 EOF
61 if [ $? -ne 0 ] ; then no_result ; fi
62
63 activity="run program 1"
64 $here/../src/pspp --testing-mode -o raw-ascii $TEMPDIR/save.stat
65 if [ $? -ne 0 ] ; then no_result ; fi
66
67 activity="create program 2"
68 cat > $TEMPDIR/read.stat << EOF
69 sysfile info file='foo.save'.
70
71 finish.
72 EOF
73 if [ $? -ne 0 ] ; then no_result ; fi
74
75 activity="run program 2"
76 $here/../src/pspp --testing-mode -o raw-ascii $TEMPDIR/read.stat
77 if [ $? -ne 0 ] ; then no_result ; fi
78
79
80 activity="compare output"
81 diff -B -b $TEMPDIR/pspp.list - << EOF
82 1.1 SYSFILE INFO.  
83 File:      $TEMPDIR/foo.save
84 Label:     No label.
85 Created:   18 Dec 03 09:05:20 by GNU pspp 0.3.1 - i686-pc-cygwin        
86 Endian:    Little.
87 Variables: 1
88 Cases:     4
89 Type:      System File.
90 Weight:    Not weighted.
91 Mode:      Compression on.
92 +--------+-------------+---+
93 |Variable|Description  |Pos|
94 |        |             |iti|
95 |        |             |on |
96 #========#=============#===#
97 |X       |Format: F2.0 |  1|
98 +--------+-------------+---+
99 EOF
100 if [ $? -ne 0 ] ; then fail ; fi
101
102
103 pass;