From edc7ea8a27565b49b4b56bb6e2655fea2528a51a Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Tue, 26 Jul 2016 15:35:06 +0200
Subject: [PATCH] check: backport upstream fixes for testsuite

Commits: 186b42c74ea054 1da4f790a11f2.
Discussion:
https://www.postgresql.org/message-id/20160409143629.2BC5CB4C40D@winpg.jp

Resolves: rhbz#1350486
Version: 09.05.0300-2
---
 ...ql-odbc-09.05.0210-arm-testsuite-fix.patch | 28 +++++++++++++++++
 ...bc-09.05.0210-sec-arch-testsuite-fix.patch | 27 +++++++++++++++++
 postgresql-odbc-09.05.0210-tests-arm.patch    | 30 -------------------
 postgresql-odbc.spec                          | 15 ++++------
 4 files changed, 61 insertions(+), 39 deletions(-)
 create mode 100644 postgresql-odbc-09.05.0210-arm-testsuite-fix.patch
 create mode 100644 postgresql-odbc-09.05.0210-sec-arch-testsuite-fix.patch
 delete mode 100644 postgresql-odbc-09.05.0210-tests-arm.patch

diff --git a/postgresql-odbc-09.05.0210-arm-testsuite-fix.patch b/postgresql-odbc-09.05.0210-arm-testsuite-fix.patch
new file mode 100644
index 0000000..460c03d
--- /dev/null
+++ b/postgresql-odbc-09.05.0210-arm-testsuite-fix.patch
@@ -0,0 +1,28 @@
+From 1da4f790a11f281cce15a2d3cc16182c099b6d5c Mon Sep 17 00:00:00 2001
+From: Hiroshi Inoue <h-inoue@dream.email.ne.jp>
+Date: Sun, 24 Jul 2016 18:58:42 +0900
+Subject: [PATCH 1/2] Fix regression test failures on armv7hl. 'char' type
+ seems to mean unsigned char on the platform. Though move_direction member of
+ QResultClass takes negative values, QR_is_moving_backward() never returns
+ TRUE. So ensure that move_direction is signed char on any platform.
+
+---
+ qresult.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/qresult.h b/qresult.h
+index 60f449a..b5d878b 100644
+--- a/qresult.h
++++ b/qresult.h
+@@ -88,7 +88,7 @@ struct QResultClass_
+ 	char	pstatus;		/* processing status */
+ 	char	aborted;		/* was aborted ? */
+ 	char	flags;			/* this result contains keyset etc ? */
+-	char	move_direction;		/* must move before fetching this
++	po_ind_t	move_direction;	/* must move before fetching this
+ 						result set */
+ 	SQLULEN		count_keyset_allocated; /* m(re)alloced count */
+ 	SQLULEN		num_cached_keys;	/* count of keys kept in backend_keys member */
+-- 
+2.7.4
+
diff --git a/postgresql-odbc-09.05.0210-sec-arch-testsuite-fix.patch b/postgresql-odbc-09.05.0210-sec-arch-testsuite-fix.patch
new file mode 100644
index 0000000..4d3c939
--- /dev/null
+++ b/postgresql-odbc-09.05.0210-sec-arch-testsuite-fix.patch
@@ -0,0 +1,27 @@
+From 186b42c74ea05431745c171327d97ffec4d7d5bb Mon Sep 17 00:00:00 2001
+From: Hiroshi Inoue <h-inoue@dream.email.ne.jp>
+Date: Mon, 25 Jul 2016 07:13:19 +0900
+Subject: [PATCH 2/2] Fix regression test failures in result-conversions-test
+ on big-endian platforms. expected/result-conversions_1.out lacks 3 lines.
+
+---
+ test/expected/result-conversions_1.out | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/test/expected/result-conversions_1.out b/test/expected/result-conversions_1.out
+index 31f55a4..2ce8e53 100644
+--- a/test/expected/result-conversions_1.out
++++ b/test/expected/result-conversions_1.out
+@@ -1320,6 +1320,9 @@ Executed: SET bytea_output=hex
+ '2011-02-15 15:49:18' (timestamp) as SQL_C_TIMESTAMP: y: 2011 m: 2 d: 15 h: 15 m: 49 s: 18 f: 0
+ '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_DATE: y: 2011 m: 2 d: 16
+ '2011-02-16 17:49:18+03' (timestamptz) as SQL_C_TIMESTAMP: y: 2011 m: 2 d: 16 h: 6 m: 49 s: 18 f: 0
++'' (text) as SQL_C_TYPE_DATE: y: 0 m: 0 d: 0
++'' (text) as SQL_C_TYPE_TIME: h: 0 m: 0 s: 0
++'' (text) as SQL_C_TYPE_TIMESTAMP: y: 0 m: 0 d: 0 h: 0 m: 0 s: 0 f: 0
+ 'foobar' (text) as SQL_C_CHAR: foob (truncated)
+ 'foobar' (text) as SQL_C_CHAR: fooba (truncated)
+ 'foobar' (text) as SQL_C_CHAR: foobar
+-- 
+2.7.4
+
diff --git a/postgresql-odbc-09.05.0210-tests-arm.patch b/postgresql-odbc-09.05.0210-tests-arm.patch
deleted file mode 100644
index ee98b51..0000000
--- a/postgresql-odbc-09.05.0210-tests-arm.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From 75cf55112bae7c0d71edafe551a66b799882d739 Mon Sep 17 00:00:00 2001
-From: Pavel Raiskup <praiskup@redhat.com>
-Date: Mon, 2 May 2016 08:14:43 +0200
-Subject: [PATCH] Disable the test only on arm for now
-
-This has been reported upstream:
-http://www.postgresql.org/message-id/1891019.xN52Kdy8p1@nb.usersys.redhat.com
-
-Related: rhbz#1330031
----
- test/tests | 1 -
- 1 file changed, 1 deletion(-)
-diff --git a/test/tests b/test/tests
-index a06a575..f923e92 100644
---- a/test/tests
-+++ b/test/tests
-@@ -34,10 +34,8 @@ TESTBINS = exe/connect-test \
- 	exe/cursor-movement-test \
- 	exe/cursor-commit-test \
- 	exe/cursor-name-test \
--	exe/cursor-block-delete-test \
- 	exe/bookmark-test \
- 	exe/declare-fetch-commit-test \
--	exe/declare-fetch-block-test \
- 	exe/positioned-update-test \
- 	exe/bulkoperations-test \
- 	exe/catalogfunctions-test \
--- 
-2.5.5
-
diff --git a/postgresql-odbc.spec b/postgresql-odbc.spec
index 91cf00b..f0ecc95 100644
--- a/postgresql-odbc.spec
+++ b/postgresql-odbc.spec
@@ -1,7 +1,7 @@
 Name: postgresql-odbc
 Summary: PostgreSQL ODBC driver
 Version: 09.05.0300
