From 22ea306ce2e49807832317dd4ea111f2c5b9f47d Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Wed, 19 Nov 2014 17:18:35 -0800 Subject: [PATCH] tests: Move ARRAY_LENGTH to a shared header for reuse Signed-off-by: Bryce Harrington Reviewed-by: Marek Chalupa --- tests/presentation-test.c | 2 -- tests/weston-test-runner.h | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/presentation-test.c b/tests/presentation-test.c index b99e93da..f97e5b36 100644 --- a/tests/presentation-test.c +++ b/tests/presentation-test.c @@ -31,8 +31,6 @@ #include "weston-test-client-helper.h" #include "presentation_timing-client-protocol.h" -#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) - static inline void * xzalloc(size_t size) { diff --git a/tests/weston-test-runner.h b/tests/weston-test-runner.h index e1db0409..193b76d3 100644 --- a/tests/weston-test-runner.h +++ b/tests/weston-test-runner.h @@ -41,6 +41,8 @@ struct weston_test { int must_fail; } __attribute__ ((aligned (32))); +#define ARRAY_LENGTH(a) ((int) (sizeof (a) / sizeof (a)[0])) + #define TEST_BEGIN(name, arg) \ static void name(arg) @@ -67,7 +69,7 @@ struct weston_test { #define ARG_TEST(name, ret, test_data) \ TEST_COMMON(name, name, ret, test_data, \ sizeof(test_data[0]), \ - sizeof(test_data) / sizeof (test_data[0])) \ + ARRAY_LENGTH(test_data)) \ TEST_BEGIN(name, void *data) \ #define TEST(name) NO_ARG_TEST(name, 0)