-
Notifications
You must be signed in to change notification settings - Fork 562
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
11 changed files
with
426 additions
and
2 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 |
---|---|---|
|
@@ -12,6 +12,7 @@ libbotan*.so.* | |
*.exe | ||
*.manifest | ||
build | ||
build_deps | ||
build.log | ||
botan | ||
botan-test | ||
|
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 |
---|---|---|
|
@@ -14,4 +14,4 @@ tab_width = 3 | |
|
||
[*.py] | ||
indent_size = 4 | ||
tab_width = 47 | ||
tab_width = 4 |
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,37 @@ | ||
{ | ||
"Botan Copyright Notice (C++)": { | ||
"prefix": [ | ||
"copyright", | ||
"header" | ||
], | ||
"body": [ | ||
"/**", | ||
" * ${1:<brief file content description>}", | ||
" * (C) ${2:<year>} Jack Lloyd", | ||
" * ${3:<year>} ${4:<your name(s)>} - ${5:<your company name (optional)>}", | ||
" *", | ||
" * Botan is released under the Simplified BSD License (see license.txt)", | ||
" */" | ||
], | ||
"description": "The copyright header provided in all of Botan's C++ and header files", | ||
"scope": "c,cpp" | ||
}, | ||
"Botan Copyright Notice (Python)": { | ||
"prefix": [ | ||
"copyright", | ||
"header" | ||
], | ||
"body": [ | ||
"\"\"\"", | ||
"${1:<brief file content description>}", | ||
"", | ||
"(C) ${2:<year>} Jack Lloyd", | ||
" ${3:<year>} ${4:<your name(s)>} (${5:<your company name (optional)>})", | ||
"", | ||
"Botan is released under the Simplified BSD License (see license.txt)", | ||
"\"\"\"" | ||
], | ||
"description": "The copyright header provided in all of Botan's Python scripts", | ||
"scope": "python" | ||
} | ||
} |
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,13 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. | ||
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp | ||
// List of extensions which should be recommended for users of this workspace. | ||
"recommendations": [ | ||
"ms-vscode.cpptools", | ||
"ms-python.python", | ||
"chiehyu.vscode-astyle", | ||
"EditorConfig.EditorConfig" | ||
], | ||
// List of extensions recommended by VS Code that should not be recommended for users of this workspace. | ||
"unwantedRecommendations": [] | ||
} |
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,30 @@ | ||
{ | ||
"configurations": [ | ||
{ | ||
"name": "Debug Unittests", | ||
"type": "cppdbg", | ||
"request": "launch", | ||
"program": "${workspaceFolder}/botan-test", | ||
"args": [ | ||
"--test-threads=1" | ||
], | ||
"stopAtEntry": false, | ||
"cwd": "${workspaceFolder}", | ||
"environment": [], | ||
"externalConsole": false, | ||
"MIMode": "gdb", | ||
"setupCommands": [ | ||
{ | ||
"description": "Enable pretty-printing for gdb", | ||
"text": "-enable-pretty-printing", | ||
"ignoreFailures": true | ||
}, | ||
{ | ||
"description": "Set Disassembly Flavor to Intel", | ||
"text": "-gdb-set disassembly-flavor intel", | ||
"ignoreFailures": true | ||
} | ||
] | ||
} | ||
] | ||
} |
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,31 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
from common import run_cmd, get_concurrency | ||
|
||
|
||
BORING_REPO = "https://github.com/reneme/boringssl.git" | ||
BORING_BRANCH = "rene/runner-20220322" | ||
|
||
BORING_PATH = "build_deps/boringssl" | ||
BOGO_PATH = os.path.join(BORING_PATH, "ssl", "test", "runner") | ||
|
||
SHIM_PATH = "./botan_bogo_shim" | ||
SHIM_CONFIG = "src/bogo_shim/config.json" | ||
|
||
|
||
def main(): | ||
if not os.path.isdir(BORING_PATH): | ||
# check out our fork of boring ssl | ||
run_cmd("git clone --depth 1 --branch %s %s %s" % | ||
(BORING_BRANCH, BORING_REPO, BORING_PATH)) | ||
|
||
# make doubly sure we're on the correct branch | ||
run_cmd("git -C %s checkout %s" % (BORING_PATH, BORING_BRANCH)) | ||
|
||
run_cmd("go test -pipe -num-workers %d -shim-path %s -shim-config %s" % | ||
(get_concurrency(), os.path.abspath(SHIM_PATH), os.path.abspath(SHIM_CONFIG)), BOGO_PATH) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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,57 @@ | ||
import os | ||
import sys | ||
import subprocess | ||
import re | ||
|
||
|
||
class BuildError(Exception): | ||
pass | ||
|
||
|
||
_MAKEFILE = "Makefile" | ||
|
||
|
||
def get_concurrency(): | ||
def_concurrency = 2 | ||
max_concurrency = 16 | ||
|
||
try: | ||
import multiprocessing | ||
return min(max_concurrency, multiprocessing.cpu_count()) | ||
except ImportError: | ||
return def_concurrency | ||
|
||
|
||
def run_cmd(cmd, workingdir=None): | ||
if isinstance(cmd, str): | ||
print('> running: ' + cmd) | ||
shell = True | ||
else: | ||
print('> running: ' + ' '.join(cmd)) | ||
shell = False | ||
sys.stdout.flush() | ||
|
||
try: | ||
subprocess.run(cmd, shell=shell, check=True, cwd=workingdir) | ||
except subprocess.CalledProcessError: | ||
raise BuildError('External command failed, aborting...') | ||
|
||
|
||
def _find_regex_in_makefile(regex): | ||
if not os.path.exists(_MAKEFILE): | ||
raise BuildError('No Makefile found. Maybe run ./configure.py?') | ||
|
||
with open(_MAKEFILE, 'r', encoding="utf-8") as f: | ||
return re.search(regex, f.read()) | ||
|
||
|
||
def get_test_binary_name(): | ||
match = _find_regex_in_makefile(r'TEST\s*=\s*([^\n]+)\n') | ||
if not match: | ||
raise BuildError('Test binary name not found in Makefile') | ||
test_file = os.path.split(match.group(1))[1] | ||
if not test_file: | ||
raise BuildError( | ||
'Cannot make sense of test binary name: ' + match.group(0)) | ||
|
||
return test_file |
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,45 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import re | ||
import sys | ||
|
||
import common | ||
|
||
|
||
TESTS_DIR = "src/tests" | ||
|
||
|
||
def get_test_names_from(test_file): | ||
if not os.path.dirname(test_file) == TESTS_DIR: | ||
raise common.BuildError( | ||
'Given file path is not a Botan unit test: ' + test_file) | ||
|
||
with open(test_file, 'r', encoding='utf-8') as f: | ||
find_test_registration = \ | ||
re.compile( | ||
r'BOTAN_REGISTER_TEST(_FN)?\s*\(\s*\"(.+)\",\s*\"(.+)\",[^)]+\)') | ||
|
||
matches = find_test_registration.findall(f.read()) | ||
tests = [match[-1] for match in matches] | ||
|
||
if not tests: | ||
raise common.BuildError( | ||
'Failed to find a BOTAN_REGISTER_TEST in the given test file: ' + test_file) | ||
|
||
return tests | ||
|
||
|
||
def main(): | ||
test_binary = os.path.join('.', common.get_test_binary_name()) | ||
|
||
if len(sys.argv) == 2: | ||
test_src_file = sys.argv[1] | ||
test_names = get_test_names_from(test_src_file) | ||
common.run_cmd("%s %s" % (test_binary, ' '.join(test_names))) | ||
else: | ||
common.run_cmd(test_binary) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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,17 @@ | ||
{ | ||
"[cpp]": { | ||
"editor.defaultFormatter": "chiehyu.vscode-astyle" | ||
}, | ||
"astyle.astylerc": "${workspaceRoot}/src/configs/astyle.rc", | ||
"astyle.cmd_options": [ | ||
"--suffix=none" | ||
], | ||
"C_Cpp.default.cppStandard": "c++17", | ||
"C_Cpp.default.cStandard": "c17", | ||
"python.linting.pylintEnabled": true, | ||
"python.linting.enabled": true, | ||
"python.linting.pylintArgs": [ | ||
"--rcfile=src/configs/pylint.rc" | ||
], | ||
"python.linting.lintOnSave": true | ||
} |
Oops, something went wrong.