summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-11-18 12:04:29 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2013-11-18 12:05:15 +0000
commite99e643ed1f2856109426f791a7615ee122d7c42 (patch)
treefaf740cbb284796d24209349b22872248467d112 /test
parentb6924161108214b4e50c25f4168564ead4000430 (diff)
tests: Avoid dependence on undefined C
Right-shifting by a negative value is undefined. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'test')
-rw-r--r--test/basic-copyarea-size.c2
-rw-r--r--test/basic-copyarea.c7
-rw-r--r--test/basic-fillrect.c7
-rw-r--r--test/basic-putimage.c7
-rw-r--r--test/basic-rectangle.c6
-rw-r--r--test/basic-stress.c2
-rw-r--r--test/basic-string.c6
-rw-r--r--test/mixed-stress.c2
-rw-r--r--test/render-composite-solid-mask.c6
-rw-r--r--test/render-composite-solid.c6
-rw-r--r--test/render-copy-alphaless.c6
-rw-r--r--test/render-copyarea-mask.c6
-rw-r--r--test/render-copyarea-size.c2
-rw-r--r--test/render-copyarea.c6
-rw-r--r--test/render-fill-copy.c6
-rw-r--r--test/render-fill.c6
-rw-r--r--test/render-trapezoid-image.c6
-rw-r--r--test/render-trapezoid.c6
-rw-r--r--test/test.h3
19 files changed, 24 insertions, 74 deletions
diff --git a/test/basic-copyarea-size.c b/test/basic-copyarea-size.c
index 732bb816..5e3373d9 100644
--- a/test/basic-copyarea-size.c
+++ b/test/basic-copyarea-size.c
@@ -57,7 +57,7 @@ int main(int argc, char **argv)
printf("size=%d\n", size);
for (i = 0; i <= DEFAULT_ITERATIONS; i++) {
- int reps = 1 << i;
+ int reps = REPS(i);
do {
int sx = rand() % (2*size) - size;
int sy = rand() % (2*size) - size;
diff --git a/test/basic-copyarea.c b/test/basic-copyarea.c
index 025b8848..8b64199d 100644
--- a/test/basic-copyarea.c
+++ b/test/basic-copyarea.c
@@ -282,13 +282,10 @@ int main(int argc, char **argv)
test_init(&test, argc, argv);
for (i = 0; i <= DEFAULT_ITERATIONS; i++) {
- int reps = 1 << i;
- int sets = 1 << (12 - i);
+ int reps = REPS(i);
+ int sets = SETS(i);
enum target t;
- if (sets < 2)
- sets = 2;
-
for (t = TARGET_FIRST; t <= TARGET_LAST; t++) {
pixel_tests(&test, reps, sets, t);
area_tests(&test, reps, sets, t);
diff --git a/test/basic-fillrect.c b/test/basic-fillrect.c
index 67d7067e..186604ce 100644
--- a/test/basic-fillrect.c
+++ b/test/basic-fillrect.c
@@ -246,13 +246,10 @@ int main(int argc, char **argv)
test_init(&test, argc, argv);
for (i = 0; i <= DEFAULT_ITERATIONS; i++) {
- int reps = 1 << i;
- int sets = 1 << (12 - i);
+ int reps = REPS(i);
+ int sets = SETS(i);
enum target t;
- if (sets < 2)
- sets = 2;
-
for (t = TARGET_FIRST; t <= TARGET_LAST; t++) {
pixel_tests(&test, reps, sets, t);
area_tests(&test, reps, sets, t);
diff --git a/test/basic-putimage.c b/test/basic-putimage.c
index 5d689088..10053bc4 100644
--- a/test/basic-putimage.c
+++ b/test/basic-putimage.c
@@ -262,13 +262,10 @@ int main(int argc, char **argv)
test_init(&test, argc, argv);
for (i = 0; i <= DEFAULT_ITERATIONS; i++) {
- int reps = 1 << i;
- int sets = 1 << (12 - i);
+ int reps = REPS(i);
+ int sets = SETS(i);
enum target t;
- if (sets < 2)
- sets = 2;
-
for (t = TARGET_FIRST; t <= TARGET_LAST; t++) {
pixel_tests(&test, reps, sets, t, 0);
area_tests(&test, reps, sets, t, 0);
diff --git a/test/basic-rectangle.c b/test/basic-rectangle.c
index 8f78bba2..8de200c1 100644
--- a/test/basic-rectangle.c
+++ b/test/basic-rectangle.c
@@ -204,13 +204,9 @@ int main(int argc, char **argv)
test_init(&test, argc, argv);
for (i = 0; i <= DEFAULT_ITERATIONS; i++) {
- int reps = 1 << i;
- int sets = 1 << (12 - i);
+ int reps = REPS(i), sets = SETS(i);
enum target t;
- if (sets < 2)
- sets = 2;
-
for (t = TARGET_FIRST; t <= TARGET_LAST; t++) {
zrect_tests(&test, reps, sets, t);
hrect_tests(&test, reps, sets, t);
diff --git a/test/basic-stress.c b/test/basic-stress.c
index 56571734..4b42865c 100644
--- a/test/basic-stress.c
+++ b/test/basic-stress.c
@@ -147,7 +147,7 @@ int main(int argc, char **argv)
test_init(&test, argc, argv);
for (i = 0; i <= DEFAULT_ITERATIONS; i++) {
- int iterations = 1 << i;
+ int iterations = REPS(i);
rect_tests(&test, iterations, 0);
rect_tests(&test, iterations, 1);
}
diff --git a/test/basic-string.c b/test/basic-string.c
index 9f59c91d..1e24b291 100644
--- a/test/basic-string.c
+++ b/test/basic-string.c
@@ -86,13 +86,9 @@ int main(int argc, char **argv)
test_init(&test, argc, argv);
for (i = 0; i <= DEFAULT_ITERATIONS; i++) {
- int reps = 1 << i;
- int sets = 1 << (12 - i);
+ int reps = REPS(i), sets = SETS(i);
enum target t;
- if (sets < 2)
- sets = 2;
-
for (t = TARGET_FIRST; t <= TARGET_LAST; t++) {
string_tests(&test, reps, sets, t);
}
diff --git a/test/mixed-stress.c b/test/mixed-stress.c
index 42e2c082..a315a9c4 100644
--- a/test/mixed-stress.c
+++ b/test/mixed-stress.c
@@ -200,7 +200,7 @@ int main(int argc, char **argv)
test_init(&test, argc, argv);
for (i = 0; i <= DEFAULT_ITERATIONS; i++) {
- int iterations = 1 << i;
+ int iterations = REPS(i);
rect_tests(&test, iterations, 0);
rect_tests(&test, iterations, 1);
}
diff --git a/test/render-composite-solid-mask.c b/test/render-composite-solid-mask.c
index b86512c8..925df3ca 100644
--- a/test/render-composite-solid-mask.c
+++ b/test/render-composite-solid-mask.c
@@ -107,13 +107,9 @@ int main(int argc, char **argv)
test_init(&test, argc, argv);
for (i = 0; i <= DEFAULT_ITERATIONS; i++) {
- int reps = 1 << i;
- int sets = 1 << (12 - i);
+ int reps = REPS(i), sets = SETS(i);
enum target t;
- if (sets < 2)
- sets = 2;
-
for (t = TARGET_FIRST; t <= TARGET_LAST; t++)
ref_tests(&test, reps, sets, t);
}
diff --git a/test/render-composite-solid.c b/test/render-composite-solid.c
index 6609c4bc..b4742af3 100644
--- a/test/render-composite-solid.c
+++ b/test/render-composite-solid.c
@@ -238,13 +238,9 @@ int main(int argc, char **argv)
test_init(&test, argc, argv);
for (i = 0; i <= DEFAULT_ITERATIONS; i++) {
- int reps = 1 << i;
- int sets = 1 << (12 - i);
+ int reps = REPS(i), sets = SETS(i);
enum target t;
- if (sets < 2)
- sets = 2;
-
for (t = TARGET_FIRST; t <= TARGET_LAST; t++) {
pixel_tests(&test, reps, sets, t);
area_tests(&test, reps, sets, t);
diff --git a/test/render-copy-alphaless.c b/test/render-copy-alphaless.c
index b9687049..5f1487eb 100644
--- a/test/render-copy-alphaless.c
+++ b/test/render-copy-alphaless.c
@@ -270,11 +270,7 @@ int main(int argc, char **argv)
test_init(&test, argc, argv);
for (i = 0; i <= DEFAULT_ITERATIONS; i++) {
- int reps = 1 << i;
- int sets = 1 << (12 - i);
-
- if (sets < 2)
- sets = 2;
+ int reps = REPS(i), sets = SETS(i);
pixel_tests(&test, reps, sets, PIXMAP);
area_tests(&test, reps, sets, PIXMAP);
diff --git a/test/render-copyarea-mask.c b/test/render-copyarea-mask.c
index c8bb7151..5116c161 100644
--- a/test/render-copyarea-mask.c
+++ b/test/render-copyarea-mask.c
@@ -149,13 +149,9 @@ int main(int argc, char **argv)
test_init(&test, argc, argv);
for (i = 0; i <= DEFAULT_ITERATIONS; i++) {
- int reps = 1 << i;
- int sets = 1 << (12 - i);
+ int reps = REPS(i), sets = SETS(i);
enum target t;
- if (sets < 2)
- sets = 2;
-
for (t = TARGET_FIRST; t <= TARGET_LAST; t++) {
rect_tests(&test, reps, sets, t, 0);
if (t != PIXMAP)
diff --git a/test/render-copyarea-size.c b/test/render-copyarea-size.c
index 65fb6caf..55e3b56b 100644
--- a/test/render-copyarea-size.c
+++ b/test/render-copyarea-size.c
@@ -65,7 +65,7 @@ int main(int argc, char **argv)
printf("size=%d\n", size);
for (i = 0; i <= DEFAULT_ITERATIONS; i++) {
- int reps = 1 << i;
+ int reps = REPS(i);
do {
int sx = rand() % (2*size) - size;
int sy = rand() % (2*size) - size;
diff --git a/test/render-copyarea.c b/test/render-copyarea.c
index bcab553b..8c00b343 100644
--- a/test/render-copyarea.c
+++ b/test/render-copyarea.c
@@ -305,13 +305,9 @@ int main(int argc, char **argv)
test_init(&test, argc, argv);
for (i = 0; i <= DEFAULT_ITERATIONS; i++) {
- int reps = 1 << i;
- int sets = 1 << (12 - i);
+ int reps = REPS(i), sets = SETS(i);
enum target t;
- if (sets < 2)
- sets = 2;
-
for (t = TARGET_FIRST; t <= TARGET_LAST; t++) {
pixel_tests(&test, reps, sets, t);
area_tests(&test, reps, sets, t);
diff --git a/test/render-fill-copy.c b/test/render-fill-copy.c
index bc4a734d..45551b22 100644
--- a/test/render-fill-copy.c
+++ b/test/render-fill-copy.c
@@ -262,13 +262,9 @@ int main(int argc, char **argv)
test_init(&test, argc, argv);
for (i = 0; i <= DEFAULT_ITERATIONS; i++) {
- int reps = 1 << i;
- int sets = 1 << (12 - i);
+ int reps = REPS(i), sets = SETS(i);
enum target t;
- if (sets < 2)
- sets = 2;
-
for (t = TARGET_FIRST; t <= TARGET_LAST; t++) {
pixel_tests(&test, reps, sets, t);
area_tests(&test, reps, sets, t);
diff --git a/test/render-fill.c b/test/render-fill.c
index 27d565bc..54be1a38 100644
--- a/test/render-fill.c
+++ b/test/render-fill.c
@@ -230,13 +230,9 @@ int main(int argc, char **argv)
test_init(&test, argc, argv);
for (i = 0; i <= DEFAULT_ITERATIONS; i++) {
- int reps = 1 << i;
- int sets = 1 << (12 - i);
+ int reps = REPS(i), sets = SETS(i);
enum target t;
- if (sets < 2)
- sets = 2;
-
for (t = TARGET_FIRST; t <= TARGET_LAST; t++) {
pixel_tests(&test, reps, sets, t);
area_tests(&test, reps, sets, t);
diff --git a/test/render-trapezoid-image.c b/test/render-trapezoid-image.c
index c794cbb8..c25661d1 100644
--- a/test/render-trapezoid-image.c
+++ b/test/render-trapezoid-image.c
@@ -585,11 +585,7 @@ int main(int argc, char **argv)
test_init(&test, argc, argv);
for (i = 0; i <= DEFAULT_ITERATIONS; i++) {
- int reps = 1 << i;
- int sets = 1 << (12 - i);
-
- if (sets < 2)
- sets = 2;
+ int reps = REPS(i), SETS(i);
for (target = TARGET_FIRST; target <= TARGET_LAST; target++) {
pixel_tests(&test, reps, sets, target, 0);
diff --git a/test/render-trapezoid.c b/test/render-trapezoid.c
index f7fd5bbf..811d9093 100644
--- a/test/render-trapezoid.c
+++ b/test/render-trapezoid.c
@@ -414,11 +414,7 @@ int main(int argc, char **argv)
test_init(&test, argc, argv);
for (i = 0; i <= DEFAULT_ITERATIONS; i++) {
- int reps = 1 << i;
- int sets = 1 << (12 - i);
-
- if (sets < 2)
- sets = 2;
+ int reps = REPS(i), sets = SETS(i);
for (target = TARGET_FIRST; target <= TARGET_LAST; target++) {
pixel_tests(&test, reps, sets, target);
diff --git a/test/test.h b/test/test.h
index 7ef4dca4..3cd94576 100644
--- a/test/test.h
+++ b/test/test.h
@@ -120,4 +120,7 @@ double test_timer_stop(struct test_display *t, struct timespec *tv);
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#endif
+#define REPS(I) (1 << (I))
+#define SETS(I) ((I) < 12 ? 1 << (12 - (I)) : 2)
+
#endif