aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2013-07-26 09:54:47 +0100
committerMatt Fleming <matt.fleming@intel.com>2013-07-26 09:54:47 +0100
commit5e1a2c5a40d591d72bb6dabbb8e0685298934a9e (patch)
tree3248ce8391216a061953b2e27ed593a1375df1d4
parent77cadda8fa63289dbd3d2bbc6eaff7c7e42688c4 (diff)
downloadsyslinux-5e1a2c5a40d591d72bb6dabbb8e0685298934a9e.tar.gz
syslinux-5e1a2c5a40d591d72bb6dabbb8e0685298934a9e.tar.xz
syslinux-5e1a2c5a40d591d72bb6dabbb8e0685298934a9e.zip
tests: syslinux_memmap_highest() unit tests
Exercise the new syslinux_memmap_highest() function. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
-rw-r--r--com32/lib/syslinux/tests/zonelist.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/com32/lib/syslinux/tests/zonelist.c b/com32/lib/syslinux/tests/zonelist.c
index 039d5c57..588351f6 100644
--- a/com32/lib/syslinux/tests/zonelist.c
+++ b/com32/lib/syslinux/tests/zonelist.c
@@ -203,6 +203,70 @@ bail:
return rv;
}
+/*
+ * Find the highest address given a set of boundary conditions.
+ */
+static int test_find_highest(void)
+{
+ struct syslinux_memmap *mmap;
+ addr_t start;
+ int rv = -1;
+ struct test_memmap_entry entries[] = {
+ 0x000000, 0x000000, SMT_FREE,
+ 0x090000, 0x002000, SMT_FREE,
+ 0x092000, 0x100000, SMT_RESERVED,
+ 0x192001, 0x000021, SMT_TERMINAL,
+ };
+
+ mmap = test_build_mmap(entries, array_sz(entries));
+ if (!mmap)
+ goto bail;
+
+ start = 0x90000;
+ rv = syslinux_memmap_highest(mmap, SMT_FREE, &start, 0x20, 0x192000, 1);
+
+ syslinux_assert(!rv, "Failed to find highest SMT_FREE address");
+ syslinux_assert_str(start == 0x91fe0,
+ "0x%x incorrect highest address", start);
+
+ start = 0x40000;
+ rv = syslinux_memmap_highest(mmap, SMT_FREE, &start, 0x20, 0x91480, 1);
+
+ syslinux_assert(!rv, "Failed to find highest SMT_FREE address");
+ syslinux_assert_str(start == 0x91460,
+ "0x%x incorrect highest address", start);
+
+
+ start = 0x90023;
+ rv = syslinux_memmap_highest(mmap, SMT_FREE, &start, 0x20, 0x90057, 0x10);
+ syslinux_assert_str(start == 0x90030,
+ "0x%x incorrectly aligned highest address", start);
+
+ start = 0x00000;
+ rv = syslinux_memmap_highest(mmap, SMT_TERMINAL, &start,
+ 0x7, 0x192300, 0x10);
+ syslinux_assert_str(start == 0x192010,
+ "0x%x incorrectly aligned SMT_TERMINAL address", start);
+
+ start = 0x192001;
+ rv = syslinux_memmap_highest(mmap, SMT_RESERVED, &start,
+ 0x400, (addr_t)-1, 1);
+ syslinux_assert_str(rv && start == 0x192001,
+ "Unexpectedly succeeded finding invalid region: 0x%x",
+ start);
+
+ start = 0x191fff;
+ rv = syslinux_memmap_highest(mmap, SMT_RESERVED, &start,
+ 0x800, (addr_t)-1, 1);
+ syslinux_assert_str(rv && start == 0x191fff,
+ "Unexpectedly succeeded finding invalid region: 0x%x",
+ start);
+ rv = 0;
+bail:
+ syslinux_free_memmap(mmap);
+ return rv;
+}
+
int main(int argc, char **argv)
{
refuse_to_alloc_reserved_region();
@@ -216,5 +280,7 @@ int main(int argc, char **argv)
alloc_in_pxe_region();
demote_free_region_to_terminal();
+ test_find_highest();
+
return 0;
}