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.
13 use std::io::process::{Command, ProcessOutput};
18 use rustrt::unwind::try;
20 local_data_key!(foo: int)
23 fn start(argc: int, argv: *const *const u8) -> int {
26 match **argv.offset(1) {
29 3 => assert!(try(|| {}).is_ok()),
30 4 => assert!(try(|| panic!()).is_err()),
31 5 => assert!(try(|| spawn(proc() {})).is_err()),
32 6 => assert!(Command::new("test").spawn().is_err()),
33 7 => assert!(foo.get().is_none()),
34 8 => assert!(try(|| { foo.replace(Some(3)); }).is_err()),
41 rt::start(argc, argv, main)
45 let args = os::args();
46 let me = args[0].as_slice();
48 let x: &[u8] = &[1u8];
49 pass(Command::new(me).arg(x).output().unwrap());
50 let x: &[u8] = &[2u8];
51 pass(Command::new(me).arg(x).output().unwrap());
52 let x: &[u8] = &[3u8];
53 pass(Command::new(me).arg(x).output().unwrap());
54 let x: &[u8] = &[4u8];
55 pass(Command::new(me).arg(x).output().unwrap());
56 let x: &[u8] = &[5u8];
57 pass(Command::new(me).arg(x).output().unwrap());
58 let x: &[u8] = &[6u8];
59 pass(Command::new(me).arg(x).output().unwrap());
60 let x: &[u8] = &[7u8];
61 pass(Command::new(me).arg(x).output().unwrap());
62 let x: &[u8] = &[8u8];
63 pass(Command::new(me).arg(x).output().unwrap());
66 fn pass(output: ProcessOutput) {
67 if !output.status.success() {
68 println!("{}", str::from_utf8(output.output.as_slice()));
69 println!("{}", str::from_utf8(output.error.as_slice()));