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

[testing] race detection #671

Closed
wants to merge 2 commits into from
Closed
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
22 changes: 22 additions & 0 deletions test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,14 @@ sumThread(void *arg)

static int NUM_THREADS = 1000;

int _race = 0;
static void testThreadRace(void *arg)
{
test("testThreadRace: ");
_race = 1;
testCond(1);
}

static void
test_natsThread(void)
{
Expand All @@ -851,6 +859,20 @@ test_natsThread(void)
natsThread **threads = NULL;
int i,j;

test("Create thread: ");
s = natsThread_Create(&t, testThreadRace, &tArgs);
testCond(s == NATS_OK);
test("main thread: ");
_race = 2;
testCond(1);
test("Joining thread: ");
natsThread_Join(t);
testCond(1);
test("Destroy thread: ");
natsThread_Destroy(t);
testCond(1);
return;

if (valgrind)
NUM_THREADS = 100;

Expand Down
Loading