Skip to content

Commit

Permalink
Add test for fixed args count
Browse files Browse the repository at this point in the history
  • Loading branch information
tiif committed Jan 4, 2025
1 parent 7085819 commit 3d062c1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/fail-dep/libc/wrong_fixed_arg_count.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//@ignore-target: windows # File handling is not implemented yet
//@compile-flags: -Zmiri-disable-isolation
use std::ffi::{CString, OsStr};
use std::os::unix::ffi::OsStrExt;

extern "C" {
fn open(path: *const libc::c_char, ...) -> libc::c_int;
}

fn main() {
let c_path = CString::new(OsStr::new("./text").as_bytes()).expect("CString::new failed");
let _fd = unsafe { open(c_path.as_ptr(), libc::O_RDWR) };
//~^ ERROR: incorrect number of fixed args
}
15 changes: 15 additions & 0 deletions tests/fail-dep/libc/wrong_fixed_arg_count.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error: Undefined Behavior: incorrect number of fixed args for `open/open64`: got 1, expected 2
--> tests/fail-dep/libc/wrong_fixed_arg_count.rs:LL:CC
|
LL | let _fd = unsafe { open(c_path.as_ptr(), libc::O_RDWR) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of fixed args for `open/open64`: got 1, expected 2
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: BACKTRACE:
= note: inside `main` at tests/fail-dep/libc/wrong_fixed_arg_count.rs:LL:CC

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

error: aborting due to 1 previous error

0 comments on commit 3d062c1

Please sign in to comment.