Skip to content

Commit

Permalink
Release v0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
arobenko committed Apr 13, 2024
2 parents deec71f + ef87d75 commit 0953fd1
Show file tree
Hide file tree
Showing 75 changed files with 5,349 additions and 1,493 deletions.
6 changes: 3 additions & 3 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ configuration:
- Release

environment:
COMMS_BRANCH: v5.2.2
CC_MQTT5_BRANCH: v2.6
COMMS_BRANCH: v5.2.3
CC_MQTT5_BRANCH: v2.7
matrix:
- CPP_STD: 17
- CPP_STD: 20
Expand Down Expand Up @@ -51,7 +51,7 @@ build_script:
- cmake .. -DCMAKE_BUILD_TYPE=%CONFIGURATION% -G "%CMAKE_GENERATOR%" %PLATFORM_PARAM% -DBOOST_ROOT="%BOOST_DIR%" ^
-DBoost_USE_STATIC_LIBS=ON -DCMAKE_CXX_STANDARD=%CPP_STD% -DCMAKE_INSTALL_PREFIX=install ^
-DCMAKE_PREFIX_PATH="%COMMON_INSTALL_DIR%" -DCC_MQTT5_BUILD_UNIT_TESTS=ON -DCC_MQTT5_CLIENT_AFL_FUZZ=ON ^
-DCC_MQTT5_CUSTOM_CLIENT_CONFIG_FILES=%APPVEYOR_BUILD_FOLDER%/client/lib/script/BareMetalConfig.cmake
-DCC_MQTT5_CUSTOM_CLIENT_CONFIG_FILES=%APPVEYOR_BUILD_FOLDER%/client/lib/script/BareMetalTestConfig.cmake
- cmake --build . --config %CONFIGURATION% --target install --parallel %NUMBER_OF_PROCESSORS%


Expand Down
135 changes: 124 additions & 11 deletions .github/workflows/actions_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: Github Actions Build
on: [push]

env:
COMMS_BRANCH: v5.2.2
CC_MQTT5_BRANCH: v2.6
COMMS_TAG: v5.2.3
CC_MQTT5_TAG: v2.7

jobs:
build_gcc_ubuntu_22_04:
Expand All @@ -19,7 +19,7 @@ jobs:
- cc_ver: 12
cpp: 20
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Prepare Install
run: sudo apt-get update --fix-missing
Expand All @@ -41,8 +41,8 @@ jobs:
COMMON_INSTALL_DIR: ${{runner.workspace}}/build/install
COMMON_BUILD_TYPE: ${{matrix.type}}
COMMON_CXX_STANDARD: ${{matrix.cpp}}
COMMS_TAG: ${{env.COMMS_BRANCH}}
CC_MQTT5_TAG: ${{env.CC_MQTT5_BRANCH}}
COMMS_TAG: ${{env.COMMS_TAG}}
CC_MQTT5_TAG: ${{env.CC_MQTT5_TAG}}

- name: Configure CMake
shell: bash
Expand All @@ -52,7 +52,7 @@ jobs:
-DCMAKE_PREFIX_PATH=${{runner.workspace}}/build/install -DCMAKE_CXX_STANDARD=${{matrix.cpp}} \
-DCC_MQTT5_WITH_DEFAULT_SANITIZERS=ON \
-DCC_MQTT5_BUILD_UNIT_TESTS=ON -DCC_MQTT5_BUILD_INTEGRATION_TESTS=ON \
-DCC_MQTT5_CUSTOM_CLIENT_CONFIG_FILES=$GITHUB_WORKSPACE/client/lib/script/BareMetalConfig.cmake \
-DCC_MQTT5_CUSTOM_CLIENT_CONFIG_FILES="$GITHUB_WORKSPACE/client/lib/script/BareMetalTestConfig.cmake;$GITHUB_WORKSPACE/client/lib/script/Qos0TestConfig.cmake;$GITHUB_WORKSPACE/client/lib/script/Qos1TestConfig.cmake" \
-DCC_MQTT5_CLIENT_AFL_FUZZ=ON
env:
CC: gcc-${{matrix.cc_ver}}
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:


steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Prepare Install
run: sudo apt-get update --fix-missing
Expand All @@ -111,8 +111,8 @@ jobs:
COMMON_INSTALL_DIR: ${{runner.workspace}}/build/install
COMMON_BUILD_TYPE: ${{matrix.type}}
COMMON_CXX_STANDARD: ${{matrix.cpp}}
COMMS_TAG: ${{env.COMMS_BRANCH}}
CC_MQTT5_TAG: ${{env.CC_MQTT5_BRANCH}}
COMMS_TAG: ${{env.COMMS_TAG}}
CC_MQTT5_TAG: ${{env.CC_MQTT5_TAG}}

