From: Sandro Santilli Date: Wed, 18 Jan 2012 08:19:42 +0000 (+0000) Subject: Test roundtrip with a binary cursor for both geometry and geography X-Git-Tag: 2.0.0alpha1~21 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7091a479fc494d350aadcffeb4f219e4e58516ac;p=postgis Test roundtrip with a binary cursor for both geometry and geography 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 --- diff --git a/regress/binary.sql b/regress/binary.sql index e1c67a7c6..c17f12ff0 100644 --- a/regress/binary.sql +++ b/regress/binary.sql @@ -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; diff --git a/regress/binary_expected b/regress/binary_expected index 0efbd17d8..e3d7fbbe8 100644 Binary files a/regress/binary_expected and b/regress/binary_expected differ diff --git a/regress/run_test b/regress/run_test index f6f979751..bc7af042d 100755 --- a/regress/run_test +++ b/regress/run_test @@ -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