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
2 changes: 1 addition & 1 deletion FlashMQTests/run-make-from-ci.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

extra_configs=()
extra_configs=("CMAKE_BUILD_TYPE=Debug")
compiler="g++"

while [ -n "$*" ]; do
Expand Down
2 changes: 1 addition & 1 deletion FlashMQTests/run-tests-from-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ STDERR_LOG=$(mktemp)

cd buildtests || exit 1

if ./flashmq-tests 2> "$STDERR_LOG" ; then
if gdb --batch -x ../show-frames-on-hook.pdb.py --args ./flashmq-tests 2> "$STDERR_LOG" ; then
echo -e '\033[01;32mSUCCESS!\033[00m'
else
echo -e '\033[01;31mBummer\033[00m'
Expand Down
57 changes: 57 additions & 0 deletions FlashMQTests/show-frames-on-hook.pdb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# NB: the gdb object is given to us by gdb, we don't need to import it

# Making gdb a bit quieter
gdb.execute("set print thread-events off")
gdb.execute("set print inferior-events off")

# since our class runs in a separate thread and has different variables we'll
# need to store $issues inside GDB itself
gdb.execute("set $issues = 0")

class ShowFrames(gdb.Breakpoint):
def stop(self):
# 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()
if frame.name().startswith("MainTests::testAsserts"):
return False
frame = frame.older()

# This is a real assert triggering
gdb.execute("set $issues += 1")

frame = gdb.selected_frame()

indentation = ""
while frame:
print(f"{indentation}- [{frame.name()}]")
indentation += " "

try:
block = frame.block()
except:
# doc: If the frame does not have a block – for example, if there is no debugging information for the code in question – then this will throw an exception.
pass
else:
for variable in block:
print(f"{indentation}{variable.print_name} = ", end='')
if variable.print_name in ['maintests']:
print("(skipped)")
else:
try:
print(f"{variable.value(frame)} ({variable.type})")
except Exception as e:
print(f"({e})")
if frame.name().startswith('MainTests::'):
# if we go further up we'll end up in test runner's code, not too interesting
break
frame = frame.older()

return False

ShowFrames("trigger_gdb_if_attached")
gdb.execute("run")
gdb.execute("quit $issues")
8 changes: 8 additions & 0 deletions FlashMQTests/testhelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@ int assert_count;
int assert_fail_count;
bool asserts_print;

void trigger_gdb_if_attached()
{
// separate function to make it easier to hook into from gdb.
// if you don't have gdb attached this is a noop.
}

bool fmq_assert(bool b, const char *failmsg, const char *actual, const char *expected, const char *file, int line)
{
assert_count++;

if (!b)
{
trigger_gdb_if_attached();

assert_fail_count++;

if (asserts_print)
Expand Down
Loading