Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grab stack traces when unit test hangs #694

Merged
merged 3 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
24 changes: 11 additions & 13 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,18 @@ jobs:
CC: ${{ matrix.compiler }}
LIBDQLITE_TRACE: 1
run: |
for bin in unit-test integration-test \
raft-core-fuzzy-test raft-core-integration-test \
raft-core-unit-test raft-uv-integration-test \
raft-uv-unit-test
do ./$bin || touch any-failed
done 2>&1 | tee -a test-suite.log
test '!' -e any-failed
tests="integration-test \
cole-miller marked this conversation as resolved.
Show resolved Hide resolved
raft-core-fuzzy-test \
raft-core-integration-test \
raft-core-unit-test \
raft-uv-integration-test \
raft-uv-unit-test"
make check TESTS="$tests"

- name: OnTestFailure
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: test-suite.log
path: test-suite.log
./unit-test --no-fork &
pid=$!
bash -c "sleep 10m; sudo gdb -p $pid -batch -ex 'thread apply all bt' -ex quit; false" &
cole-miller marked this conversation as resolved.
Show resolved Hide resolved
wait -n

- name: Coverage
env:
Expand Down
5 changes: 5 additions & 0 deletions test/unit/lib/test_registry.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "../../../src/lib/registry.h"

#include "../../lib/runner.h"
#include "../../lib/sqlite.h"

TEST_MODULE(lib_registry);

Expand Down Expand Up @@ -45,6 +46,8 @@ static void *setup(const MunitParameter params[], void *user_data)
(void)params;
(void)user_data;

SETUP_SQLITE;

registry = (struct test_registry *)munit_malloc(sizeof(*registry));

test_registry_init(registry);
Expand All @@ -58,6 +61,8 @@ static void tear_down(void *data)

test_registry_close(registry);
free(registry);

TEAR_DOWN_SQLITE;
}

TEST_SUITE(add);
Expand Down
6 changes: 6 additions & 0 deletions test/unit/test_vfs2.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "../../src/lib/byte.h"
#include "../lib/fs.h"
#include "../lib/runner.h"
#include "../lib/sqlite.h"

#include <sqlite3.h>

Expand All @@ -29,6 +30,9 @@ static void *set_up(const MunitParameter params[], void *user_data)
(void)params;
(void)user_data;
struct fixture *f = munit_malloc(sizeof(*f));

SETUP_SQLITE;

f->dir = test_dir_setup();
f->vfs = vfs2_make(sqlite3_vfs_find("unix"), "dqlite-vfs2");
munit_assert_ptr_not_null(f->vfs);
Expand All @@ -43,6 +47,8 @@ static void tear_down(void *data)
vfs2_destroy(f->vfs);
test_dir_tear_down(f->dir);
free(f);

TEAR_DOWN_SQLITE;
}

static void prepare_wals(const char *dbname,
Expand Down
Loading