From: David Spickett Date: Fri, 3 Sep 2021 18:48:06 +0000 (-0700) Subject: [compiler-rt][Profile] Wait for child threads in set-file-object test X-Git-Tag: upstream/15.0.7~32276 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5e50d3073a5ead122a731580ded3f1cb3c21ee54;p=platform%2Fupstream%2Fllvm.git [compiler-rt][Profile] Wait for child threads in set-file-object test We've been seeing this test return 31 instead of 32 for the "functions" line in this test on our AArch64 bots. One possible cause is some of the children not finishing in time before the llvm-profdata commands are run, if the machine is heavily loaded. Wait for all the children to finish before exiting the parent. Reviewed By: zequanwu Differential Revision: https://reviews.llvm.org/D109222 --- diff --git a/compiler-rt/test/profile/ContinuousSyncMode/set-file-object.c b/compiler-rt/test/profile/ContinuousSyncMode/set-file-object.c index d32dd57..d710b39 100644 --- a/compiler-rt/test/profile/ContinuousSyncMode/set-file-object.c +++ b/compiler-rt/test/profile/ContinuousSyncMode/set-file-object.c @@ -41,6 +41,9 @@ #include #include +#include +#include + const int num_child_procs_to_spawn = 32; extern int __llvm_profile_is_continuous_mode_enabled(void); @@ -70,6 +73,24 @@ int main(int argc, char **argv) { return 1; } } + for (I = 0; I < num_child_procs_to_spawn; ++I) { + int status; + pid_t waited_pid = waitpid(child_pids[I], &status, 0); + if (waited_pid != child_pids[I]) { + fprintf(stderr, "Failed to wait on child %d\n", I); + return 1; + } + if (!WIFEXITED(status)) { + fprintf(stderr, "Child %d did not terminate normally\n", I); + return 1; + } + int return_status = WEXITSTATUS(status); + if (return_status != 0) { + fprintf(stderr, "Child %d exited with non zero status %d\n", I, + return_status); + return 1; + } + } } else if (strcmp(argv[1], "set") == 0) { // Child processes. if (!__llvm_profile_is_continuous_mode_enabled()) {