Fixed bug #13024
[pspp-builds.git] / tests / command / sysfile-info.sh
1 #!/bin/sh
2
3 # This program tests that SYSFILE INFO works.
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      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
19         echo "NOT cleaning $TEMPDIR"
20         return ; 
21      fi
22      rm -rf $TEMPDIR
23 }
24
25
26 fail()
27 {
28     echo $activity
29     echo FAILED
30     cleanup;
31     exit 1;
32 }
33
34
35 no_result()
36 {
37     echo $activity
38     echo NO RESULT;
39     cleanup;
40     exit 2;
41 }
42
43 pass()
44 {
45     cleanup;
46     exit 0;
47 }
48
49 mkdir -p $TEMPDIR
50
51 cd $TEMPDIR
52
53 activity="Create test file"
54 cat > $TESTFILE << EOF
55 DATA LIST LIST /x * name (a10) .
56 BEGIN DATA
57 1 one
58 2 two
59 3 three
60 END DATA.
61 SAVE OUTFILE='pro.sav'.
62
63 sysfile info file='pro.sav'.
64 EOF
65 if [ $? -ne 0 ] ; then no_result ; fi
66
67
68 activity="run program"
69 $SUPERVISOR $here/../src/pspp --testing-mode -o raw-ascii $TESTFILE
70 if [ $? -ne 0 ] ; then no_result ; fi
71
72 activity="filter output"
73 grep -v '^Created: ' $TEMPDIR/pspp.list > $TEMPDIR/out-filtered
74 if [ $? -ne 0 ] ; then no_result ; fi
75
76 activity="compare output"
77 diff $TEMPDIR/out-filtered - << EOF
78 1.1 DATA LIST.  Reading free-form data from the command file.
79 +--------+------+
80 |Variable|Format|
81 #========#======#
82 |x       |F8.0  |
83 |name    |A10   |
84 +--------+------+
85
86 2.1 SYSFILE INFO.  
87 File:      pro.sav
88 Label:     No label.
89 Endian:    Little.
90 Variables: 2
91 Cases:     3
92 Type:      System File.
93 Weight:    Not weighted.
94 Mode:      Compression off.
95
96 +--------+-------------+---+
97 |Variable|Description  |Pos|
98 |        |             |iti|
99 |        |             |on |
100 #========#=============#===#
101 |x       |Format: F8.2 |  1|
102 +--------+-------------+---+
103 |name    |Format: A10  |  2|
104 +--------+-------------+---+
105
106 EOF
107 if [ $? -ne 0 ] ; then fail ; fi
108
109 pass;