1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 use std::io::process::{Command, ProcessOutput};
13 use std::rt::unwind::try;
16 use std::thread::Thread;
17 use std::thunk::Thunk;
20 fn start(argc: int, argv: *const *const u8) -> int {
23 match **argv.offset(1) {
26 3 => assert!(try(|| {}).is_ok()),
27 4 => assert!(try(|| panic!()).is_err()),
28 5 => assert!(Command::new("test").spawn().is_err()),
36 range(0, argc as uint).map(|i| {
37 String::from_raw_buf(*argv.offset(i as int)).into_bytes()
38 }).collect::<Vec<_>>()
40 let me = args[0].as_slice();
42 let x: &[u8] = &[1u8];
43 pass(Command::new(me).arg(x).output().unwrap());
44 let x: &[u8] = &[2u8];
45 pass(Command::new(me).arg(x).output().unwrap());
46 let x: &[u8] = &[3u8];
47 pass(Command::new(me).arg(x).output().unwrap());
48 let x: &[u8] = &[4u8];
49 pass(Command::new(me).arg(x).output().unwrap());
50 let x: &[u8] = &[5u8];
51 pass(Command::new(me).arg(x).output().unwrap());
56 fn pass(output: ProcessOutput) {
57 if !output.status.success() {
58 println!("{}", str::from_utf8(output.output.as_slice()));
59 println!("{}", str::from_utf8(output.error.as_slice()));