]> granicus.if.org Git - postgis/commitdiff
Test roundtrip with a binary cursor for both geometry and geography
authorSandro Santilli <strk@keybit.net>
Wed, 18 Jan 2012 08:19:42 +0000 (08:19 +0000)
committerSandro Santilli <strk@keybit.net>
Wed, 18 Jan 2012 08:19:42 +0000 (08:19 +0000)
With this commit the binary.sql testcase doesn't test the actual
binary output anymore but rather uses canonical binary output to
copy objects to a temporary file, then uses canonical binary input
to read the objects again into a new table and then compares the
original and the final tables.

In order for this to work run_test was modified to pass a :tmpfile
variable to testcases. Next stop: typmod for canonical binary input.

See ticket #850 for more info

git-svn-id: http://svn.osgeo.org/postgis/trunk@8861 b70326c6-7e19-0410-871a-916f4a2858ee

regress/binary.sql
regress/binary_expected
regress/run_test

index e1c67a7c6abb90b6f2230109dfae28d5266c2cdc..c17f12ff08db551490ba185aefc7f864a84e1265 100644 (file)
@@ -31,7 +31,11 @@ SELECT st_force_4d(g) FROM tm.geoms WHERE id < 15 ORDER BY id;
 INSERT INTO tm.geoms(g)
 SELECT st_setsrid(g,4326) FROM tm.geoms ORDER BY id;
 
-COPY ( SELECT g FROM tm.geoms ORDER BY id ) TO STDOUT WITH BINARY;
+COPY tm.geoms TO :tmpfile WITH BINARY;
+CREATE TABLE tm.geoms_in AS SELECT * FROM tm.geoms LIMIT 0;
+COPY tm.geoms_in FROM :tmpfile WITH BINARY;
+SELECT 'geometry', count(*) FROM tm.geoms_in i, tm.geoms o WHERE i.id = o.id
+ AND ST_OrderingEquals(i.g, o.g);
 
 CREATE TABLE tm.geogs AS SELECT id,g::geography FROM tm.geoms
 WHERE geometrytype(g) NOT LIKE '%CURVE%'
@@ -41,6 +45,10 @@ WHERE geometrytype(g) NOT LIKE '%CURVE%'
   AND geometrytype(g) NOT LIKE 'TIN%'
 ;
 
-COPY ( SELECT g FROM tm.geogs ORDER BY id ) TO STDOUT WITH BINARY;
+COPY tm.geogs TO :tmpfile WITH BINARY;
+CREATE TABLE tm.geogs_in AS SELECT * FROM tm.geogs LIMIT 0;
+COPY tm.geogs_in FROM :tmpfile WITH BINARY;
+SELECT 'geometry', count(*) FROM tm.geogs_in i, tm.geogs o WHERE i.id = o.id
+ AND ST_OrderingEquals(i.g::geometry, o.g::geometry);
 
-DROP SCHEMA tm CASCADE;
+--DROP SCHEMA tm CASCADE;
index 0efbd17d83c3cc0b32d74af21d6ce1a73dc443a5..e3d7fbbe8ac1053bc61df690cc4b319b508a1850 100644 (file)
Binary files a/regress/binary_expected and b/regress/binary_expected differ
index f6f9797510bed4462696ac3933110656d00163e8..bc7af042de9f944784c640c4becbf257df075710 100755 (executable)
@@ -43,7 +43,8 @@ if [ -z "$TMPDIR" ]; then
        TMPDIR=/tmp/pgis_reg_$$
 fi
 
-mkdir -p ${TMPDIR}
+mkdir -p ${TMPDIR}/tmp
+chmod 777 ${TMPDIR}/tmp
 
 VERBOSE=0
 OPT_CLEAN=no
@@ -179,12 +180,11 @@ run_simple_test ()
        show_progress
 
        OUTFILE="${TMPDIR}/test_${RUN}_out"
-       TMPFILE="${TMPDIR}/test_${RUN}_tmp"
+       TMPFILE="${TMPDIR}/tmp/test_${RUN}_tmp"
        DIFFILE="${TMPDIR}/test_${RUN}_diff"
 
        # Use intermediate file to prevent MingW buffering problems
-       ${PSQL} -tXA < "${_sql}" ${DB} > ${TMPFILE} 2>&1
-       cat ${TMPFILE} \
+       ${PSQL} -v "tmpfile='${TMPFILE}'" -tXA < "${_sql}" ${DB} 2>&1 \
                | grep --binary-files=text -v "^$" \
                | grep --binary-files=text -v "^INSERT" \
                | grep --binary-files=text -v "^DELETE" \
@@ -203,7 +203,7 @@ run_simple_test ()
                | sed 's/Self-intersection .*/Self-intersection/' \
                | sed 's/^ROLLBACK/COMMIT/' \
                > "${OUTFILE}"
-       rm ${TMPFILE}
+       rm -f ${TMPFILE} # should we keep this ?
 
        for expfiles in "${_expected}*"; do
                if diff -u "${_expected}" "${OUTFILE}" > ${DIFFILE}; then