-Release: 1%{?dist}
+Release: 2%{?dist}
 License: LGPLv2+
 Group: Applications/Databases
 URL: http://psqlodbc.projects.postgresql.org/
@@ -10,9 +10,10 @@ Source0: http://ftp.postgresql.org/pub/odbc/versions/src/psqlodbc-%{version}.tar
 
 Source1: postgres-testing.sh
 
-Source2: postgresql-odbc-09.05.0210-tests-arm.patch
 
 Patch0: postgresql-odbc-09.05.0210-revert-money-fix.patch
+Patch1: postgresql-odbc-09.05.0210-arm-testsuite-fix.patch
+Patch2: postgresql-odbc-09.05.0210-sec-arch-testsuite-fix.patch
 
 BuildRequires: unixODBC-devel postgresql-devel
 BuildRequires: postgresql-server
@@ -64,14 +65,7 @@ cd test && make installcheck %{_smp_mflags} || {
 	find -name regression.diffs | while read line; do
 		cat "$line"
 	done
-
-	%ifarch armv7hl
-	echo "=== running the testsuite again with disabled expected failures ==="
-	cat %{SOURCE2} | patch -p2
-	make installcheck %{_smp_mflags}
-	%else
 	false
-	%endif
 }
 
 
@@ -107,6 +101,9 @@ the PostgreSQL unixODBC driver.
 
 
 %changelog
+* Tue Jul 26 2016 Pavel Raiskup <praiskup@redhat.com> - 09.05.0300-2
+- backport upstream fixes for testsuite failures (rhbz#1350486)
+
 * Sat Jun 18 2016 Pavel Raiskup <praiskup@redhat.com> - 09.05.0300-1
 - rebase to latest upstream version, per release notes:
   https://odbc.postgresql.org/docs/release.html