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

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