Use a unique exit status when the runtime fails normally

Check for it in run-fail tests
This commit is contained in:
Brian Anderson 2011-09-08 13:42:04 -07:00
parent 6f6f36172b
commit 0ea55ffdc8
4 changed files with 15 additions and 6 deletions

View file

@ -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.

View file

@ -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];

View file

@ -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();
}

View file

@ -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);
}