fa2b99e
From 990e42d9c751d089cea161a25b7c2ade0a15d279 Mon Sep 17 00:00:00 2001
fa2b99e
From: Edward Thomson <ethomson@edwardthomson.com>
fa2b99e
Date: Thu, 13 Sep 2018 13:27:07 +0100
fa2b99e
Subject: [PATCH] tests: don't run buf::oom on 32-bit systems
fa2b99e
fa2b99e
On a 32-bit Linux systems, the value large enough to make malloc
fa2b99e
guarantee a failure is also large enough that valgrind considers it
fa2b99e
"fishy".  Skip this test on those systems entirely.
fa2b99e
fa2b99e
(cherry picked from commit 415a8ae9c9b6ac18f0524b6af8e58408b426457d)
fa2b99e
---
fa2b99e
 tests/buf/oom.c | 14 +++++++++-----
fa2b99e
 1 file changed, 9 insertions(+), 5 deletions(-)
fa2b99e
fa2b99e
diff --git a/tests/buf/oom.c b/tests/buf/oom.c
fa2b99e
index 16a03cc1a..86f5e7239 100644
fa2b99e
--- a/tests/buf/oom.c
fa2b99e
+++ b/tests/buf/oom.c
fa2b99e
@@ -11,12 +11,8 @@
fa2b99e
  */
fa2b99e
 #if defined(GIT_ARCH_64) && defined(__linux__)
fa2b99e
 # define TOOBIG 0x0fffffffffffffff
fa2b99e
-#elif defined(__linux__)
fa2b99e
-# define TOOBIG 0x0fffffff
fa2b99e
 #elif defined(GIT_ARCH_64)
fa2b99e
 # define TOOBIG 0xffffffffffffff00
fa2b99e
-#else
fa2b99e
-# define TOOBIG 0xffffff00
fa2b99e
 #endif
fa2b99e
 
fa2b99e
 /**
fa2b99e
@@ -25,13 +21,18 @@
fa2b99e
  * will fail.  And because the git_buf_grow() wrapper always
fa2b99e
  * sets mark_oom, the code in git_buf_try_grow() will free
fa2b99e
  * the internal buffer and set it to git_buf__oom.
fa2b99e
- * 
fa2b99e
+ *
fa2b99e
  * We initialized the internal buffer to (the static variable)
fa2b99e
  * git_buf__initbuf.  The purpose of this test is to make sure
fa2b99e
  * that we don't try to free the static buffer.
fa2b99e
+ *
fa2b99e
+ * Skip this test entirely on 32-bit platforms; a buffer large enough
fa2b99e
+ * to guarantee malloc failures is so large that valgrind considers
fa2b99e
+ * it likely to be an error.
fa2b99e
  */
fa2b99e
 void test_buf_oom__grow(void)
fa2b99e
 {
fa2b99e
+#ifdef GIT_ARCH_64
fa2b99e
 	git_buf buf = GIT_BUF_INIT;
fa2b99e
 
fa2b99e
 	git_buf_clear(&buf;;
fa2b99e
@@ -40,6 +41,9 @@ void test_buf_oom__grow(void)
fa2b99e
 	cl_assert(git_buf_oom(&buf));
fa2b99e
 
fa2b99e
 	git_buf_free(&buf;;
fa2b99e
+#else
fa2b99e
+    cl_skip();
fa2b99e
+#endif
fa2b99e
 }
fa2b99e
 
fa2b99e
 void test_buf_oom__grow_by(void)
fa2b99e
-- 
fa2b99e
2.19.1
fa2b99e