Skip to content

Commit 9520d36

Browse files
committed
Update tests
1 parent 161b0b5 commit 9520d36

3 files changed

Lines changed: 78 additions & 29 deletions

File tree

‎tests/unit/out/refcount/fn_ptr_stable_sort.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fn main_0() -> i32 {
6060
});
6161
(v.as_pointer() as Ptr<Item>).sort_with_cmp(
6262
(v.as_pointer() as Ptr<Item>).to_end().get_offset(),
63-
Compare_0,
63+
*FnPtr::<fn(Ptr<Item>, Ptr<Item>) -> bool>::new(Compare_0),
6464
);
6565
assert!(
6666
((*(*(v.as_pointer() as Ptr<Item>)

‎tests/unit/out/refcount/qsort_bsearch.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn main_0() -> i32 {
2929
for __i in 0..8_usize {
3030
let mut __min = __i;
3131
for __j in (__i + 1)..8_usize {
32-
if cmp_int_0(
32+
if FnPtr::<fn(AnyPtr, AnyPtr) -> i32>::new(cmp_int_0)(
3333
__base.offset(__j * ::std::mem::size_of::<i32>()).to_any(),
3434
__base.offset(__min * ::std::mem::size_of::<i32>()).to_any(),
3535
) < 0
@@ -76,7 +76,7 @@ fn main_0() -> i32 {
7676
while __lo <= __hi && __found.is_null() {
7777
let __mid = __lo + (__hi - __lo) / 2;
7878
let __elem = __base.offset(__mid as usize * ::std::mem::size_of::<i32>());
79-
let __r = cmp_int_0(
79+
let __r = FnPtr::<fn(AnyPtr, AnyPtr) -> i32>::new(cmp_int_0)(
8080
((key.as_pointer()) as Ptr<i32>).to_any().clone(),
8181
__elem.to_any(),
8282
);
@@ -106,7 +106,7 @@ fn main_0() -> i32 {
106106
while __lo <= __hi && __found.is_null() {
107107
let __mid = __lo + (__hi - __lo) / 2;
108108
let __elem = __base.offset(__mid as usize * ::std::mem::size_of::<i32>());
109-
let __r = cmp_int_0(
109+
let __r = FnPtr::<fn(AnyPtr, AnyPtr) -> i32>::new(cmp_int_0)(
110110
((miss_key.as_pointer()) as Ptr<i32>).to_any().clone(),
111111
__elem.to_any(),
112112
);

‎tests/unit/out/refcount/unistd.rs‎

Lines changed: 74 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub fn test_close_0() {
4848
}
4949
pub fn test_lseek_1() {
5050
let path: Value<Ptr<u8>> = Rc::new(RefCell::new(Ptr::from_string_literal(
51-
b"/tmp/cpp2rust_lseek_test.tmp",
51+
b"cpp2rust_lseek_test.tmp",
5252
)));
5353
let fp: Value<Ptr<CFile>> = Rc::new(RefCell::new(
5454
match CFile::open(
@@ -88,7 +88,7 @@ pub fn test_lseek_1() {
8888
let fd: Value<i32> = Rc::new(RefCell::new((*fp.borrow()).with(|__f| __f.fd)));
8989
assert!(
9090
((({
91-
let __whence = match 2 {
91+
let __whence = match ::libc::SEEK_END {
9292
0 => nix::unistd::Whence::SeekSet,
9393
1 => nix::unistd::Whence::SeekCur,
9494
2 => nix::unistd::Whence::SeekEnd,
@@ -108,7 +108,7 @@ pub fn test_lseek_1() {
108108
);
109109
assert!(
110110
((({
111-
let __whence = match 0 {
111+
let __whence = match ::libc::SEEK_SET {
112112
0 => nix::unistd::Whence::SeekSet,
113113
1 => nix::unistd::Whence::SeekCur,
114114
2 => nix::unistd::Whence::SeekEnd,
@@ -176,7 +176,7 @@ pub fn test_lseek_1() {
176176
}
177177
pub fn test_read_2() {
178178
let path: Value<Ptr<u8>> = Rc::new(RefCell::new(Ptr::from_string_literal(
179-
b"/tmp/cpp2rust_read_test.tmp",
179+
b"cpp2rust_read_test.tmp",
180180
)));
181181
let fp: Value<Ptr<CFile>> = Rc::new(RefCell::new(
182182
match CFile::open(
@@ -272,7 +272,7 @@ pub fn test_read_2() {
272272
}
273273
pub fn test_unlink_3() {
274274
let path: Value<Ptr<u8>> = Rc::new(RefCell::new(Ptr::from_string_literal(
275-
b"/tmp/cpp2rust_unlink_test.tmp",
275+
b"cpp2rust_unlink_test.tmp",
276276
)));
277277
let fp: Value<Ptr<CFile>> = Rc::new(RefCell::new(
278278
match CFile::open(
@@ -400,7 +400,7 @@ pub fn test_pipe_4() {
400400
}
401401
pub fn test_ftruncate_5() {
402402
let path: Value<Ptr<u8>> = Rc::new(RefCell::new(Ptr::from_string_literal(
403-
b"/tmp/cpp2rust_ftruncate_test.tmp",
403+
b"cpp2rust_ftruncate_test.tmp",
404404
)));
405405
let fp: Value<Ptr<CFile>> = Rc::new(RefCell::new(
406406
match CFile::open(
@@ -452,7 +452,7 @@ pub fn test_ftruncate_5() {
452452
(*fd.borrow_mut()) = (*fp.borrow()).with(|__f| __f.fd);
453453
assert!(
454454
((({
455-
let __whence = match 2 {
455+
let __whence = match ::libc::SEEK_END {
456456
0 => nix::unistd::Whence::SeekSet,
457457
1 => nix::unistd::Whence::SeekCur,
458458
2 => nix::unistd::Whence::SeekEnd,
@@ -536,20 +536,68 @@ pub fn test_open_6() {
536536
}
537537
pub fn test_fcntl_7() {
538538
assert!(
539-
(((panic!(
540-
"fcntl is not supported in the refcount model (fd={}, cmd={}, varargs={})",
541-
0,
542-
1,
543-
&[].len()
544-
) >= -1_i32) as i32)
539+
((({
540+
let __res = match 1 {
541+
::libc::F_GETFL => FdRegistry::with_fd(0, |__fd| {
542+
nix::fcntl::fcntl(__fd, nix::fcntl::FcntlArg::F_GETFL)
543+
}),
544+
::libc::F_SETFL => {
545+
let __flags = nix::fcntl::OFlag::from_bits_retain(i32::get(&&[][0]));
546+
FdRegistry::with_fd(0, |__fd| {
547+
nix::fcntl::fcntl(__fd, nix::fcntl::FcntlArg::F_SETFL(__flags))
548+
})
549+
}
550+
::libc::F_GETFD => FdRegistry::with_fd(0, |__fd| {
551+
nix::fcntl::fcntl(__fd, nix::fcntl::FcntlArg::F_GETFD)
552+
}),
553+
::libc::F_SETFD => {
554+
let __flags = nix::fcntl::FdFlag::from_bits_retain(i32::get(&&[][0]));
555+
FdRegistry::with_fd(0, |__fd| {
556+
nix::fcntl::fcntl(__fd, nix::fcntl::FcntlArg::F_SETFD(__flags))
557+
})
558+
}
559+
__cmd => panic!("fcntl: unsupported cmd {}", __cmd),
560+
};
561+
match __res {
562+
Ok(__r) => __r,
563+
Err(__e) => {
564+
libcc2rs::cpp2rust_errno().write(__e as i32);
565+
-1
566+
}
567+
}
568+
} >= -1_i32) as i32)
545569
!= 0)
546570
);
547-
let duped: Value<i32> = Rc::new(RefCell::new(panic!(
548-
"fcntl is not supported in the refcount model (fd={}, cmd={}, varargs={})",
549-
0,
550-
0,
551-
&[(100).into(),].len()
552-
)));
571+
let duped: Value<i32> = Rc::new(RefCell::new({
572+
let __res = match 0 {
573+
::libc::F_GETFL => FdRegistry::with_fd(0, |__fd| {
574+
nix::fcntl::fcntl(__fd, nix::fcntl::FcntlArg::F_GETFL)
575+
}),
576+
::libc::F_SETFL => {
577+
let __flags = nix::fcntl::OFlag::from_bits_retain(i32::get(&&[(100).into()][0]));
578+
FdRegistry::with_fd(0, |__fd| {
579+
nix::fcntl::fcntl(__fd, nix::fcntl::FcntlArg::F_SETFL(__flags))
580+
})
581+
}
582+
::libc::F_GETFD => FdRegistry::with_fd(0, |__fd| {
583+
nix::fcntl::fcntl(__fd, nix::fcntl::FcntlArg::F_GETFD)
584+
}),
585+
::libc::F_SETFD => {
586+
let __flags = nix::fcntl::FdFlag::from_bits_retain(i32::get(&&[(100).into()][0]));
587+
FdRegistry::with_fd(0, |__fd| {
588+
nix::fcntl::fcntl(__fd, nix::fcntl::FcntlArg::F_SETFD(__flags))
589+
})
590+
}
591+
__cmd => panic!("fcntl: unsupported cmd {}", __cmd),
592+
};
593+
match __res {
594+
Ok(__r) => __r,
595+
Err(__e) => {
596+
libcc2rs::cpp2rust_errno().write(__e as i32);
597+
-1
598+
}
599+
}
600+
}));
553601
assert!(((((*duped.borrow()) >= -1_i32) as i32) != 0));
554602
if ((((*duped.borrow()) >= 0) as i32) != 0) {
555603
FdRegistry::close((*duped.borrow()));
@@ -558,12 +606,13 @@ pub fn test_fcntl_7() {
558606
pub fn test_ioctl_8() {
559607
let arg: Value<i32> = Rc::new(RefCell::new(0));
560608
assert!(
561-
(((panic!(
562-
"ioctl is not supported in the refcount model (fd={}, request={}, varargs={})",
563-
0,
564-
0_u64,
565-
&[(arg.as_pointer()).into(),].len()
566-
) >= -1_i32) as i32)
609+
((({
610+
panic!(
611+
"ioctl is not supported in the refcount model (fd={}, request={})",
612+
0, 0_u64
613+
);
614+
0
615+
} >= -1_i32) as i32)
567616
!= 0)
568617
);
569618
}

0 commit comments

Comments
 (0)