Skip to content

Commit 2a35dae

Browse files
committed
Add user_defined_same_as_libc test
1 parent f4ba247 commit 2a35dae

2 files changed

Lines changed: 17 additions & 20 deletions

File tree

tests/unit/out/refcount/user_defined_same_as_libc.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,22 @@ use std::io::prelude::*;
66
use std::io::{Read, Seek, Write};
77
use std::os::fd::AsFd;
88
use std::rc::{Rc, Weak};
9-
pub fn fopen_0(path: Ptr<u8>, mode: Ptr<u8>) -> Ptr<::std::fs::File> {
10-
let path: Value<Ptr<u8>> = Rc::new(RefCell::new(path));
11-
let mode: Value<Ptr<u8>> = Rc::new(RefCell::new(mode));
12-
(*path.borrow()).clone();
13-
(*mode.borrow()).clone();
14-
return Ptr::null();
9+
pub fn strchr_0(s: Ptr<u8>, c: i32) -> Ptr<u8> {
10+
let s: Value<Ptr<u8>> = Rc::new(RefCell::new(s));
11+
let c: Value<i32> = Rc::new(RefCell::new(c));
12+
return Ptr::<u8>::null();
1513
}
1614
pub fn main() {
1715
std::process::exit(main_0());
1816
}
1917
fn main_0() -> i32 {
20-
let fp: Value<Ptr<::std::fs::File>> = Rc::new(RefCell::new(
18+
let p: Value<Ptr<u8>> = Rc::new(RefCell::new(
2119
({
22-
let _path: Ptr<u8> = Ptr::from_string_literal("/tmp/irrelevant-file");
23-
let _mode: Ptr<u8> = Ptr::from_string_literal("r");
24-
fopen_0(_path, _mode)
20+
let _s: Ptr<u8> = Ptr::from_string_literal("hello");
21+
let _c: i32 = ('l' as i32);
22+
strchr_0(_s, _c)
2523
}),
2624
));
27-
assert!(((((*fp.borrow()).is_null()) as i32) != 0));
25+
assert!(((((*p.borrow()).is_null()) as i32) != 0));
2826
return 0;
2927
}

tests/unit/out/unsafe/user_defined_same_as_libc.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ use std::collections::BTreeMap;
66
use std::io::{Read, Seek, Write};
77
use std::os::fd::{AsFd, FromRawFd, IntoRawFd};
88
use std::rc::Rc;
9-
pub unsafe fn fopen_0(mut path: *const u8, mut mode: *const u8) -> *mut ::std::fs::File {
10-
&(path);
11-
&(mode);
9+
pub unsafe fn strchr_0(mut s: *const u8, mut c: i32) -> *mut u8 {
1210
return std::ptr::null_mut();
1311
}
1412
pub fn main() {
@@ -17,11 +15,12 @@ pub fn main() {
1715
}
1816
}
1917
unsafe fn main_0() -> i32 {
20-
let mut fp: *mut ::std::fs::File = (unsafe {
21-
let _path: *const u8 = (b"/tmp/irrelevant-file\0".as_ptr().cast_mut()).cast_const();
22-
let _mode: *const u8 = (b"r\0".as_ptr().cast_mut()).cast_const();
23-
fopen_0(_path, _mode)
24-
});
25-
assert!(((((fp).is_null()) as i32) != 0));
18+
let mut p: *const u8 = (unsafe {
19+
let _s: *const u8 = b"hello\0".as_ptr().cast_mut().cast_const();
20+
let _c: i32 = ('l' as i32);
21+
strchr_0(_s, _c)
22+
})
23+
.cast_const();
24+
assert!(((((p).is_null()) as i32) != 0));
2625
return 0;
2726
}

0 commit comments

Comments
 (0)