When env parsing is moved and only done once we cannot continue to
change the value of a env variable during a test.  Change the
shmoverride tests to only run tests that fit with the current value
of HUGETLB_SHM and have run_tests.sh call each test with both possible
values of HGUETLB_SHM.

Signed-off-by: Eric B Munson <[EMAIL PROTECTED]>
---
 tests/run_tests.sh           |    6 ++++--
 tests/shmoverride_unlinked.c |   36 ++++++++++++++++++++++--------------
 2 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 9064451..3d559db 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -342,8 +342,10 @@ check_linkhuge_tests
     run_test get_huge_pages
 
 # Test overriding of shmget()
-    run_test shmoverride_linked
-    run_test LD_PRELOAD=libhugetlbfs.so shmoverride_unlinked
+    run_test HUGETLB_SHM=no shmoverride_linked
+    run_test HUGETLB_SHM=yes shmoverride_linked
+    run_test HUGETLB_SHM=no LD_PRELOAD=libhugetlbfs.so shmoverride_unlinked
+    run_test HUGETLB_SHM=yes LD_PRELOAD=libhugetlbfs.so shmoverride_unlinked
 
 # Test hugetlbfs filesystem quota accounting
     run_test quota.sh
diff --git a/tests/shmoverride_unlinked.c b/tests/shmoverride_unlinked.c
index 5813cb7..ba0b335 100644
--- a/tests/shmoverride_unlinked.c
+++ b/tests/shmoverride_unlinked.c
@@ -200,6 +200,8 @@ void cleanup(void)
 
 int main(int argc, char **argv)
 {
+       char *env;
+
        test_init(argc, argv);
        check_must_be_root();
        local_check_free_huge_pages(POOL_SIZE);
@@ -213,21 +215,27 @@ int main(int argc, char **argv)
        hpage_size = local_read_meminfo("Hugepagesize:") * 1024;
        bpage_size = getpagesize();
 
-       /* Run the test with small pages */
-       setenv("HUGETLB_SHM", "no", 1);
-       run_test("override-not-requested-aligned", 1, 0, POOL_SIZE, 0);
-
-       /* Run the test with large pages */
-       setenv("HUGETLB_SHM", "yes", 1);
-       run_test("override-requested-aligned", 1, 0, POOL_SIZE, 1);
-
-       /* Run the test with large pages but with an unaligned size */
-       setenv("HUGETLB_SHM", "yes", 1);
-       run_test("override-requested-unaligned", 1, 1, POOL_SIZE, 2);
+       env = getenv("HUGETLB_SHM");
 
-       /* Run the test with no pool but requested large pages */
-       setup_hugetlb_pool(0);
-       run_test("override-requested-aligned-nopool", 1, 0, 0, 0);
+       /* Now that all env parsing is in one location and is only done once
+        * during library init, we cannot modify the value of HGUETLB_SHM
+        * in the middle of the test, instead run the tests that fit with
+        * the current value of HUGETLB_SHM
+        */
+       if (env && strcasecmp(env, "yes") == 0) {
+               /* Run the test with large pages */
+               run_test("override-requested-aligned", 1, 0, POOL_SIZE, 1);
+
+               /* Run the test with large pages but with an unaligned size */
+               run_test("override-requested-unaligned", 1, 1, POOL_SIZE, 2);
+
+               /* Run the test with no pool but requested large pages */
+               setup_hugetlb_pool(0);
+               run_test("override-requested-aligned-nopool", 1, 0, 0, 0);
+       } else {
+               /* Run the test with small pages */
+               run_test("override-not-requested-aligned", 1, 0, POOL_SIZE, 0);
+       }
 
        PASS();
 }
-- 
1.6.0.3


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to