File: fix-keepalive1-failures-on-kfreebsd.patch

package info (click to toggle)
xapian-core 1.4.11-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 21,876 kB
  • sloc: cpp: 120,318; ansic: 9,802; sh: 4,664; perl: 851; makefile: 567; tcl: 319; python: 40
file content (58 lines) | stat: -rw-r--r-- 2,119 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Description: Fix keepalive1 failures on kfreebsd
Author: Olly Betts <olly@survex.com>
Origin: upstream
Last-Update: 2019-02-22

--- xapian-core-1.4.10.orig/tests/api_db.cc
+++ xapian-core-1.4.10/tests/api_db.cc
@@ -1012,8 +1012,11 @@ DEFINE_TESTCASE(keepalive1, remote) {
     /* Test that things break without keepalives */
     sleep(10);
     enquire.set_query(Xapian::Query("word"));
-    TEST_EXCEPTION(Xapian::NetworkError,
-		   enquire.get_mset(0, 10));
+    /* Currently this can throw NetworkError or NetworkTimeoutError (which is
+     * a subclass of NetworkError).
+     */
+    TEST_EXCEPTION_BASE_CLASS(Xapian::NetworkError,
+			      enquire.get_mset(0, 10));
 
     return true;
 }
--- xapian-core-1.4.10.orig/tests/harness/testutils.h
+++ xapian-core-1.4.10/tests/harness/testutils.h
@@ -74,8 +74,8 @@ void test_mset_order_equal(const Xapian:
 	(M).size() << "' expected '" << (S) << "':\n" << \
 	"Full mset was:\n" << (M))
 
-/// Check that CODE throws exactly Xapian exception TYPE.
-#define TEST_EXCEPTION(TYPE, CODE) \
+/// Helper macro.
+#define TEST_EXCEPTION_(TYPE, CODE, EXACT) \
     do { \
 	expected_exception = STRINGIZE(TYPE); \
 	if (strncmp(expected_exception, "Xapian::", \
@@ -86,12 +86,20 @@ void test_mset_order_equal(const Xapian:
 	    CODE; \
 	    FAIL_TEST("Expected " << expected_exception << " not thrown"); \
 	} catch (const TYPE& e) { \
-	    if (strcmp(expected_exception, e.get_type()) != 0) { \
-		FAIL_TEST("Caught subclass " << e.get_type() << \
-			  " of expected " << expected_exception); \
+	    if (EXACT) { \
+		if (strcmp(expected_exception, e.get_type()) != 0) { \
+		    FAIL_TEST("Caught subclass " << e.get_type() << \
+			      " of expected " << expected_exception); \
+		} \
 	    } \
 	} \
 	expected_exception = NULL;\
     } while (0)
 
+/// Check that CODE throws Xapian exception derived from TYPE.
+#define TEST_EXCEPTION_BASE_CLASS(TYPE, CODE) TEST_EXCEPTION_(TYPE, CODE, false)
+
+/// Check that CODE throws exactly Xapian exception TYPE.
+#define TEST_EXCEPTION(TYPE, CODE) TEST_EXCEPTION_(TYPE, CODE, true)
+
 #endif // OM_HGUARD_TESTUTILS_H