Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ jobs:
- run: sudo apt install -y cmake libssl-dev libcurl4-openssl-dev ${{ matrix.aptpkg }}
# Building
- run: ./run-make-from-ci.sh --compiler "${{ matrix.compiler }}"
# Test prerequisites
- run: sudo apt install -y gdb
# Testing
- run: ./run-tests-from-ci.sh
3 changes: 3 additions & 0 deletions .github/workflows/testing_non_sse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ jobs:
- run: sudo apt install -y cmake libssl-dev libcurl4-openssl-dev ${{ matrix.aptpkg }}
# Building
- run: ./run-make-from-ci.sh --compiler "${{ matrix.compiler }}" --extra-config "FMQ_NO_SSE=1"
# Test prerequisites
- run: sudo apt install -y gdb
# Testing
- run: ./run-tests-from-ci.sh
35 changes: 35 additions & 0 deletions FlashMQTests/fmq-generate-core-file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import time
import os


class FMQGenerateCoreFile(gdb.Command):
"""Generate a corefile with a dynamic name instead of core.PID"""

def __init__(self):
super().__init__("fmq-generate-core-file", gdb.COMMAND_USER)

def invoke(self, arg, from_tty):
# Are in in[MainTests::testAsserts]? If yes don't do anything (this is testing the framework on bootup)
frame = gdb.selected_frame()
while frame:
# The name is a bit compiler dependent, I've seen:
# MainTests::testAsserts
# MainTests::testAsserts()
frame_name = frame.name() or ''
if frame_name.startswith("MainTests::testAsserts"):
return False
frame = frame.older()

# This is something else
try:
runid = f".{os.environ['FMQ_RUN_ID']}."
except KeyError:
runid = "."
gdb.execute(
f"generate-core-file core{runid}{time.strftime('%Y-%d-%mT%H%M%S')}.{time.thread_time_ns()}"
)
issues = gdb.convenience_variable('issues') or 0
gdb.set_convenience_variable('issues', issues + 1)


FMQGenerateCoreFile() # this registers the CLI command
8 changes: 8 additions & 0 deletions FlashMQTests/main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <csignal>
#include <iostream>
#include <vector>

Expand All @@ -9,8 +10,15 @@ void printHelp(const std::string &arg0)
std::cout << "Usage: " << arg0 << " [ --skip-tests-with-internet ] [ --skip-server-tests ] " << " <tests> " << std::endl;
}

void signal_noop(int signal)
{
std::cout << "Signal NoOP (if you used save-core-on-sigvtalrm.gdb a core dump will now be created)" << std::endl;
}

int main(int argc, char *argv[])
{
std::signal(SIGVTALRM, signal_noop);

bool skip_tests_with_internet = false;
bool skip_server_tests = false;
std::vector<std::string> tests;
Expand Down
16 changes: 15 additions & 1 deletion FlashMQTests/run-tests-from-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,27 @@

STDERR_LOG=$(mktemp)


export FMQ_RUN_ID=$EPOCHSECONDS # this is only granular to the second but that should be fine

cd buildtests || exit 1

if ./flashmq-tests 2> "$STDERR_LOG" ; then
if gdb --batch -x ../fmq-generate-core-file.py -x ../save-core-on-sigvtalrm.gdb --args ./flashmq-tests 2> "$STDERR_LOG" ; then
echo -e '\033[01;32mSUCCESS!\033[00m'
else
echo -e '\033[01;31mBummer\033[00m'
echo -e "\n\nTail of stderr:\n\n"
tail -n 200 "$STDERR_LOG"

for i in "core.${FMQ_RUN_ID}."*
do
[[ "$i" == "core.${FMQ_RUN_ID}.*" ]] && break
echo ""
echo ",#############################################,"
echo "| $i |"
echo "'#############################################'"
gdb --batch --ex "bt -full" "./flashmq-tests" "$i"
done

exit 1
fi
16 changes: 16 additions & 0 deletions FlashMQTests/save-core-on-sigvtalrm.gdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Less verbose gdb please
set print thread-events off
set print inferior-events off

# fmq-generate-core-file will increase $issues when it dumps
set $issues = 0

catch signal SIGVTALRM
commands
fmq-generate-core-file
continue
end

run

exit $issues
3 changes: 3 additions & 0 deletions FlashMQTests/testhelpers.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "testhelpers.h"

#include <iostream>
#include <csignal>
#include <cstring>

int assert_count;
Expand All @@ -15,6 +16,8 @@ bool fmq_assert(bool b, const char *failmsg, const char *actual, const char *exp
{
assert_fail_count++;

raise(SIGVTALRM); // to create a corefile using GDB (if attached)

if (asserts_print)
{
// There are two types of failmsg: unformatted ones and formatted ones.
Expand Down
Loading