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