diff --git a/libs/cobalt b/libs/cobalt index a1a1020..182ed0e 160000 --- a/libs/cobalt +++ b/libs/cobalt @@ -1 +1 @@ -Subproject commit a1a1020416cdf222e716374fba4f8451920f453b +Subproject commit 182ed0eca70b162da2dd08ffb12ee3b70b050561 diff --git a/libs/codecs b/libs/codecs index 85061b2..b5008ac 160000 --- a/libs/codecs +++ b/libs/codecs @@ -1 +1 @@ -Subproject commit 85061b2b21c4fed25c60fbe4d0f80923ed2e1f2a +Subproject commit b5008acce547fcda8a4c17c83c08fac14c020c5f diff --git a/libs/crypto b/libs/crypto index 36d1279..f1b1a59 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 36d1279d9048ff667183ec2e45c6e1961a34dd6a +Subproject commit f1b1a593c4a67b35e79ece396f4b3c0066d68166 diff --git a/libs/secure b/libs/secure index a88fc50..92de982 160000 --- a/libs/secure +++ b/libs/secure @@ -1 +1 @@ -Subproject commit a88fc50ff08a65943ceca860374955366634103d +Subproject commit 92de982fdf03f8f15f50ed753b07f0aee9392cc7 diff --git a/tools/test/crypto_dudect_judge_test.py b/tools/test/crypto_dudect_judge_test.py index 9a50e65..f30dced 100644 --- a/tools/test/crypto_dudect_judge_test.py +++ b/tools/test/crypto_dudect_judge_test.py @@ -10,16 +10,22 @@ |t| is 10 or more, the planted program and the harness's test excepted; with --rerun it measures each judged case over 10 again in two fresh processes and fails exactly when two of the three values are 10 or more, naming them; it never reruns a case that is not judged; it refuses an -output with no case line; and on wasip2 it runs the program through the launcher. Run with the +output with no case line; on wasip2 it runs the program through the launcher; and it prints the +CPU it runs on, read from /proc/cpuinfo's text as dudect.hpp reads it, and repeats it in each +warning. Run with the names of some cases to run only those.""" from __future__ import annotations +import importlib.util +import platform +import re import shlex import subprocess import sys import tempfile from collections.abc import Callable +from importlib.machinery import SourceFileLoader from pathlib import Path ROOT = Path(__file__).resolve().parents[2] @@ -49,6 +55,15 @@ def run_judge(*args: str) -> subprocess.CompletedProcess[str]: check=False, timeout=120) +def judge_module(): + """The judge, imported, for its functions.""" + spec = importlib.util.spec_from_file_location('dudect_judge', JUDGE) + assert spec is not None and isinstance(spec.loader, SourceFileLoader) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + def write_output(directory: Path, name: str, text: str, suffix: str = '') -> Path: """bin//.output holding text and the lane's exit line.""" where = directory / f'{name}.test/clang/release{suffix}' @@ -149,6 +164,37 @@ def judge_wasip2_launcher(scratch: Path) -> None: assert '69.80, 1.00, 1.00' in done.stdout, done.stdout +HOST = re.compile(r'^dudect host cpu="[^"]+" microcode=\S+$') + + +def judge_prints_host(scratch: Path) -> None: + write_output(scratch, 'dudect_bearssl', BEARSSL) + done = run_judge('--bin', str(scratch), '--target', 'wasip2') + expect(done, 0) + host = done.stdout.splitlines()[0] + assert HOST.match(host), done.stdout + if platform.system() in ('Linux', 'Darwin') and platform.machine() in ('x86_64', 'AMD64'): + assert 'cpu="unavailable"' not in host, host + warnings = [line for line in done.stdout.splitlines() if line.startswith('::warning')] + assert len(warnings) == 1 and warnings[0].endswith('%0A' + host), warnings + + +def judge_parses_cpuinfo(scratch: Path) -> None: + del scratch + parse = judge_module().parse_cpuinfo + x86 = ('processor\t: 0\nvendor_id\t: AuthenticAMD\n' + 'model name\t: AMD EPYC 9V74 80-Core Processor\nmicrocode\t: 0xa10113e\n' + 'processor\t: 1\nmodel name\t: other\n') + assert parse(x86) == ('AMD EPYC 9V74 80-Core Processor', '0xa10113e'), parse(x86) + quoted = 'model name\t: Intel(R) Xeon(R) "6975P-C"\nmicrocode\t: 0x1 "a"\n' + assert parse(quoted) == ("Intel(R) Xeon(R) '6975P-C'", '0x1__a_'), parse(quoted) + arm64 = ('processor\t: 0\nCPU implementer\t: 0x41\nCPU architecture: 8\n' + 'CPU variant\t: 0x1\nCPU part\t: 0xd4f\nCPU revision\t: 1\n') + assert parse(arm64) == ('arm64 implementer=0x41 part=0xd4f variant=0x1 revision=1', + 'unavailable'), parse(arm64) + assert parse('') == ('unavailable', 'unavailable'), parse('') + + CASES: list[Callable[[Path], None]] = [ judge_prints_and_warns, judge_two_of_three_pass, @@ -157,6 +203,8 @@ def judge_wasip2_launcher(scratch: Path) -> None: judge_skips_planted, judge_output_without_case_lines, judge_wasip2_launcher, + judge_prints_host, + judge_parses_cpuinfo, ]