forked from yhirose/cpp-httplib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This integrates the "main" test suite (test/test.cc) in Meson. This allows to run the tests in the CI with the Meson-built version of the library to ensure that nothing breaks unexpectedly. It also simplifies life of downstream packagers, that do not have to write a custom build script to split the library and run tests but can instead just let Meson do that for them.
- Loading branch information
Showing
7 changed files
with
179 additions
and
5 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
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
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,97 @@ | ||
# SPDX-FileCopyrightText: 2021 Andrea Pappacoda | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
gtest_dep = dependency('gtest', main: true) | ||
openssl = find_program('openssl') | ||
test_conf = files('test.conf') | ||
|
||
key_pem = custom_target( | ||
'key_pem', | ||
output: 'key.pem', | ||
command: [openssl, 'genrsa', '-out', '@OUTPUT@', '2048'] | ||
) | ||
|
||
temp_req = custom_target( | ||
'temp_req', | ||
input: key_pem, | ||
output: 'temp_req', | ||
command: [openssl, 'req', '-new', '-batch', '-config', test_conf, '-key', '@INPUT@', '-out', '@OUTPUT@'] | ||
) | ||
|
||
cert_pem = custom_target( | ||
'cert_pem', | ||
input: [temp_req, key_pem], | ||
output: 'cert.pem', | ||
command: [openssl, 'x509', '-in', '@INPUT0@', '-days', '3650', '-req', '-signkey', '@INPUT1@', '-out', '@OUTPUT@'] | ||
) | ||
|
||
cert2_pem = custom_target( | ||
'cert2_pem', | ||
input: key_pem, | ||
output: 'cert2.pem', | ||
command: [openssl, 'req', '-x509', '-config', test_conf, '-key', '@INPUT@', '-sha256', '-days', '3650', '-nodes', '-out', '@OUTPUT@', '-extensions', 'SAN'] | ||
) | ||
|
||
rootca_key_pem = custom_target( | ||
'rootca_key_pem', | ||
output: 'rootCA.key.pem', | ||
command: [openssl, 'genrsa', '-out', '@OUTPUT@', '2048'] | ||
) | ||
|
||
rootca_cert_pem = custom_target( | ||
'rootca_cert_pem', | ||
input: rootca_key_pem, | ||
output: 'rootCA.cert.pem', | ||
command: [openssl, 'req', '-x509', '-new', '-batch', '-config', files('test.rootCA.conf'), '-key', '@INPUT@', '-days', '1024', '-out', '@OUTPUT@'] | ||
) | ||
|
||
client_key_pem = custom_target( | ||
'client_key_pem', | ||
output: 'client.key.pem', | ||
command: [openssl, 'genrsa', '-out', '@OUTPUT@', '2048'] | ||
) | ||
|
||
client_temp_req = custom_target( | ||
'client_temp_req', | ||
input: client_key_pem, | ||
output: 'client_temp_req', | ||
command: [openssl, 'req', '-new', '-batch', '-config', test_conf, '-key', '@INPUT@', '-out', '@OUTPUT@'] | ||
) | ||
|
||
client_cert_pem = custom_target( | ||
'client_cert_pem', | ||
input: [client_temp_req, rootca_cert_pem, rootca_key_pem], | ||
output: 'client.cert.pem', | ||
command: [openssl, 'x509', '-in', '@INPUT0@', '-days', '370', '-req', '-CA', '@INPUT1@', '-CAkey', '@INPUT2@', '-CAcreateserial', '-out', '@OUTPUT@'] | ||
) | ||
|
||
# Copy test files to the build directory | ||
configure_file(input: 'ca-bundle.crt', output: 'ca-bundle.crt', copy: true) | ||
configure_file(input: 'image.jpg', output: 'image.jpg', copy: true) | ||
subdir(join_paths('www', 'dir')) | ||
subdir(join_paths('www2', 'dir')) | ||
subdir(join_paths('www3', 'dir')) | ||
|
||
test( | ||
'main', | ||
executable( | ||
'main', | ||
'test.cc', | ||
dependencies: [ | ||
cpp_httplib_dep, | ||
gtest_dep | ||
] | ||
), | ||
depends: [ | ||
key_pem, | ||
cert_pem, | ||
cert2_pem, | ||
rootca_key_pem, | ||
rootca_cert_pem, | ||
client_key_pem, | ||
client_cert_pem | ||
], | ||
workdir: meson.current_build_dir(), | ||
timeout: 300 | ||
) |
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,7 @@ | ||
# SPDX-FileCopyrightText: 2021 Andrea Pappacoda | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
configure_file(input: 'index.html', output: 'index.html', copy: true) | ||
configure_file(input: 'test.abcde', output: 'test.abcde', copy: true) | ||
configure_file(input: 'test.html', output: 'test.html', copy: 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,6 @@ | ||
# SPDX-FileCopyrightText: 2021 Andrea Pappacoda | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
configure_file(input: 'index.html', output: 'index.html', copy: true) | ||
configure_file(input: 'test.html', output: 'test.html', copy: 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,6 @@ | ||
# SPDX-FileCopyrightText: 2021 Andrea Pappacoda | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
configure_file(input: 'index.html', output: 'index.html', copy: true) | ||
configure_file(input: 'test.html', output: 'test.html', copy: true) |