Skip to content

Commit

Permalink
tests: display system error for the special files test
Browse files Browse the repository at this point in the history
  • Loading branch information
liushuyu committed Apr 3, 2021
1 parent 1b8556d commit 1d5d533
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/all.rs
Expand Up @@ -1157,27 +1157,27 @@ fn tar_directory_containing_special_files() {
use std::ffi::CString;

let td = t!(TempBuilder::new().prefix("tar-rs").tempdir());
let cdev = td.path().join("chr");
let fifo = td.path().join("fifo");

unsafe {
let cdev_path = t!(CString::new(cdev.to_str().unwrap()));
let ret = libc::mknod(cdev_path.as_ptr(), libc::S_IFCHR | 0o644, 0);
assert_eq!(ret, 0);
let fifo_path = t!(CString::new(fifo.to_str().unwrap()));
let ret = libc::mknod(fifo_path.as_ptr(), libc::S_IFIFO | 0o644, 0);
assert_eq!(ret, 0);
if ret != 0 {
libc::perror(fifo_path.as_ptr());
panic!("Failed to create a FIFO file");
}
}

t!(env::set_current_dir(td.path()));
let mut ar = Builder::new(Vec::new());
// append_path has a different logic for processing files, so we need to test it as well
t!(ar.append_path("chr"));
t!(ar.append_path("fifo"));
t!(ar.append_dir_all("special", td.path()));
// unfortunately, block device file cannot be created by non-root users
// as a substitute, just test the file that exists on most Unix systems
t!(env::set_current_dir("/dev/"));
t!(ar.append_path("loop0"));
// CI systems seem to have issues with creating a chr device
t!(ar.append_path("null"));
t!(ar.finish());
}

0 comments on commit 1d5d533

Please sign in to comment.