Skip to content

Commit 968612e

Browse files
committed
Add run-make test for libnative file I/O and O_NONBLOCK
This tests #13336.
1 parent 339d400 commit 968612e

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-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,10 @@
1+
#include <fcntl.h>
2+
#include <stdio.h>
3+
4+
int main() {
5+
if (fcntl(1, F_SETFL, O_NONBLOCK) == -1) {
6+
perror("fcntl");
7+
return 1;
8+
}
9+
return 0;
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use std::io;
2+
use std::io::IoResult;
3+
use std::os;
4+
5+
fn run() -> IoResult<()> {
6+
let mut out = io::stdio::stdout_raw();
7+
for _ in range(0u, 32) {
8+
let mut buf = ['x' as u8, ..1024];
9+
buf[1023] = '\n' as u8;
10+
try!(out.write(buf));
11+
}
12+
Ok(())
13+
}
14+
15+
fn main() {
16+
match run() {
17+
Err(e) => {
18+
(writeln!(&mut io::stderr(), "Error: {}", e)).unwrap();
19+
os::set_exit_status(1);
20+
}
21+
Ok(()) => ()
22+
}
23+
}

0 commit comments

Comments
 (0)