From 7e73f1a972f13699c3c2cb80ad50c834b8a8464e Mon Sep 17 00:00:00 2001 From: Andreas Cord-Landwehr Date: Sat, 26 Sep 2020 10:32:56 +0000 Subject: Introduce plausibility check for outbound licenes When creating a library or executable, several source files are combined into a binary artifact that has an outbound license of its own. This test generator allows to check if the combined source files are compatible with the desired outbound license. Requirements for using these tests: - input source files must contain the SPDX-License-Information tag - python3 must be available - the "reuse spdx" tool must be available --- tests/CMakeLists.txt | 5 ++ tests/ECMCheckOutboundLicenseTest/CMakeLists.txt | 88 ++++++++++++++++++++++ .../run_test.cmake.config | 0 .../testdata/BSD-2-Clause.cpp | 6 ++ .../testdata/GPL-2.0-only.cpp | 6 ++ .../testdata/GPL-2.0-or-later.cpp | 6 ++ .../testdata/GPL-3.0-only.cpp | 6 ++ .../testdata/LGPL-2.1-or-later.cpp | 6 ++ .../testdata/LGPL-3.0-only.cpp | 6 ++ 9 files changed, 129 insertions(+) create mode 100644 tests/ECMCheckOutboundLicenseTest/CMakeLists.txt create mode 100644 tests/ECMCheckOutboundLicenseTest/run_test.cmake.config create mode 100644 tests/ECMCheckOutboundLicenseTest/testdata/BSD-2-Clause.cpp create mode 100644 tests/ECMCheckOutboundLicenseTest/testdata/GPL-2.0-only.cpp create mode 100644 tests/ECMCheckOutboundLicenseTest/testdata/GPL-2.0-or-later.cpp create mode 100644 tests/ECMCheckOutboundLicenseTest/testdata/GPL-3.0-only.cpp create mode 100644 tests/ECMCheckOutboundLicenseTest/testdata/LGPL-2.1-or-later.cpp create mode 100644 tests/ECMCheckOutboundLicenseTest/testdata/LGPL-3.0-only.cpp (limited to 'tests') diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 866df5bb..1901ca16 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -60,6 +60,11 @@ endmacro() list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/find-modules) +# enforce finding of ReuseTool in parent scope of module, beause +# only here the module path can point into the source directory +find_package(ReuseTool) +add_subdirectory(ECMCheckOutboundLicenseTest) + # Skip if PyQt not available find_file(SIP_Qt5Core_Mod_FILE NAMES QtCoremod.sip diff --git a/tests/ECMCheckOutboundLicenseTest/CMakeLists.txt b/tests/ECMCheckOutboundLicenseTest/CMakeLists.txt new file mode 100644 index 00000000..1aab9a58 --- /dev/null +++ b/tests/ECMCheckOutboundLicenseTest/CMakeLists.txt @@ -0,0 +1,88 @@ +set(ECM_MODULE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../modules) +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../modules) +include(ECMCheckOutboundLicense) + +# check relative and absolute input paths +ecm_check_outbound_license( +LICENSES LGPL-2.1-only +TEST_NAME absolute-path-handling +FILES + testdata/BSD-2-Clause.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/testdata/LGPL-2.1-or-later.cpp +) + +# check test case generation wihout TEST_NAME statement +ecm_check_outbound_license( +LICENSES LGPL-2.1-only +FILES + testdata/BSD-2-Clause.cpp +) + +# check multi license case +ecm_check_outbound_license( +LICENSES LGPL-2.1-only GPL-3.0-only +TEST_NAME multiple-licenses +FILES + testdata/BSD-2-Clause.cpp +) + + +# check for valid LGPL-2.1-only +ecm_check_outbound_license( +LICENSES LGPL-2.1-only +TEST_NAME valid-LGPL-2.1-only +FILES + testdata/BSD-2-Clause.cpp + testdata/LGPL-2.1-or-later.cpp +) + +# check for valid LGPL-3.0-only +ecm_check_outbound_license( +LICENSES LGPL-3.0-only +TEST_NAME valid-LGPL-3.0-only +FILES + testdata/BSD-2-Clause.cpp + testdata/LGPL-2.1-or-later.cpp + testdata/LGPL-3.0-only.cpp +) + +# check for valid GPL-2.0-only +ecm_check_outbound_license( +LICENSES GPL-2.0-only +TEST_NAME valid-GPL-2.0-only +FILES + testdata/BSD-2-Clause.cpp + testdata/LGPL-2.1-or-later.cpp + testdata/GPL-2.0-only.cpp +) + +# check for valid GPL-3.0-only +ecm_check_outbound_license( +LICENSES GPL-3.0-only +TEST_NAME valid-GPL-3.0-only +FILES + testdata/BSD-2-Clause.cpp + testdata/LGPL-2.1-or-later.cpp + testdata/LGPL-3.0-only.cpp + testdata/GPL-3.0-only.cpp +) + +# check for invalid GPL-3.0-only +ecm_check_outbound_license( +LICENSES LGPL-2.1-only +TEST_NAME invalid-LGPL-2.1-only +FILES + testdata/LGPL-2.0-only.cpp + testdata/GPL-3.0-only.cpp +WILL_FAIL +) + +# check for invalid GPL-3.0-only +ecm_check_outbound_license( +LICENSES GPL-3.0-only +TEST_NAME invalid-GPL-3.0-only +FILES + testdata/GPL-2.0-only.cpp + testdata/GPL-3.0-only.cpp +WILL_FAIL +) diff --git a/tests/ECMCheckOutboundLicenseTest/run_test.cmake.config b/tests/ECMCheckOutboundLicenseTest/run_test.cmake.config new file mode 100644 index 00000000..e69de29b diff --git a/tests/ECMCheckOutboundLicenseTest/testdata/BSD-2-Clause.cpp b/tests/ECMCheckOutboundLicenseTest/testdata/BSD-2-Clause.cpp new file mode 100644 index 00000000..18c14530 --- /dev/null +++ b/tests/ECMCheckOutboundLicenseTest/testdata/BSD-2-Clause.cpp @@ -0,0 +1,6 @@ +/* + SPDX-FileCopyrightText: 2020 Jane Doe + SPDX-License-Identifier: BSD-2-Clause +*/ + +// nothing in here, it is only a test diff --git a/tests/ECMCheckOutboundLicenseTest/testdata/GPL-2.0-only.cpp b/tests/ECMCheckOutboundLicenseTest/testdata/GPL-2.0-only.cpp new file mode 100644 index 00000000..7c227947 --- /dev/null +++ b/tests/ECMCheckOutboundLicenseTest/testdata/GPL-2.0-only.cpp @@ -0,0 +1,6 @@ +/* + SPDX-FileCopyrightText: 2020 John Doe + SPDX-License-Identifier: GPL-2.0-only +*/ + +// nothing in here, it is only a test diff --git a/tests/ECMCheckOutboundLicenseTest/testdata/GPL-2.0-or-later.cpp b/tests/ECMCheckOutboundLicenseTest/testdata/GPL-2.0-or-later.cpp new file mode 100644 index 00000000..58769c51 --- /dev/null +++ b/tests/ECMCheckOutboundLicenseTest/testdata/GPL-2.0-or-later.cpp @@ -0,0 +1,6 @@ +/* + SPDX-FileCopyrightText: 2020 John Doe + SPDX-License-Identifier: GPL-2.0-or-later +*/ + +// nothing in here, it is only a test diff --git a/tests/ECMCheckOutboundLicenseTest/testdata/GPL-3.0-only.cpp b/tests/ECMCheckOutboundLicenseTest/testdata/GPL-3.0-only.cpp new file mode 100644 index 00000000..8261c2ba --- /dev/null +++ b/tests/ECMCheckOutboundLicenseTest/testdata/GPL-3.0-only.cpp @@ -0,0 +1,6 @@ +/* + SPDX-FileCopyrightText: 2020 John Doe + SPDX-License-Identifier: GPL-3.0-only +*/ + +// nothing in here, it is only a test diff --git a/tests/ECMCheckOutboundLicenseTest/testdata/LGPL-2.1-or-later.cpp b/tests/ECMCheckOutboundLicenseTest/testdata/LGPL-2.1-or-later.cpp new file mode 100644 index 00000000..44b52a38 --- /dev/null +++ b/tests/ECMCheckOutboundLicenseTest/testdata/LGPL-2.1-or-later.cpp @@ -0,0 +1,6 @@ +/* + SPDX-FileCopyrightText: 2020 John Doe + SPDX-License-Identifier: LGPL-2.1-or-later +*/ + +// nothing in here, it is only a test diff --git a/tests/ECMCheckOutboundLicenseTest/testdata/LGPL-3.0-only.cpp b/tests/ECMCheckOutboundLicenseTest/testdata/LGPL-3.0-only.cpp new file mode 100644 index 00000000..3ffd899b --- /dev/null +++ b/tests/ECMCheckOutboundLicenseTest/testdata/LGPL-3.0-only.cpp @@ -0,0 +1,6 @@ +/* + SPDX-FileCopyrightText: 2020 Jane Doe + SPDX-License-Identifier: LGPL-3.0-only +*/ + +// nothing in here, it is only a test -- cgit v1.2.1