Skip to content

Commit e14a2b6

Browse files
committed
Add run-make test for libnative file I/O and O_NONBLOCK
This tests rust-lang#13336.
1 parent 31e8f24 commit e14a2b6

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-include ../tools.mk
2+
3+
all:
4+
$(RUSTC) write.rs
5+
$(CC) -o $(TMPDIR)/mknblock mknblock.c
6+
mkfifo $(TMPDIR)/fifo
7+
/bin/sh -c "(sleep 1; cat) < $(TMPDIR)/fifo > /dev/null" &
8+
/bin/sh -c "($(TMPDIR)/mknblock; $(TMPDIR)/write) > $(TMPDIR)/fifo"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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.
4+
//
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.
10+
11+
#include <fcntl.h>
12+
#include <stdio.h>
13+
14+
int main() {
15+
if (fcntl(1, F_SETFL, O_NONBLOCK) == -1) {
16+
perror("fcntl");
17+
return 1;
18+
}
19+
return 0;
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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.
4+
//
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.
10+
11+
use std::io;
12+
use std::io::IoResult;
13+
use std::os;
14+
15+
fn run() -> IoResult<()> {
16+
let mut out = io::stdio::stdout_raw();
17+
for _ in range(0u, 1024) {
18+
let mut buf = ['x' as u8, ..1024];
19+
buf[1023] = '\n' as u8;
20+
try!(out.write(buf));
21+
}
22+
Ok(())
23+
}
24+
25+
fn main() {
26+
match run() {
27+
Err(e) => {
28+
(writeln!(&mut io::stderr(), "Error: {}", e)).unwrap();
29+
os::set_exit_status(1);
30+
}
31+
Ok(()) => ()
32+
}
33+
}

0 commit comments

Comments
 (0)