Skip to content

Commit

Permalink
i#725 attach: Remove flakiness from attach test
Browse files Browse the repository at this point in the history
Removes the printing of "event_post_attach" in the client.attach test,
as it had non-deterministic ordering versus the "thread init" printing
(and runall.cmake requires "thread init").  Replaces with a boolean
check and error print at exit to ensure we saw the attach event.

This completes the base attach feature.  Future problems should open new issues.

Fixes #725
  • Loading branch information
derekbruening committed Aug 4, 2023
1 parent bd11f79 commit 5297875
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
1 change: 0 additions & 1 deletion suite/tests/client-interface/attach_blocking.expect
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
starting
thank you for testing attach
thread init
event_post_attach
done
10 changes: 7 additions & 3 deletions suite/tests/client-interface/attach_test.dll.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* **********************************************************
* Copyright (c) 2021-2022 Google, Inc. All rights reserved.
* Copyright (c) 2021-2023 Google, Inc. All rights reserved.
* Copyright (c) 2008-2010 VMware, Inc. All rights reserved.
* **********************************************************/

Expand Down Expand Up @@ -39,14 +39,17 @@

static thread_id_t injection_tid;
static bool first_thread = true;
static bool saw_attach_event = false;

static void
dr_exit(void)
{
if (!saw_attach_event)
dr_fprintf(STDERR, "Error: never saw attach event!\n");
#ifdef WINDOWS
dr_fprintf(STDERR, "done\n");
#else
/* The app prints 'done' for us. */
/* The app prints 'done' for us. */
#endif
}

Expand Down Expand Up @@ -91,7 +94,8 @@ dr_exception_event(void *drcontext, dr_exception_t *excpt)
static void
event_post_attach(void)
{
dr_fprintf(STDERR, "%s\n", __FUNCTION__);
// We do not print here as the ordering is non-deterministic vs thread init.
saw_attach_event = true;
}

DR_EXPORT
Expand Down
6 changes: 0 additions & 6 deletions suite/tests/client-interface/attach_test.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@ starting attachee
starting
#endif
thank you for testing attach
#ifdef WINDOWS
event_post_attach
thread init
#else
thread init
event_post_attach
#endif
#ifdef WINDOWS
MessageBox closed
#endif
Expand Down

0 comments on commit 5297875

Please sign in to comment.