From: Subrata M. <su...@li...> - 2009-01-23 07:29:58
|
Signed-Off-By: Subrata Modak<su...@li...>, -- diff -uprN ltp-intermediate-20090121.orig/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c ltp-intermediate-20090121/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c --- ltp-intermediate-20090121.orig/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c 2009-01-23 11:18:14.000000000 +0530 +++ ltp-intermediate-20090121/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c 2009-01-23 11:24:08.000000000 +0530 @@ -52,10 +52,12 @@ */ #include "ipcshm.h" +#include "system_specific_hugepages_info.h" char *TCID = "hugeshmget02"; int TST_TOTAL = 4; extern int Tst_count; +unsigned long huge_pages_shm_to_be_allocated; int exp_enos[] = {ENOENT, EEXIST, EINVAL, 0}; /* 0 terminated list of */ /* expected errnos */ @@ -69,26 +71,9 @@ struct test_case_t { int size; int flags; int error; -} TC[] = { - /* EINVAL - size is 0 */ - {&shmkey2, 0, SHM_HUGETLB | IPC_CREAT | IPC_EXCL | SHM_RW, EINVAL}, - - /* EINVAL - size is negative */ - //{&shmkey2, -1, SHM_HUGETLB | IPC_CREAT | IPC_EXCL | SHM_RW, EINVAL}, - - /* EINVAL - size is larger than created segment */ - {&shmkey, HUGE_SHM_SIZE * 2, SHM_HUGETLB | SHM_RW, EINVAL}, - - /* EEXIST - the segment exists and IPC_CREAT | IPC_EXCL is given */ - {&shmkey, HUGE_SHM_SIZE, SHM_HUGETLB | IPC_CREAT | IPC_EXCL | SHM_RW, EEXIST}, - - /* ENOENT - no segment exists for the key and IPC_CREAT is not given */ - /* use shm_id_2 (-1) as the key */ - {&shm_id_2, HUGE_SHM_SIZE, SHM_HUGETLB | SHM_RW, ENOENT} }; -int main(int ac, char **av) -{ +int main(int ac, char **av) { int lc; /* loop counter */ char *msg; /* message returned from parse_opts */ int i; @@ -98,6 +83,25 @@ 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 ; + + struct test_case_t TC[] = { + /* EINVAL - size is 0 */ + {&shmkey2, 0, SHM_HUGETLB | IPC_CREAT | IPC_EXCL | SHM_RW, EINVAL}, + /* EINVAL - size is negative */ + //{&shmkey2, -1, SHM_HUGETLB | IPC_CREAT | IPC_EXCL | SHM_RW, EINVAL}, + /* EINVAL - size is larger than created segment */ + {&shmkey, huge_pages_shm_to_be_allocated * 2, SHM_HUGETLB | SHM_RW, EINVAL}, + /* EEXIST - the segment exists and IPC_CREAT | IPC_EXCL is given */ + {&shmkey, huge_pages_shm_to_be_allocated, SHM_HUGETLB | IPC_CREAT | IPC_EXCL | SHM_RW, EEXIST}, + /* ENOENT - no segment exists for the key and IPC_CREAT is not given */ + /* use shm_id_2 (-1) as the key */ + {&shm_id_2, huge_pages_shm_to_be_allocated, SHM_HUGETLB | SHM_RW, ENOENT} + }; + setup(); /* global setup */ /* The following loop checks looping state if -i option given */ @@ -167,10 +171,8 @@ setup(void) shmkey2 = shmkey + 1; - if ((shm_id_1 = shmget(shmkey, HUGE_SHM_SIZE, IPC_CREAT | IPC_EXCL | - SHM_RW)) == -1) { - tst_brkm(TBROK, cleanup, "couldn't create shared memory " - "segment in setup()"); + if ((shm_id_1 = shmget(shmkey, huge_pages_shm_to_be_allocated, IPC_CREAT | IPC_EXCL | SHM_RW)) == -1) { + tst_brkm(TBROK, cleanup, "couldn't create shared memory segment in setup()"); } Regards-- Subrata |