3 # This program tests the psql import feature.
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
8 # ensure that top_srcdir and top_builddir are absolute
9 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
10 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
11 top_srcdir=`cd $top_srcdir; pwd`
12 top_builddir=`cd $top_builddir; pwd`
14 PSPP=$top_builddir/src/ui/terminal/pspp
16 STAT_CONFIG_PATH=$top_srcdir/config
17 export STAT_CONFIG_PATH
25 pgpath=`$PG_CONFIG | awk '/BINDIR/{print $3}'`
29 if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then
30 echo "NOT cleaning $TEMPDIR"
33 PGHOST=$TEMPDIR $pgpath/pg_ctl -D $TEMPDIR/cluster stop -w -o "-k $TEMPDIR -h ''" > /dev/null 2>&1
61 if [ ! -x $pgpath/initdb ] ; then
62 echo 'No Postgres server was found, so the postgres database interface cannot be tested.'
71 activity="create cluster"
72 $pgpath/initdb -D $TEMPDIR/cluster -A trust > /dev/null
73 if [ $? -ne 0 ] ; then no_result ; fi
77 PGHOST=$TEMPDIR PGPORT=$port $pgpath/pg_ctl -D $TEMPDIR/cluster start -w -o "-k $TEMPDIR" > /dev/null
78 if [ $? -ne 0 ] ; then no_result ; fi
81 activity="create database"
82 createdb -h $TEMPDIR -p $port $dbase > /dev/null 2> /dev/null
85 activity="populate database"
86 psql -h $TEMPDIR -p $port $dbase > /dev/null << EOF
94 numeric numeric(50,6) ,
104 timestamp timestamp ,
105 timestamptz timestamptz ,
110 INSERT INTO thing VALUES (
127 'January 8 04:05:06 1999',
128 'January 8 04:05:06 1999 PST',
133 INSERT INTO thing VALUES (
156 INSERT INTO thing VALUES (
173 '10-Jan-1963 23:58:00',
174 '10-Jan-1963 23:58:00 CET',
175 '2 year 1 month 12 days 1 hours 3 minutes 4 seconds',
179 if [ $? -ne 0 ] ; then fail ; fi
181 activity="create program"
182 cat > $TESTFILE <<EOF
184 /CONNECT="host=$TEMPDIR port=$port dbname=$dbase"
186 /SQL="select * from thing".
192 if [ $? -ne 0 ] ; then no_result ; fi
195 activity="run program"
196 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
197 if [ $? -ne 0 ] ; then no_result ; fi
199 activity="compare output"
200 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
201 diff -b $TEMPDIR/pspp.list - << 'EOF'
203 +---------------+-------------------------------------------+--------+
204 |Variable |Description |Position|
205 #===============#===========================================#========#
206 |bool |Format: F8.2 | 1|
207 | |Measure: Scale | |
208 | |Display Alignment: Right | |
209 | |Display Width: 8 | |
210 +---------------+-------------------------------------------+--------+
211 |bytea |Format: AHEX2 | 2|
212 | |Measure: Nominal | |
213 | |Display Alignment: Left | |
214 | |Display Width: 1 | |
215 +---------------+-------------------------------------------+--------+
216 |char |Format: A8 | 3|
217 | |Measure: Nominal | |
218 | |Display Alignment: Left | |
219 | |Display Width: 8 | |
220 +---------------+-------------------------------------------+--------+
221 |int8 |Format: F8.2 | 4|
222 | |Measure: Scale | |
223 | |Display Alignment: Right | |
224 | |Display Width: 8 | |
225 +---------------+-------------------------------------------+--------+
226 |int2 |Format: F8.2 | 5|
227 | |Measure: Scale | |
228 | |Display Alignment: Right | |
229 | |Display Width: 8 | |
230 +---------------+-------------------------------------------+--------+
231 |int4 |Format: F8.2 | 6|
232 | |Measure: Scale | |
233 | |Display Alignment: Right | |
234 | |Display Width: 8 | |
235 +---------------+-------------------------------------------+--------+
236 |numeric |Format: E40.6 | 7|
237 | |Measure: Scale | |
238 | |Display Alignment: Right | |
239 | |Display Width: 8 | |
240 +---------------+-------------------------------------------+--------+
241 |text |Format: A16 | 8|
242 | |Measure: Nominal | |
243 | |Display Alignment: Left | |
244 | |Display Width: 16 | |
245 +---------------+-------------------------------------------+--------+
246 |oid |Format: F8.2 | 9|
247 | |Measure: Scale | |
248 | |Display Alignment: Right | |
249 | |Display Width: 8 | |
250 +---------------+-------------------------------------------+--------+
251 |float4 |Format: F8.2 | 10|
252 | |Measure: Scale | |
253 | |Display Alignment: Right | |
254 | |Display Width: 8 | |
255 +---------------+-------------------------------------------+--------+
256 |float8 |Format: F8.2 | 11|
257 | |Measure: Scale | |
258 | |Display Alignment: Right | |
259 | |Display Width: 8 | |
260 +---------------+-------------------------------------------+--------+
261 |money |Format: DOLLAR8.2 | 12|
262 | |Measure: Scale | |
263 | |Display Alignment: Right | |
264 | |Display Width: 8 | |
265 +---------------+-------------------------------------------+--------+
266 |pbchar |Format: A8 | 13|
267 | |Measure: Nominal | |
268 | |Display Alignment: Left | |
269 | |Display Width: 8 | |
270 +---------------+-------------------------------------------+--------+
271 |varchar |Format: A8 | 14|
272 | |Measure: Nominal | |
273 | |Display Alignment: Left | |
274 | |Display Width: 8 | |
275 +---------------+-------------------------------------------+--------+
276 |date |Format: DATE11 | 15|
277 | |Measure: Scale | |
278 | |Display Alignment: Right | |
279 | |Display Width: 8 | |
280 +---------------+-------------------------------------------+--------+
281 |time |Format: TIME11.0 | 16|
282 | |Measure: Scale | |
283 | |Display Alignment: Right | |
284 | |Display Width: 8 | |
285 +---------------+-------------------------------------------+--------+
286 |timestamp |Format: DATETIME22.0 | 17|
287 | |Measure: Scale | |
288 | |Display Alignment: Right | |
289 | |Display Width: 8 | |
290 +---------------+-------------------------------------------+--------+
291 |timestamptz |Format: DATETIME22.0 | 18|
292 | |Measure: Scale | |
293 | |Display Alignment: Right | |
294 | |Display Width: 8 | |
295 +---------------+-------------------------------------------+--------+
296 |interval |Format: DTIME13.0 | 19|
297 | |Measure: Scale | |
298 | |Display Alignment: Right | |
299 | |Display Width: 8 | |
300 +---------------+-------------------------------------------+--------+
301 |interval_months|Format: F3.0 | 20|
302 | |Measure: Scale | |
303 | |Display Alignment: Right | |
304 | |Display Width: 8 | |
305 +---------------+-------------------------------------------+--------+
306 |timetz |Format: TIME11.0 | 21|
307 | |Measure: Scale | |
308 | |Display Alignment: Right | |
309 | |Display Width: 8 | |
310 +---------------+-------------------------------------------+--------+
311 |timetz_zone |Format: F8.2 | 22|
312 | |Measure: Scale | |
313 | |Display Alignment: Right | |
314 | |Display Width: 8 | |
315 +---------------+-------------------------------------------+--------+
316 bool bytea char int8 int2 int4 numeric text oid float4 float8 money pbchar varchar date time timestamp timestamptz interval interval_months timetz timetz_zone
317 -------- ----- -------- -------- -------- -------- ---------------------------------------- ---------------- -------- -------- -------- -------- -------- -------- ----------- ----------- ---------------------- ---------------------- ------------- --------------- ----------- -----------
318 .00 30 a .00 .00 .00 -2.560980E+002 this-long-text .00 .00 .00 $.01 a A 01-JAN-2000 0:00:00 08-JAN-1999 04:05:06 08-JAN-1999 12:05:06 0 00:01:00 0 10:09:00 4.00
319 . 20 . . . . . . . . . . . . . . . .
320 1.00 31 b 1.00 1.00 1.00 6.553500E+004 that-long-text .00 1.00 1.00 $1.23 b B 10-JAN-1963 1:05:02 10-JAN-1963 23:58:00 10-JAN-1963 22:58:00 12 01:03:04 25 1:05:02 -7.00
322 if [ $? -ne 0 ] ; then fail ; fi