-
Notifications
You must be signed in to change notification settings - Fork 729
Dev shell tests with pytest #4062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
20bef28
nix: move devShell test into pytest
dougch b44fe1e
Merge branch 'main' into devShell_tests
dougch 76d1623
PR feedback
dougch 7c76283
Merge branch 'main' into devShell_tests
dougch 6c2fd86
addressing PR feedback
dougch 8cb8a60
Merge branch 'main' into devShell_tests
dougch 22d9ccb
Merge branch 'main' into devShell_tests
dougch c7bc07a
Removing sslyze/nassl check
dougch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 os | ||
import shutil | ||
import subprocess | ||
import pytest | ||
|
||
|
||
ALL_LCS = ["openssl-3.0", "openssl-1.1.1", | ||
"openssl-1.0.2", "libressl", "aws-lc"] | ||
|
||
|
||
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 | ||
assert lc is not None | ||
libcrypto = translate_lc(lc) | ||
include_path = os.getenv("CMAKE_INCLUDE_PATH") | ||
assert include_path is not None | ||
assert libcrypto in ALL_LCS | ||
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. | ||
assert lc is not None | ||
libcrypto = translate_lc(lc) | ||
include_path = os.getenv("CMAKE_INCLUDE_PATH") | ||
assert include_path is not None | ||
ALL_LCS.remove(libcrypto) | ||
for library in ALL_LCS: | ||
dougch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.