Esempio n. 1
0
def check_functest_sanitizers(implementation):
    env = None
    if platform.machine() == 'ppc' and os.environ.get('CC', 'gcc') == 'clang':
        raise unittest.SkipTest("Clang does not support ASAN on ppc")
    elif platform.machine() in ['armv7l', 'aarch64']:
        env = {'ASAN_OPTIONS': 'detect_leaks=0'}
    else:
        print("Supported platform: {}".format(platform.machine()))

    helpers.ensure_available('valgrind')
    helpers.make('clean-scheme',
                 'functest',
                 TYPE=implementation.scheme.type,
                 SCHEME=implementation.scheme.name,
                 IMPLEMENTATION=implementation.name,
                 EXTRAFLAGS='-fsanitize=address,undefined',
                 working_dir=os.path.join('..', 'test'),
                 env=env)
    helpers.run_subprocess(
        [
            os.path.join(
                '..', 'bin', 'functest_{}_{}{}'.format(
                    implementation.scheme.name, implementation.name,
                    '.exe' if os.name == 'nt' else ''))
        ],
        os.path.join('..', 'bin'),
        env=env,
    )
    # Remove files with ASAN library compiled in
    helpers.make('clean-scheme',
                 TYPE=implementation.scheme.type,
                 SCHEME=implementation.scheme.name,
                 IMPLEMENTATION=implementation.name,
                 working_dir=os.path.join('..', 'test'))
Esempio n. 2
0
def check_format(implementation: pqclean.Implementation):
    helpers.ensure_available('astyle')
    cfiles = implementation.cfiles()
    hfiles = implementation.hfiles()
    result = helpers.run_subprocess(
        ['astyle', '--dry-run', '--options=../.astylerc', *cfiles, *hfiles])
    assert (not ('Formatted' in result))
Esempio n. 3
0
def check_tidy(implementation: pqclean.Implementation):
    ensure_available('clang-tidy')
    cfiles = glob(os.path.join(implementation.path(), '*.c'))
    common_files = glob(os.path.join('..', 'common', '*.c'))
    run_subprocess([
        'clang-tidy',
        '-quiet',
        '-header-filter=.*',
        *cfiles,
        *common_files,
        '--',
        '-iquote',
        os.path.join('..', 'common'),
        '-iquote',
        implementation.path(),
    ])
Esempio n. 4
0
def test_clang_tidy(implementation: pqclean.Implementation):
    helpers.ensure_available('clang-tidy')
    cfiles = implementation.cfiles()
    common_files = glob(os.path.join('..', 'common', '*.c'))
    (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")

    assert returncode == 0, "Clang-tidy returned %d" % returncode
Esempio n. 5
0
def check_format(implementation: pqclean.Implementation):
    ensure_available('astyle')
    cfiles = implementation.cfiles()
    hfiles = implementation.hfiles()
    run_subprocess(
        ['astyle', '--dry-run', '--options=../.astylerc', *cfiles, *hfiles])