mirror of
https://github.com/henrydcase/pqc.git
synced 2024-11-22 23:48:58 +00:00
Avoid clang tidy segfault (#106)
* Gracefully degrade if clang-tidy segfaults * Typo on returncode
This commit is contained in:
parent
b2ef82e2da
commit
5b0174d282
@ -30,8 +30,11 @@ def run_subprocess(command, working_dir='.', env=None, expected_returncode=0):
|
||||
env=env,
|
||||
)
|
||||
print(result.stdout.decode('utf-8'))
|
||||
assert result.returncode == expected_returncode, \
|
||||
"Got unexpected return code {}".format(result.returncode)
|
||||
if expected_returncode is not None:
|
||||
assert result.returncode == expected_returncode, \
|
||||
"Got unexpected return code {}".format(result.returncode)
|
||||
else:
|
||||
return (result.returncode, result.stdout.decode('utf-8'))
|
||||
return result.stdout.decode('utf-8')
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
import os
|
||||
from glob import glob
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import pqclean
|
||||
import helpers
|
||||
@ -17,18 +18,26 @@ def test_clang_tidy():
|
||||
|
||||
def check_tidy(implementation: pqclean.Implementation):
|
||||
helpers.ensure_available('clang-tidy')
|
||||
cfiles = glob(os.path.join(implementation.path(), '*.c'))
|
||||
cfiles = implementation.cfiles()
|
||||
common_files = glob(os.path.join('..', 'common', '*.c'))
|
||||
helpers.run_subprocess(['clang-tidy',
|
||||
'-quiet',
|
||||
'-header-filter=.*'] +
|
||||
additional_flags +
|
||||
[*cfiles,
|
||||
*common_files,
|
||||
'--',
|
||||
'-iquote', os.path.join('..', 'common'),
|
||||
'-iquote', implementation.path(),
|
||||
])
|
||||
(returncode, _) = helpers.run_subprocess(
|
||||
['clang-tidy',
|
||||
'-quiet',
|
||||
'-header-filter=.*',
|
||||
*additional_flags,
|
||||
*cfiles,
|
||||
*common_files,
|
||||
'--',
|
||||
'-iquote', os.path.join('..', 'common'),
|
||||
'-iquote', implementation.path()],
|
||||
expected_returncode=None,
|
||||
)
|
||||
|
||||
# Detect and gracefully avoid segfaults
|
||||
if returncode == -11:
|
||||
raise unittest.SkipTest("clang-tidy segfaulted")
|
||||
else:
|
||||
assert returncode == 0, "Clang-tidy returned %d" % returncode
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
Reference in New Issue
Block a user