Fix test_alg_info.py on Windows platform (#1821)

* Fix test_alg_info.py on Windows platform

Signed-off-by: zinag <uzinag@163.com>

* Remove incorrect print

Signed-off-by: zinag <uzinag@163.com>

---------

Signed-off-by: zinag <uzinag@163.com>
This commit is contained in:
qnfm 2024-06-17 13:19:22 +00:00 committed by GitHub
parent 6ee5de2522
commit c8a2beb5a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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())
@ -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())