Skip to content

Commit 0ea55ff

Browse files
committed
Use a unique exit status when the runtime fails normally
Check for it in run-fail tests
1 parent 6f6f361 commit 0ea55ff

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

src/rt/rust_internal.h

+3
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ static size_t const TIME_SLICE_IN_MS = 10;
9999

100100
static size_t const BUF_BYTES = 2048;
101101

102+
// The error status to use when the process fails
103+
#define PROC_FAIL_CODE 101;
104+
102105
// Every reference counted object should use this macro and initialize
103106
// ref_count.
104107

src/rt/rust_kernel.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ rust_kernel::fail() {
140140
// Runtime to terminate it in an unusual way" when trying to shutdown
141141
// cleanly.
142142
#if defined(__WIN32__)
143-
exit(1);
143+
exit(rval);
144144
#endif
145145
for(size_t i = 0; i < num_threads; ++i) {
146146
rust_scheduler *thread = threads[i];

src/rt/rust_scheduler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ rust_scheduler::fail() {
7171
log(NULL, log_err, "domain %s @0x%" PRIxPTR " root task failed",
7272
name, this);
7373
I(this, kernel->rval == 0);
74-
kernel->rval = 1;
74+
kernel->rval = PROC_FAIL_CODE;
7575
kernel->fail();
7676
}
7777

src/test/compiletest/runtest.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,21 @@ fn run_rfail_test(cx: &cx, props: &test_props, testfile: &str) {
5151

5252
procres = exec_compiled_test(cx, props, testfile);
5353

54-
if procres.status == 0 {
55-
fatal_procres("run-fail test didn't produce an error!", procres);
56-
}
57-
54+
// The value our Makefile configures valgrind to return on failure
5855
const valgrind_err: int = 100;
5956
if procres.status == valgrind_err {
6057
fatal_procres("run-fail test isn't valgrind-clean!", procres);
6158
}
6259

60+
// The value the rust runtime returns on failure
61+
const rust_err: int = 101;
62+
if procres.status != rust_err {
63+
fatal_procres(
64+
#fmt("run-fail test produced the wrong error code: %d",
65+
procres.status),
66+
procres);
67+
}
68+
6369
check_error_patterns(props, testfile, procres);
6470
}
6571

0 commit comments

Comments
 (0)