2014-06-04 10:54:35 -07:00
|
|
|
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
use std::io::process::{Command, ProcessOutput};
|
|
|
|
use std::os;
|
|
|
|
use std::str;
|
2014-11-14 14:38:41 -08:00
|
|
|
use std::rt;
|
2014-11-26 08:12:18 -05:00
|
|
|
use std::thunk::Thunk;
|
2014-11-14 14:38:41 -08:00
|
|
|
|
2014-11-23 19:21:17 -08:00
|
|
|
use std::rt::unwind::try;
|
2014-06-04 10:54:35 -07:00
|
|
|
|
|
|
|
#[start]
|
2014-06-25 12:47:34 -07:00
|
|
|
fn start(argc: int, argv: *const *const u8) -> int {
|
2014-06-04 10:54:35 -07:00
|
|
|
if argc > 1 {
|
|
|
|
unsafe {
|
|
|
|
match **argv.offset(1) {
|
|
|
|
1 => {}
|
|
|
|
2 => println!("foo"),
|
|
|
|
3 => assert!(try(|| {}).is_ok()),
|
2014-10-09 15:17:22 -04:00
|
|
|
4 => assert!(try(|| panic!()).is_err()),
|
2014-11-26 08:12:18 -05:00
|
|
|
5 => assert!(try(|| spawn(move|| {})).is_err()),
|
2014-06-04 10:54:35 -07:00
|
|
|
6 => assert!(Command::new("test").spawn().is_err()),
|
2014-10-09 15:17:22 -04:00
|
|
|
_ => panic!()
|
2014-06-04 10:54:35 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2014-12-14 00:05:32 -08:00
|
|
|
let args = unsafe {
|
|
|
|
Vec::from_fn(argc as uint, |i| {
|
|
|
|
String::from_raw_buf(*argv.offset(i as int)).into_bytes()
|
|
|
|
})
|
|
|
|
};
|
2014-10-14 23:05:01 -07:00
|
|
|
let me = args[0].as_slice();
|
2014-06-04 10:54:35 -07:00
|
|
|
|
2014-08-04 14:19:02 +02:00
|
|
|
let x: &[u8] = &[1u8];
|
|
|
|
pass(Command::new(me).arg(x).output().unwrap());
|
|
|
|
let x: &[u8] = &[2u8];
|
|
|
|
pass(Command::new(me).arg(x).output().unwrap());
|
|
|
|
let x: &[u8] = &[3u8];
|
|
|
|
pass(Command::new(me).arg(x).output().unwrap());
|
|
|
|
let x: &[u8] = &[4u8];
|
|
|
|
pass(Command::new(me).arg(x).output().unwrap());
|
|
|
|
let x: &[u8] = &[5u8];
|
|
|
|
pass(Command::new(me).arg(x).output().unwrap());
|
|
|
|
let x: &[u8] = &[6u8];
|
|
|
|
pass(Command::new(me).arg(x).output().unwrap());
|
2014-12-14 00:05:32 -08:00
|
|
|
|
|
|
|
0
|
2014-06-04 10:54:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
fn pass(output: ProcessOutput) {
|
|
|
|
if !output.status.success() {
|
|
|
|
println!("{}", str::from_utf8(output.output.as_slice()));
|
|
|
|
println!("{}", str::from_utf8(output.error.as_slice()));
|
|
|
|
}
|
|
|
|
}
|