Fix use of "export" to work with traditional shells.
[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 STAT_CONFIG_PATH=$top_srcdir/config
14 export STAT_CONFIG_PATH
15
16
17 cleanup()
18 {
19      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
20         echo "NOT cleaning $TEMPDIR"
21         return ; 
22      fi
23      rm -rf $TEMPDIR
24 }
25
26
27 fail()
28 {
29     echo $activity
30     echo FAILED
31     cleanup;
32     exit 1;
33 }
34
35
36 no_result()
37 {
38     echo $activity
39     echo NO RESULT;
40     cleanup;
41     exit 2;
42 }
43
44 pass()
45 {
46     cleanup;
47     exit 0;
48 }
49
50 mkdir -p $TEMPDIR
51
52 cd $TEMPDIR
53
54 activity="Create test file"
55 cat > $TESTFILE << EOF
56 DATA LIST LIST /x * name (a10) .
57 BEGIN DATA
58 1 one
59 2 two
60 3 three
61 END DATA.
62 SAVE OUTFILE='pro.sav'.
63
64 sysfile info file='pro.sav'.
65 EOF
66 if [ $? -ne 0 ] ; then no_result ; fi
67
68
69 activity="run program"
70 $SUPERVISOR $here/../src/pspp --testing-mode -o raw-ascii $TESTFILE
71 if [ $? -ne 0 ] ; then no_result ; fi
72
73 activity="filter output"
74 egrep -v '^(Created|Endian): ' $TEMPDIR/pspp.list > $TEMPDIR/out-filtered
75 if [ $? -ne 0 ] ; then no_result ; fi
76
77 activity="compare output"
78 diff -b -B -w $TEMPDIR/out-filtered - << EOF
79 1.1 DATA LIST.  Reading free-form data from the command file.
80 +--------+------+
81 |Variable|Format|
82 #========#======#
83 |x       |F8.0  |
84 |name    |A10   |
85 +--------+------+
86
87 2.1 SYSFILE INFO.  
88 File:      pro.sav
89 Label:     No label.
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;