Skip to content

Commit f1752e0

Browse files
committed
Update tests
1 parent e3d0e63 commit f1752e0

3 files changed

Lines changed: 98 additions & 6 deletions

File tree

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,16 @@ fn main_0() -> i32 {
3333
}
3434
}));
3535
assert!(((((*fd.borrow()) >= 0) as i32) != 0));
36-
assert!((((libc::isatty((*fd.borrow())) == 0) as i32) != 0));
36+
assert!(
37+
(((match FdRegistry::with_fd((*fd.borrow()), |__fd| nix::unistd::isatty(__fd)) {
38+
Ok(__tty) => __tty as i32,
39+
Err(__e) => {
40+
libcc2rs::cpp2rust_errno().write(__e as i32);
41+
0
42+
}
43+
} == 0) as i32)
44+
!= 0)
45+
);
3746
assert!((((FdRegistry::close((*fd.borrow())) == 0) as i32) != 0));
3847
assert!(
3948
(((match nix::unistd::unlink((*path.borrow()).to_rust_string().as_str()) {

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

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,46 @@ fn main_0() -> i32 {
4848
} == 11_isize) as i32)
4949
!= 0)
5050
);
51-
assert!((((libc::lseek((*fd.borrow()), 0_i64, 2) == 11_i64) as i32) != 0));
52-
assert!((((libc::lseek((*fd.borrow()), 6_i64, 0) == 6_i64) as i32) != 0));
51+
assert!(
52+
((({
53+
let __whence = match 2 {
54+
0 => nix::unistd::Whence::SeekSet,
55+
1 => nix::unistd::Whence::SeekCur,
56+
2 => nix::unistd::Whence::SeekEnd,
57+
__w => panic!("lseek: unsupported whence {__w}"),
58+
};
59+
match FdRegistry::with_fd((*fd.borrow()), |__fd| {
60+
nix::unistd::lseek(__fd, 0_i64, __whence)
61+
}) {
62+
Ok(__off) => __off,
63+
Err(__e) => {
64+
libcc2rs::cpp2rust_errno().write(__e as i32);
65+
-1
66+
}
67+
}
68+
} == 11_i64) as i32)
69+
!= 0)
70+
);
71+
assert!(
72+
((({
73+
let __whence = match 0 {
74+
0 => nix::unistd::Whence::SeekSet,
75+
1 => nix::unistd::Whence::SeekCur,
76+
2 => nix::unistd::Whence::SeekEnd,
77+
__w => panic!("lseek: unsupported whence {__w}"),
78+
};
79+
match FdRegistry::with_fd((*fd.borrow()), |__fd| {
80+
nix::unistd::lseek(__fd, 6_i64, __whence)
81+
}) {
82+
Ok(__off) => __off,
83+
Err(__e) => {
84+
libcc2rs::cpp2rust_errno().write(__e as i32);
85+
-1
86+
}
87+
}
88+
} == 6_i64) as i32)
89+
!= 0)
90+
);
5391
let buf: Value<Box<[u8]>> = Rc::new(RefCell::new(
5492
(0..16).map(|_| <u8>::default()).collect::<Box<[u8]>>(),
5593
));
@@ -93,8 +131,36 @@ fn main_0() -> i32 {
93131
} == 0) as i32)
94132
!= 0)
95133
);
96-
assert!((((libc::ftruncate((*fd.borrow()), 5_i64) == 0) as i32) != 0));
97-
assert!((((libc::lseek((*fd.borrow()), 0_i64, 2) == 5_i64) as i32) != 0));
134+
assert!(
135+
(((match FdRegistry::with_fd((*fd.borrow()), |__fd| nix::unistd::ftruncate(__fd, 5_i64)) {
136+
Ok(()) => 0,
137+
Err(__e) => {
138+
libcc2rs::cpp2rust_errno().write(__e as i32);
139+
-1
140+
}
141+
} == 0) as i32)
142+
!= 0)
143+
);
144+
assert!(
145+
((({
146+
let __whence = match 2 {
147+
0 => nix::unistd::Whence::SeekSet,
148+
1 => nix::unistd::Whence::SeekCur,
149+
2 => nix::unistd::Whence::SeekEnd,
150+
__w => panic!("lseek: unsupported whence {__w}"),
151+
};
152+
match FdRegistry::with_fd((*fd.borrow()), |__fd| {
153+
nix::unistd::lseek(__fd, 0_i64, __whence)
154+
}) {
155+
Ok(__off) => __off,
156+
Err(__e) => {
157+
libcc2rs::cpp2rust_errno().write(__e as i32);
158+
-1
159+
}
160+
}
161+
} == 5_i64) as i32)
162+
!= 0)
163+
);
98164
assert!((((FdRegistry::close((*fd.borrow())) == 0) as i32) != 0));
99165
assert!(
100166
(((match nix::unistd::unlink((*path.borrow()).to_rust_string().as_str()) {

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,24 @@ fn main_0() -> i32 {
3838
}
3939
}));
4040
assert!(((((*s.borrow()) >= 0) as i32) != 0));
41-
assert!((((libc::listen((*s.borrow()), 5) == 0) as i32) != 0));
41+
assert!(
42+
(((match nix::sys::socket::Backlog::new(5) {
43+
Ok(__b) => match FdRegistry::with_fd((*s.borrow()), |__fd| nix::sys::socket::listen(
44+
&__fd, __b
45+
)) {
46+
Ok(()) => 0,
47+
Err(__e) => {
48+
libcc2rs::cpp2rust_errno().write(__e as i32);
49+
-1
50+
}
51+
},
52+
Err(__e) => {
53+
libcc2rs::cpp2rust_errno().write(__e as i32);
54+
-1
55+
}
56+
} == 0) as i32)
57+
!= 0)
58+
);
4259
assert!((((FdRegistry::close((*s.borrow())) == 0) as i32) != 0));
4360
return 0;
4461
}

0 commit comments

Comments
 (0)