-
Notifications
You must be signed in to change notification settings - Fork 714
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
104 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import platform | ||
import pytest | ||
|
||
ALL = set(["aarch64", "x86_64"]) | ||
|
||
|
||
def pytest_runtest_setup(item): | ||
supported_platforms = ALL.intersection(mark.name for mark in item.iter_markers()) | ||
plat = platform.machine() | ||
if supported_platforms and plat not in supported_platforms: | ||
pytest.skip("platform specific test; not running on {}".format(plat)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[pytest] | ||
markers = | ||
aarch64: tests that should pass on aarch64 | ||
x86_64: tests that should pass on x86_64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import enum | ||
import sys | ||
import os | ||
import shutil | ||
import subprocess | ||
import platform | ||
import pytest | ||
|
||
|
||
def translate_lc(lc: str): | ||
# awslc for S2N_LIBCRYPTO is special. | ||
if "awslc" in lc: | ||
return "aws-lc" | ||
else: | ||
return lc | ||
|
||
|
||
@pytest.mark.parametrize("lc", [os.getenv("S2N_LIBCRYPTO")]) | ||
def test_s2n_libcrypto(lc): | ||
# Validate S2N_LIBCRYPTO is in the CMAKE_INCLUDE_PATH | ||
libcrypto = translate_lc(lc) | ||
include_path = os.getenv("CMAKE_INCLUDE_PATH") | ||
assert libcrypto is not None | ||
assert include_path is not None | ||
assert libcrypto in include_path | ||
|
||
|
||
@pytest.mark.parametrize("lc", [os.getenv("S2N_LIBCRYPTO")]) | ||
def test_s2n_libcrypto_uniq(lc): | ||
# Make certain we only have the preferred libcrypto in CMAKE_INCLUDE_PATH. | ||
libcrypto = translate_lc(lc) | ||
include_path = os.getenv("CMAKE_INCLUDE_PATH") | ||
assert libcrypto is not None | ||
assert include_path is not None | ||
all_lcs = ["openssl-3.0", "openssl-1.1.1", | ||
"openssl-1.0.2", "libressl", "aws-lc"] | ||
all_lcs.remove(libcrypto) | ||
for library in all_lcs: | ||
assert library not in include_path | ||
|
||
|
||
@pytest.mark.parametrize("cmd,expected,version", [ | ||
("gnutls-serv", "gnutls-serv 3.7", "--version"), | ||
("gnutls-cli", "gnutls-cli 3.7", "--version"), | ||
("openssl", "OpenSSL 1.1.1", "version"), | ||
("java", "Corretto-17", "--version")]) | ||
def test_utility_versions(cmd, expected, version): | ||
# Valildate utility is in the path and the correct version. | ||
abspath = shutil.which(cmd) | ||
result = "" | ||
with subprocess.Popen([abspath, version], shell=False, stdout=subprocess.PIPE) as p: | ||
output = p.stdout.readlines() | ||
for line in output: | ||
result += line.decode().strip() | ||
' '.join(result) | ||
assert expected in result | ||
|
||
|
||
def test_python(): | ||
# Validate python _from nix_ is in the PATH. | ||
assert 'nix' in shutil.which('python') | ||
|
||
|
||
def test_pytest(): | ||
# Validate pytest _from nix_ is in the PATH. | ||
assert 'nix' in shutil.which('pytest') | ||
|
||
|
||
@pytest.mark.x86_64 | ||
def test_sslyze(): | ||
# On x86, validate sslyze is available | ||
assert 'nix' in shutil.which('sslyze') | ||
|
||
|
||
@pytest.mark.x86_64 | ||
def test_nassl(): | ||
# On x86 validate nassl and version. | ||
import nassl | ||
assert nassl.__name__ == "nassl" | ||
assert nassl.__version__ == "5.0.0" | ||
|
||
|
||
if __name__ == "__main__": | ||
print("Use pytest") |