35a64c8788f9f611cf6136ae5cd5b517f6be0463
[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
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 cp $TEMPDIR/pspp.list /tmp/bar
63
64 activity="run program 1"
65 $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 $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;