Skip to content

Commit 54713af

Browse files
committed
add TLS failure test case in task.rs
1 parent 59221e9 commit 54713af

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/libcore/task.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,3 +1283,23 @@ fn test_tls_overwrite_multiple_types() unsafe {
12831283
local_data_set(int_key, @31337);
12841284
}
12851285
}
1286+
1287+
#[test]
1288+
#[should_fail]
1289+
#[ignore(cfg(windows))]
1290+
fn test_tls_cleanup_on_failure() unsafe {
1291+
fn str_key(+_x: @str) { }
1292+
fn box_key(+_x: @@()) { }
1293+
fn int_key(+_x: @int) { }
1294+
local_data_set(str_key, @"parent data");
1295+
local_data_set(box_key, @@());
1296+
task::spawn{|| // spawn_linked
1297+
local_data_set(str_key, @"string data");
1298+
local_data_set(box_key, @@());
1299+
local_data_set(int_key, @42);
1300+
fail;
1301+
}
1302+
// Not quite nondeterministic.
1303+
local_data_set(int_key, @31337);
1304+
fail;
1305+
}

0 commit comments

Comments
 (0)