summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorVitaly _Vi Shukela <vi0oss@gmail.com>2020-09-10 23:04:35 +0300
committerVitaly _Vi Shukela <vi0oss@gmail.com>2020-09-20 01:51:46 +0300
commit74cb1545f4d2249b6086c3f4aa242e43362759de (patch)
treed710ee4a9a9a40f69a3a03aa853ce4469ba448c4 /test
parent2c2440521acb5942a5f937b8d3126577cf91106a (diff)
downloadnix-74cb1545f4d2249b6086c3f4aa242e43362759de.zip
Mark nix::unistd::fork as unsafe.
Fix tests. No change in documentation. Resolves #1030.
Diffstat (limited to 'test')
-rw-r--r--test/sys/test_ptrace.rs4
-rw-r--r--test/sys/test_uio.rs2
-rw-r--r--test/sys/test_wait.rs8
-rw-r--r--test/test_unistd.rs6
4 files changed, 10 insertions, 10 deletions
diff --git a/test/sys/test_ptrace.rs b/test/sys/test_ptrace.rs
index 46ea3d6a..3b60dd70 100644
--- a/test/sys/test_ptrace.rs
+++ b/test/sys/test_ptrace.rs
@@ -81,7 +81,7 @@ fn test_ptrace_cont() {
return;
}
- match fork().expect("Error: Fork Failed") {
+ match unsafe{fork()}.expect("Error: Fork Failed") {
Child => {
ptrace::traceme().unwrap();
// As recommended by ptrace(2), raise SIGTRAP to pause the child
@@ -132,7 +132,7 @@ fn test_ptrace_syscall() {
let _m = crate::FORK_MTX.lock().expect("Mutex got poisoned by another test");
- match fork().expect("Error: Fork Failed") {
+ match unsafe{fork()}.expect("Error: Fork Failed") {
Child => {
ptrace::traceme().unwrap();
// first sigstop until parent is ready to continue
diff --git a/test/sys/test_uio.rs b/test/sys/test_uio.rs
index 236560f4..4fa838c9 100644
--- a/test/sys/test_uio.rs
+++ b/test/sys/test_uio.rs
@@ -212,7 +212,7 @@ fn test_process_vm_readv() {
let mut vector = vec![1u8, 2, 3, 4, 5];
let (r, w) = pipe().unwrap();
- match fork().expect("Error: Fork Failed") {
+ match unsafe{fork()}.expect("Error: Fork Failed") {
Parent { child } => {
close(w).unwrap();
// wait for child
diff --git a/test/sys/test_wait.rs b/test/sys/test_wait.rs
index 53b7c84a..d1056250 100644
--- a/test/sys/test_wait.rs
+++ b/test/sys/test_wait.rs
@@ -11,7 +11,7 @@ fn test_wait_signal() {
let _ = crate::FORK_MTX.lock().expect("Mutex got poisoned by another test");
// Safe: The child only calls `pause` and/or `_exit`, which are async-signal-safe.
- match fork().expect("Error: Fork Failed") {
+ match unsafe{fork()}.expect("Error: Fork Failed") {
Child => {
pause();
unsafe { _exit(123) }
@@ -28,7 +28,7 @@ fn test_wait_exit() {
let _m = crate::FORK_MTX.lock().expect("Mutex got poisoned by another test");
// Safe: Child only calls `_exit`, which is async-signal-safe.
- match fork().expect("Error: Fork Failed") {
+ match unsafe{fork()}.expect("Error: Fork Failed") {
Child => unsafe { _exit(12); },
Parent { child } => {
assert_eq!(waitpid(child, None), Ok(WaitStatus::Exited(child, 12)));
@@ -48,7 +48,7 @@ fn test_waitstatus_from_raw() {
fn test_waitstatus_pid() {
let _m = crate::FORK_MTX.lock().expect("Mutex got poisoned by another test");
- match fork().unwrap() {
+ match unsafe{fork()}.unwrap() {
Child => unsafe { _exit(0) },
Parent { child } => {
let status = waitpid(child, None).unwrap();
@@ -98,7 +98,7 @@ mod ptrace {
require_capability!(CAP_SYS_PTRACE);
let _m = crate::FORK_MTX.lock().expect("Mutex got poisoned by another test");
- match fork().expect("Error: Fork Failed") {
+ match unsafe{fork()}.expect("Error: Fork Failed") {
Child => ptrace_child(),
Parent { child } => ptrace_parent(child),
}
diff --git a/test/test_unistd.rs b/test/test_unistd.rs
index 0b2a810a..c7a75fbe 100644
--- a/test/test_unistd.rs
+++ b/test/test_unistd.rs
@@ -32,7 +32,7 @@ fn test_fork_and_waitpid() {
let _m = crate::FORK_MTX.lock().expect("Mutex got poisoned by another test");
// Safe: Child only calls `_exit`, which is signal-safe
- match fork().expect("Error: Fork Failed") {
+ match unsafe{fork()}.expect("Error: Fork Failed") {
Child => unsafe { _exit(0) },
Parent { child } => {
// assert that child was created and pid > 0
@@ -60,7 +60,7 @@ fn test_wait() {
let _m = crate::FORK_MTX.lock().expect("Mutex got poisoned by another test");
// Safe: Child only calls `_exit`, which is signal-safe
- match fork().expect("Error: Fork Failed") {
+ match unsafe{fork()}.expect("Error: Fork Failed") {
Child => unsafe { _exit(0) },
Parent { child } => {
let wait_status = wait();
@@ -302,7 +302,7 @@ macro_rules! execve_test_factory(
// Safe: Child calls `exit`, `dup`, `close` and the provided `exec*` family function.
// NOTE: Technically, this makes the macro unsafe to use because you could pass anything.
// The tests make sure not to do that, though.
- match fork().unwrap() {
+ match unsafe{fork()}.unwrap() {
Child => {
// Make `writer` be the stdout of the new process.
dup2(writer, 1).unwrap();