-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IDs representing a GPL v2 license are translated into "GPL" to be recognised by the kernel. Licenses defined in a BpfScript config block take precedence over SPDX IDs.
- Loading branch information
Showing
5 changed files
with
123 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include <optional> | ||
#include <string> | ||
#include <string_view> | ||
|
||
#include "bpftrace.h" | ||
#include "driver.h" | ||
#include "gtest/gtest.h" | ||
|
||
namespace bpftrace::test::parser_licenses { | ||
|
||
void test(std::string_view input, std::optional<std::string> expected_license) | ||
{ | ||
BPFtrace bpftrace; | ||
Driver driver{ bpftrace }; | ||
ASSERT_EQ(0, driver.parse_str(input)); | ||
EXPECT_EQ(expected_license, | ||
bpftrace.config_.try_get(ConfigKeyString::license)); | ||
} | ||
|
||
TEST(ParserLicenses, GPL_v2_only) | ||
{ | ||
test(R"( | ||
// SPDX-License-Identifier: GPL-2.0-only | ||
BEGIN {} | ||
)", | ||
"GPL"); | ||
} | ||
|
||
TEST(ParserLicenses, GPL_v2_or_later) | ||
{ | ||
test(R"( | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
BEGIN {} | ||
)", | ||
"GPL"); | ||
} | ||
|
||
TEST(ParserLicenses, GPL_v1) | ||
{ | ||
test(R"( | ||
// SPDX-License-Identifier: GPL-1.0-only | ||
BEGIN {} | ||
)", | ||
"GPL-1.0-only"); | ||
} | ||
|
||
TEST(ParserLicenses, GPL_v3) | ||
{ | ||
test(R"( | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
BEGIN {} | ||
)", | ||
"GPL-3.0-only"); | ||
} | ||
|
||
TEST(ParserLicenses, Apache_2) | ||
{ | ||
test(R"( | ||
// SPDX-License-Identifier: Apache-2.0 | ||
BEGIN {} | ||
)", | ||
"Apache-2.0"); | ||
} | ||
|
||
} // namespace bpftrace::test::parser_licenses |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters