Blame SOURCES/0001-testutils-fix-range_is_mapped.patch

f4a552
From 192ac21a3c057c5dedca4cdd1bf700f38992030c Mon Sep 17 00:00:00 2001
f4a552
Message-Id: <192ac21a3c057c5dedca4cdd1bf700f38992030c.1496667760.git.jstancek@redhat.com>
f4a552
From: Jan Stancek <jstancek@redhat.com>
f4a552
Date: Thu, 1 Jun 2017 09:48:41 +0200
f4a552
Subject: [PATCH v2 1/2] testutils: fix range_is_mapped()
f4a552
f4a552
It doesn't return correct value when tested region is
f4a552
completely inside existing mapping:
f4a552
f4a552
  +--------------------------------------+
f4a552
  ^ start                                ^ end
f4a552
           +----------------+
f4a552
           ^ low            ^ high
f4a552
f4a552
Rather than testing for all combinations of 2 regions overlapping,
f4a552
flip the condition and test if they don't overlap.
f4a552
f4a552
Signed-off-by: Jan Stancek <jstancek@redhat.com>
f4a552
---
f4a552
 tests/testutils.c | 22 ++++++++++++++++------
f4a552
 1 file changed, 16 insertions(+), 6 deletions(-)
f4a552
f4a552
This is a v2 series for:
f4a552
  https://groups.google.com/forum/#!topic/libhugetlbfs/tAsWjuJ7x8k
f4a552
f4a552
diff --git a/tests/testutils.c b/tests/testutils.c
f4a552
index 629837045465..f42852e1938b 100644
f4a552
--- a/tests/testutils.c
f4a552
+++ b/tests/testutils.c
f4a552
@@ -190,19 +190,29 @@ int range_is_mapped(unsigned long low, unsigned long high)
f4a552
 			return -1;
f4a552
 		}
f4a552
 
f4a552
-		if ((start >= low) && (start < high)) {
f4a552
+		/*
f4a552
+		 * (existing mapping)    (tested region)
f4a552
+		 * +----------------+      +.......+
f4a552
+		 * ^start           ^end   ^ low   ^high
f4a552
+		 */
f4a552
+		if (low >= end) {
f4a552
 			fclose(f);
f4a552
-			return 1;
f4a552
+			return 0;
f4a552
 		}
f4a552
-		if ((end >= low) && (end < high)) {
f4a552
+
f4a552
+		/*
f4a552
+		 * (tested region)  (existing mapping)
f4a552
+		 *     +.....+      +----------------+
f4a552
+		 *     ^low  ^high  ^ start          ^end
f4a552
+		 */
f4a552
+		if (high <= start) {
f4a552
 			fclose(f);
f4a552
-			return 1;
f4a552
+			return 0;
f4a552
 		}
f4a552
-
f4a552
 	}
f4a552
 
f4a552
 	fclose(f);
f4a552
-	return 0;
f4a552
+	return 1;
f4a552
 }
f4a552
 
f4a552
 /*
f4a552
-- 
f4a552
1.8.3.1
f4a552