Skip to content

Commit c5bd850

Browse files
committed
Remove any possibility to run tests in parallel.
1 parent 7c4c3ea commit c5bd850

File tree

6 files changed

+112
-113
lines changed

6 files changed

+112
-113
lines changed

suite/auto-sync/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ vendor/llvm_root
44
src/auto-sync/config.json
55
src/autosync/cpptranslator/Tests/Differ/test_saved_patches.json
66
src/autosync.egg-info
7+
src/autosync/Tests/MCUpdaterTests/ARCH/Output
8+
src/autosync/Tests/MCUpdaterTests/Disassembler/ARCH/Output
79
src/autosync/lit_config/test_dir_*
810
src/autosync/lit_config/.lit_test_times.txt
911
src/autosync/Tests/MCUpdaterTests/test_output

suite/auto-sync/src/autosync/MCUpdater.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def exec(self) -> sp.CompletedProcess:
6060
else:
6161
self.cmd = re.sub(r"llvm-mc", f"llvm-mc -mattr={self.mattr}", self.cmd)
6262

63+
log.debug(f"Run: {self.cmd}")
6364
result = sp.run(self.cmd.split(" "), input=content, capture_output=True)
6465
return result
6566

@@ -141,6 +142,7 @@ def init_tests(self, unified_test_cases: bool):
141142
if mc_output.stderr and not mc_output.stdout:
142143
# We can still continue. We just ignore the failed cases.
143144
log.debug(f"llvm-mc cmd stderr: {mc_output.stderr}")
145+
log.debug(f"llvm-mc result: {mc_output}")
144146
text_section = 0 # Counts the .text sections
145147
asm_pat = f"(?P<asm_text>.+)"
146148
enc_pat = r"(\[?(?P<enc_bytes>((0x[a-fA-F0-9]{1,2}[, ]{0,2}))+)[^, ]?\]?)"
@@ -318,7 +320,7 @@ def build_test_files(self, mc_cmds: list[LLVM_MC_Command]) -> list[TestFile]:
318320
test_files = list()
319321
n_all = len(mc_cmds)
320322
for i, mcc in enumerate(mc_cmds):
321-
print(f"{i}/{n_all} {mcc.file.name}", flush=True, end="\r")
323+
print(f"{i + 1}/{n_all} {mcc.file.name}", flush=True, end="\r")
322324
test_files.append(
323325
TestFile(
324326
self.arch,
@@ -411,6 +413,7 @@ def gen_all(self):
411413
self.check_prerequisites(test_paths)
412414
log.info("Generate MC regression tests")
413415
llvm_mc_cmds = self.run_llvm_lit(test_paths)
416+
log.info(f"Got {len(llvm_mc_cmds)} llvm-mc commands to run")
414417
self.test_files = self.build_test_files(llvm_mc_cmds)
415418
for slink in self.symbolic_links:
416419
log.debug(f"Unlink {slink}")

suite/auto-sync/src/autosync/Tests/MCUpdaterTests/ARCH/Output/test_b.txt.script

Lines changed: 0 additions & 1 deletion
This file was deleted.

suite/auto-sync/src/autosync/Tests/MCUpdaterTests/ARCH/Output/test_c.txt.script

Lines changed: 0 additions & 1 deletion
This file was deleted.

suite/auto-sync/src/autosync/Tests/MCUpdaterTests/Disassembler/ARCH/Output/test_a.txt.script

Lines changed: 0 additions & 2 deletions
This file was deleted.

suite/auto-sync/src/autosync/Tests/test_mcupdater.py

Lines changed: 106 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import sys
77
import unittest
88
from pathlib import Path
9-
from threading import Lock
109

1110
from autosync.Helper import get_path, test_only_overwrite_path_var
1211
from autosync.MCUpdater import MCUpdater
@@ -21,117 +20,112 @@ def setUpClass(cls):
2120
format="%(levelname)-5s - %(message)s",
2221
force=True,
2322
)
24-
cls.mutex = Lock()
2523

26-
def test_unified_test_cases(self):
27-
with self.mutex:
28-
out_dir = Path(
29-
get_path("{MCUPDATER_TEST_OUT_DIR}")
30-
.joinpath("merged")
31-
.joinpath("unified")
32-
)
33-
if not out_dir.exists():
34-
out_dir.mkdir(parents=True)
35-
for file in out_dir.iterdir():
36-
logging.debug(f"Delete old file: {file}")
37-
os.remove(file)
38-
test_only_overwrite_path_var(
39-
"{MCUPDATER_OUT_DIR}",
40-
out_dir,
41-
)
42-
self.updater = MCUpdater(
43-
"ARCH", get_path("{MCUPDATER_TEST_DIR}"), [], [], True
44-
)
45-
self.updater.gen_all()
46-
self.assertTrue(
47-
self.compare_files(out_dir, ["test_a.txt.yaml", "test_b.txt.yaml"])
48-
)
24+
def test_test_case_gen(self):
25+
"""
26+
To enforce sequential execution of the tests, we execute them in here.
27+
And don't make them a separated test.
28+
"""
29+
self.assertTrue(self.unified_test_cases(), "Failed: unified_test_cases")
30+
self.assertTrue(self.separated_test_cases(), "Failed: separated_test_cases")
31+
self.assertTrue(
32+
self.multi_mode_unified_test_cases(),
33+
"Failed: multi_mode_unified_test_cases",
34+
)
35+
self.assertTrue(
36+
self.multi_mode_separated_test_cases(),
37+
"Failed: multi_mode_separated_test_cases",
38+
)
39+
40+
def unified_test_cases(self):
41+
out_dir = Path(
42+
get_path("{MCUPDATER_TEST_OUT_DIR}").joinpath("merged").joinpath("unified")
43+
)
44+
if not out_dir.exists():
45+
out_dir.mkdir(parents=True)
46+
for file in out_dir.iterdir():
47+
logging.debug(f"Delete old file: {file}")
48+
os.remove(file)
49+
test_only_overwrite_path_var(
50+
"{MCUPDATER_OUT_DIR}",
51+
out_dir,
52+
)
53+
self.updater = MCUpdater("ARCH", get_path("{MCUPDATER_TEST_DIR}"), [], [], True)
54+
self.updater.gen_all()
55+
return self.compare_files(out_dir, ["test_a.txt.yaml", "test_b.txt.yaml"])
4956

50-
def test_separated_test_cases(self):
51-
with self.mutex:
52-
out_dir = Path(
53-
get_path("{MCUPDATER_TEST_OUT_DIR}")
54-
.joinpath("merged")
55-
.joinpath("separated")
56-
)
57-
if not out_dir.exists():
58-
out_dir.mkdir(parents=True)
59-
for file in out_dir.iterdir():
60-
logging.debug(f"Delete old file: {file}")
61-
os.remove(file)
62-
test_only_overwrite_path_var(
63-
"{MCUPDATER_OUT_DIR}",
64-
out_dir,
65-
)
66-
self.updater = MCUpdater(
67-
"ARCH", get_path("{MCUPDATER_TEST_DIR}"), [], [], False
68-
)
69-
self.updater.gen_all()
70-
self.assertTrue(
71-
self.compare_files(out_dir, ["test_a.txt.yaml", "test_b.txt.yaml"])
72-
)
57+
def separated_test_cases(self):
58+
out_dir = Path(
59+
get_path("{MCUPDATER_TEST_OUT_DIR}")
60+
.joinpath("merged")
61+
.joinpath("separated")
62+
)
63+
if not out_dir.exists():
64+
out_dir.mkdir(parents=True)
65+
for file in out_dir.iterdir():
66+
logging.debug(f"Delete old file: {file}")
67+
os.remove(file)
68+
test_only_overwrite_path_var(
69+
"{MCUPDATER_OUT_DIR}",
70+
out_dir,
71+
)
72+
self.updater = MCUpdater(
73+
"ARCH", get_path("{MCUPDATER_TEST_DIR}"), [], [], False
74+
)
75+
self.updater.gen_all()
76+
return self.compare_files(out_dir, ["test_a.txt.yaml", "test_b.txt.yaml"])
7377

74-
def test_multi_mode_unified_test_cases(self):
75-
with self.mutex:
76-
out_dir = Path(
77-
get_path("{MCUPDATER_TEST_OUT_DIR}")
78-
.joinpath("multi")
79-
.joinpath("unified")
80-
)
81-
if not out_dir.exists():
82-
out_dir.mkdir(parents=True)
83-
for file in out_dir.iterdir():
84-
logging.debug(f"Delete old file: {file}")
85-
os.remove(file)
86-
test_only_overwrite_path_var(
87-
"{MCUPDATER_OUT_DIR}",
88-
out_dir,
89-
)
90-
self.updater = MCUpdater(
91-
"ARCH", get_path("{MCUPDATER_TEST_DIR}"), [], [], True, multi_mode=True
92-
)
93-
self.updater.gen_all()
94-
self.assertTrue(
95-
self.compare_files(
96-
out_dir,
97-
[
98-
"test_a_aarch64_v8a__fp_armv8.txt.yaml",
99-
"test_a_arm64_v8.2a.txt.yaml",
100-
"test_b_arm64.txt.yaml",
101-
],
102-
)
103-
)
78+
def multi_mode_unified_test_cases(self):
79+
out_dir = Path(
80+
get_path("{MCUPDATER_TEST_OUT_DIR}").joinpath("multi").joinpath("unified")
81+
)
82+
if not out_dir.exists():
83+
out_dir.mkdir(parents=True)
84+
for file in out_dir.iterdir():
85+
logging.debug(f"Delete old file: {file}")
86+
os.remove(file)
87+
test_only_overwrite_path_var(
88+
"{MCUPDATER_OUT_DIR}",
89+
out_dir,
90+
)
91+
self.updater = MCUpdater(
92+
"ARCH", get_path("{MCUPDATER_TEST_DIR}"), [], [], True, multi_mode=True
93+
)
94+
self.updater.gen_all()
95+
return self.compare_files(
96+
out_dir,
97+
[
98+
"test_a_aarch64_v8a__fp_armv8.txt.yaml",
99+
"test_a_arm64_v8.2a.txt.yaml",
100+
"test_b_arm64.txt.yaml",
101+
],
102+
)
104103

105-
def test_multi_mode_separated_test_cases(self):
106-
with self.mutex:
107-
out_dir = Path(
108-
get_path("{MCUPDATER_TEST_OUT_DIR}")
109-
.joinpath("multi")
110-
.joinpath("separated")
111-
)
112-
if not out_dir.exists():
113-
out_dir.mkdir(parents=True)
114-
for file in out_dir.iterdir():
115-
logging.debug(f"Delete old file: {file}")
116-
os.remove(file)
117-
test_only_overwrite_path_var(
118-
"{MCUPDATER_OUT_DIR}",
119-
out_dir,
120-
)
121-
self.updater = MCUpdater(
122-
"ARCH", get_path("{MCUPDATER_TEST_DIR}"), [], [], False, multi_mode=True
123-
)
124-
self.updater.gen_all()
125-
self.assertTrue(
126-
self.compare_files(
127-
out_dir,
128-
[
129-
"test_a_aarch64_v8a__fp_armv8.txt.yaml",
130-
"test_a_arm64_v8.2a.txt.yaml",
131-
"test_b_arm64.txt.yaml",
132-
],
133-
)
134-
)
104+
def multi_mode_separated_test_cases(self):
105+
out_dir = Path(
106+
get_path("{MCUPDATER_TEST_OUT_DIR}").joinpath("multi").joinpath("separated")
107+
)
108+
if not out_dir.exists():
109+
out_dir.mkdir(parents=True)
110+
for file in out_dir.iterdir():
111+
logging.debug(f"Delete old file: {file}")
112+
os.remove(file)
113+
test_only_overwrite_path_var(
114+
"{MCUPDATER_OUT_DIR}",
115+
out_dir,
116+
)
117+
self.updater = MCUpdater(
118+
"ARCH", get_path("{MCUPDATER_TEST_DIR}"), [], [], False, multi_mode=True
119+
)
120+
self.updater.gen_all()
121+
return self.compare_files(
122+
out_dir,
123+
[
124+
"test_a_aarch64_v8a__fp_armv8.txt.yaml",
125+
"test_a_arm64_v8.2a.txt.yaml",
126+
"test_b_arm64.txt.yaml",
127+
],
128+
)
135129

136130
def compare_files(self, out_dir: Path, filenames: list[str]) -> bool:
137131
if not out_dir.is_dir():
@@ -153,16 +147,20 @@ def compare_files(self, out_dir: Path, filenames: list[str]) -> bool:
153147
logging.error(f"{efile} does not exist")
154148
return False
155149
with open(efile) as f:
150+
logging.debug(f"Read {efile}")
156151
expected = f.read()
157152

158153
afile = out_dir.joinpath(file)
159154
if not afile.exists():
160155
logging.error(f"{afile} does not exist")
161156
return False
162157
with open(afile) as f:
158+
logging.debug(f"Read {afile}")
163159
actual = f.read()
164160
if expected != actual:
165161
logging.error("Files mismatch")
162+
print(f"Expected: {efile}")
163+
print(f"Actual: {afile}\n")
166164
print(f"Expected:\n\n{expected}\n")
167165
print(f"Actual:\n\n{actual}\n")
168166
return False

0 commit comments

Comments
 (0)