From fc9b226d19b59e965b1746ba5dc6fc603de3b591 Mon Sep 17 00:00:00 2001 From: Kieran Bingham Date: Wed, 23 Jun 2021 23:10:20 +0100 Subject: test: Ensure LIBCAMERA_BASE_PRIVATE isn't public If LIBCAMERA_BASE_PRIVATE is ever exposed on the libcamera public dependencies, then the private.h header protection will be circumvented. Provide a test which will fail (at compile time) if the LIBCAMERA_BASE_PRIVATE define ever leaks to the public dependencies. Reviewed-by: Paul Elder Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham --- test/meson.build | 1 + test/public-api.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 test/public-api.cpp diff --git a/test/meson.build b/test/meson.build index 73eb44d0..2c3e7654 100644 --- a/test/meson.build +++ b/test/meson.build @@ -25,6 +25,7 @@ subdir('v4l2_videodevice') public_tests = [ ['geometry', 'geometry.cpp'], + ['public-api', 'public-api.cpp'], ['signal', 'signal.cpp'], ['span', 'span.cpp'], ] diff --git a/test/public-api.cpp b/test/public-api.cpp new file mode 100644 index 00000000..a1cebcf9 --- /dev/null +++ b/test/public-api.cpp @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2021, Google Inc. + * + * public-api.cpp - Public API validation + */ + +#include + +#include "test.h" + +class PublicAPITest : public Test +{ + int run() + { +#ifdef LIBCAMERA_BASE_PRIVATE +#error "Public interfaces should not be exposed to LIBCAMERA_BASE_PRIVATE" + return TestFail; +#else + return TestPass; +#endif + } +}; + +TEST_REGISTER(PublicAPITest) -- cgit v1.2.1