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