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