- name: Configure CMake
shell: bash
Expand All @@ -122,7 +122,7 @@ jobs:
-DCMAKE_PREFIX_PATH=${{runner.workspace}}/build/install -DCMAKE_CXX_STANDARD=${{matrix.cpp}} \
-DCC_MQTT5_WITH_DEFAULT_SANITIZERS=ON \
-DCC_MQTT5_BUILD_UNIT_TESTS=ON -DCC_MQTT5_BUILD_INTEGRATION_TESTS=ON \
-DCC_MQTT5_CUSTOM_CLIENT_CONFIG_FILES=$GITHUB_WORKSPACE/client/lib/script/BareMetalConfig.cmake \
-DCC_MQTT5_CUSTOM_CLIENT_CONFIG_FILES="$GITHUB_WORKSPACE/client/lib/script/BareMetalTestConfig.cmake;$GITHUB_WORKSPACE/client/lib/script/Qos0TestConfig.cmake;$GITHUB_WORKSPACE/client/lib/script/Qos1TestConfig.cmake" \
-DCC_MQTT5_CLIENT_AFL_FUZZ=ON
env:
CC: clang-${{matrix.cc_ver}}
Expand All @@ -138,4 +138,117 @@ jobs:
working-directory: ${{runner.workspace}}/build
shell: bash
run: ctest -V


build_msvc_2019:
runs-on: windows-2019
strategy:
fail-fast: false
matrix:
type: [Debug, Release, MinSizeRel]
arch: [Win32, x64]
cpp: [17]

steps:
- uses: actions/checkout@v4

- name: Create Build Environment
run: cmake -E make_directory ${{runner.workspace}}/build

- name: Install Boost
shell: cmd
run: |
choco install boost-msvc-14.2
- name: Prepare externals
shell: cmd
run: |
%GITHUB_WORKSPACE%\script\prepare_externals.bat
env:
BUILD_DIR: ${{runner.workspace}}/build
PLATFORM: ${{matrix.arch}}
EXTERNALS_DIR: ${{runner.workspace}}/externals
COMMON_INSTALL_DIR: ${{runner.workspace}}/build/install
COMMON_BUILD_TYPE: ${{matrix.type}}
COMMON_CXX_STANDARD: ${{matrix.cpp}}
COMMS_TAG: ${{env.COMMS_TAG}}
CC_MQTT5_TAG: ${{env.CC_MQTT5_TAG}}

- name: Configure CMake
shell: cmd
working-directory: ${{runner.workspace}}/build
run: |
cmake %GITHUB_WORKSPACE% -A ${{matrix.arch}} -DCMAKE_BUILD_TYPE=${{matrix.type}} -DCMAKE_INSTALL_PREFIX=install ^
-DCMAKE_PREFIX_PATH=${{runner.workspace}}/build/install -DCMAKE_CXX_STANDARD=${{matrix.cpp}} -DBoost_USE_STATIC_LIBS=ON ^
-DCC_MQTT5_BUILD_UNIT_TESTS=ON ^
-DCC_MQTT5_CUSTOM_CLIENT_CONFIG_FILES="%GITHUB_WORKSPACE%/client/lib/script/BareMetalTestConfig.cmake;%GITHUB_WORKSPACE%/client/lib/script/Qos0TestConfig.cmake;%GITHUB_WORKSPACE%/client/lib/script/Qos1TestConfig.cmake" ^
-DCC_MQTT5_CLIENT_AFL_FUZZ=ON
- name: Build Target
working-directory: ${{runner.workspace}}/build
shell: cmd
run: cmake --build . --config ${{matrix.type}} --target install
env:
VERBOSE: 1
- name: Testing
working-directory: ${{runner.workspace}}/build
shell: cmd
run: ctest -V

build_msvc_2022:
runs-on: windows-2022
strategy:
fail-fast: false
matrix:
type: [Debug, Release, MinSizeRel]
arch: [Win32, x64]
cpp: [17, 20]

steps:
- uses: actions/checkout@v4

- name: Create Build Environment
run: cmake -E make_directory ${{runner.workspace}}/build

- name: Install Boost
if: matrix.arch == 'x64'
shell: cmd
run: |
choco install boost-msvc-14.3
- name: Prepare externals
shell: cmd
run: |
%GITHUB_WORKSPACE%\script\prepare_externals.bat
env:
BUILD_DIR: ${{runner.workspace}}/build
PLATFORM: ${{matrix.arch}}
EXTERNALS_DIR: ${{runner.workspace}}/externals
COMMON_INSTALL_DIR: ${{runner.workspace}}/build/install
COMMON_BUILD_TYPE: ${{matrix.type}}
COMMON_CXX_STANDARD: ${{matrix.cpp}}
COMMS_TAG: ${{env.COMMS_TAG}}
CC_MQTT5_TAG: ${{env.CC_MQTT5_TAG}}

