|
17 | 17 | from subprocess import getoutput |
18 | 18 |
|
19 | 19 | BUGTOOL_OUTPUT_DIR = "/var/opt/xen/bug-report/" |
20 | | -BUGTOOL_DOM0_TEMPL = "tests/integration/dom0-template" |
| 20 | +BUGTOOL_DOM0_TEMPL = "tests/integration/dom0-template/" |
21 | 21 |
|
22 | 22 |
|
23 | 23 | def run(command): |
@@ -49,11 +49,21 @@ def check_file(path): |
49 | 49 | return contents |
50 | 50 |
|
51 | 51 |
|
52 | | -def verify_content_from_dom0_template(path): |
| 52 | +def assert_content_from_dom0_template(path, control_path=None): |
53 | 53 | """Compare the contents of output directories or files with the test's Dom0 template directories""" |
54 | 54 | assert path[0] != "/" |
55 | | - assert filecmp.dircmp(path, BUGTOOL_DOM0_TEMPL + path) |
56 | | - # After successfuly verficiation of the files, remove the checked output files (missed files remain): |
| 55 | + control = BUGTOOL_DOM0_TEMPL + (control_path or path) |
| 56 | + print(control) |
| 57 | + if os.path.isdir(path): |
| 58 | + result = filecmp.dircmp(path, control) |
| 59 | + if result.diff_files or result.right_only: |
| 60 | + print(result.report) |
| 61 | + raise RuntimeError("Missing or Differing files found in " + path) |
| 62 | + else: |
| 63 | + if not filecmp.cmp(path, control): |
| 64 | + os.system("cat " + path) |
| 65 | + raise RuntimeError(control) |
| 66 | + # Remove verified output files/directories. Untested files will remain and cause the testcase to FAIL: |
57 | 67 | try: |
58 | 68 | os.unlink(path) |
59 | 69 | except OSError: |
@@ -99,3 +109,5 @@ def run_bugtool_entry(archive_type, test_entries): |
99 | 109 | etree.XMLSchema(etree.parse(xmlschema)).assertValid(etree.parse("inventory.xml")) |
100 | 110 | # After successfuly validation of the inventory.xml, remove it (not removed files make the test fail): |
101 | 111 | os.unlink("inventory.xml") |
| 112 | + # assert_content_from_dom0_template() does not know the srcdir: add a symlink so it can reach the tests |
| 113 | + os.symlink(srcdir + "/tests", "tests") |
0 commit comments