|
11 | 11 | import pytest |
12 | 12 | import requests |
13 | 13 |
|
| 14 | +from framework import utils |
14 | 15 | from framework.ab_test import ( |
15 | 16 | git_ab_test_guest_command, |
16 | 17 | git_ab_test_guest_command_if_pr, |
17 | | - git_ab_test_host_command_if_pr, |
18 | 18 | is_pr, |
19 | 19 | set_did_not_grow_comparator, |
20 | 20 | ) |
@@ -212,20 +212,17 @@ def check_vulnerabilities_on_guest(status): |
212 | 212 | assert report_guest_vulnerabilities == known_guest_vulnerabilities |
213 | 213 |
|
214 | 214 |
|
| 215 | +# Nothing can be sensibly tested in a PR context here |
| 216 | +@pytest.mark.skipif( |
| 217 | + is_pr(), reason="Test depends solely on factors external to GitHub repository" |
| 218 | +) |
215 | 219 | def test_spectre_meltdown_checker_on_host(spectre_meltdown_checker): |
216 | 220 | """ |
217 | 221 | Test with the spectre / meltdown checker on host. |
218 | 222 | """ |
219 | | - output = git_ab_test_host_command_if_pr( |
220 | | - f"sh {spectre_meltdown_checker} --batch json", |
221 | | - comparator=set_did_not_grow_comparator( |
222 | | - spectre_meltdown_reported_vulnerablities |
223 | | - ), |
224 | | - check_in_nonpr=False, |
225 | | - ) |
| 223 | + rc, output, _ = utils.run_cmd(f"sh {spectre_meltdown_checker} --batch json") |
226 | 224 |
|
227 | | - # Outside the PR context, checks the return code with some exceptions. |
228 | | - if output and output.returncode != 0: |
| 225 | + if output and rc != 0: |
229 | 226 | report = spectre_meltdown_reported_vulnerablities(output) |
230 | 227 | expected = {} |
231 | 228 | assert report == expected, f"Unexpected vulnerabilities: {report} vs {expected}" |
@@ -383,17 +380,15 @@ def get_vuln_files_exception_dict(template): |
383 | 380 | return exception_dict |
384 | 381 |
|
385 | 382 |
|
| 383 | +# Nothing can be sensibly tested here in a PR context |
| 384 | +@pytest.mark.skipif( |
| 385 | + is_pr(), reason="Test depends solely on factors external to GitHub repository" |
| 386 | +) |
386 | 387 | def test_vulnerabilities_on_host(): |
387 | 388 | """ |
388 | 389 | Test vulnerabilities files on host. |
389 | 390 | """ |
390 | | - |
391 | | - git_ab_test_host_command_if_pr( |
392 | | - f"! grep -r Vulnerable {VULN_DIR}", |
393 | | - comparator=set_did_not_grow_comparator( |
394 | | - lambda output: set(output.stdout.splitlines()) |
395 | | - ), |
396 | | - ) |
| 391 | + utils.check_output(f"! grep -r Vulnerable {VULN_DIR}") |
397 | 392 |
|
398 | 393 |
|
399 | 394 | def check_vulnerabilities_files_on_guest(microvm): |
|
0 commit comments