From: Subrata M. <su...@li...> - 2009-01-23 07:30:09
|
Signed-Off-By: Subrata Modak<su...@li...>, -- diff -uprN ltp-intermediate-20090121.orig/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat01.c ltp-intermediate-20090121/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat01.c --- ltp-intermediate-20090121.orig/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat01.c 2009-01-23 11:26:46.000000000 +0530 +++ ltp-intermediate-20090121/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat01.c 2009-01-23 11:37:59.000000000 +0530 @@ -57,10 +57,12 @@ */ #include "ipcshm.h" +#include "system_specific_hugepages_info.h" char *TCID = "hugeshmat01"; int TST_TOTAL = 3; extern int Tst_count; +unsigned long huge_pages_shm_to_be_allocated; #define CASE0 10 /* values to write into the shared */ #define CASE1 20 /* memory location. */ @@ -102,6 +104,11 @@ int main(int ac, char **av) tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg); } + 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"); + else + huge_pages_shm_to_be_allocated = ( get_no_of_hugepages() * hugepages_size() * 1024) / 2 ; + setup(); /* global setup */ /* The following loop checks looping state if -i option given */ @@ -176,7 +183,7 @@ check_functionality(int i) } /* check the size of the segment */ - if (buf.shm_segsz != HUGE_SHM_SIZE) { + if (buf.shm_segsz != huge_pages_shm_to_be_allocated) { tst_resm(TFAIL, "segment size is incorrect"); return; } @@ -251,7 +258,7 @@ setup(void) shmkey = getipckey(); /* create a shared memory resource with read and write permissions */ - if ((shm_id_1 = shmget(shmkey++, HUGE_SHM_SIZE, SHM_HUGETLB | SHM_RW | IPC_CREAT | + if ((shm_id_1 = shmget(shmkey++, huge_pages_shm_to_be_allocated, SHM_HUGETLB | SHM_RW | IPC_CREAT | IPC_EXCL)) == -1) { tst_brkm(TBROK, cleanup, "Failed to create shared memory " "resource 1 in setup()"); Regards-- Subrata |