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 <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Kieran Bingham 2021-06-23 23:10:20 +01:00
parent 5c01d54120
commit fc9b226d19
2 changed files with 26 additions and 0 deletions

View file

@ -25,6 +25,7 @@ subdir('v4l2_videodevice')
public_tests = [
['geometry', 'geometry.cpp'],
['public-api', 'public-api.cpp'],
['signal', 'signal.cpp'],
['span', 'span.cpp'],
]

25
test/public-api.cpp Normal file
View file

@ -0,0 +1,25 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Copyright (C) 2021, Google Inc.
*
* public-api.cpp - Public API validation
*/
#include <libcamera/libcamera.h>
#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)