Skip to content

Commit

Permalink
Remove Qt dependency from tests
Browse files Browse the repository at this point in the history
It was easy to do, because the test code itself was STL. Qt was only
used for the framework.

The Qxxxx macros used still work, and call FMQ macros.

The new assert functions have been well tested, and actually have
automatic tests themselves, to avoid silently not actually testing.
  • Loading branch information
halfgaar committed Mar 3, 2024
1 parent 676fb4e commit 6c102aa
Show file tree
Hide file tree
Showing 25 changed files with 896 additions and 375 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ jobs:
include:
- os: ubuntu-22.04
friendly: clang
SPEC: linux-clang
compiler: clang++
aptpkg: clang
- os: ubuntu-22.04
friendly: gcc
SPEC: linux-g++
compiler: g++
aptpkg: build-essential
runs-on: ${{ matrix.os }}
defaults:
Expand All @@ -23,7 +23,7 @@ jobs:
uses: actions/checkout@v3
- run: sudo apt update
# Build prerequisites
- run: sudo apt install -y cmake libssl-dev qtbase5-dev libcurl4-openssl-dev ${{ matrix.aptpkg }}
- run: sudo apt install -y cmake libssl-dev libcurl4-openssl-dev ${{ matrix.aptpkg }}
# Building
- run: ./run-make-from-ci.sh --spec "${{ matrix.SPEC }}"
- run: ./run-make-from-ci.sh --compiler "${{ matrix.compiler }}"
- run: ./run-tests-from-ci.sh
8 changes: 4 additions & 4 deletions .github/workflows/testing_non_sse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ jobs:
include:
- os: ubuntu-22.04
friendly: clang
SPEC: linux-clang
compiler: clang++
aptpkg: clang
- os: ubuntu-22.04
friendly: gcc
SPEC: linux-g++
compiler: g++
aptpkg: build-essential
runs-on: ${{ matrix.os }}
defaults:
Expand All @@ -23,7 +23,7 @@ jobs:
uses: actions/checkout@v3
- run: sudo apt update
# Build prerequisites
- run: sudo apt install -y cmake libssl-dev qtbase5-dev libcurl4-openssl-dev ${{ matrix.aptpkg }}
- run: sudo apt install -y cmake libssl-dev libcurl4-openssl-dev ${{ matrix.aptpkg }}
# Building
- run: ./run-make-from-ci.sh --spec "${{ matrix.SPEC }}" --extra-config "DEFINES += FMQ_NO_SSE"
- run: ./run-make-from-ci.sh --compiler "${{ matrix.compiler }}" --extra-config "FMQ_NO_SSE=1"
- run: ./run-tests-from-ci.sh
180 changes: 180 additions & 0 deletions FlashMQTests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
cmake_minimum_required(VERSION 3.5)
cmake_policy(SET CMP0048 NEW)
include(CheckCXXCompilerFlag)

project(FlashMQTests VERSION 1.0.0 LANGUAGES CXX)

add_definitions(-DOPENSSL_API_COMPAT=0x10100000L)
add_definitions(-DFLASHMQ_VERSION=\"${PROJECT_VERSION}\")
add_definitions(-DTESTING)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if (FMQ_NO_SSE)
add_definitions(-DFMQ_NO_SSE)
message("Building tests wihout SSE.")
else()
SET(CMAKE_CXX_FLAGS "-msse4.2")
endif()

set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -rdynamic")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic")

add_compile_options(-Wall)

add_library(test_plugin SHARED
plugins/test_plugin.h plugins/test_plugin.cpp
plugins/curlfunctions.h plugins/curlfunctions.cpp
)

target_link_libraries(test_plugin curl)

# Copying to a version 0.0.1 file is a bit of a hack. I'm not sure how to version it in this CMake otherwise.
add_custom_command(TARGET test_plugin POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "plugins/")
add_custom_command(TARGET test_plugin POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:test_plugin> "plugins/libtest_plugin.so.0.0.1")

