Skip to content

Commit

Permalink
Fix test_alg_info.py on Windows platform (open-quantum-safe#1821)
Browse files Browse the repository at this point in the history
* Fix test_alg_info.py on Windows platform

Signed-off-by: zinag <[email protected]>

* Remove incorrect print

Signed-off-by: zinag <[email protected]>

---------

Signed-off-by: zinag <[email protected]>
  • Loading branch information
qnfm committed Jun 17, 2024
1 parent 6ee5de2 commit c8a2beb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tests/test_alg_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ def test_alg_info_kem(kem_name):
alg_info = yaml.safe_load(output)['KEMs'][kem_name]
assert(not(alg_info['isnull']))
# find and load the datasheet
datasheet_filename = helpers.run_subprocess(['grep', '-r', '-l', kem_name, 'docs/algorithms/kem']).splitlines()[0]
if platform.system() == 'Windows':
command = f"Select-String -Path 'docs/algorithms/kem/*' -Pattern '{kem_name}' -SimpleMatch -List | Select-Object -ExpandProperty Path"
datasheet_filename = helpers.run_subprocess(['powershell', '-Command', command]).splitlines()[0]
else:
datasheet_filename = helpers.run_subprocess(['grep', '-r', '-l', kem_name, 'docs/algorithms/kem']).splitlines()[0]
datasheet_filename = datasheet_filename.replace('.md','.yml')
with open(datasheet_filename, 'r', encoding='utf8') as datasheet_fh:
datasheet = yaml.safe_load(datasheet_fh.read())
Expand Down Expand Up @@ -45,7 +49,11 @@ def test_alg_info_sig(sig_name):
alg_info = yaml.safe_load(output)['SIGs'][sig_name]
assert(not(alg_info['isnull']))
# find and load the datasheet
datasheet_filename = helpers.run_subprocess(['grep', '-r', '-l', sig_name, 'docs/algorithms/sig']).splitlines()[0]
if platform.system() == 'Windows':
command = f"Select-String -Path 'docs/algorithms/sig/*' -Pattern '{sig_name}' -SimpleMatch -List | Select-Object -ExpandProperty Path"
datasheet_filename = helpers.run_subprocess(['powershell', '-Command', command]).splitlines()[0]
else:
datasheet_filename = helpers.run_subprocess(['grep', '-r', '-l', sig_name, 'docs/algorithms/sig']).splitlines()[0]
datasheet_filename = datasheet_filename.replace('.md','.yml')
with open(datasheet_filename, 'r', encoding='utf8') as datasheet_fh:
datasheet = yaml.safe_load(datasheet_fh.read())
Expand Down

0 comments on commit c8a2beb

Please sign in to comment.