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