# Copy in a way that always copies, to avoid unexpected staleness.
add_custom_command(TARGET test_plugin POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/UTF-8-test.txt"
"${CMAKE_BINARY_DIR}/UTF-8-test.txt")
add_custom_command(TARGET test_plugin POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/../fuzztests/plainwebsocketpacket1_handshake.dat"
"${CMAKE_BINARY_DIR}/plainwebsocketpacket1_handshake.dat")

add_executable(flashmq-tests
../forward_declarations.h
../mainapp.h
../utils.h
../threaddata.h
../client.h
../session.h
../mqttpacket.h
../exceptions.h
../types.h
../subscriptionstore.h
../rwlockguard.h
../retainedmessage.h
../cirbuf.h
../logger.h
../plugin.h
../configfileparser.h
../sslctxmanager.h
../timer.h
../iowrapper.h
../mosquittoauthoptcompatwrap.h
../settings.h
../listener.h
../unscopedlock.h
../scopedsocket.h
../bindaddr.h
../oneinstancelock.h
../evpencodectxmanager.h
../acltree.h
../enums.h
../threadlocalutils.h
../flashmq_plugin.h
../retainedmessagesdb.h
../persistencefile.h
../sessionsandsubscriptionsdb.h
../qospacketqueue.h
../threadglobals.h
../threadloop.h
../publishcopyfactory.h
../variablebyteint.h
../mqtt5properties.h
../globalstats.h
../derivablecounter.h
../packetdatatypes.h
../haproxy.h
../network.h
../subscription.h
../sharedsubscribers.h
../pluginloader.h
../queuedtasks.h
../acksender.h
../bridgeconfig.h
../dnsresolver.h
../globber.h

../mainapp.cpp
../utils.cpp
../threaddata.cpp
../client.cpp
../session.cpp
../mqttpacket.cpp
../exceptions.cpp
../types.cpp
../subscriptionstore.cpp
../rwlockguard.cpp
../retainedmessage.cpp
../cirbuf.cpp
../logger.cpp
../plugin.cpp
../configfileparser.cpp
../sslctxmanager.cpp
../timer.cpp
../iowrapper.cpp
../mosquittoauthoptcompatwrap.cpp
../settings.cpp
../listener.cpp
../unscopedlock.cpp
../scopedsocket.cpp
../bindaddr.cpp
../oneinstancelock.cpp
../evpencodectxmanager.cpp
../acltree.cpp
../threadlocalutils.cpp
../flashmq_plugin.cpp
../retainedmessagesdb.cpp
../persistencefile.cpp
../sessionsandsubscriptionsdb.cpp
../qospacketqueue.cpp
../threadglobals.cpp
../threadloop.cpp
../publishcopyfactory.cpp
../variablebyteint.cpp
../mqtt5properties.cpp
../globalstats.cpp
../derivablecounter.cpp
../packetdatatypes.cpp
../haproxy.cpp
../network.cpp
../subscription.cpp
../sharedsubscribers.cpp
../pluginloader.cpp
../queuedtasks.cpp
../acksender.cpp
../bridgeconfig.cpp
../dnsresolver.cpp
../bridgeinfodb.h
../bridgeinfodb.cpp
../globber.cpp
../x509manager.h
../x509manager.cpp
../backgroundworker.h ../backgroundworker.cpp
../flashmqtestclient.cpp ../flashmqtestclient.h
main.cpp
mainappinthread.h mainappinthread.cpp
maintests.h maintests.cpp
testhelpers.cpp testhelpers.h
flashmqtempdir.h flashmqtempdir.cpp
tst_maintests.cpp
retaintests.cpp
conffiletemp.cpp conffiletemp.h
filecloser.cpp filecloser.h
plugintests.cpp
sharedsubscriptionstests.cpp
websockettests.cpp
willtests.cpp
dnstests.cpp
testinitializer.h testinitializer.cpp

)

target_include_directories(flashmq-tests PUBLIC ..)

target_link_libraries(flashmq-tests pthread dl ssl crypto resolv anl)





165 changes: 0 additions & 165 deletions FlashMQTests/FlashMQTests.pro

This file was deleted.

Loading

0 comments on commit 6c102aa

Please sign in to comment.