From 4778401badd032e0b6b81aa68927596779b1a94e Mon Sep 17 00:00:00 2001 From: "Matthias J. Kannwischer" Date: Sun, 22 Dec 2024 00:10:55 +0800 Subject: [PATCH] Python 3.7: Do not rely on enum value evaluating to __str__(..) For some reason f"{enum_value}" evaluates to the numeric representation (e.g, "1" for TEST_TYPES.MLKEM) in Python3.7, while it evaluates to the string representation (__str__) in Python >=3.8. Workaround would to be to add an explicit str(...), but this commit instead adds an explicit function called make_target mapping a test type to a make target. This would also allow us to use a differnt name for the make target than the name of the enum value. Signed-off-by: Matthias J. Kannwischer --- scripts/lib/mlkem_test.py | 2 +- scripts/lib/util.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts/lib/mlkem_test.py b/scripts/lib/mlkem_test.py index aa0ad35fe..99d94c2bb 100644 --- a/scripts/lib/mlkem_test.py +++ b/scripts/lib/mlkem_test.py @@ -96,7 +96,7 @@ def dict2str(dict): args = [ "make", f"CROSS_PREFIX={self.cross_prefix}", - f"{self.test_type}", + f"{self.test_type.make_target()}", ] + extra_make_args env = os.environ.copy() diff --git a/scripts/lib/util.py b/scripts/lib/util.py index 0333712cc..263589e6c 100644 --- a/scripts/lib/util.py +++ b/scripts/lib/util.py @@ -100,6 +100,20 @@ def bin(self): if self == TEST_TYPES.ACVP: return "acvp_mlkem" + def make_target(self): + if self == TEST_TYPES.MLKEM: + return "mlkem" + if self == TEST_TYPES.BENCH: + return "bench" + if self == TEST_TYPES.BENCH_COMPONENTS: + return "bench_components" + if self == TEST_TYPES.NISTKAT: + return "nistkat" + if self == TEST_TYPES.KAT: + return "kat" + if self == TEST_TYPES.ACVP: + return "acvp" + def bin_path(self, scheme): return path( f"test/build/{scheme.name.lower()}/bin/{self.bin()}{scheme.suffix()}"