|
5 | 5 | import datetime
|
6 | 6 |
|
7 | 7 | from framework import utils_repo
|
| 8 | +from framework.defs import FC_WORKSPACE_DIR |
| 9 | +from host_tools.cargo_build import cargo |
8 | 10 |
|
9 | 11 | AMAZON_COPYRIGHT_YEARS = range(2018, datetime.datetime.now().year + 1)
|
10 | 12 | AMAZON_COPYRIGHT = (
|
@@ -116,5 +118,31 @@ def test_for_valid_licenses():
|
116 | 118 | assert not error_msg, f"Files {error_msg} have invalid licenses"
|
117 | 119 |
|
118 | 120 |
|
| 121 | +def test_dependency_licenses(): |
| 122 | + """Ensure license compatibility for Firecracker. |
| 123 | +
|
| 124 | + For a list of currently allowed licenses checkout deny.toml in |
| 125 | + the root directory. |
| 126 | + """ |
| 127 | + toml_file = FC_WORKSPACE_DIR / "Cargo.toml" |
| 128 | + |
| 129 | + _, stdout, stderr = cargo( |
| 130 | + "deny", f"--manifest-path {toml_file} check licenses bans" |
| 131 | + ) |
| 132 | + assert "licenses ok" in stdout |
| 133 | + |
| 134 | + # "cargo deny" should deny licenses by default but for some reason copyleft is allowed |
| 135 | + # by it and if we add a dependency which has copyleft licenses "cargo deny" won't report |
| 136 | + # it unless it is explicitly told to do so from the deny.toml. |
| 137 | + # Our current deny.toml seems to cover all the cases we need but, |
| 138 | + # if there is an exception like copyleft (where we don't want and don't deny |
| 139 | + # in deny.toml and is allowed by cardo deny), we don't want to be left in the dark. |
| 140 | + # For such cases check "cargo deny" output, make sure that there are no warnings reported |
| 141 | + # related to the license and take appropriate actions i.e. either add them to allow list |
| 142 | + # or remove them if they are incompatible with our licenses. |
| 143 | + license_res = [line for line in stderr.split("\n") if "license" in line] |
| 144 | + assert not license_res |
| 145 | + |
| 146 | + |
119 | 147 | if __name__ == "__main__":
|
120 | 148 | test_for_valid_licenses()
|
0 commit comments