[LTP] [PATCH] fix "hugetlb" several tests

Mitani
2010-04-13T06:58:52Z

Hi,

I tried "hugemmap", "hugeshmat", "hugeshmctl", "hugeshmdt" and
"hugeshmget" tests.
And I found several fails in them:
------------<at "${LTPROOT}/testcases/kernel/mem/hugetlb/" directory>
- ./hugemmap/
1) hugemmap04 : return code = 2

- ./hugeshmat/
2) hugeshmat01 : return code = 6
3) hugeshmat02 : return code = 6
4) hugeshmat03 : return code = 2

- ./hugeshmctl/
5) hugeshmctl01 : return code = 6
6) hugeshmctl02 : return code = 6
7) hugeshmctl03 : return code = 2

- ./hugeshmdt/
8) hugeshmdt01 : return code = 6

- ./hugeshmget/
9) hugeshmget01 : return code = 2
10) hugeshmget02 : return code = 6
11) hugeshmget03 : return code = 6
12) hugeshmget05 : return code = 2
------------

These tests output following messages:
------------
a) All tests:
"TBROK : Test cannot be continued owning to sufficient availability of
Hugepages on the system"

b) 2), 3), 5), 6), 8), 10), 11) tests:
"TWARN : tst_rmdir(): TESTDIR was NULL; no removal attempted"
------------

Both case a) and case b) are caused by the same reason.

All of case a) failures occured at the following points (for example
hugemmap04):
------------<hugemmap04.c - main()>
/* Check number of hugepages */
if (get_no_of_hugepages() <= 0 || hugepages_size() <= 0)
tst_brkm(TBROK, cleanup, "Test cannot be continued owning to
\
sufficient availability of Hugepages on the
system");
------------

I found out that "HugePages_Total" parameter of "/proc/meminfo" file
is set to "0". This caused above TBROK failure. It is environment problem.

But, in this case, tests must not return with TBROK, but with TCONF,
I think.

And, in case b), these tests try to delete "TESTDIR" directory by
calling "tst_rmdir()" function in "cleanup()" function.
But, "TESTDIR" never set if "tst_tmpdir()" function isn't called.
I think that case b)'s tests must not call cleanup() function.

I want to suggest following patch.

Signed-off-by: Tomonori Mitani <mitani@ryobi.co.jp>

============
--- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c 2010-04-01
15:23:09.000000000 +0900
+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c 2010-04-13
11:23:33.000000000 +0900
@@ -127,7 +127,7 @@

/* Check number of hugepages */
if (get_no_of_hugepages() <= 0 || hugepages_size() <= 0)
- tst_brkm(TBROK, cleanup, "Test cannot be continued owning to
\
+ tst_brkm(TCONF, cleanup, "Test cannot be continued owning to
\
sufficient availability of Hugepages on the
system");

/* Perform global setup for test */
--- a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat01.c 2010-04-01
15:23:09.000000000 +0900
+++ b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat01.c 2010-04-13
11:36:25.000000000 +0900
@@ -105,7 +105,7 @@
}

if ( get_no_of_hugepages() <= 0 || hugepages_size() <= 0 )
- tst_brkm(TBROK, cleanup, "Test cannot be continued owning to
sufficient availability of Hugepages on the system");
+ tst_brkm(TCONF, tst_exit, "Test cannot be continued owning to
sufficient availability of Hugepages on the system");
else
huge_pages_shm_to_be_allocated = ( get_no_of_hugepages() *
hugepages_size() * 1024) / 2 ;

--- a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat02.c 2010-04-01
15:23:09.000000000 +0900
+++ b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat02.c 2010-04-13
11:37:41.000000000 +0900
@@ -102,7 +102,7 @@
}

if ( get_no_of_hugepages() <= 0 || hugepages_size() <= 0 )
- tst_brkm(TBROK, cleanup, "Test cannot be continued owning to
sufficient availability of Hugepages on the system");
+ tst_brkm(TCONF, tst_exit, "Test cannot be continued owning to
sufficient availability of Hugepages on the system");
else
huge_pages_shm_to_be_allocated = ( get_no_of_hugepages() *
hugepages_size() * 1024) / 2 ;

--- a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat03.c 2010-04-01
15:23:09.000000000 +0900
+++ b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat03.c 2010-04-13
11:38:16.000000000 +0900
@@ -86,7 +86,7 @@
}

if ( get_no_of_hugepages() <= 0 || hugepages_size() <= 0 )
- tst_brkm(TBROK, cleanup, "Test cannot be continued owning to
sufficient availability of Hugepages on the system");
+ tst_brkm(TCONF, cleanup, "Test cannot be continued owning to
sufficient availability of Hugepages on the system");
else
huge_pages_shm_to_be_allocated = ( get_no_of_hugepages() *
hugepages_size() * 1024) / 2 ;

--- a/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c 2010-04-01
15:23:09.000000000 +0900
+++ b/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl01.c 2010-04-13
11:41:23.000000000 +0900
@@ -130,7 +130,7 @@
}

if ( get_no_of_hugepages() <= 0 || hugepages_size() <= 0 )
- tst_brkm(TBROK, cleanup, "Test cannot be continued owning to
sufficient availability of Hugepages on the system");
+ tst_brkm(TCONF, tst_exit, "Test cannot be continued owning to
sufficient availability of Hugepages on the system");
else
huge_pages_shm_to_be_allocated = ( get_no_of_hugepages() *
hugepages_size() * 1024) / 2 ;

--- a/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl02.c 2010-04-01
15:23:09.000000000 +0900
+++ b/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl02.c 2010-04-13
11:41:48.000000000 +0900
@@ -102,7 +102,7 @@
}

if ( get_no_of_hugepages() <= 0 || hugepages_size() <= 0 )
- tst_brkm(TBROK, cleanup, "Test cannot be continued owning to
sufficient availability of Hugepages on the system");
+ tst_brkm(TCONF, tst_exit, "Test cannot be continued owning to
sufficient availability of Hugepages on the system");
else
huge_pages_shm_to_be_allocated = ( get_no_of_hugepages() *
hugepages_size() * 1024) / 2 ;

--- a/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl03.c 2010-04-01
15:23:09.000000000 +0900
+++ b/testcases/kernel/mem/hugetlb/hugeshmctl/hugeshmctl03.c 2010-04-13
11:42:10.000000000 +0900
@@ -105,7 +105,7 @@
}

if ( get_no_of_hugepages() <= 0 || hugepages_size() <= 0 )
- tst_brkm(TBROK, cleanup, "Test cannot be continued owning to
sufficient availability of Hugepages on the system");
+ tst_brkm(TCONF, cleanup, "Test cannot be continued owning to
sufficient availability of Hugepages on the system");
else
huge_pages_shm_to_be_allocated = ( get_no_of_hugepages() *
hugepages_size() * 1024) / 2 ;

--- a/testcases/kernel/mem/hugetlb/hugeshmdt/hugeshmdt01.c 2010-04-01
15:23:09.000000000 +0900
+++ b/testcases/kernel/mem/hugetlb/hugeshmdt/hugeshmdt01.c 2010-04-13
11:42:55.000000000 +0900
@@ -87,7 +87,7 @@
}

if ( get_no_of_hugepages() <= 0 || hugepages_size() <= 0 )
- tst_brkm(TBROK, cleanup, "Test cannot be continued owning to
sufficient availability of Hugepages on the system");
+ tst_brkm(TCONF, tst_exit, "Test cannot be continued owning to
sufficient availability of Hugepages on the system");
else
huge_pages_shm_to_be_allocated = ( get_no_of_hugepages() *
hugepages_size() * 1024) / 2 ;

--- a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c 2010-04-01
15:23:09.000000000 +0900
+++ b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c 2010-04-13
11:43:30.000000000 +0900
@@ -82,7 +82,7 @@

/* The following loop checks looping state if -i option given */
if ( get_no_of_hugepages() <= 0 || hugepages_size() <= 0 )
- tst_brkm(TBROK, cleanup, "Test cannot be continued owning to
sufficient availability of Hugepages on the system");
+ tst_brkm(TCONF, cleanup, "Test cannot be continued owning to
sufficient availability of Hugepages on the system");
else
huge_pages_shm_to_be_allocated = ( get_no_of_hugepages() *
hugepages_size() * 1024) / 2 ;

--- a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c 2010-04-01
15:23:09.000000000 +0900
+++ b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c 2010-04-13
11:43:51.000000000 +0900
@@ -84,7 +84,7 @@
}

if ( get_no_of_hugepages() <= 0 || hugepages_size() <= 0 )
- tst_brkm(TBROK, cleanup, "Test cannot be continued owning to
sufficient availability of Hugepages on the system");
+ tst_brkm(TCONF, tst_exit, "Test cannot be continued owning to
sufficient availability of Hugepages on the system");
else
huge_pages_shm_to_be_allocated = ( get_no_of_hugepages() *
hugepages_size() * 1024) / 2 ;

--- a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c 2010-04-01
15:23:09.000000000 +0900
+++ b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c 2010-04-13
11:44:10.000000000 +0900
@@ -85,7 +85,7 @@

/* The following loop checks looping state if -i option given */
if ( get_no_of_hugepages() <= 0 || hugepages_size() <= 0 )
- tst_brkm(TBROK, cleanup, "Test cannot be continued owning to
sufficient availability of Hugepages on the system");
+ tst_brkm(TCONF, tst_exit, "Test cannot be continued owning to
sufficient availability of Hugepages on the system");
else
huge_pages_shm_to_be_allocated = ( get_no_of_hugepages() *
hugepages_size() * 1024) / 2 ;

--- a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget05.c 2010-04-01
15:23:09.000000000 +0900
+++ b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget05.c 2010-04-13
11:44:29.000000000 +0900
@@ -86,7 +86,7 @@
}

if ( get_no_of_hugepages() <= 0 || hugepages_size() <= 0 )
- tst_brkm(TBROK, cleanup, "Test cannot be continued owning to
sufficient availability of Hugepages on the system");
+ tst_brkm(TCONF, cleanup, "Test cannot be continued owning to
sufficient availability of Hugepages on the system");
else
huge_pages_shm_to_be_allocated = ( get_no_of_hugepages() *
hugepages_size() * 1024) / 2 ;

============

Regards--

-Tomonori Mitani