- name: Configure CMake
shell: cmd
working-directory: ${{runner.workspace}}/build
run: |
cmake %GITHUB_WORKSPACE% -A ${{matrix.arch}} -DCMAKE_BUILD_TYPE=${{matrix.type}} -DCMAKE_INSTALL_PREFIX=install ^
-DCMAKE_PREFIX_PATH=${{runner.workspace}}/build/install -DCMAKE_CXX_STANDARD=${{matrix.cpp}} -DBoost_USE_STATIC_LIBS=ON ^
-DCC_MQTT5_BUILD_UNIT_TESTS=ON ^
-DCC_MQTT5_CUSTOM_CLIENT_CONFIG_FILES="%GITHUB_WORKSPACE%/client/lib/script/BareMetalTestConfig.cmake;%GITHUB_WORKSPACE%/client/lib/script/Qos0TestConfig.cmake;%GITHUB_WORKSPACE%/client/lib/script/Qos1TestConfig.cmake" ^
-DCC_MQTT5_CLIENT_APPS=${{env.HAS_BOOST}} -DCC_MQTT5_CLIENT_AFL_FUZZ=${{env.HAS_BOOST}}
env:
HAS_BOOST: "${{ matrix.arch == 'x64' && 'ON' || 'OFF' }}"

- name: Build Target
working-directory: ${{runner.workspace}}/build
shell: cmd
run: cmake --build . --config ${{matrix.type}} --target install
env:
VERBOSE: 1
- name: Testing
working-directory: ${{runner.workspace}}/build
shell: cmd
run: ctest -V

22 changes: 8 additions & 14 deletions client/afl_fuzz/AflFuzz.cpp.templ
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ public:

if (!cc_mqtt5_##NAME##client_is_network_disconnected(m_client.get())) {
infoLog() << "Insufficient data in buffer (" << dataLen << "), reporting network disconnected..." << std::endl;
cc_mqtt5_##NAME##client_notify_network_disconnected(m_client.get(), true);
cc_mqtt5_##NAME##client_notify_network_disconnected(m_client.get());
brokerDisconnectReportCb(this, nullptr);
continue;
}

Expand Down Expand Up @@ -192,7 +193,7 @@ public:
if ((consumed == 0U) && noMoreRead) {
if (!cc_mqtt5_##NAME##client_is_network_disconnected(m_client.get())) {
infoLog() << "No data consumed and no more input, reporting network disconnected..." << std::endl;
cc_mqtt5_##NAME##client_notify_network_disconnected(m_client.get(), true);
cc_mqtt5_##NAME##client_notify_network_disconnected(m_client.get());
continue;
}

Expand Down Expand Up @@ -277,12 +278,7 @@ private:
m_state.m_disconnected = false;
m_state.m_reauthRequired = !m_opts.authMethod().empty();
m_state.m_publishCount = 0U;

auto ec = cc_mqtt5_##NAME##client_init(m_client.get());
assert(ec == CC_Mqtt5ErrorCode_Success);
if (ec != CC_Mqtt5ErrorCode_Success) {
exit(-1);
}
m_state.m_connected = false;
}

void doConnect()
Expand Down Expand Up @@ -550,6 +546,7 @@ private:

m_state.m_disconnected = true;
m_state.m_reinitRequired = true;
m_state.m_connected = false;

CC_Mqtt5ErrorCode ec = CC_Mqtt5ErrorCode_ValuesLimit;
auto handle = cc_mqtt5_##NAME##client_disconnect_prepare(m_client.get(), &ec);
Expand All @@ -574,7 +571,7 @@ private:
if (ec != CC_Mqtt5ErrorCode_Success) {
errorLog() << "Failed to send disconnect\n";
return;
}
}
}

bool createGeneratorIfNeeded()
Expand Down Expand Up @@ -639,11 +636,8 @@ private:
auto& state = asThis(data)->m_state;
state.m_disconnected = true;
state.m_connected = false;

if (!cc_mqtt5_##NAME##client_is_network_disconnected(asThis(data)->m_client.get())) {
state.m_reinitRequired = true;
state.m_connectRequired = true;
}
state.m_reinitRequired = true;
state.m_connectRequired = true;
}

