path: root/tests/testutils.c
AgeCommit message (Collapse)Author
2012-12-07Revert "exhaust malloc arenas before malloc tests"Eric B Munson
This reverts commit cdd2fa336d9980eb268a775b7cf9c49e3b698cd7. Conflicts: tests/hugetests.h tests/testutils.c With the removal of sscanf from the setup routines, the malloc tests now pass without having to exhaust small page allocations. Signed-off-by: Eric B Munson <emunson@mgebm.net> Cc: Jan Stancek <jstancek@redhat.com> Cc: Steve Capper <steve.capper@arm.com>
2012-11-06fail test only when MAP_FIXED fails on free slicesJan Stancek
huge_at_4GB_normal_below, huge_below_4GB_normal_above, straddle_4GB are tests to test corner cases on powerpc. powerpc manages memory using slices: low (0-4G) and high (4G-). These tests are using MAP_FIXED and try to mmap hugepage at various locations. Issue is that kernel or ld.so can be already using region that these tests want to use. At the moment it ends with failure: # ./obj64/straddle_4GB Starting testcase "./obj64/straddle_4GB", pid 25949 Mapping without MAP_FIXED at ff000000...got 0xefffe000000 instead, never mind Mapping with MAP_FIXED at ff000000 FAIL mmap() FIXED failed: Device or resource busy Looking at mappings prior to failed mmap, there are already some libraries mapped to first high slice (0). 10010000-10020000 r--p 00000000 fd:01 2893006 /root/libhugetlbfs/tests/obj64/straddle_4GB 10020000-10030000 rw-p 00010000 fd:01 2893006 /root/libhugetlbfs/tests/obj64/straddle_4GB 8015160000-8015190000 r-xp 00000000 fd:01 1857222 /usr/lib64/ld-2.15.so 8015190000-80151a0000 r--p 00020000 fd:01 1857222 /usr/lib64/ld-2.15.so 80151a0000-80151b0000 rw-p 00030000 fd:01 1857222 /usr/lib64/ld-2.15.so 80151d0000-8015390000 r-xp 00000000 fd:01 1857223 /usr/lib64/libc-2.15.so 8015390000-80153a0000 r--p 001b0000 fd:01 1857223 /usr/lib64/libc-2.15.so 80153a0000-80153c0000 rw-p 001c0000 fd:01 1857223 /usr/lib64/libc-2.15.so 80153c0000-80153e0000 r-xp 00000000 fd:01 1835789 /usr/lib64/libpthread-2.15.so 80153e0000-80153f0000 r--p 00010000 fd:01 1835789 /usr/lib64/libpthread-2.15.so 80153f0000-8015400000 rw-p 00020000 fd:01 1835789 /usr/lib64/libpthread-2.15.so 8015400000-8015410000 r-xp 00000000 fd:01 1842374 /usr/lib64/libdl-2.15.so 8015410000-8015420000 r--p 00000000 fd:01 1842374 /usr/lib64/libdl-2.15.so 8015420000-8015430000 rw-p 00010000 fd:01 1842374 /usr/lib64/libdl-2.15.so 10022e00000-10022e30000 rw-p 00000000 00:00 0 [heap] fff8e650000-fff8e670000 r-xp 00000000 fd:01 1837902 /usr/lib64/libhugetlbfs.so fff8e670000-fff8e680000 r--p 00010000 fd:01 1837902 /usr/lib64/libhugetlbfs.so fff8e680000-fff8e690000 rw-p 00020000 fd:01 1837902 /usr/lib64/libhugetlbfs.so fff8e690000-fff8e6a0000 r-xp 00000000 fd:01 1842940 /usr/lib64/libhugetlbfs_privutils.so fff8e6a0000-fff8e6b0000 r--p 00000000 fd:01 1842940 /usr/lib64/libhugetlbfs_privutils.so fff8e6b0000-fff8e6c0000 rw-p 00010000 fd:01 1842940 /usr/lib64/libhugetlbfs_privutils.so fff8e6c0000-fff8e6d0000 rw-p 00000000 00:00 0 fff8e6d0000-fff8e6f0000 r-xp 00000000 00:00 0 [vdso] fffc7110000-fffc7140000 rw-p 00000000 00:00 0 [stack] This patch checks that slices used by tests are actually free (not mapped). If they are not free and mmap fails, test will PASS as inconclusive. Signed-off-by: Jan Stancek <jstancek@redhat.com> Signed-off-by: Eric B Munson <emunson@mgebm.net>
2012-09-06exhaust malloc arenas before malloc testsJan Stancek
First allocation in malloc tests is just 1024 bytes. If there is enough free mem in malloc arenas, this first allocation can be satisfied without call to MORECORE() and testcase will fail. LD_PRELOAD=libhugetlbfs.so HUGETLB_MORECORE=yes malloc (2M: 64): FAIL Address is not hugepage When looking at output from HUGETLB_DEBUG=1 it appears that hook to __morecore doesn't work as there is no trace from hugetlbfs_morecore. This patch will keep malloc-ing 1-byte chunks of memory as long as it comes from '[heap]' or maximum is reached. This will force glibc to call MORECORE() before actual malloc/malloc_manysmall test begins. Signed-off-by: Jan Stancek <jstancek@redhat.com> Signed-off-by: Eric B Munson <emunson@mgebm.net>
2010-11-29Read /proc/self/smaps to test page size of mappingEric B Munson
When MAP_HUGETLB is used, the standard test for a mapping being backed by huge pages fails because the mapping will not be on hugetlbfs. Instead of testing the filesystem backing the mapping, this patch adds a check of reported MMU page size from /proc/self/smaps. get_mapping_page_size returns the page size that is being used for the specified mapping in bytes. Signed-off-by: Eric B Munson <emunson@mgebm.net> Acked-by: Mel Gorman <mel@csn.ul.ie>
2008-10-14utils: Make pool counter manipulation code part of the library APIAdam Litke
The need to set and get pool counters for multiple huge page sizes is about to extend beyond just the libhugetlbfs tests. Move the counter code into hugeutils.c and make the top-level functions part of the libhugetlbfs pool and mount configuration API. This involves altering some function names and prologues to make them more consistent with the existing libhugetlbfs API. We create a new libtestutils.c for test case utilities that depend on linkage to libhugetlbfs. NOTE: This patch will cause the shmoverride test to fail compilation. This is fixed up by the next patch. [apw@shadowen.org: consolidate makefile updates in one place] Signed-off-by: Adam Litke <agl@us.ibm.com> Acked-by: Mel Gorman <mel@csn.ul.ie> Signed-off-by: Andy Whitcroft <apw@shadowen.org>
2008-10-09tests: Avoid call to gethugepagesize it could be unsafeAdam Litke
The function select_pool_counter() may be called by a test that does not link to libhugetlbfs. Therefore it is unsafe to call gethugepagesize because that function may not always be available. Also, the default size is already known so just use the value that has already been determined. Signed-off-by: Adam Litke <agl@us.ibm.com> Signed-off-by: Eric B Munson <ebmunson@us.ibm.com>
2008-09-25testutils: Convert the system default page size to bytesAdam Litke
When reading the system default huge page size from /proc/meminfo, I forgot to convert it back to bytes from kB. This caused the check that invokes single huge page size compatibility mode to always return false. Fix it so we are not comparing apples to kilo-apples. Signed-off-by: Adam Litke <agl@us.ibm.com> Signed-off-by: Eric B Munson <ebmunson@us.ibm.com>
2008-09-11cleanup: Store page sizes in bytesAdam Litke
To avoid confusion, the library should store page sizes in bytes and library interfaces should take page size parameters in bytes as well. Signed-off-by: Adam Litke <agl@us.ibm.com> Acked-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Eric B Munson <ebmunson@us.ibm.com>
2008-08-26tests: Function to check if default mount point uses system default page sizeAdam Litke
Add a function to compare the huge page size displayed in /proc/meminfo (which is the kernel's default size) with the size used by a given mount point. This will be used by the quota test to determine if a special mount option must be used. Signed-off-by: Adam Litke <agl@us.ibm.com>
2008-08-26tests: Make functions to read/set counters values multi-pagesize awareAdam Litke
Many test cases read or set the size of the hugetlb pool or are interested in other pool counters (such as the number of pages reserved). When the kernel supported only one huge page size, /proc/meminfo contained definitive information about the hugetlb pool and /proc/sys/vm/nr_hugepages was used to change the size of the pool. These locations only control the pool for the kernel's default huge page size. The configuration for other page sizes must be done via sysfs. This new complexity can be abstracted by an interface that can get and set pool counters. To maintain backwards compatibility with kernels that have only /proc interfaces, when working with the kernel default huge page size we continue to use /proc. For other sizes, use sysfs. Signed-off-by: Adam Litke <agl@us.ibm.com>
2008-07-30tests: fix error outputsNishanth Aravamudan
I find it annoying that many tests when they FAIL don't output the errno related to the failure point. Fix that up across the tests. A few other small cleanups in there, as well. Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com> Acked-by: David Gibson <dwg@au1.ibm.com>
2008-07-21tests: Handle expected differences brought on by private reservationsAdam Litke
The private reservations feature in new kernels changes the semantics of private huge page mappings in ways that are recognizable by the libhugetlbfs test suite. So far, counters and quota are effected. Reserved private mappings now affect the pool counters in the same way as shared mappings. FS quota is now allocated up-front (mmap time) for private mappings so going over quota will now cause the mmap to fail rather than a SIGBUS at page instantiation time. To preserve backwards compatibility, the test suite must correctly test kernels with and without private reservation support. To achieve this, a function to check the running kernel's semantics is needed. This patch adds a function that attempts to check for private reservations. Use of the pool counters in the manner employed is racy but since this is a test suite and meant to be run by itself, the counters method should work. The function is clearly commented to warn against using it for real programs. Signed-off-by: Adam Litke <agl@us.ibm.com> Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
2008-07-21tests: testutils copy of read_meminfo buffer is too smallAdam Litke
When the hugeutils.c version of read_meminfo was copied to testutils.c, the wrong constant was used to size the buffer used to read /proc/meminfo. This resulted in a smaller (1024B) size instead of 2048B. Some fields were added to /proc/meminfo in a recent kernel and that bumped meminfo over 1024B. Correct the constant usage to bump the size up to 2048B. Signed-off-by: Adam Litke <agl@us.ibm.com> Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
2008-04-15Update check_hugetlb_shm_group to properly read gid from /procEric B Munson
check_hugetlb_shm_get tries to read the value from /proc/vm/sys/hugetlb_shm_group and use that value in a comparison against users gid. This test will fail a majority of the time. This patch ensures that the correct value is used in the comparison by converting the value read from the file from an ascii string to an integer value. Signed-off-by: Eric Munson <ebmunson@us.ibm.com> Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
2008-04-08tests: check uid/gid in tests where it mattersNishanth Aravamudan
`make check`, when run as a normal user, currently produces the following output relevant to permissions: quota (32): mount: Operation not permitted FAIL quota (64): mount: Operation not permitted FAIL This is because we are using mount() when we aren't root. Note, that the counters testcase also will do funny things if the dynamic pool is enabled, but we aren't root (not verified at runtime as I was on SLES10-SP1, but based upon code inspection), as it attempts to change /proc/sys/vm/nr_hugepages. ./run_tests.sh: line 117: /proc/sys/kernel/shmmax: Permission denied set shmmax limit to 335544320 ./run_tests.sh: line 119: /proc/sys/kernel/shmall: Permission denied shm-fork 10 10 (32): FAIL shmget(): Cannot allocate memory shm-fork 10 10 (64): FAIL shmget(): Cannot allocate memory shm-fork 10 20 (32): FAIL shmget(): Cannot allocate memory shm-fork 10 20 (64): FAIL shmget(): Cannot allocate memory shm-getraw 20 /dev/full (32): FAIL shmget(): Cannot allocate memory shm-getraw 20 /dev/full (64): FAIL shmget(): Cannot allocate memory ./run_tests.sh: line 123: /proc/sys/kernel/shmmax: Permission denied ./run_tests.sh: line 124: /proc/sys/kernel/shmall: Permission denied make: *** [stress] Error 1 This is because we are unconditionally writing into a sysctl for the bash errors and within the shm testcases, are using SHM_HUGETLB without verifying our gid is in /proc/sys/vm/hugetlb_shm_group. Add helper functions to testutils to verify we are root and that our gid is the same as that in /proc/sys/vm/hugetlb_shm_group. Now, the same testcase produce: quota (32): Bad configuration: Must be root quota (64): Bad configuration: Must be root counters (32): Bad configuration: Must be root counters (64): Bad configuration: Must be root shm-fork 10 10 (32): Bad configuration: Do not have permission to use SHM_HUGETLB shm-fork 10 10 (64): Bad configuration: Do not have permission to use SHM_HUGETLB shm-fork 10 20 (32): Bad configuration: Do not have permission to use SHM_HUGETLB shm-fork 10 20 (64): Bad configuration: Do not have permission to use SHM_HUGETLB shm-getraw 20 /dev/full (32): Bad configuration: Do not have permission to use SHM_HUGETLB shm-getraw 20 /dev/full (64): Bad configuration: Do not have permission to use SHM_HUGETLB And make no longer fails. Tested as both root and non-root with hugetlbfs mount permissions set to 01777. Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
2008-03-07test_addr_huge(): change ERROR to verbose_printfAndrew Hastings
The heapshrink test case calls test_addr_huge() to verify that the heap shrank. test_addr_huge() emits an error message: ERR: Couldn't find address 0x260000f in /proc/self/maps Change the ERROR() to a verbose_printf() so that a successful test run will not contain an error message. Signed-off-by: Andrew Hastings <abh@cray.com> Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
2008-03-06tests: verify there are enough huge pagesJon Tollefson
tests: Verify there are enough huge pages to run the test. Creates a common function in testutils.c to check the number of free pages against the number of needed pages. Signed-off-by: Jon Tollefson <kniht@linux.vnet.ibm.com> Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
2008-03-04change tests to read /proc/meminfoAndrew Hastings
Move read_meminfo() from tests/counters.c to tests/testutils.c. Change these tests to use read_meminfo("HugePages_Free:") instead of expecting a command line argument for the number of free hugepages: alloc-instantiate-race chunk-overcommit truncate_sigbus_versus_oom Signed-off-by: Andrew Hastings <abh@cray.com> Acked-by: Adam Litke <agl@us.ibm.com> Acked-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
2007-05-14test_utils: fix test_addr_huge for anon pagesAndrew Hastings
If the address being tested resides in an anon region that immediately follows a hugetlb region, test_addr_huge erroneously reports the address as huge. Signed-off-by: Andrew Hastings <abh@cray.com> Acked-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
2007-01-04fix typo in testutilsNishanth Aravamudan
Fix a small typo in testutils.c. Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
2006-12-04Fix the linkshare testcaseNishanth Aravamudan
The linkshare testcase has a number of problems, which cause it to fail unexpectedly. But, because the children's return status was not being checked, we, in error, PASS the test when we should FAIL. Fix this and reorganize the code to make it more sane to parse and debug. Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
2006-11-13Small tweaks to make debugging failing testcases easierDavid Gibson
Two things to make debugging easier: - Use an fflush() after each verbose_printf(), so that line buffering won't mean messages get re-ordered w.r.t. the operations they're describing (this can be particularly confusing when straceing a testcase). - When quiet mode isn't on, print the testname and pid at the beginning of each test from test_init(). This saves a few steps finding the pid when attaching gdb, or strace, or examining /proc/XX/maps. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
2006-06-19cleanup: Remove trailing whitespaceaglitke
Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
2006-06-08sharing: Large import of segment sharing code.aglitke
2006-03-02cleanup() after Ctrl-CDavid Gibson
Add a default SIGINT handler in all the testcases which will call the cleanup() function. In particular this means the shm tests won't leave around a shm segment if Ctrl-Ced. Also remove error checking from the cleanup() functions - it could just lead to dangerous recursion (TEST_BUG() tries to call cleanup()).
2006-02-28Fix cleanup of shm regions in testcasesDavid Gibson
If we received shmid 0 (possible), the SysV shm testcases would fail to clean up the shared memory segment before exiting, usuaully causing spurious failures of later tests. Fix.
2006-02-27Cleanup and bugfixing of stress testsDavid Gibson
A whole bunch of fixes to the stress tests. This makes them more robust (don't fail when they shouldn't), more selective (do fail when they should), produces more helpful diagnostics when they do fail, makes them more quiest when verbosity is not explicitly requested and makes the coding style closer to that of the functional test cases. Particularly notable, I've fixed a serious bug in mmap-cow introduced when I first imported the stress tests - it wasn't actually triggering any COWs at all.
2006-01-09Added copyright notices and LGPL invocation.1.0-pre1David Gibson
2005-12-01Remove default SEGV handler from testcases, to make SEGVs more obviouslyDavid Gibson
worse than other FAILs. Add testcase for gethugepagesize() operating on a /proc/meminfo with no hugepage info (e.g. on kernel without hugepage support).
2005-11-29New important testcases, further work on automatic segment mapping.David Gibson
2005-11-22Various updates.David Gibson
2005-11-22Vaguely working morecore.David Gibson
2005-11-18First cut.David Gibson