Added a test for reading/writing of portable files.
[pspp-builds.git] / tests / command / import-export.sh
1 #!/bin/sh
2
3 # This program tests the IMPORT and EXPORT commands
4
5 TEMPDIR=/tmp/pspp-tst-$$
6
7 here=`pwd`;
8
9 # ensure that top_srcdir is absolute
10 cd $top_srcdir; top_srcdir=`pwd`
11
12 export STAT_CONFIG_PATH=$top_srcdir/config
13
14
15 cleanup()
16 {
17      rm -rf $TEMPDIR
18 }
19
20
21 fail()
22 {
23     echo $activity
24     echo FAILED
25     cleanup;
26     exit 1;
27 }
28
29
30 no_result()
31 {
32     echo $activity
33     echo NO RESULT;
34     cleanup;
35     exit 2;
36 }
37
38 pass()
39 {
40     cleanup;
41     exit 0;
42 }
43
44 mkdir -p $TEMPDIR
45
46 cd $TEMPDIR
47
48 activity="create program"
49 cat > $TEMPDIR/prog.stat <<EOF
50 DATA LIST LIST /x * y *.
51 BEGIN DATA.
52 1 2
53 3 4
54 5 6
55 END DATA.
56
57 EXPORT /OUTFILE='wiz.por'.
58
59 LIST.
60
61 IMPORT /FILE='wiz.por'.
62
63 LIST.
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 $TEMPDIR/prog.stat
70 if [ $? -ne 0 ] ; then no_result ; fi
71
72 activity="compare output"
73 diff $TEMPDIR/pspp.list - << EOF
74 1.1 DATA LIST.  Reading free-form data from the command file.
75 +--------+------+
76 |Variable|Format|
77 #========#======#
78 |X       |F8.0  |
79 |Y       |F8.0  |
80 +--------+------+
81
82        X        Y
83 -------- --------
84     1.00     2.00 
85     3.00     4.00 
86     5.00     6.00 
87
88        X        Y
89 -------- --------
90     1.00     2.00 
91     3.00     4.00 
92     5.00     6.00 
93
94 EOF
95 if [ $? -ne 0 ] ; then fail ; fi
96
97 pass;