diff options
author | Robin Krahl <me@robin-krahl.de> | 2018-07-05 22:44:35 +0200 |
---|---|---|
committer | Robin Krahl <me@robin-krahl.de> | 2018-07-05 22:50:51 +0200 |
commit | 63013dee539b33c682dd46ae4a086b2f75f46f16 (patch) | |
tree | 74416caef4a38ea3dfeefb967e3d50f2c0e0b727 | |
parent | 494f5b3c285bf4b42c57e85f3b7b7e26620378e8 (diff) | |
download | libnitrokey-63013dee539b33c682dd46ae4a086b2f75f46f16.tar.gz libnitrokey-63013dee539b33c682dd46ae4a086b2f75f46f16.tar.bz2 |
Add a test to ensure valid C code in the C API
All current tests are written in C++. Therefore C++-only code in the C
API might not be detected by the tests. This patch adds a minimal test
written in C that only includes the C API header. This should make sure
that the C API code is valid.
The new test is called `test_minimal.c` and is added to the CMake
COMPILE_OFFLINE_TESTS option.
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | unittest/test_minimal.c | 28 |
2 files changed, 32 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 06ab448..43d15df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -178,6 +178,10 @@ IF(COMPILE_OFFLINE_TESTS) #run with 'make test' or 'ctest' include (CTest) add_test (runs test_offline) + + add_executable(test_minimal unittest/test_minimal.c) + target_link_libraries(test_minimal ${EXTRA_LIBS} nitrokey) + add_test(minimal test_minimal) ENDIF() IF (COMPILE_TESTS) diff --git a/unittest/test_minimal.c b/unittest/test_minimal.c new file mode 100644 index 0000000..3cf3dd7 --- /dev/null +++ b/unittest/test_minimal.c @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2018 Nitrokey UG + * + * This file is part of libnitrokey. + * + * libnitrokey is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * libnitrokey is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with libnitrokey. If not, see <http://www.gnu.org/licenses/>. + * + * SPDX-License-Identifier: LGPL-3.0 + */ + +#include "../NK_C_API.h" + +// This test is only intended to make sure that the C API header can be +// compiled by a C compiler. (All other tests are written in C++.) +int main() { + return 0; +} |