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