From 0ea55ffdc87cd65de707d2d947cb57084be950f7 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 8 Sep 2011 13:42:04 -0700 Subject: [PATCH] Use a unique exit status when the runtime fails normally Check for it in run-fail tests --- src/rt/rust_internal.h | 3 +++ src/rt/rust_kernel.cpp | 2 +- src/rt/rust_scheduler.cpp | 2 +- src/test/compiletest/runtest.rs | 14 ++++++++++---- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/rt/rust_internal.h b/src/rt/rust_internal.h index d2c8574280b0..c01fc5f31279 100644 --- a/src/rt/rust_internal.h +++ b/src/rt/rust_internal.h @@ -99,6 +99,9 @@ static size_t const TIME_SLICE_IN_MS = 10; static size_t const BUF_BYTES = 2048; +// The error status to use when the process fails +#define PROC_FAIL_CODE 101; + // Every reference counted object should use this macro and initialize // ref_count. diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp index 54b1cc98d436..e5234b9d6f5d 100644 --- a/src/rt/rust_kernel.cpp +++ b/src/rt/rust_kernel.cpp @@ -140,7 +140,7 @@ rust_kernel::fail() { // Runtime to terminate it in an unusual way" when trying to shutdown // cleanly. #if defined(__WIN32__) - exit(1); + exit(rval); #endif for(size_t i = 0; i < num_threads; ++i) { rust_scheduler *thread = threads[i]; diff --git a/src/rt/rust_scheduler.cpp b/src/rt/rust_scheduler.cpp index 3a69184d3fe8..b127ec77efad 100644 --- a/src/rt/rust_scheduler.cpp +++ b/src/rt/rust_scheduler.cpp @@ -71,7 +71,7 @@ rust_scheduler::fail() { log(NULL, log_err, "domain %s @0x%" PRIxPTR " root task failed", name, this); I(this, kernel->rval == 0); - kernel->rval = 1; + kernel->rval = PROC_FAIL_CODE; kernel->fail(); } diff --git a/src/test/compiletest/runtest.rs b/src/test/compiletest/runtest.rs index c98f1deba246..fdcd627811db 100644 --- a/src/test/compiletest/runtest.rs +++ b/src/test/compiletest/runtest.rs @@ -51,15 +51,21 @@ fn run_rfail_test(cx: &cx, props: &test_props, testfile: &str) { procres = exec_compiled_test(cx, props, testfile); - if procres.status == 0 { - fatal_procres("run-fail test didn't produce an error!", procres); - } - + // The value our Makefile configures valgrind to return on failure const valgrind_err: int = 100; if procres.status == valgrind_err { fatal_procres("run-fail test isn't valgrind-clean!", procres); } + // The value the rust runtime returns on failure + const rust_err: int = 101; + if procres.status != rust_err { + fatal_procres( + #fmt("run-fail test produced the wrong error code: %d", + procres.status), + procres); + } + check_error_patterns(props, testfile, procres); }