Skip to content

Commit

Permalink
Merge pull request #375 from pq-code-package/fix-tests
Browse files Browse the repository at this point in the history
Fix tests error handling and logging output file
  • Loading branch information
mkannwischer authored Nov 12, 2024
2 parents 7b4928a + 2a6328c commit ef592d0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
16 changes: 9 additions & 7 deletions scripts/lib/mlkem_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,8 @@ def bench(
def all(self, func: bool, kat: bool, nistkat: bool):
config_logger(self.verbose)

exit_code = 0

def all(opt: bool):
code = 0
if self.compile:
compiles = [
*([self._func.compile] if func else []),
Expand All @@ -461,7 +460,7 @@ def all(opt: bool):
try:
f(opt)
except SystemExit as e:
exit_code = exit_code or e
code = code or e

sys.stdout.flush()

Expand All @@ -474,15 +473,18 @@ def all(opt: bool):

for f in runs:
try:
f(opt)
code = code or int(f(opt))
except SystemExit as e:
exit_code = exit_code or e
code = code or e

sys.stdout.flush()
return code

exit_code = 0

if self.opt.lower() == "all" or self.opt.lower() == "no_opt":
all(False)
exit_code = exit_code or all(False)
if self.opt.lower() == "all" or self.opt.lower() == "opt":
all(True)
exit_code = exit_code or all(True)

exit(exit_code)
4 changes: 3 additions & 1 deletion scripts/lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ def add_summaries(fn, title, summaries):


def config_logger(verbose):
logging.basicConfig(format="%(levelname)-5s > %(name)-40s %(message)s")
logging.basicConfig(
stream=sys.stdout, format="%(levelname)-5s > %(name)-40s %(message)s"
)

logger = logging.getLogger()

Expand Down

0 comments on commit ef592d0

Please sign in to comment.