Skip to content

Commit

Permalink
Update tool.drcov.fib.template and add ifndef in fib.c for intercept_…
Browse files Browse the repository at this point in the history
…signal.
  • Loading branch information
ivankyluk committed Jan 21, 2025
1 parent 35b2b18 commit 552e793
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 20 deletions.
6 changes: 4 additions & 2 deletions suite/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2670,8 +2670,10 @@ if (NOT ANDROID) # TODO i#38: Port test to Android.
set(client.memory_dump_test_expectbase "memory_dump_test")
endif ()
tobuild_ci(client.memory_dump_test client-interface/memory_dump_test.c "" "" "")
torunonly_ci(client.attach_memory_dump_test common.fib client.memory_dump_test.dll
client-interface/attach_memory_dump_test.runall "" "" "attach")
if (LINUX)
torunonly_ci(client.attach_memory_dump_test common.fib client.memory_dump_test.dll
client-interface/attach_memory_dump_test.runall "" "" "attach")
endif ()
endif ()
endif ()

Expand Down
9 changes: 8 additions & 1 deletion suite/tests/common/fib.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ fib(int n)
return fib(n - 1) + fib(n - 2);
}

#ifndef WINDOWS
/* A no-op signal_handler to handle SIGTERM for attach memory dump test. */
static void
signal_handler(int sig)
{
}
#endif

int
main(int argc, char **argv)
Expand All @@ -83,7 +85,12 @@ main(int argc, char **argv)
INIT();
USE_USER32();

intercept_signal(SIGTERM, (handler_3_t)signal_handler, /*sigstack=*/false);
if (argc > 1 && strcmp(argv[1], "attach") == 0) {
attach = true;
#ifndef WINDOWS
intercept_signal(SIGTERM, (handler_3_t)signal_handler, /*sigstack=*/false);
}
#endif

print("fib(%d)=%d\n", 5, fib(5));
/* Enable use as a shorter test for tool.drcacheof.func_view. */
Expand Down
38 changes: 21 additions & 17 deletions suite/tests/common/tool.drcov.fib.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,31 @@ DA:66,1
DA:67,0
DA:68,1
DA:69,1
DA:73,1
DA:76,1
#if defined(WINDOWS)
DA:77,1
#endif
DA:79,1
DA:75,0
DA:76,0
DA:81,1
DA:82,0
DA:83,1
DA:85,1
DA:88,1
DA:89,1
DA:90,1
#if defined(WINDOWS)
DA:91,1
#endif
DA:93,1
DA:94,1
#if defined(WINDOWS)
DA:89,0
DA:91,0
DA:95,1
#endif
DA:97,1
DA:98,1
DA:98,0
DA:101,1
DA:102,0
DA:104,0
DA:105,0
DA:106,0
DA:109,1
DA:111,1
DA:114,1
DA:115,1
DA:116,1
DA:119,1
DA:120,1
DA:123,1
DA:126,1
DA:127,0
DA:129,1
end_of_record

0 comments on commit 552e793

Please sign in to comment.