mirror of
https://github.com/boostorg/mqtt5.git
synced 2025-08-02 14:04:36 +02:00
Run test coverage
Summary:
related to T13434
- boost is installed as header only (binaries do not work with the coroutine code)
- added test coverage, final results: d9ef85a89b/tree
- finally can compile coroutine code
Reviewers: ivica
Reviewed By: ivica
Subscribers: miljen, iljazovic
Differential Revision: https://repo.mireo.local/D27287
This commit is contained in:
49
.github/workflows/ci.yml
vendored
49
.github/workflows/ci.yml
vendored
@@ -28,16 +28,6 @@ jobs:
|
|||||||
cxxflags: ''
|
cxxflags: ''
|
||||||
ldflags: ''
|
ldflags: ''
|
||||||
|
|
||||||
- toolset: g++-12
|
|
||||||
compiler: g++-12
|
|
||||||
install: g++-12
|
|
||||||
os: ubuntu-latest
|
|
||||||
container: ubuntu:22.04
|
|
||||||
build-type: 'Release'
|
|
||||||
cxxstd: 17
|
|
||||||
cxxflags: ''
|
|
||||||
ldflags: ''
|
|
||||||
|
|
||||||
- toolset: clang++-12
|
- toolset: clang++-12
|
||||||
compiler: clang++-12
|
compiler: clang++-12
|
||||||
install: clang++-12
|
install: clang++-12
|
||||||
@@ -64,14 +54,14 @@ jobs:
|
|||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
container: ubuntu:22.04
|
container: ubuntu:22.04
|
||||||
build-type: 'Release'
|
build-type: 'Release'
|
||||||
cxxstd: 17
|
cxxstd: 20
|
||||||
cxxflags: '-fdeclspec'
|
cxxflags: ''
|
||||||
ldflags: ''
|
ldflags: ''
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
container: ${{ matrix.container }}
|
container: ${{ matrix.container }}
|
||||||
env:
|
env:
|
||||||
CXXFLAGS: ${{ matrix.cxxflags }} -Wall -Wextra -std=c++17
|
CXXFLAGS: ${{ matrix.cxxflags }} -Wall -Wextra
|
||||||
LDFLAGS: ${{ matrix.ldflags }}
|
LDFLAGS: ${{ matrix.ldflags }}
|
||||||
CMAKE_BUILD_PARALLEL_LEVEL: 4
|
CMAKE_BUILD_PARALLEL_LEVEL: 4
|
||||||
|
|
||||||
@@ -83,33 +73,32 @@ jobs:
|
|||||||
if: matrix.container
|
if: matrix.container
|
||||||
run: |
|
run: |
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get -y install sudo wget tar cmake git openssl libssl-dev pkg-config
|
apt-get -y install sudo wget tar cmake openssl libssl-dev pkg-config
|
||||||
|
|
||||||
- name: Install compiler
|
- name: Install compiler
|
||||||
run: sudo apt-get install -y ${{ matrix.install }}
|
run: sudo apt-get install -y ${{ matrix.install }}
|
||||||
|
|
||||||
- name: Install Boost
|
- name: Setup Boost
|
||||||
uses: MarkusJx/install-boost@v2.4.4
|
run: |
|
||||||
id: install-boost
|
wget https://archives.boost.io/release/${{ env.BOOST_VERSION }}/source/boost_${{ env.BOOST_DIR_VER_NAME }}.tar.gz
|
||||||
with:
|
tar xzf boost_${{ env.BOOST_DIR_VER_NAME }}.tar.gz
|
||||||
boost_version: 1.82.0
|
mkdir /usr/local/boost_${{ env.BOOST_DIR_VER_NAME }}
|
||||||
platform_version: 22.04
|
mv boost_${{ env.BOOST_DIR_VER_NAME }}/boost /usr/local/boost_${{ env.BOOST_DIR_VER_NAME }}
|
||||||
|
rm boost_${{ env.BOOST_DIR_VER_NAME }}.tar.gz
|
||||||
|
|
||||||
- name: Setup library
|
- name: Setup library
|
||||||
run: |
|
run: |
|
||||||
cmake -S . -B build/${{ matrix.compiler }} -DCMAKE_CXX_COMPILER="${{ matrix.compiler }}"
|
cmake -S . -B build -DCMAKE_CXX_COMPILER="${{ matrix.compiler }}" \
|
||||||
sudo cmake --install build/${{ matrix.compiler }}
|
-DBoost_INCLUDE_DIR="/usr/local/boost_${{ env.BOOST_DIR_VER_NAME }}"
|
||||||
env:
|
sudo cmake --install build
|
||||||
BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }}
|
|
||||||
|
|
||||||
- name: Build tests
|
- name: Build tests
|
||||||
run: |
|
run: |
|
||||||
cmake -S test/unit -B test/unit/build/${{ matrix.compiler }} \
|
cmake -S test/unit -B test/unit/build \
|
||||||
-DCMAKE_CXX_COMPILER="${{ matrix.compiler }}" -DCMAKE_CXX_FLAGS="${{ env.CXXFLAGS }}" \
|
-DCMAKE_CXX_COMPILER="${{ matrix.compiler }}" -DCMAKE_CXX_FLAGS="${{ env.CXXFLAGS }}" \
|
||||||
-DCMAKE_EXE_LINKER_FLAGS="${{ env.LDFLAGS }}" -DCMAKE_BUILD_TYPE="${{ matrix.build-type }}"
|
-DCMAKE_CXX_STANDARD="${{ matrix.cxxstd }}" -DCMAKE_EXE_LINKER_FLAGS="${{ env.LDFLAGS }}" -DCMAKE_BUILD_TYPE="${{ matrix.build-type }}" \
|
||||||
cmake --build test/unit/build/${{ matrix.compiler }}
|
-DBoost_INCLUDE_DIR="/usr/local/boost_${{ env.BOOST_DIR_VER_NAME }}"
|
||||||
env:
|
cmake --build test/unit/build -j 4
|
||||||
BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }}
|
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: ./test/unit/build/${{ matrix.compiler }}/mqtt-test --log_level=test_suite
|
run: ./test/unit/build/mqtt-test --log_level=test_suite
|
||||||
|
84
.github/workflows/coverage.yml
vendored
Normal file
84
.github/workflows/coverage.yml
vendored
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
name: coverage
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
env:
|
||||||
|
BOOST_VERSION: 1.82.0
|
||||||
|
BOOST_DIR_VER_NAME: 1_82_0
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
posix:
|
||||||
|
name: "coverage ${{matrix.compiler}} -std=c++${{matrix.cxxstd}}"
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- toolset: coverage
|
||||||
|
compiler: g++-11
|
||||||
|
install: g++-11
|
||||||
|
os: ubuntu-latest
|
||||||
|
container: ubuntu:22.04
|
||||||
|
cxxstd: 20
|
||||||
|
cxxflags: '-g -O0 -std=c++20 --coverage -fkeep-inline-functions -fkeep-static-functions'
|
||||||
|
ldflags: '--coverage'
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
container: ${{ matrix.container }}
|
||||||
|
env:
|
||||||
|
CMAKE_BUILD_PARALLEL_LEVEL: 4
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup container environment
|
||||||
|
if: matrix.container
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get -y install sudo wget tar cmake openssl libssl-dev pkg-config lcov
|
||||||
|
|
||||||
|
- name: Install compiler
|
||||||
|
run: sudo apt-get install -y ${{ matrix.install }}
|
||||||
|
|
||||||
|
- name: Setup Boost
|
||||||
|
run: |
|
||||||
|
wget https://archives.boost.io/release/${{ env.BOOST_VERSION }}/source/boost_${{ env.BOOST_DIR_VER_NAME }}.tar.gz
|
||||||
|
tar xzf boost_${{ env.BOOST_DIR_VER_NAME }}.tar.gz
|
||||||
|
mkdir /usr/local/boost_${{ env.BOOST_DIR_VER_NAME }}
|
||||||
|
mv boost_${{ env.BOOST_DIR_VER_NAME }}/boost /usr/local/boost_${{ env.BOOST_DIR_VER_NAME }}
|
||||||
|
rm boost_${{ env.BOOST_DIR_VER_NAME }}.tar.gz
|
||||||
|
|
||||||
|
- name: Setup library
|
||||||
|
run: |
|
||||||
|
cmake -S . -B build -DCMAKE_CXX_COMPILER="${{ matrix.compiler }}" \
|
||||||
|
-DBoost_INCLUDE_DIR="/usr/local/boost_${{ env.BOOST_DIR_VER_NAME }}"
|
||||||
|
sudo cmake --install build
|
||||||
|
|
||||||
|
- name: Build tests
|
||||||
|
run: |
|
||||||
|
cmake -S test/unit -B test/unit/build -DCMAKE_CXX_COMPILER="${{ matrix.compiler }}" -DCMAKE_CXX_FLAGS="${{ matrix.cxxflags }}" \
|
||||||
|
-DCMAKE_EXE_LINKER_FLAGS="${{ matrix.ldflags }}" -DCMAKE_BUILD_TYPE="Coverage" \
|
||||||
|
-DBoost_INCLUDE_DIR="/usr/local/boost_${{ env.BOOST_DIR_VER_NAME }}"
|
||||||
|
cmake --build test/unit/build -j 4
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: ./test/unit/build/mqtt-test --log_level=test_suite
|
||||||
|
|
||||||
|
- name: Generate Coverage Report
|
||||||
|
run: |
|
||||||
|
lcov --capture --output-file coverage.info --directory test/unit/build
|
||||||
|
lcov --remove coverage.info '/usr/include/*' --output-file coverage.info
|
||||||
|
lcov --remove coverage.info '**/test/*' --output-file coverage.info
|
||||||
|
lcov --remove coverage.info '**/boost/*' --output-file coverage.info
|
||||||
|
|
||||||
|
- name: Upload coverage reports to Codecov
|
||||||
|
uses: codecov/codecov-action@v3
|
||||||
|
with:
|
||||||
|
files: coverage.info
|
||||||
|
fail_ci_if_error: true
|
||||||
|
env:
|
||||||
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
@@ -24,7 +24,6 @@ add_executable(
|
|||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(mqtt-test PRIVATE include)
|
target_include_directories(mqtt-test PRIVATE include)
|
||||||
target_compile_features(mqtt-test PRIVATE cxx_std_17)
|
|
||||||
target_compile_definitions(mqtt-test PRIVATE BOOST_TEST_NO_MAIN=1)
|
target_compile_definitions(mqtt-test PRIVATE BOOST_TEST_NO_MAIN=1)
|
||||||
|
|
||||||
find_package(OpenSSL REQUIRED)
|
find_package(OpenSSL REQUIRED)
|
||||||
|
@@ -190,7 +190,7 @@ BOOST_AUTO_TEST_CASE(rerunning_the_client) {
|
|||||||
using client_type = mqtt_client<stream_type>;
|
using client_type = mqtt_client<stream_type>;
|
||||||
client_type c(ioc, "");
|
client_type c(ioc, "");
|
||||||
|
|
||||||
c.brokers("mqtt.mireo.local", 1883)
|
c.brokers("broker.hivemq.com", 1883)
|
||||||
.credentials("test-cli", "", "")
|
.credentials("test-cli", "", "")
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
|
@@ -27,30 +27,6 @@ void async_teardown(
|
|||||||
|
|
||||||
} // end namespace boost::beast::websocket
|
} // end namespace boost::beast::websocket
|
||||||
|
|
||||||
constexpr char mireo_ca[] =
|
|
||||||
"-----BEGIN CERTIFICATE-----\n"
|
|
||||||
"MIIDUTCCAjmgAwIBAgIUAzV59EhZA5MXluHNqRi9cBP0x9swDQYJKoZIhvcNAQEL\n"
|
|
||||||
"BQAwGDEWMBQGA1UEAwwNTWlyZW8gUm9vdCBDQTAeFw0yMjA0MDcxMzM1MjlaFw0z\n"
|
|
||||||
"MjA0MDQxMzM1MjlaMBgxFjAUBgNVBAMMDU1pcmVvIFJvb3QgQ0EwggEiMA0GCSqG\n"
|
|
||||||
"SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCin/qsHpdxT3iW0SEHhAcTfESyQcfwGtJE\n"
|
|
||||||
"jcRrGEj36X6eahyY4AF+4Mlz2vWFeW52ayGXpQKn/z4tChdN80txdY77YmEX7XE0\n"
|
|
||||||
"HHZYY6toNq/+mNX9h2HvB0GW+8+E0YfNN/HloTxDo3RT8+IovY9OSXt44vY4YtQK\n"
|
|
||||||
"JbvZIm2Q8Iuv3vfNR05uFa4HcNqFhELh10jss0xG/54Y2NvB6xdKOZ8LRQuIX+Fu\n"
|
|
||||||
"QRzMiqRFQPUJzWxbKF5I/MFiKWmAG0QNPDnlb8XtPmFTFCWY9X96wOpQOczrxT2+\n"
|
|
||||||
"+vnTxPA3aTAkz7M4yUuocZQqTlbdfdGOSAENXavewdMCyy5bQsSLAgMBAAGjgZIw\n"
|
|
||||||
"gY8wHQYDVR0OBBYEFLdUGYfJRf9mbM/fTav9U2vFI+TRMFMGA1UdIwRMMEqAFLdU\n"
|
|
||||||
"GYfJRf9mbM/fTav9U2vFI+TRoRykGjAYMRYwFAYDVQQDDA1NaXJlbyBSb290IENB\n"
|
|
||||||
"ghQDNXn0SFkDkxeW4c2pGL1wE/TH2zAMBgNVHRMEBTADAQH/MAsGA1UdDwQEAwIB\n"
|
|
||||||
"BjANBgkqhkiG9w0BAQsFAAOCAQEAHm5d4YUP8BYcks10UCdswLtxbMUN99fNbnYo\n"
|
|
||||||
"RMxx4EapwhEZFSNbIZvf1INJd5Po+hH5jteBeFVP+4zKqrhg3I8pjdC4josHmrhS\n"
|
|
||||||
"28OjOFWp6xNJC43BHnLpc84bH0+XIEBbk7YA6H3GjpsZ7aJkhj/JPjjNq7bmyYN7\n"
|
|
||||||
"1I9RK4PtIrNtUFbSsHZCZhf8Amtl8PrpktITECjfqCq+8uOAqP4McTIQ1JKwYy6f\n"
|
|
||||||
"O6iu0eybJCFhWYENTUQyPi1VtEwOpWNLzaXBYdj69Xg8wA/J9RZIoqXWvtHv4rPF\n"
|
|
||||||
"HGudMEIVB3y2vVLmujvQCqYPZWwbgpy5mN3F4uBNuZhTIwWRFg==\n"
|
|
||||||
"-----END CERTIFICATE-----\n"
|
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
namespace async_mqtt5 {
|
namespace async_mqtt5 {
|
||||||
|
|
||||||
template <typename StreamBase>
|
template <typename StreamBase>
|
||||||
@@ -101,25 +77,24 @@ asio::awaitable<void> sanity_check(mqtt_client<StreamType, TlsContext>& c) {
|
|||||||
BOOST_CHECK(!ec_2);
|
BOOST_CHECK(!ec_2);
|
||||||
BOOST_CHECK(!pubcomp_rc);
|
BOOST_CHECK(!pubcomp_rc);
|
||||||
|
|
||||||
std::vector<subscribe_topic> topics;
|
subscribe_topic sub_topic = subscribe_topic {
|
||||||
topics.push_back(subscribe_topic{
|
"test/mqtt-test", async_mqtt5::subscribe_options {
|
||||||
"test/mqtt-test", {
|
|
||||||
qos_e::exactly_once,
|
qos_e::exactly_once,
|
||||||
subscribe_options::no_local_e::no,
|
subscribe_options::no_local_e::no,
|
||||||
subscribe_options::retain_as_published_e::retain,
|
subscribe_options::retain_as_published_e::retain,
|
||||||
subscribe_options::retain_handling_e::send
|
subscribe_options::retain_handling_e::send
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
auto [sub_ec, sub_codes, sub_props] = co_await c.async_subscribe(
|
auto [sub_ec, sub_codes, sub_props] = co_await c.async_subscribe(
|
||||||
topics, subscribe_props {}, use_nothrow_awaitable
|
sub_topic, subscribe_props {}, use_nothrow_awaitable
|
||||||
);
|
);
|
||||||
BOOST_CHECK(!sub_ec);
|
BOOST_CHECK(!sub_ec);
|
||||||
BOOST_CHECK(!sub_codes[0]);
|
BOOST_CHECK(!sub_codes[0]);
|
||||||
auto [rec, topic, payload, publish_props] = co_await c.async_receive(use_nothrow_awaitable);
|
auto [rec, topic, payload, publish_props] = co_await c.async_receive(use_nothrow_awaitable);
|
||||||
|
|
||||||
auto [unsub_ec, unsub_codes, unsub_props] = co_await c.async_unsubscribe(
|
auto [unsub_ec, unsub_codes, unsub_props] = co_await c.async_unsubscribe(
|
||||||
std::vector<std::string>{"test/mqtt-test"}, unsubscribe_props {},
|
"test/mqtt-test", unsubscribe_props {},
|
||||||
use_nothrow_awaitable
|
use_nothrow_awaitable
|
||||||
);
|
);
|
||||||
BOOST_CHECK(!unsub_ec);
|
BOOST_CHECK(!unsub_ec);
|
||||||
@@ -138,7 +113,7 @@ BOOST_AUTO_TEST_CASE(tcp_client_check) {
|
|||||||
client_type c(ioc, "");
|
client_type c(ioc, "");
|
||||||
|
|
||||||
c.credentials("tcp-tester", "", "")
|
c.credentials("tcp-tester", "", "")
|
||||||
.brokers("emqtt.mireo.local", 1883)
|
.brokers("broker.hivemq.com", 1883)
|
||||||
.will({ "test/mqtt-test", "Client disconnected!", qos_e::at_least_once })
|
.will({ "test/mqtt-test", "Client disconnected!", qos_e::at_least_once })
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
@@ -175,7 +150,7 @@ BOOST_AUTO_TEST_CASE(websocket_tcp_client_check) {
|
|||||||
client_type c(ioc, "");
|
client_type c(ioc, "");
|
||||||
|
|
||||||
c.credentials("websocket-tcp-tester", "", "")
|
c.credentials("websocket-tcp-tester", "", "")
|
||||||
.brokers("emqtt.mireo.local/mqtt", 8083)
|
.brokers("broker.hivemq.com/mqtt", 8000)
|
||||||
.will({ "test/mqtt-test", "Client disconnected!", qos_e::at_least_once })
|
.will({ "test/mqtt-test", "Client disconnected!", qos_e::at_least_once })
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
@@ -208,15 +183,11 @@ BOOST_AUTO_TEST_CASE(openssl_tls_client_check) {
|
|||||||
using stream_type = asio::ssl::stream<asio::ip::tcp::socket>;
|
using stream_type = asio::ssl::stream<asio::ip::tcp::socket>;
|
||||||
asio::ssl::context tls_context(asio::ssl::context::tls_client);
|
asio::ssl::context tls_context(asio::ssl::context::tls_client);
|
||||||
|
|
||||||
error_code ec;
|
|
||||||
tls_context.add_certificate_authority(asio::buffer(mireo_ca), ec);
|
|
||||||
tls_context.set_verify_mode(asio::ssl::verify_peer);
|
|
||||||
|
|
||||||
using client_type = mqtt_client<stream_type, decltype(tls_context)>;
|
using client_type = mqtt_client<stream_type, decltype(tls_context)>;
|
||||||
client_type c(ioc, "", std::move(tls_context));
|
client_type c(ioc, "", std::move(tls_context));
|
||||||
|
|
||||||
c.credentials("openssl-tls-tester", "", "")
|
c.credentials("openssl-tls-tester", "", "")
|
||||||
.brokers("emqtt.mireo.local", 8883)
|
.brokers("broker.hivemq.com", 8883)
|
||||||
.will({ "test/mqtt-test", "Client disconnected!", qos_e::at_least_once })
|
.will({ "test/mqtt-test", "Client disconnected!", qos_e::at_least_once })
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
@@ -249,16 +220,13 @@ BOOST_AUTO_TEST_CASE(websocket_tls_client_check) {
|
|||||||
asio::ssl::stream<asio::ip::tcp::socket>
|
asio::ssl::stream<asio::ip::tcp::socket>
|
||||||
>;
|
>;
|
||||||
|
|
||||||
error_code ec;
|
|
||||||
asio::ssl::context tls_context(asio::ssl::context::tls_client);
|
asio::ssl::context tls_context(asio::ssl::context::tls_client);
|
||||||
tls_context.add_certificate_authority(asio::buffer(mireo_ca), ec);
|
|
||||||
tls_context.set_verify_mode(asio::ssl::verify_peer);
|
|
||||||
|
|
||||||
using client_type = mqtt_client<stream_type, decltype(tls_context)>;
|
using client_type = mqtt_client<stream_type, decltype(tls_context)>;
|
||||||
client_type c(ioc, "", std::move(tls_context));
|
client_type c(ioc, "", std::move(tls_context));
|
||||||
|
|
||||||
c.credentials("websocket-tls-tester", "", "")
|
c.credentials("websocket-tls-tester", "", "")
|
||||||
.brokers("emqtt.mireo.local/mqtt", 8884)
|
.brokers("broker.hivemq.com/mqtt", 8884)
|
||||||
.will({ "test/mqtt-test", "Client disconnected!", qos_e::at_least_once })
|
.will({ "test/mqtt-test", "Client disconnected!", qos_e::at_least_once })
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user