summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2014-11-17 14:43:33 +0100
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-11-17 14:43:33 +0100
commita535cdedfbd280c5e07be1c2445e09973836509a (patch)
tree22239380a3016c00a09249c9d4c5c0f32bf16055 /lib
parentaa63fc740c510ed44c1a8dc0fc00f0c92c0581a2 (diff)
lib/os: Pust igt_require into memory check function
More in line with the usual igt pattern and simplifies the code - every called just wrapped it in igt_require. Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/igt_aux.h2
-rw-r--r--lib/intel_os.c25
2 files changed, 10 insertions, 17 deletions
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index 7bca11c4..6c83c53e 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -82,7 +82,7 @@ uint64_t intel_get_avail_ram_mb(void);
uint64_t intel_get_total_ram_mb(void);
uint64_t intel_get_total_swap_mb(void);
-bool intel_check_memory(uint32_t count, uint32_t size, unsigned mode);
+void intel_require_memory(uint32_t count, uint32_t size, unsigned mode);
#define CHECK_RAM 0x1
#define CHECK_SWAP 0x2
diff --git a/lib/intel_os.c b/lib/intel_os.c
index c8793b97..c1b88bcc 100644
--- a/lib/intel_os.c
+++ b/lib/intel_os.c
@@ -193,7 +193,7 @@ intel_get_total_swap_mb(void)
}
/**
- * intel_check_memory:
+ * intel_require_memory:
* @count: number of surfaces that will be created
* @size: the size in bytes of each surface
* @mode: a bitfield declaring whether the test will be run in RAM or in SWAP
@@ -209,11 +209,10 @@ intel_get_total_swap_mb(void)
* for their tests. oom-killer tests should only run if this reports that
* there is not enough RAM + SWAP!
*
- * Returns:
- * Whether the estimated amount of memory required for the objects
- * fits in the available memory on the system.
+ * If there is not enough RAM this function calls igt_skip with an appropriate
+ * message. It only ever returns if the requirement is fullfilled.
*/
-bool intel_check_memory(uint32_t count, uint32_t size, unsigned mode)
+void intel_require_memory(uint32_t count, uint32_t size, unsigned mode)
{
/* rough estimate of how many bytes the kernel requires to track each object */
#define KERNEL_BO_OVERHEAD 512
@@ -235,19 +234,13 @@ bool intel_check_memory(uint32_t count, uint32_t size, unsigned mode)
total += intel_get_total_swap_mb();
total *= 1024 * 1024;
- if (total <= required) {
- igt_log(IGT_LOG_INFO,
- "Estimated that we need %llu bytes for the test, but only have %llu bytes available (%s%s)\n",
- (long long)required, (long long)total,
- mode & (CHECK_RAM | CHECK_SWAP) ? "RAM" : "",
- mode & CHECK_SWAP ? " + swap": "");
- return 0;
- }
-
- return 1;
+ igt_skip_on_f(total <= required,
+ "Estimated that we need %llu bytes for the test, but only have %llu bytes available (%s%s)\n",
+ (long long)required, (long long)total,
+ mode & (CHECK_RAM | CHECK_SWAP) ? "RAM" : "",
+ mode & CHECK_SWAP ? " + swap": "");
}
-
void
intel_purge_vm_caches(void)
{