summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/kselftest_harness.h
diff options
context:
space:
mode:
authorShuah Khan <skhan@linuxfoundation.org>2021-12-08 10:47:42 -0700
committerShuah Khan <skhan@linuxfoundation.org>2021-12-10 17:50:17 -0700
commit066b34aa5461f6072dbbecb690f4fe446b736ebf (patch)
tree17eb5e4f0c9a0058804ec152fb0b9d360da1df4f /tools/testing/selftests/kselftest_harness.h
parenta738a4ce8421b2187fa5b74bb475eeeb6ec9ac14 (diff)
downloadlinux-066b34aa5461f6072dbbecb690f4fe446b736ebf.tar.bz2
tools: fix ARRAY_SIZE defines in tools and selftests hdrs
tools/include/linux/kernel.h and kselftest_harness.h are missing ifndef guard around ARRAY_SIZE define. Fix them to avoid duplicate define errors during compile when another file defines it. This problem was found when compiling selftests that include a header with ARRAY_SIZE define. ARRAY_SIZE is defined in several selftests. There are about 25+ duplicate defines in various selftests source and header files. Add ARRAY_SIZE to kselftest.h in preparation for removing duplicate ARRAY_SIZE defines from individual test files. Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'tools/testing/selftests/kselftest_harness.h')
-rw-r--r--tools/testing/selftests/kselftest_harness.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
index 79a182cfa43a..471eaa7b3a3f 100644
--- a/tools/testing/selftests/kselftest_harness.h
+++ b/tools/testing/selftests/kselftest_harness.h
@@ -671,7 +671,9 @@
#define EXPECT_STRNE(expected, seen) \
__EXPECT_STR(expected, seen, !=, 0)
+#ifndef ARRAY_SIZE
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+#endif
/* Support an optional handler after and ASSERT_* or EXPECT_*. The approach is
* not thread-safe, but it should be fine in most sane test scenarios.