Make reserved memory regions detection more robust
authorReto Buerki <reet@codelabs.ch>
Fri, 29 Sep 2017 14:10:49 +0000 (16:10 +0200)
committerReto Buerki <reet@codelabs.ch>
Fri, 29 Sep 2017 15:03:53 +0000 (17:03 +0200)
Newer Linux kernels (tested with 4.13) changed the casing of the memory
type from 'reserved' to 'Reserved'. Therefore convert to lowercase
before comparison in filterMemoryBlocks function.

data/creator/memorycreator/casing/0/end [new file with mode: 0644]
data/creator/memorycreator/casing/0/start [new file with mode: 0644]
data/creator/memorycreator/casing/0/type [new file with mode: 0644]
src/creator.py
test/test_creator.py

diff --git a/data/creator/memorycreator/casing/0/end b/data/creator/memorycreator/casing/0/end
new file mode 100644 (file)
index 0000000..d8b1532
--- /dev/null
@@ -0,0 +1 @@
+0xf009
diff --git a/data/creator/memorycreator/casing/0/start b/data/creator/memorycreator/casing/0/start
new file mode 100644 (file)
index 0000000..dbf47d1
--- /dev/null
@@ -0,0 +1 @@
+0x000a
diff --git a/data/creator/memorycreator/casing/0/type b/data/creator/memorycreator/casing/0/type
new file mode 100644 (file)
index 0000000..de81916
--- /dev/null
@@ -0,0 +1 @@
+Reserved
index 3b9a86f..cb7f6cd 100644 (file)
@@ -209,7 +209,8 @@ class MemoryCreator():
         result = []
         print "Filtering memory blocks..."
         filterlist = [mem for mem in memoryBlockList
-                      if mem.name == "reserved" or mem.size == "16#0000#"]
+                      if mem.name.lower() == "reserved" or
+                      mem.size == "16#0000#"]
         result = util.removeListsFromList(memoryBlockList, filterlist)
         return result
 
index 50d85c9..eb5713d 100644 (file)
@@ -179,6 +179,7 @@ class TestMemoryCreator():
         loc = os.path.join(self.testdir, "memmap")
         invalidloc = os.path.join(self.testdir, "memmap_invalid")
         incompleteloc = os.path.join(self.testdir, "memmap_incomplete")
+        casing = os.path.join(self.testdir, "casing")
 
         # Test isAllocatable function
         mem1_name = "System RAM"
@@ -204,6 +205,8 @@ class TestMemoryCreator():
         memoryBlockList_incomplete = self.memcreator.getMemoryBlocks(
             incompleteloc)
         assert not memoryBlockList_incomplete
+        memoryBlockList_casing = self.memcreator.getMemoryBlocks(casing)
+        assert not memoryBlockList_casing
 
         memoryBlockList = self.memcreator.getMemoryBlocks(loc)
         assert len(memoryBlockList) == 2