static void messageReceivedReportCb(void* data, const CC_Mqtt5MessageInfo* info)
Expand Down
14 changes: 5 additions & 9 deletions client/app/common/AppClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,6 @@ bool AppClient::start(int argc, const char* argv[])
return true;
}

auto ec = ::cc_mqtt5_client_init(m_client.get());
if (ec != CC_Mqtt5ErrorCode_Success) {
logError() << "Failed to initialize client object." << std::endl;
return false;
}

if (!createSession()) {
return false;
}
Expand All @@ -170,9 +164,10 @@ std::string AppClient::toString(CC_Mqtt5ErrorCode val)
"CC_Mqtt5ErrorCode_BufferOverflow",
"CC_Mqtt5ErrorCode_NotSupported",
"CC_Mqtt5ErrorCode_RetryLater",
"CC_Mqtt5ErrorCode_Terminating",
"CC_Mqtt5ErrorCode_Disconnecting",
"CC_Mqtt5ErrorCode_NetworkDisconnected",
"CC_Mqtt5ErrorCode_NotAuthenticated",
"CC_Mqtt5ErrorCode_PreparationLocked",
};
static constexpr std::size_t MapSize = std::extent<decltype(Map)>::value;
static_assert(MapSize == CC_Mqtt5ErrorCode_ValuesLimit);
Expand Down Expand Up @@ -755,10 +750,11 @@ bool AppClient::createSession()
});

m_session->setNetworkDisconnectedReportCb(
[this](bool disconnected)
[this]()
{
assert(m_client);
::cc_mqtt5_client_notify_network_disconnected(m_client.get(), disconnected);
::cc_mqtt5_client_notify_network_disconnected(m_client.get());
brokerDisconnectedImpl(nullptr);
}
);

Expand Down
6 changes: 6 additions & 0 deletions client/app/common/ProgramOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ void ProgramOptions::addSubscribe()
("sub-topic,t", po::value<StringsList>(), "Subscribe topic filter. Can be used multiple times.")
("sub-qos,q", po::value<UnsignedsList>(), "Subscribe max QoS: 0, 1, or 2. Defaults to 2. Can be used multiple times "
"(for each topic filter correspondingly).")
("sub-no-retained", "Disable reception of the retained messages")
("sub-binary", "Force binary output of the received message data")
("sub-id", po::value<unsigned>()->default_value(0), "\"Subscription Identifier\" property.")
("sub-user-prop", po::value<StringsList>(), "Add \"User Property\" in \"key=value\" format to the SUBSCRIBE request.")
Expand Down Expand Up @@ -332,6 +333,11 @@ ProgramOptions::UnsignedsList ProgramOptions::subQoses() const
return result;
}

bool ProgramOptions::subNoRetained() const
{
return m_vm.count("sub-no-retained") > 0U;
}

bool ProgramOptions::subBinary() const
{
return m_vm.count("sub-binary") > 0U;
Expand Down
1 change: 1 addition & 0 deletions client/app/common/ProgramOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class ProgramOptions
// Subscribe Options
StringsList subTopics() const;
UnsignedsList subQoses() const;
bool subNoRetained() const;
bool subBinary() const;
unsigned subId() const;
StringsList subUserProps() const;
Expand Down
8 changes: 5 additions & 3 deletions client/app/common/Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,16 @@ unsigned Session::reportData(const std::uint8_t* buf, std::size_t bufLen)
return m_dataReportCb(buf, bufLen);
}

void Session::reportNetworkDisconnected(bool disconnected)
void Session::reportNetworkDisconnected()
{
if (disconnected == m_networkDisconnected) {
if (m_networkDisconnected) {
return;
}

m_networkDisconnected = true;

assert(m_networkDisconnectedReportCb);
m_networkDisconnectedReportCb(disconnected);
m_networkDisconnectedReportCb();
}

} // namespace cc_mqtt5_client_app
4 changes: 2 additions & 2 deletions client/app/common/Session.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Session
m_dataReportCb = std::forward<TFunc>(func);
}

using NetworkDisconnectedReportCb = std::function<void (bool)>;
using NetworkDisconnectedReportCb = std::function<void ()>;
template <typename TFunc>
void setNetworkDisconnectedReportCb(TFunc&& func)
{
Expand All @@ -67,7 +67,7 @@ class Session
static std::ostream& logError();

unsigned reportData(const std::uint8_t* buf, std::size_t bufLen);
void reportNetworkDisconnected(bool disconnected);
void reportNetworkDisconnected();

virtual bool startImpl() = 0;
virtual void sendDataImpl(const std::uint8_t* buf, std::size_t bufLen) = 0;
Expand Down
Loading

0 comments on commit 0953fd1

Please sign in to comment.