Rev 9923 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9923 | Rev 9931 | ||
---|---|---|---|
Line 86... | Line 86... | ||
86 | draw_row(header_name, header_package) |
86 | draw_row(header_name, header_package) |
87 | draw_line() |
87 | draw_line() |
88 | for name, package in not_exists: |
88 | for name, package in not_exists: |
89 | draw_row(name, package) |
89 | draw_row(name, package) |
90 | draw_line() |
90 | draw_line() |
- | 91 | install_command = 'sudo apt install' |
|
- | 92 | for _, package in not_exists: |
|
- | 93 | install_command += f' {package}' |
|
- | 94 | log(f"Try to install with:\n {install_command}\n") |
|
91 | exit() |
95 | exit() |
Line 92... | Line 96... | ||
92 | 96 | ||
93 | 97 | ||
Line 146... | Line 150... | ||
146 | tests.append(test_folder_path) |
150 | tests.append(test_folder_path) |
147 | return tests |
151 | return tests |
Line 148... | Line 152... | ||
148 | 152 | ||
- | 153 | ||
149 | 154 | def run_tests_serially_thread(test, root_dir): |
|
150 | def run_tests_serially_thread(test, root_dir): |
155 | print("\nRunning QEMU tests.") |
151 | errors = [] |
156 | errors = [] |
152 | test_number = 1 |
157 | test_number = 1 |
Line 180... | Line 185... | ||
180 | thread = Thread(target=run_tests_serially_thread, args=(tests, root_dir)) |
185 | thread = Thread(target=run_tests_serially_thread, args=(tests, root_dir)) |
181 | thread.start() |
186 | thread.start() |
182 | return thread |
187 | return thread |
Line -... | Line 188... | ||
- | 188 | ||
- | 189 | ||
- | 190 | def test_umka(): |
|
- | 191 | class Test: |
|
- | 192 | def __init__(self, path, deps): |
|
- | 193 | self.path = os.path.realpath(path) |
|
- | 194 | self.name = os.path.basename(path) |
|
- | 195 | self.deps = deps |
|
- | 196 | filename_no_ext = os.path.splitext(self.path)[0] |
|
- | 197 | self.ref_log = f"{filename_no_ext}.ref.log" |
|
- | 198 | self.out_log = f"{filename_no_ext}.out.log" |
|
- | 199 | self.ref_png = f"{filename_no_ext}.ref.png" |
|
- | 200 | self.out_png = f"{filename_no_ext}.out.png" |
|
- | 201 | self.log_diff = f"{filename_no_ext}.log.diff" |
|
- | 202 | self.check_png = os.path.exists(self.ref_png) |
|
- | 203 | ||
- | 204 | def find_tests(): |
|
- | 205 | def find_test_dependencies(umka_shell_command_file): |
|
- | 206 | # TODO: Cache the result to not parse tests on each run. |
|
- | 207 | deps = set() |
|
- | 208 | with open(umka_shell_command_file) as f: |
|
- | 209 | test_dir = os.path.dirname(umka_shell_command_file) |
|
- | 210 | for line in f: |
|
- | 211 | parts = line.split() |
|
- | 212 | for dependant in ("disk_add", "ramdisk_init"): |
|
- | 213 | try: |
|
- | 214 | idx = parts.index(dependant) |
|
- | 215 | relative_img_path = parts[idx + 1] |
|
- | 216 | dep_path = f"{test_dir}/{relative_img_path}" |
|
- | 217 | deps.add(os.path.realpath(dep_path)) |
|
- | 218 | except: |
|
- | 219 | pass |
|
- | 220 | return tuple(deps) |
|
- | 221 | ||
- | 222 | tests = [] |
|
- | 223 | for umka_shell_command_file in os.listdir("umka/test"): |
|
- | 224 | umka_shell_command_file = f"umka/test/{umka_shell_command_file}" |
|
- | 225 | if not umka_shell_command_file.endswith(".t"): |
|
- | 226 | continue |
|
- | 227 | if not os.path.isfile(umka_shell_command_file): |
|
- | 228 | continue |
|
- | 229 | deps = find_test_dependencies(umka_shell_command_file) |
|
- | 230 | tests.append(Test(umka_shell_command_file, deps)) |
|
- | 231 | ||
- | 232 | return tests |
|
- | 233 | ||
- | 234 | print("\nCollecting UMKa tests.", flush = True) |
|
- | 235 | tests = find_tests() |
|
- | 236 | # Excluded: #acpi_. |
|
- | 237 | tags_to_tests = ("#xfs_", "#xfsv5_", "#exfat_", "#fat_", "#ext_", "#s05k_", |
|
- | 238 | "#s4k_", "#f30_", "#f70_", "#f70s0_", "#f70s1_", "#f70s5_", |
|
- | 239 | "#lookup_", "#bug_", "#xattr_", "#unicode_", "#draw_", |
|
- | 240 | "#coverage_", "#i40_", "#net_", "#arp_", "#input_", |
|
- | 241 | "#gpt_", "#uevent_") |
|
- | 242 | tests_to_run = [] |
|
- | 243 | for test in tests: |
|
- | 244 | # If none of required tags are in the test name - skip it. |
|
- | 245 | for tag in tags_to_tests: |
|
- | 246 | if tag in test.name: |
|
- | 247 | break |
|
- | 248 | else: |
|
- | 249 | continue |
|
- | 250 | ||
- | 251 | # Check test dependencies. |
|
- | 252 | unmet_deps = [] |
|
- | 253 | for dep in test.deps: |
|
- | 254 | if not os.path.exists(dep): |
|
- | 255 | unmet_deps.append(dep) |
|
- | 256 | ||
- | 257 | if len(unmet_deps) > 0: |
|
- | 258 | print(f"*** WARNING: Test {test.name} has been skipped, unmet dependencies:") |
|
- | 259 | for dep in unmet_deps: |
|
- | 260 | print(f"- {os.path.basename(dep)}") |
|
- | 261 | continue |
|
- | 262 | ||
- | 263 | tests_to_run.append(test) |
|
- | 264 | ||
- | 265 | failed_tests = [] |
|
- | 266 | test_count = len(tests_to_run) |
|
- | 267 | test_i = 1 |
|
- | 268 | print("\nRunning UMKa tests.") |
|
- | 269 | for test in tests_to_run: |
|
- | 270 | print(f"[{test_i}/{test_count}] Running test {test.name}... ", end = "", flush = True) |
|
- | 271 | if os.system(f"(cd umka/test && ../umka_shell -ri {test.path} -o {test.out_log})") != 0: |
|
- | 272 | print("ABORT") |
|
- | 273 | else: |
|
- | 274 | fail_reasons = [] |
|
- | 275 | if not filecmp.cmp(test.out_log, test.ref_log): |
|
- | 276 | fail_reasons.append("log") |
|
- | 277 | if test.check_png and not filecmp.cmp(test.out_png, test.ref_png): |
|
- | 278 | fail_reasons.append("png") |
|
- | 279 | if fail_reasons: |
|
- | 280 | failed_tests.append((test, fail_reasons)) |
|
- | 281 | print("FAILURE") |
|
- | 282 | else: |
|
- | 283 | print("SUCCESS") |
|
- | 284 | test_i += 1 |
|
- | 285 | ||
- | 286 | if len(failed_tests) != 0: |
|
- | 287 | print("\nFailed UMKa tests:") |
|
- | 288 | for failed_test in failed_tests: |
|
- | 289 | test = failed_test[0] |
|
- | 290 | reasons = failed_test[1] |
|
- | 291 | message = f"- {test.name}" |
|
- | 292 | if "log" in reasons: |
|
- | 293 | os.system(f"git --no-pager diff --no-index {test.ref_log} {test.out_log} > {test.log_diff}") |
|
- | 294 | message += f"\n - logs differ: {test.log_diff}" |
|
- | 295 | if "png" in reasons: |
|
- | 296 | message += f"\n - pngs are different:\n" |
|
- | 297 | message += f" - {test.ref_png}\n" |
|
- | 298 | message += f" - {test.out_png}" |
|
- | 299 | print(message) |
|
183 | 300 | ||
184 | 301 | ||
185 | def build_umka(): |
302 | def build_umka(): |
186 | kolibrios_dir = os.path.abspath("../../") |
303 | print("\nBuilding UMKa... ", end = "", flush = True) |
187 | env = os.environ |
304 | env = os.environ |
188 | env["KOLIBRIOS"] = kolibrios_dir |
305 | env["KOLIBRIOS"] = os.path.abspath("../../") |
189 | env["HOST"] = "linux" |
306 | env["HOST"] = "linux" |
190 | env["CC"] = "clang" |
307 | env["CC"] = "clang" |
191 | popen = subprocess.Popen(shlex.split("make -C umka umka_shell"), env = env) |
308 | popen = subprocess.Popen(shlex.split("make --silent -C umka umka_shell default.skn"), env = env) |
- | 309 | if popen.wait() != 0: |
|
- | 310 | subprocess.Popen(shlex.split("make --no-print-directory -C umka clean umka_shell default.skn"), env = env) |
|
- | 311 | if os.system("make --silent -C umka/apps board_cycle") != 0: |
|
- | 312 | os.system("make --no-print-directory -C umka/apps clean board_cycle") |
|
- | 313 | if os.system("make --silent -C umka/tools all") != 0: |
|
- | 314 | os.system("make --no-print-directory -C umka/tools clean all") |
|
- | 315 | print("Done.") |
|
- | 316 | ||
Line 192... | Line 317... | ||
192 | if popen.wait() != 0: |
317 | print("\nGenerating images for UMKa tests.", flush = True) |
193 | subprocess.Popen(shlex.split("make -C umka clean"), env = env) |
318 | os.system("(cd umka/img && sudo ./gen.sh)") |
194 | 319 | ||
195 | 320 | ||
196 | def download_umka(): |
321 | def download_umka(): |
Line 197... | Line -... | ||
197 | if not os.path.exists("umka"): |
- | |
198 | if os.system("git clone https://github.com/KolibriOS/umka") != 0: |
- | |
199 | print("Couldn't clone UMKa repo") |
- | |
200 | exit() |
- | |
201 | - | ||
202 | - | ||
203 | def download_umka_imgs(): |
- | |
204 | imgs = [ |
- | |
205 | "fat32_test0.img", |
- | |
206 | "jfs.img", |
- | |
207 | "kolibri.img", |
- | |
208 | "xfs_borg_bit.img", |
- | |
209 | "xfs_v4_btrees_l2.img", |
- | |
210 | "xfs_v4_files_s05k_b4k_n8k.img", |
- | |
211 | "xfs_v4_ftype0_s05k_b2k_n8k_xattr.img", |
- | |
212 | "xfs_v4_ftype0_s05k_b2k_n8k.img", |
- | |
213 | "xfs_v4_ftype0_s4k_b4k_n8k.img", |
- | |
214 | "xfs_v4_ftype1_s05k_b2k_n8k.img", |
- | |
215 | "xfs_v4_unicode.img", |
- | |
216 | "xfs_v4_xattr.img", |
- | |
217 | "xfs_v5_files_s05k_b4k_n8k.img", |
- | |
218 | "xfs_v5_ftype1_s05k_b2k_n8k.img", |
- | |
219 | ] |
- | |
220 | 322 | if not os.path.exists("umka"): |
|
221 | for img in imgs: |
323 | if os.system("git clone https://github.com/KolibriOS/umka") != 0: |
Line 222... | Line 324... | ||
222 | if not os.path.exists(f"umka/img/{img}"): |
324 | print("Couldn't clone UMKa repo") |
223 | download(f"http://ftp.kolibrios.org/users/Boppan/img/{img}", |
325 | exit() |
Line 239... | Line 341... | ||
239 | 341 | ||
240 | prepare_test_img() |
342 | prepare_test_img() |
241 | if use_umka: |
343 | if use_umka: |
242 | download_umka() |
344 | download_umka() |
- | 345 | build_umka() |
|
243 | build_umka() |
346 | test_umka() |
244 | tests = collect_tests() |
347 | tests = collect_tests() |
245 | serial_executor_thread = run_tests_serially(tests, root_dir) |
348 | serial_executor_thread = run_tests_serially(tests, root_dir) |