[PATCH i-g-t 1/2] lib/os: Pust igt_require into memory check function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 lib/igt_aux.h                |  2 +-
 lib/intel_os.c               | 25 +++++++++----------------
 tests/eviction_common.c      | 12 ++++++------
 tests/gem_cpu_reloc.c        |  2 +-
 tests/gem_evict_alignment.c  |  4 ++--
 tests/gem_evict_everything.c |  4 ++--
 tests/gem_linear_blits.c     |  4 ++--
 tests/gem_tiled_blits.c      |  4 ++--
 tests/gem_tiled_swapping.c   |  2 +-
 tests/gem_userptr_blits.c    |  2 +-
 10 files changed, 27 insertions(+), 34 deletions(-)

diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index 7bca11c427f3..6c83c53ea10f 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 c8793b97cdf8..c1b88bccfef5 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)
 {
diff --git a/tests/eviction_common.c b/tests/eviction_common.c
index 03d8e8c722ab..52578e2525b6 100644
--- a/tests/eviction_common.c
+++ b/tests/eviction_common.c
@@ -77,7 +77,7 @@ static int minor_evictions(int fd, struct igt_eviction_test_ops *ops,
 
 	total_surfaces = gem_aperture_size(fd) / surface_size + 1;
 	igt_require(nr_surfaces < total_surfaces);
-	igt_require(intel_check_memory(total_surfaces, surface_size, CHECK_RAM));
+	intel_require_memory(total_surfaces, surface_size, CHECK_RAM);
 
 	bo = malloc((nr_surfaces + total_surfaces)*sizeof(*bo));
 	igt_assert(bo);
@@ -112,7 +112,7 @@ static int major_evictions(int fd, struct igt_eviction_test_ops *ops,
 	uint32_t *bo;
 	int ret;
 
-	igt_require(intel_check_memory(nr_surfaces, surface_size, CHECK_RAM));
+	intel_require_memory(nr_surfaces, surface_size, CHECK_RAM);
 
 	bo = malloc(nr_surfaces*sizeof(*bo));
 	igt_assert(bo);
@@ -141,12 +141,12 @@ static int swapping_evictions(int fd, struct igt_eviction_test_ops *ops,
 	uint32_t *bo;
 	int i, n, pass, ret;
 
-	igt_require(intel_check_memory(working_surfaces, surface_size, CHECK_RAM));
+	intel_require_memory(working_surfaces, surface_size, CHECK_RAM);
 
 	if (trash_surfaces < working_surfaces)
 		trash_surfaces = working_surfaces;
 
-	igt_require(intel_check_memory(trash_surfaces, surface_size, CHECK_RAM | CHECK_SWAP));
+	intel_require_memory(trash_surfaces, surface_size, CHECK_RAM | CHECK_SWAP);
 
 	bo = malloc(trash_surfaces*sizeof(*bo));
 	igt_assert(bo);
@@ -179,7 +179,7 @@ static int forking_evictions(int fd, struct igt_eviction_test_ops *ops,
 	int num_threads = sysconf(_SC_NPROCESSORS_ONLN);
 	int bo_count;
 
-	igt_require(intel_check_memory(working_surfaces, surface_size, CHECK_RAM));
+	intel_require_memory(working_surfaces, surface_size, CHECK_RAM);
 
 	if (flags & FORKING_EVICTIONS_SWAPPING) {
 		bo_count = trash_surfaces;
@@ -190,7 +190,7 @@ static int forking_evictions(int fd, struct igt_eviction_test_ops *ops,
 		bo_count = working_surfaces;
 
 	igt_assert(working_surfaces <= bo_count);
-	igt_require(intel_check_memory(bo_count, surface_size, CHECK_RAM | CHECK_SWAP));
+	intel_require_memory(bo_count, surface_size, CHECK_RAM | CHECK_SWAP);
 
 	bo = malloc(bo_count*sizeof(*bo));
 	igt_assert(bo);
diff --git a/tests/gem_cpu_reloc.c b/tests/gem_cpu_reloc.c
index e7e0fc739feb..1413ebfca01d 100644
--- a/tests/gem_cpu_reloc.c
+++ b/tests/gem_cpu_reloc.c
@@ -183,7 +183,7 @@ igt_simple_main
 	if (igt_run_in_simulation())
 		count = 10;
 
-	igt_require(intel_check_memory(1+count, 4096, CHECK_RAM));
+	intel_require_memory(1+count, 4096, CHECK_RAM);
 
 	handles = malloc (count * sizeof(uint32_t));
 	igt_assert(handles);
diff --git a/tests/gem_evict_alignment.c b/tests/gem_evict_alignment.c
index e814f36cc044..e2d42a04058d 100644
--- a/tests/gem_evict_alignment.c
+++ b/tests/gem_evict_alignment.c
@@ -134,7 +134,7 @@ static void minor_evictions(int fd, int size, int count)
 	uint32_t *bo, *sel;
 	int n, m, alignment, pass, fail;
 
-	igt_require(intel_check_memory(2*count, size, CHECK_RAM));
+	intel_require_memory(2 * count, size, CHECK_RAM);
 
 	bo = malloc(3*count*sizeof(*bo));
 	igt_assert(bo);
@@ -164,7 +164,7 @@ static void major_evictions(int fd, int size, int count)
 	int n, m, loop, alignment, max;
 	uint32_t *bo;
 
-	igt_require(intel_check_memory(count, size, CHECK_RAM));
+	intel_require_memory(count, size, CHECK_RAM);
 
 	bo = malloc(count*sizeof(*bo));
 	igt_assert(bo);
diff --git a/tests/gem_evict_everything.c b/tests/gem_evict_everything.c
index db8023730274..4b7768c1f948 100644
--- a/tests/gem_evict_everything.c
+++ b/tests/gem_evict_everything.c
@@ -151,7 +151,7 @@ static void test_forking_evictions(int fd, int size, int count,
 	int trash_count;
 
 	trash_count = intel_get_total_ram_mb() * 11 / 10;
-	igt_require(intel_check_memory(trash_count, size, CHECK_RAM | CHECK_SWAP));
+	intel_require_memory(trash_count, size, CHECK_RAM | CHECK_SWAP);
 
 	forking_evictions(fd, &fault_ops, size, count, trash_count, flags);
 }
@@ -161,7 +161,7 @@ static void test_swapping_evictions(int fd, int size, int count)
 	int trash_count;
 
 	trash_count = intel_get_total_ram_mb() * 11 / 10;
-	igt_require(intel_check_memory(trash_count, size, CHECK_RAM | CHECK_SWAP));
+	intel_require_memory(trash_count, size, CHECK_RAM | CHECK_SWAP);
 
 	swapping_evictions(fd, &fault_ops, size, count, trash_count);
 }
diff --git a/tests/gem_linear_blits.c b/tests/gem_linear_blits.c
index 0ef583f65e11..78c539ae8346 100644
--- a/tests/gem_linear_blits.c
+++ b/tests/gem_linear_blits.c
@@ -268,7 +268,7 @@ int main(int argc, char **argv)
 
 		count = 3 * gem_aperture_size(fd) / (1024*1024) / 2;
 		igt_require(count > 1);
-		igt_require(intel_check_memory(count, sizeof(linear), CHECK_RAM));
+		intel_require_memory(count, sizeof(linear), CHECK_RAM);
 		run_test(fd, count);
 	}
 
@@ -279,7 +279,7 @@ int main(int argc, char **argv)
 
 		count = 3 * gem_aperture_size(fd) / (1024*1024) / 2;
 		igt_require(count > 1);
-		igt_require(intel_check_memory(count, sizeof(linear), CHECK_RAM));
+		intel_require_memory(count, sizeof(linear), CHECK_RAM);
 		igt_fork_signal_helper();
 		run_test(fd, count);
 		igt_stop_signal_helper();
diff --git a/tests/gem_tiled_blits.c b/tests/gem_tiled_blits.c
index 02a46958af5e..76d256f4d8d8 100644
--- a/tests/gem_tiled_blits.c
+++ b/tests/gem_tiled_blits.c
@@ -218,7 +218,7 @@ int main(int argc, char **argv)
 
 		count = 3 * gem_aperture_size(fd) / (1024*1024) / 2;
 		count += (count & 1) == 0;
-		igt_require(intel_check_memory(count, 1024*1024, CHECK_RAM));
+		intel_require_memory(count, 1024*1024, CHECK_RAM);
 
 		run_test(count);
 	}
@@ -230,7 +230,7 @@ int main(int argc, char **argv)
 
 		count = 3 * gem_aperture_size(fd) / (1024*1024) / 2;
 		count += (count & 1) == 0;
-		igt_require(intel_check_memory(count, 1024*1024, CHECK_RAM));
+		intel_require_memory(count, 1024*1024, CHECK_RAM);
 
 		igt_fork_signal_helper();
 		run_test(count);
diff --git a/tests/gem_tiled_swapping.c b/tests/gem_tiled_swapping.c
index add0c5adaaf2..4520d4734c03 100644
--- a/tests/gem_tiled_swapping.c
+++ b/tests/gem_tiled_swapping.c
@@ -169,7 +169,7 @@ igt_simple_main
 		(long)intel_get_avail_ram_mb(),
 		(long)intel_get_total_ram_mb(),
 		(long)intel_get_total_swap_mb());
-	igt_require(intel_check_memory(count, 1024*1024, CHECK_RAM | CHECK_SWAP));
+	intel_require_memory(count, 1024*1024, CHECK_RAM | CHECK_SWAP);
 
 	for (n = 0; n < count; n++) {
 		bo_handles[n] = create_bo_and_fill(fd);
diff --git a/tests/gem_userptr_blits.c b/tests/gem_userptr_blits.c
index 35394531f3d2..886a62993a89 100644
--- a/tests/gem_userptr_blits.c
+++ b/tests/gem_userptr_blits.c
@@ -891,7 +891,7 @@ static int test_coherency(int fd, int count)
 	uint32_t start = 0;
 	int i, ret;
 
-	igt_require(intel_check_memory(count, sizeof(linear), CHECK_RAM));
+	intel_require_memory(count, sizeof(linear), CHECK_RAM);
 	igt_info("Using 2x%d 1MiB buffers\n", count);
 
 	ret = posix_memalign((void **)&memory, PAGE_SIZE, count*sizeof(linear));
-- 
2.1.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux