summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBryant Mairs <bryantmairs@google.com>2017-12-15 14:18:14 -0800
committerBryant Mairs <bryantmairs@google.com>2017-12-20 07:05:04 -0800
commit149d6c1009e9c59b37076e5dba3e282c91b06ea1 (patch)
tree22ad98e60bc2195e099995bda17c84df12ce30ad /test
parent5d50acaa806b0b0cc6c04d26232fc6a6f10d18a3 (diff)
downloadnix-149d6c1009e9c59b37076e5dba3e282c91b06ea1.zip
Use write_all instead of write
Several tests make the assumption that all data is written, which is not guaranteed with write(), so use write_all() instead.
Diffstat (limited to 'test')
-rw-r--r--test/sys/test_aio.rs22
-rw-r--r--test/test_fcntl.rs4
-rw-r--r--test/test_pty.rs2
-rw-r--r--test/test_sendfile.rs2
-rw-r--r--test/test_unistd.rs2
5 files changed, 16 insertions, 16 deletions
diff --git a/test/sys/test_aio.rs b/test/sys/test_aio.rs
index 79a6b6c4..7cfc313d 100644
--- a/test/sys/test_aio.rs
+++ b/test/sys/test_aio.rs
@@ -100,7 +100,7 @@ fn test_aio_cancel_all() {
fn test_fsync() {
const INITIAL: &'static [u8] = b"abcdef123456";
let mut f = tempfile().unwrap();
- f.write(INITIAL).unwrap();
+ f.write_all(INITIAL).unwrap();
let mut aiocb = AioCb::from_fd( f.as_raw_fd(),
0, //priority
SigevNotify::SigevNone);
@@ -123,7 +123,7 @@ fn test_fsync_error() {
// Create an invalid AioFsyncMode
let mode = unsafe { mem::transmute(666) };
let mut f = tempfile().unwrap();
- f.write(INITIAL).unwrap();
+ f.write_all(INITIAL).unwrap();
let mut aiocb = AioCb::from_fd( f.as_raw_fd(),
0, //priority
SigevNotify::SigevNone);
@@ -139,7 +139,7 @@ fn test_aio_suspend() {
let timeout = TimeSpec::seconds(10);
let rbuf = Rc::new(vec![0; 4].into_boxed_slice());
let mut f = tempfile().unwrap();
- f.write(INITIAL).unwrap();
+ f.write_all(INITIAL).unwrap();
let mut wcb = AioCb::from_slice( f.as_raw_fd(),
2, //offset
@@ -180,7 +180,7 @@ fn test_read() {
let rbuf = Rc::new(vec![0; 4].into_boxed_slice());
const EXPECT: &'static [u8] = b"cdef";
let mut f = tempfile().unwrap();
- f.write(INITIAL).unwrap();
+ f.write_all(INITIAL).unwrap();
{
let mut aiocb = AioCb::from_boxed_slice( f.as_raw_fd(),
2, //offset
@@ -208,7 +208,7 @@ fn test_read_error() {
const INITIAL: &'static [u8] = b"abcdef123456";
let rbuf = Rc::new(vec![0; 4].into_boxed_slice());
let mut f = tempfile().unwrap();
- f.write(INITIAL).unwrap();
+ f.write_all(INITIAL).unwrap();
let mut aiocb = AioCb::from_boxed_slice( f.as_raw_fd(),
-1, //an invalid offset
rbuf.clone(),
@@ -226,7 +226,7 @@ fn test_read_into_mut_slice() {
let mut rbuf = vec![0; 4];
const EXPECT: &'static [u8] = b"cdef";
let mut f = tempfile().unwrap();
- f.write(INITIAL).unwrap();
+ f.write_all(INITIAL).unwrap();
{
let mut aiocb = AioCb::from_mut_slice( f.as_raw_fd(),
2, //offset
@@ -273,7 +273,7 @@ fn test_write() {
const EXPECT: &'static [u8] = b"abCDEF123456";
let mut f = tempfile().unwrap();
- f.write(INITIAL).unwrap();
+ f.write_all(INITIAL).unwrap();
let mut aiocb = AioCb::from_slice( f.as_raw_fd(),
2, //offset
&wbuf,
@@ -336,7 +336,7 @@ fn test_write_sigev_signal() {
const EXPECT: &'static [u8] = b"abCDEF123456";
let mut f = tempfile().unwrap();
- f.write(INITIAL).unwrap();
+ f.write_all(INITIAL).unwrap();
let mut aiocb = AioCb::from_slice( f.as_raw_fd(),
2, //offset
&WBUF,
@@ -371,7 +371,7 @@ fn test_lio_listio_wait() {
const EXPECT: &'static [u8] = b"abCDEF123456";
let mut f = tempfile().unwrap();
- f.write(INITIAL).unwrap();
+ f.write_all(INITIAL).unwrap();
{
let mut wcb = AioCb::from_slice( f.as_raw_fd(),
@@ -414,7 +414,7 @@ fn test_lio_listio_nowait() {
const EXPECT: &'static [u8] = b"abCDEF123456";
let mut f = tempfile().unwrap();
- f.write(INITIAL).unwrap();
+ f.write_all(INITIAL).unwrap();
{
let mut wcb = AioCb::from_slice( f.as_raw_fd(),
@@ -467,7 +467,7 @@ fn test_lio_listio_signal() {
let sigev_notify = SigevNotify::SigevSignal { signal: Signal::SIGUSR2,
si_value: 0 };
- f.write(INITIAL).unwrap();
+ f.write_all(INITIAL).unwrap();
{
let mut wcb = AioCb::from_slice( f.as_raw_fd(),
diff --git a/test/test_fcntl.rs b/test/test_fcntl.rs
index 795b6c85..6c232258 100644
--- a/test/test_fcntl.rs
+++ b/test/test_fcntl.rs
@@ -10,7 +10,7 @@ use std::os::unix::fs;
fn test_openat() {
const CONTENTS: &'static [u8] = b"abcd";
let mut tmp = NamedTempFile::new().unwrap();
- tmp.write(CONTENTS).unwrap();
+ tmp.write_all(CONTENTS).unwrap();
let dirfd = open(tmp.path().parent().unwrap(),
OFlag::empty(),
@@ -64,7 +64,7 @@ mod linux_android {
fn test_splice() {
const CONTENTS: &'static [u8] = b"abcdef123456";
let mut tmp = tempfile().unwrap();
- tmp.write(CONTENTS).unwrap();
+ tmp.write_all(CONTENTS).unwrap();
let (rd, wr) = pipe().unwrap();
let mut offset: loff_t = 5;
diff --git a/test/test_pty.rs b/test/test_pty.rs
index 7104a9a5..0060f60d 100644
--- a/test/test_pty.rs
+++ b/test/test_pty.rs
@@ -20,7 +20,7 @@ fn test_explicit_close() {
};
// This should work. But if there's been a double close, then it will
// return EBADF
- f.write(b"whatever").unwrap();
+ f.write_all(b"whatever").unwrap();
}
/// Test equivalence of `ptsname` and `ptsname_r`
diff --git a/test/test_sendfile.rs b/test/test_sendfile.rs
index 7db65b9a..689f5a60 100644
--- a/test/test_sendfile.rs
+++ b/test/test_sendfile.rs
@@ -12,7 +12,7 @@ use nix::sys::sendfile::sendfile;
fn test_sendfile() {
const CONTENTS: &'static [u8] = b"abcdef123456";
let mut tmp = tempfile().unwrap();
- tmp.write(CONTENTS).unwrap();
+ tmp.write_all(CONTENTS).unwrap();
let (rd, wr) = pipe().unwrap();
let mut offset: off_t = 5;
diff --git a/test/test_unistd.rs b/test/test_unistd.rs
index 93b54143..e8f9b448 100644
--- a/test/test_unistd.rs
+++ b/test/test_unistd.rs
@@ -339,7 +339,7 @@ fn test_lseek() {
fn test_lseek64() {
const CONTENTS: &'static [u8] = b"abcdef123456";
let mut tmp = tempfile().unwrap();
- tmp.write(CONTENTS).unwrap();
+ tmp.write_all(CONTENTS).unwrap();
let tmpfd = tmp.into_raw_fd();
lseek64(tmpfd, 5, Whence::SeekSet).unwrap();