Skip to contentSkip to conversation

tests: Forbid to run the blit tests with count of 1

PATCH New Damien Lespiau 1 participant 1 message Feb 12, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests: Forbid to run the blit tests with count of 1

From: Damien Lespiau <[email protected]>

Invoking say,

sudo ./tests/gem_render_linear_blits 1

does not make a lot of sense as we're creating a single bo. The test does not yell at you and passes, even if the rendercopy function does not do anything. This makes it quite harmful when trying to debug rendercopy without realizing that count is the number of allocated bos and must be >= 2.

---
 tests/gem_linear_blits.c        | 4 ++++
 tests/gem_render_linear_blits.c | 5 +++++
 tests/gem_render_tiled_blits.c  | 5 +++++
 tests/gem_tiled_blits.c         | 3 +++
 4 files changed, 17 insertions(+)
tests/gem_linear_blits.c +4 -0
index fe15f1d..ec2dc56 100644
@@ -189,6 +189,10 @@ int main(int argc, char **argv)
 		count = atoi(argv[1]);
 	if (count == 0)
 		count = 3 * gem_aperture_size(fd) / (1024*1024) / 2;
+	else if (count < 2) {
+		fprintf(stderr, "count must be >= 2\n");
+		return 1;
+	}
 
 	if (count > intel_get_total_ram_mb() * 9 / 10) {
 		count = intel_get_total_ram_mb() * 9 / 10;
tests/gem_render_linear_blits.c +5 -0
index 8ba24a3..a7e0189 100644
@@ -85,6 +85,11 @@ int main(int argc, char **argv)
 		count = atoi(argv[1]);
 	if (count == 0)
 		count = 3 * gem_aperture_size(fd) / SIZE / 2;
+	else if (count < 2) {
+		fprintf(stderr, "count must be >= 2\n");
+		return 1;
+	}
+
 	printf("Using %d 1MiB buffers\n", count);
 
 	bo = malloc(sizeof(*bo)*count);
tests/gem_render_tiled_blits.c +5 -0
index 31b2ee1..626e652 100644
@@ -88,6 +88,11 @@ int main(int argc, char **argv)
 		count = atoi(argv[1]);
 	if (count == 0)
 		count = 3 * gem_aperture_size(fd) / SIZE / 2;
+	else if (count < 2) {
+		fprintf(stderr, "count must be >= 2\n");
+		return 1;
+	}
+
 	printf("Using %d 1MiB buffers\n", count);
 
 	buf = malloc(sizeof(*buf)*count);
tests/gem_tiled_blits.c +3 -0
index a6d5555..bb43976 100644
@@ -132,6 +132,9 @@ int main(int argc, char **argv)
 	if (count == 0) {
 		count = 3 * gem_aperture_size(fd) / (1024*1024) / 2;
 		count += (count & 1) == 0;
+	} else if (count < 2) {
+		fprintf(stderr, "count must be >= 2\n");
+		return 1;
 	}
 
 	if (count > intel_get_total_ram_mb() * 9 / 10) {
Signature · 1 line
1.7.11.7