Skip to content

Commit 3423917

Browse files
committed
---
yaml --- r: 59377 b: refs/heads/snap-stage3 c: dfe608d h: refs/heads/master i: 59375: 546d870 v: v3
1 parent 5fd9ccd commit 3423917

File tree

6 files changed

+73
-368
lines changed

6 files changed

+73
-368
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: c081ffbd1e845687202a975ea2e698b623e5722f
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: bf748e50017ab7cdb0f703ec9438793226d43a22
4+
refs/heads/snap-stage3: dfe608dc9949f913985bc8cfd8aedfe61b57d1d6
55
refs/heads/try: c50a9d5b664478e533ba1d1d353213d70c8ad589
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libcore/run.rs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,4 +855,74 @@ mod tests {
855855
fn waitpid_non_existant_pid() {
856856
run::waitpid(123456789); // assume that this pid doesn't exist
857857
}
858+
859+
#[test]
860+
fn test_destroy_once() {
861+
let mut p = run::start_program("echo", []);
862+
p.destroy(); // this shouldn't crash (and nor should the destructor)
863+
}
864+
865+
#[test]
866+
fn test_destroy_twice() {
867+
let mut p = run::start_program("echo", []);
868+
p.destroy(); // this shouldnt crash...
869+
p.destroy(); // ...and nor should this (and nor should the destructor)
870+
}
871+
872+
fn test_destroy_actually_kills(force: bool) {
873+
874+
#[cfg(unix)]
875+
static BLOCK_COMMAND: &'static str = "cat";
876+
877+
#[cfg(windows)]
878+
static BLOCK_COMMAND: &'static str = "cmd";
879+
880+
#[cfg(unix)]
881+
fn process_exists(pid: libc::pid_t) -> bool {
882+
run::program_output("ps", [~"-p", pid.to_str()]).out.contains(pid.to_str())
883+
}
884+
885+
#[cfg(windows)]
886+
fn process_exists(pid: libc::pid_t) -> bool {
887+
888+
use libc::types::os::arch::extra::DWORD;
889+
use libc::funcs::extra::kernel32::{CloseHandle, GetExitCodeProcess, OpenProcess};
890+
use libc::consts::os::extra::{FALSE, PROCESS_QUERY_INFORMATION, STILL_ACTIVE };
891+
892+
unsafe {
893+
let proc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid as DWORD);
894+
if proc.is_null() {
895+
return false;
896+
}
897+
// proc will be non-null if the process is alive, or if it died recently
898+
let mut status = 0;
899+
GetExitCodeProcess(proc, &mut status);
900+
CloseHandle(proc);
901+
return status == STILL_ACTIVE;
902+
}
903+
}
904+
905+
// this program will stay alive indefinitely trying to read from stdin
906+
let mut p = run::start_program(BLOCK_COMMAND, []);
907+
908+
assert!(process_exists(p.get_id()));
909+
910+
if force {
911+
p.force_destroy();
912+
} else {
913+
p.destroy();
914+
}
915+
916+
assert!(!process_exists(p.get_id()));
917+
}
918+
919+
#[test]
920+
fn test_unforced_destroy_actually_kills() {
921+
test_destroy_actually_kills(false);
922+
}
923+
924+
#[test]
925+
fn test_forced_destroy_actually_kills() {
926+
test_destroy_actually_kills(true);
927+
}
858928
}

branches/snap-stage3/src/libcore/vec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3304,7 +3304,7 @@ mod tests {
33043304
}
33053305

33063306
#[test]
3307-
fn test_iter_nonempty() {
3307+
fn test_each_nonempty() {
33083308
let mut i = 0;
33093309
for each(~[1, 2, 3]) |v| {
33103310
i += *v;
@@ -3313,7 +3313,7 @@ mod tests {
33133313
}
33143314

33153315
#[test]
3316-
fn test_iteri() {
3316+
fn test_eachi() {
33173317
let mut i = 0;
33183318
for eachi(~[1, 2, 3]) |j, v| {
33193319
if i == 0 { assert!(*v == 1); }

branches/snap-stage3/src/libstd/rc.rs

Lines changed: 0 additions & 275 deletions
This file was deleted.

branches/snap-stage3/src/libstd/std.rc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ pub mod uv_global_loop;
5050
pub mod c_vec;
5151
pub mod timer;
5252
pub mod io_util;
53-
pub mod rc;
5453

5554
// Concurrency
5655

0 commit comments

Comments
 (0)