[gjs/gnome-3-30] tests: Don't time-limit the unit tests
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/gnome-3-30] tests: Don't time-limit the unit tests
- Date: Mon, 22 Oct 2018 14:32:03 +0000 (UTC)
commit 358a979769d14089993710b0bfbabed409a2ea6b
Author: Philip Chimento <philip chimento gmail com>
Date: Mon Aug 20 22:28:52 2018 -0400
tests: Don't time-limit the unit tests
Previously there was code that would intentionally crash if more than 7
minutes elapsed, in case the tests got stuck on autobuilders. This code
is more harmful than helpful, see the following table:
Times it has killed a stuck test on GitLab: . . . . . . . . 0
Times it has killed a JS_GC_ZEAL test: . . . . . . . . . 34
Times it has killed my GDB session because I forgot
to add the stupid environment variable: . . . . . . . . 478
test/gjs-test-utils.cpp | 88 -------------------------------------------------
test/gjs-test-utils.h | 2 --
test/gjs-tests.cpp | 5 ---
3 files changed, 95 deletions(-)
---
diff --git a/test/gjs-test-utils.cpp b/test/gjs-test-utils.cpp
index e3d89342..127d2baf 100644
--- a/test/gjs-test-utils.cpp
+++ b/test/gjs-test-utils.cpp
@@ -88,91 +88,3 @@ gjs_unit_test_exception_message(GjsUnitTestFixture *fx)
JS_ClearPendingException(fx->cx);
return retval;
}
-
-/* Fork a process that waits the given time then
- * sends us ABRT
- */
-void
-gjs_crash_after_timeout(int seconds)
-{
- pid_t parent_pid;
- int pipe_fds[2];
- fd_set read_fds;
- struct timeval term_time;
- struct timeval remaining;
- struct timeval now;
- int old_flags;
-
- /* We use a pipe to know in the child when the parent exited */
- if (pipe(pipe_fds) != 0) {
- fprintf(stderr, "Failed to create pipe to crash-in-timeout process: %s\n",
- strerror(errno));
- return;
- }
-
- /* We want pipe_fds[1] to only be open in the parent process; when it closes
- * the child will see an EOF. Setting FD_CLOEXEC is protection in case the
- * parent spawns off some process without properly closing fds.
- */
- old_flags = fcntl(pipe_fds[1], F_GETFD);
- if (old_flags == -1 ||
- fcntl(pipe_fds[1], F_SETFD, old_flags | FD_CLOEXEC) != 0) {
- fprintf(stderr, "Couldn't make crash-timeout pipe FD_CLOEXEC: %s\n",
- strerror(errno));
- return;
- }
-
- parent_pid = getpid();
-
- switch (fork()) {
- case -1:
- fprintf(stderr, "Failed to fork crash-in-timeout process: %s\n",
- strerror(errno));
- return;
- case 0:
- /* child */
- break;
- default:
- /* parent */
- close(pipe_fds[0]);
- return;
- }
-
- close (pipe_fds[1]);
-
- gettimeofday (&now, NULL);
-
- term_time = now;
- term_time.tv_sec += seconds;
-
- FD_ZERO(&read_fds);
- FD_SET(pipe_fds[0], &read_fds);
-
- while (true) {
- remaining.tv_sec = term_time.tv_sec - now.tv_sec;
- remaining.tv_usec = term_time.tv_usec - now.tv_usec;
- if (remaining.tv_usec < 0) {
- remaining.tv_usec += 1000;
- remaining.tv_sec -= 1;
- }
-
- if (remaining.tv_sec < 0) /* expired */
- break;
-
- select(pipe_fds[0] + 1, &read_fds, NULL, NULL, &remaining);
- if (FD_ISSET(pipe_fds[0], &read_fds)) {
- /* The parent exited */
- _exit(0);
- }
-
- gettimeofday(&now, NULL);
- }
-
- if (kill(parent_pid, 0) == 0) {
- fprintf(stderr, "Timeout of %d seconds expired; aborting process %d\n",
- seconds, (int) parent_pid);
- kill(parent_pid, SIGABRT);
- }
-
- _exit(1);
-}
diff --git a/test/gjs-test-utils.h b/test/gjs-test-utils.h
index 92c4c4cf..c9ba764e 100644
--- a/test/gjs-test-utils.h
+++ b/test/gjs-test-utils.h
@@ -46,8 +46,6 @@ void gjs_unit_test_fixture_teardown(GjsUnitTestFixture *fx,
char *gjs_unit_test_exception_message(GjsUnitTestFixture *fx);
-void gjs_crash_after_timeout(int seconds);
-
void gjs_test_add_tests_for_coverage ();
void gjs_test_add_tests_for_parse_call_args(void);
diff --git a/test/gjs-tests.cpp b/test/gjs-tests.cpp
index 820be6fa..e482c80f 100644
--- a/test/gjs-tests.cpp
+++ b/test/gjs-tests.cpp
@@ -406,11 +406,6 @@ int
main(int argc,
char **argv)
{
- /* give the unit tests 7 minutes to complete, unless an environment variable
- * is set; use this when running under GDB, for example */
- if (!g_getenv("GJS_TEST_SKIP_TIMEOUT"))
- gjs_crash_after_timeout(60 * 7);
-
/* Avoid interference in the tests from stray environment variable */
g_unsetenv("GJS_ENABLE_PROFILER");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]