Skip to content

Commit e3d0e63

Browse files
committed
Update tests
1 parent 527dea1 commit e3d0e63

2 files changed

Lines changed: 0 additions & 400 deletions

File tree

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

Lines changed: 0 additions & 308 deletions
Original file line numberDiff line numberDiff line change
@@ -138,313 +138,5 @@ fn main_0() -> i32 {
138138
} == 0) as i32)
139139
!= 0)
140140
);
141-
let fds: Value<Box<[i32]>> = Rc::new(RefCell::new(
142-
(0..2).map(|_| <i32>::default()).collect::<Box<[i32]>>(),
143-
));
144-
assert!(
145-
(((match nix::unistd::pipe() {
146-
Ok((__r, __w)) => {
147-
let __fds = (fds.as_pointer() as Ptr<i32>).clone();
148-
__fds.write(FdRegistry::register(__r));
149-
__fds.offset(1).write(FdRegistry::register(__w));
150-
0
151-
}
152-
Err(__e) => {
153-
libcc2rs::cpp2rust_errno().write(__e as i32);
154-
-1
155-
}
156-
} == 0) as i32)
157-
!= 0)
158-
);
159-
assert!(
160-
(((match FdRegistry::with_fd((*fds.borrow())[(1) as usize], |__fd| {
161-
Ptr::from_string_literal(b"ab")
162-
.to_any()
163-
.reinterpret_cast::<u8>()
164-
.with_slice(2_usize, |__buf| nix::unistd::write(__fd, __buf))
165-
}) {
166-
Ok(__n) => __n as isize,
167-
Err(__e) => {
168-
libcc2rs::cpp2rust_errno().write(__e as i32);
169-
-1
170-
}
171-
} == 2_isize) as i32)
172-
!= 0)
173-
);
174-
let buf2: Value<Box<[u8]>> = Rc::new(RefCell::new(
175-
(0..4).map(|_| <u8>::default()).collect::<Box<[u8]>>(),
176-
));
177-
{
178-
((buf2.as_pointer() as Ptr<u8>) as Ptr<u8>)
179-
.to_any()
180-
.memset((0) as u8, ::std::mem::size_of::<[u8; 4]>() as usize);
181-
((buf2.as_pointer() as Ptr<u8>) as Ptr<u8>).to_any().clone()
182-
};
183-
assert!(
184-
(((match FdRegistry::with_fd((*fds.borrow())[(0) as usize], |__fd| {
185-
((buf2.as_pointer() as Ptr<u8>) as Ptr<u8>)
186-
.to_any()
187-
.reinterpret_cast::<u8>()
188-
.with_slice_mut(::std::mem::size_of::<[u8; 4]>(), |__buf| {
189-
nix::unistd::read(__fd, __buf)
190-
})
191-
}) {
192-
Ok(__n) => __n as isize,
193-
Err(__e) => {
194-
libcc2rs::cpp2rust_errno().write(__e as i32);
195-
-1
196-
}
197-
} == 2_isize) as i32)
198-
!= 0)
199-
);
200-
assert!(
201-
((({
202-
let mut __it1 = (buf2.as_pointer() as Ptr<u8>).to_c_string_iterator();
203-
let mut __it2 = Ptr::from_string_literal(b"ab").to_c_string_iterator();
204-
loop {
205-
let __c1 = __it1.next();
206-
let __c2 = __it2.next();
207-
if __c1 != __c2 {
208-
break (__c1.unwrap_or(0) as i32) - (__c2.unwrap_or(0) as i32);
209-
}
210-
if __c1.is_none() {
211-
break 0;
212-
}
213-
}
214-
} == 0) as i32)
215-
!= 0)
216-
);
217-
assert!((((FdRegistry::close((*fds.borrow())[(1) as usize]) == 0) as i32) != 0));
218-
assert!(
219-
(((match FdRegistry::with_fd((*fds.borrow())[(0) as usize], |__fd| {
220-
((buf2.as_pointer() as Ptr<u8>) as Ptr<u8>)
221-
.to_any()
222-
.reinterpret_cast::<u8>()
223-
.with_slice_mut(::std::mem::size_of::<[u8; 4]>(), |__buf| {
224-
nix::unistd::read(__fd, __buf)
225-
})
226-
}) {
227-
Ok(__n) => __n as isize,
228-
Err(__e) => {
229-
libcc2rs::cpp2rust_errno().write(__e as i32);
230-
-1
231-
}
232-
} == 0_isize) as i32)
233-
!= 0)
234-
);
235-
assert!((((FdRegistry::close((*fds.borrow())[(0) as usize]) == 0) as i32) != 0));
236-
let s: Value<i32> = Rc::new(RefCell::new({
237-
let __family = match libc::AF_INET {
238-
::libc::AF_INET => nix::sys::socket::AddressFamily::Inet,
239-
::libc::AF_INET6 => nix::sys::socket::AddressFamily::Inet6,
240-
::libc::AF_UNIX => nix::sys::socket::AddressFamily::Unix,
241-
__d => panic!("socket: unsupported domain {__d}"),
242-
};
243-
let __flags = nix::sys::socket::SockFlag::from_bits_truncate(libc::SOCK_STREAM);
244-
let __ty = match libc::SOCK_STREAM & !nix::sys::socket::SockFlag::all().bits() {
245-
::libc::SOCK_STREAM => nix::sys::socket::SockType::Stream,
246-
::libc::SOCK_DGRAM => nix::sys::socket::SockType::Datagram,
247-
__t => panic!("socket: unsupported type {__t}"),
248-
};
249-
let __proto = match 0 {
250-
0 => None,
251-
::libc::IPPROTO_TCP => Some(nix::sys::socket::SockProtocol::Tcp),
252-
::libc::IPPROTO_UDP => Some(nix::sys::socket::SockProtocol::Udp),
253-
__p => panic!("socket: unsupported protocol {__p}"),
254-
};
255-
match nix::sys::socket::socket(__family, __ty, __flags, __proto) {
256-
Ok(__ofd) => FdRegistry::register(__ofd),
257-
Err(__e) => {
258-
libcc2rs::cpp2rust_errno().write(__e as i32);
259-
-1
260-
}
261-
}
262-
}));
263-
assert!(((((*s.borrow()) >= 0) as i32) != 0));
264-
assert!(
265-
(((match nix::sys::socket::Backlog::new(5) {
266-
Ok(__b) => match FdRegistry::with_fd((*s.borrow()), |__fd| nix::sys::socket::listen(
267-
&__fd, __b
268-
)) {
269-
Ok(()) => 0,
270-
Err(__e) => {
271-
libcc2rs::cpp2rust_errno().write(__e as i32);
272-
-1
273-
}
274-
},
275-
Err(__e) => {
276-
libcc2rs::cpp2rust_errno().write(__e as i32);
277-
-1
278-
}
279-
} == 0) as i32)
280-
!= 0)
281-
);
282-
assert!((((FdRegistry::close((*s.borrow())) == 0) as i32) != 0));
283-
(*fd.borrow_mut()) = {
284-
let __mode = match &[(420).into()].first() {
285-
Some(__m) => nix::sys::stat::Mode::from_bits_truncate(i32::get(__m) as ::libc::mode_t),
286-
None => nix::sys::stat::Mode::empty(),
287-
};
288-
match nix::fcntl::open(
289-
(*path.borrow()).to_rust_string().as_str(),
290-
nix::fcntl::OFlag::from_bits_retain(
291-
((::libc::O_RDWR | ::libc::O_CREAT) | ::libc::O_TRUNC),
292-
),
293-
__mode,
294-
) {
295-
Ok(__ofd) => FdRegistry::register(__ofd),
296-
Err(__e) => {
297-
libcc2rs::cpp2rust_errno().write(__e as i32);
298-
-1
299-
}
300-
}
301-
};
302-
assert!(((((*fd.borrow()) >= 0) as i32) != 0));
303-
assert!(
304-
(((match FdRegistry::with_fd((*fd.borrow()), |__fd| nix::unistd::isatty(__fd)) {
305-
Ok(__tty) => __tty as i32,
306-
Err(__e) => {
307-
libcc2rs::cpp2rust_errno().write(__e as i32);
308-
0
309-
}
310-
} == 0) as i32)
311-
!= 0)
312-
);
313-
assert!(
314-
(((match FdRegistry::with_fd((*fd.borrow()), |__fd| {
315-
Ptr::from_string_literal(b"hello world")
316-
.to_any()
317-
.reinterpret_cast::<u8>()
318-
.with_slice(11_usize, |__buf| nix::unistd::write(__fd, __buf))
319-
}) {
320-
Ok(__n) => __n as isize,
321-
Err(__e) => {
322-
libcc2rs::cpp2rust_errno().write(__e as i32);
323-
-1
324-
}
325-
} == 11_isize) as i32)
326-
!= 0)
327-
);
328-
assert!(
329-
((({
330-
let __whence = match 2 {
331-
0 => nix::unistd::Whence::SeekSet,
332-
1 => nix::unistd::Whence::SeekCur,
333-
2 => nix::unistd::Whence::SeekEnd,
334-
__w => panic!("lseek: unsupported whence {__w}"),
335-
};
336-
match FdRegistry::with_fd((*fd.borrow()), |__fd| {
337-
nix::unistd::lseek(__fd, 0_i64, __whence)
338-
}) {
339-
Ok(__off) => __off,
340-
Err(__e) => {
341-
libcc2rs::cpp2rust_errno().write(__e as i32);
342-
-1
343-
}
344-
}
345-
} == 11_i64) as i32)
346-
!= 0)
347-
);
348-
assert!(
349-
((({
350-
let __whence = match 0 {
351-
0 => nix::unistd::Whence::SeekSet,
352-
1 => nix::unistd::Whence::SeekCur,
353-
2 => nix::unistd::Whence::SeekEnd,
354-
__w => panic!("lseek: unsupported whence {__w}"),
355-
};
356-
match FdRegistry::with_fd((*fd.borrow()), |__fd| {
357-
nix::unistd::lseek(__fd, 6_i64, __whence)
358-
}) {
359-
Ok(__off) => __off,
360-
Err(__e) => {
361-
libcc2rs::cpp2rust_errno().write(__e as i32);
362-
-1
363-
}
364-
}
365-
} == 6_i64) as i32)
366-
!= 0)
367-
);
368-
{
369-
((buf.as_pointer() as Ptr<u8>) as Ptr<u8>)
370-
.to_any()
371-
.memset((0) as u8, ::std::mem::size_of::<[u8; 16]>() as usize);
372-
((buf.as_pointer() as Ptr<u8>) as Ptr<u8>).to_any().clone()
373-
};
374-
assert!(
375-
(((match FdRegistry::with_fd((*fd.borrow()), |__fd| {
376-
((buf.as_pointer() as Ptr<u8>) as Ptr<u8>)
377-
.to_any()
378-
.reinterpret_cast::<u8>()
379-
.with_slice_mut(::std::mem::size_of::<[u8; 16]>(), |__buf| {
380-
nix::unistd::read(__fd, __buf)
381-
})
382-
}) {
383-
Ok(__n) => __n as isize,
384-
Err(__e) => {
385-
libcc2rs::cpp2rust_errno().write(__e as i32);
386-
-1
387-
}
388-
} == 5_isize) as i32)
389-
!= 0)
390-
);
391-
assert!(
392-
((({
393-
let mut __it1 = (buf.as_pointer() as Ptr<u8>).to_c_string_iterator();
394-
let mut __it2 = Ptr::from_string_literal(b"world").to_c_string_iterator();
395-
loop {
396-
let __c1 = __it1.next();
397-
let __c2 = __it2.next();
398-
if __c1 != __c2 {
399-
break (__c1.unwrap_or(0) as i32) - (__c2.unwrap_or(0) as i32);
400-
}
401-
if __c1.is_none() {
402-
break 0;
403-
}
404-
}
405-
} == 0) as i32)
406-
!= 0)
407-
);
408-
assert!(
409-
(((match FdRegistry::with_fd((*fd.borrow()), |__fd| nix::unistd::ftruncate(__fd, 5_i64)) {
410-
Ok(()) => 0,
411-
Err(__e) => {
412-
libcc2rs::cpp2rust_errno().write(__e as i32);
413-
-1
414-
}
415-
} == 0) as i32)
416-
!= 0)
417-
);
418-
assert!(
419-
((({
420-
let __whence = match 2 {
421-
0 => nix::unistd::Whence::SeekSet,
422-
1 => nix::unistd::Whence::SeekCur,
423-
2 => nix::unistd::Whence::SeekEnd,
424-
__w => panic!("lseek: unsupported whence {__w}"),
425-
};
426-
match FdRegistry::with_fd((*fd.borrow()), |__fd| {
427-
nix::unistd::lseek(__fd, 0_i64, __whence)
428-
}) {
429-
Ok(__off) => __off,
430-
Err(__e) => {
431-
libcc2rs::cpp2rust_errno().write(__e as i32);
432-
-1
433-
}
434-
}
435-
} == 5_i64) as i32)
436-
!= 0)
437-
);
438-
assert!((((FdRegistry::close((*fd.borrow())) == 0) as i32) != 0));
439-
assert!(
440-
(((match nix::unistd::unlink((*path.borrow()).to_rust_string().as_str()) {
441-
Ok(()) => 0,
442-
Err(__e) => {
443-
libcc2rs::cpp2rust_errno().write(__e as i32);
444-
-1
445-
}
446-
} == 0) as i32)
447-
!= 0)
448-
);
449141
return 0;
450142
}

0 commit comments

Comments
 (0)