Skip to content

Commit e7a838b

Browse files
committed
fix tests on MacOS
1 parent 4e99d36 commit e7a838b

6 files changed

Lines changed: 175 additions & 248 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn main_0() -> i32 {
1717
__bytes
1818
}));
1919
let file: Value<Box<[i8]>> = Rc::new(RefCell::new(i8::array_from_literal(
20-
b"test_stdcopy_ostream\xff.txt\0",
20+
b"test_stdcopy_ostream\xc3\xa9.txt\0",
2121
)));
2222
{
2323
let ofs: Value<::std::fs::File> = Rc::new(RefCell::new(

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

Lines changed: 119 additions & 177 deletions
Original file line numberDiff line numberDiff line change
@@ -70,160 +70,145 @@ fn main_0() -> i32 {
7070
Some(__f) => Ptr::alloc(__f),
7171
None => Ptr::null(),
7272
};
73-
assert!((!((fp).is_null())));
74-
assert!(
75-
({
76-
let __r = fp.with(|__f| __f.close());
77-
fp.delete();
78-
__r
79-
} == 0)
80-
);
8173
let st: Value<libcc2rs::Stat> = Rc::new(RefCell::new(Default::default()));
82-
assert!(
83-
({
84-
(({
85-
let mut __tmp_0 = { (st.as_pointer()) };
86-
match Ptr::<i8>::from_string_literal(b"unlink-\xff.tmp")
87-
.with_c_bytes(nix::sys::stat::stat)
88-
{
89-
Ok(__s) => {
90-
__tmp_0.with_mut(|__st| *__st = Stat::from_libc(&__s));
91-
0
92-
}
93-
Err(__e) => {
94-
libcc2rs::cpp2rust_errno().write(__e as i32);
95-
-1
96-
}
97-
}
74+
if (!((fp).is_null())) {
75+
assert!(
76+
({
77+
let __r = fp.with(|__f| __f.close());
78+
fp.delete();
79+
__r
9880
} == 0)
99-
&& ({ (*st.borrow()).st_size } == (0 as ::libc::off_t)))
100-
})
101-
);
102-
assert!(
103-
({
104-
(({
105-
let mut __tmp_1 = { (st.as_pointer()) };
106-
match sibling.with_c_bytes(nix::sys::stat::stat) {
107-
Ok(__s) => {
108-
__tmp_1.with_mut(|__st| *__st = Stat::from_libc(&__s));
109-
0
110-
}
111-
Err(__e) => {
112-
libcc2rs::cpp2rust_errno().write(__e as i32);
113-
-1
81+
);
82+
assert!(
83+
({
84+
(({
85+
let mut __tmp_0 = { (st.as_pointer()) };
86+
match Ptr::<i8>::from_string_literal(b"unlink-\xff.tmp")
87+
.with_c_bytes(nix::sys::stat::stat)
88+
{
89+
Ok(__s) => {
90+
__tmp_0.with_mut(|__st| *__st = Stat::from_libc(&__s));
91+
0
92+
}
93+
Err(__e) => {
94+
libcc2rs::cpp2rust_errno().write(__e as i32);
95+
-1
96+
}
11497
}
98+
} == 0)
99+
&& ({ (*st.borrow()).st_size } == (0 as ::libc::off_t)))
100+
})
101+
);
102+
assert!(
103+
(match Ptr::<i8>::from_string_literal(b"unlink-\xff.tmp")
104+
.with_c_os_str(|__from| Ptr::<i8>::from_string_literal(b"unlink-\xfe.tmp")
105+
.with_c_os_str(|__to| ::std::fs::rename(__from, __to)))
106+
{
107+
Ok(()) => 0,
108+
Err(__e) => {
109+
libcc2rs::cpp2rust_errno().write(__e.raw_os_error().unwrap_or(::libc::EIO));
110+
-1
115111
}
116112
} == 0)
117-
&& ({ (*st.borrow()).st_size } == (8 as ::libc::off_t)))
118-
})
119-
);
120-
assert!(
121-
(match Ptr::<i8>::from_string_literal(b"unlink-\xff.tmp")
122-
.with_c_os_str(|__from| Ptr::<i8>::from_string_literal(b"unlink-\xfe.tmp")
123-
.with_c_os_str(|__to| ::std::fs::rename(__from, __to)))
113+
);
114+
let mut fd: i32 = {
115+
let __mode = match Box::<[VaArg]>::from([]).first() {
116+
Some(__m) => {
117+
nix::sys::stat::Mode::from_bits_truncate(i32::get(__m) as ::libc::mode_t)
118+
}
119+
None => nix::sys::stat::Mode::empty(),
120+
};
121+
match Ptr::<i8>::from_string_literal(b"unlink-\xfe.tmp").with_c_bytes(|__path| {
122+
nix::fcntl::open(
123+
__path,
124+
nix::fcntl::OFlag::from_bits_retain(::libc::O_RDONLY),
125+
__mode,
126+
)
127+
}) {
128+
Ok(__ofd) => FdRegistry::register(__ofd),
129+
Err(__e) => {
130+
libcc2rs::cpp2rust_errno().write(__e as i32);
131+
-1
132+
}
133+
}
134+
};
135+
assert!((fd >= 0));
136+
assert!((FdRegistry::close(fd) == 0));
137+
let mut path: Ptr<i8> = match Ptr::<i8>::from_string_literal(b"unlink-\xfe.tmp")
138+
.with_c_os_str(|__path| ::std::fs::canonicalize(__path))
124139
{
125-
Ok(()) => 0,
140+
Ok(__p) => {
141+
let mut __bytes = __p.into_os_string().into_encoded_bytes();
142+
__bytes.push(0);
143+
if Ptr::<i8>::null().is_null() {
144+
Ptr::alloc_array(CChar::from_byte_vec(__bytes).into_boxed_slice())
145+
} else {
146+
Ptr::<i8>::null().write_c_bytes(&__bytes);
147+
Ptr::<i8>::null()
148+
}
149+
}
126150
Err(__e) => {
127151
libcc2rs::cpp2rust_errno().write(__e.raw_os_error().unwrap_or(::libc::EIO));
128-
-1
152+
Ptr::null()
129153
}
130-
} == 0)
131-
);
132-
let mut fd: i32 = {
133-
let __mode = match Box::<[VaArg]>::from([]).first() {
134-
Some(__m) => nix::sys::stat::Mode::from_bits_truncate(i32::get(__m) as ::libc::mode_t),
135-
None => nix::sys::stat::Mode::empty(),
136154
};
137-
match Ptr::<i8>::from_string_literal(b"unlink-\xfe.tmp").with_c_bytes(|__path| {
138-
nix::fcntl::open(
139-
__path,
140-
nix::fcntl::OFlag::from_bits_retain(::libc::O_RDONLY),
141-
__mode,
142-
)
143-
}) {
144-
Ok(__ofd) => FdRegistry::register(__ofd),
145-
Err(__e) => {
146-
libcc2rs::cpp2rust_errno().write(__e as i32);
147-
-1
148-
}
149-
}
150-
};
151-
assert!((fd >= 0));
152-
assert!((FdRegistry::close(fd) == 0));
153-
let mut path: Ptr<i8> = match Ptr::<i8>::from_string_literal(b"unlink-\xfe.tmp")
154-
.with_c_os_str(|__path| ::std::fs::canonicalize(__path))
155-
{
156-
Ok(__p) => {
157-
let mut __bytes = __p.into_os_string().into_encoded_bytes();
158-
__bytes.push(0);
159-
if Ptr::<i8>::null().is_null() {
160-
Ptr::alloc_array(CChar::from_byte_vec(__bytes).into_boxed_slice())
161-
} else {
162-
Ptr::<i8>::null().write_c_bytes(&__bytes);
163-
Ptr::<i8>::null()
164-
}
165-
}
166-
Err(__e) => {
167-
libcc2rs::cpp2rust_errno().write(__e.raw_os_error().unwrap_or(::libc::EIO));
168-
Ptr::null()
169-
}
170-
};
171-
assert!((!((path).is_null())));
172-
assert!(
173-
({
174-
let mut __it1 = {
175-
let mut __tmp_2 = { (path).clone() };
176-
let __t = ('/' as i32) as i8;
177-
match __tmp_2
178-
.to_c_string_iterator()
179-
.enumerate()
180-
.filter(|__e| __e.1 == __t)
181-
.last()
182-
{
183-
Some((__i, _)) => __tmp_2.offset(__i),
184-
None => {
185-
if __t == 0 {
186-
__tmp_2.offset(__tmp_2.to_c_string_iterator().count())
187-
} else {
188-
Ptr::null()
155+
assert!((!((path).is_null())));
156+
assert!(
157+
({
158+
let mut __it1 = {
159+
let mut __tmp_1 = { (path).clone() };
160+
let __t = ('/' as i32) as i8;
161+
match __tmp_1
162+
.to_c_string_iterator()
163+
.enumerate()
164+
.filter(|__e| __e.1 == __t)
165+
.last()
166+
{
167+
Some((__i, _)) => __tmp_1.offset(__i),
168+
None => {
169+
if __t == 0 {
170+
__tmp_1.offset(__tmp_1.to_c_string_iterator().count())
171+
} else {
172+
Ptr::null()
173+
}
189174
}
190175
}
191176
}
192-
}
193-
.to_c_string_iterator();
194-
let mut __it2 =
195-
Ptr::<i8>::from_string_literal(b"/unlink-\xfe.tmp").to_c_string_iterator();
196-
loop {
197-
let __c1 = __it1.next();
198-
let __c2 = __it2.next();
199-
if __c1 != __c2 {
200-
break (__c1.unwrap_or(0) as u8 as i32) - (__c2.unwrap_or(0) as u8 as i32);
177+
.to_c_string_iterator();
178+
let mut __it2 =
179+
Ptr::<i8>::from_string_literal(b"/unlink-\xfe.tmp").to_c_string_iterator();
180+
loop {
181+
let __c1 = __it1.next();
182+
let __c2 = __it2.next();
183+
if __c1 != __c2 {
184+
break (__c1.unwrap_or(0) as u8 as i32) - (__c2.unwrap_or(0) as u8 as i32);
185+
}
186+
if __c1.is_none() {
187+
break 0;
188+
}
201189
}
202-
if __c1.is_none() {
203-
break 0;
190+
} == 0)
191+
);
192+
libcc2rs::free_refcount((path).to_any());
193+
assert!(
194+
(match Ptr::<i8>::from_string_literal(b"unlink-\xfe.tmp")
195+
.with_c_bytes(|__path| nix::unistd::unlink(__path))
196+
{
197+
Ok(()) => 0,
198+
Err(__e) => {
199+
libcc2rs::cpp2rust_errno().write(__e as i32);
200+
-1
204201
}
205-
}
206-
} == 0)
207-
);
208-
libcc2rs::free_refcount((path).to_any());
209-
assert!(
210-
(match Ptr::<i8>::from_string_literal(b"unlink-\xfe.tmp")
211-
.with_c_bytes(|__path| nix::unistd::unlink(__path))
212-
{
213-
Ok(()) => 0,
214-
Err(__e) => {
215-
libcc2rs::cpp2rust_errno().write(__e as i32);
216-
-1
217-
}
218-
} == 0)
219-
);
202+
} == 0)
203+
);
204+
}
220205
assert!(
221206
({
222207
(({
223-
let mut __tmp_3 = { (st.as_pointer()) };
208+
let mut __tmp_2 = { (st.as_pointer()) };
224209
match sibling.with_c_bytes(nix::sys::stat::stat) {
225210
Ok(__s) => {
226-
__tmp_3.with_mut(|__st| *__st = Stat::from_libc(&__s));
211+
__tmp_2.with_mut(|__st| *__st = Stat::from_libc(&__s));
227212
0
228213
}
229214
Err(__e) => {
@@ -235,49 +220,6 @@ fn main_0() -> i32 {
235220
&& ({ (*st.borrow()).st_size } == (8 as ::libc::off_t)))
236221
})
237222
);
238-
assert!(
239-
(match Ptr::<i8>::from_string_literal(b"unlink-\xfd").with_c_bytes(|__path| {
240-
nix::unistd::mkdir(__path, nix::sys::stat::Mode::from_bits_truncate(493_u32))
241-
}) {
242-
Ok(()) => 0,
243-
Err(__e) => {
244-
libcc2rs::cpp2rust_errno().write(__e as i32);
245-
-1
246-
}
247-
} == 0)
248-
);
249-
let mut dir: Ptr<libcc2rs::CDir> = match Ptr::<i8>::from_string_literal(b"unlink-\xfd")
250-
.with_c_bytes(|__path| {
251-
nix::dir::Dir::open(
252-
__path,
253-
nix::fcntl::OFlag::O_RDONLY,
254-
nix::sys::stat::Mode::empty(),
255-
)
256-
}) {
257-
Ok(__dir) => Ptr::alloc(CDir::from_dir(__dir)),
258-
Err(__e) => {
259-
libcc2rs::cpp2rust_errno().write(__e as i32);
260-
Ptr::null()
261-
}
262-
};
263-
assert!((!((dir).is_null())));
264-
assert!(
265-
({
266-
dir.delete();
267-
0
268-
} == 0)
269-
);
270-
assert!(
271-
(match Ptr::<i8>::from_string_literal(b"unlink-\xfd")
272-
.with_c_os_str(|__path| ::std::fs::remove_dir(__path))
273-
{
274-
Ok(()) => 0,
275-
Err(__e) => {
276-
libcc2rs::cpp2rust_errno().write(__e.raw_os_error().unwrap_or(::libc::EIO));
277-
-1
278-
}
279-
} == 0)
280-
);
281223
assert!(
282224
(match sibling.with_c_bytes(|__path| nix::unistd::unlink(__path)) {
283225
Ok(()) => 0,

‎tests/unit/out/unsafe/stdcopy_ostream.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ unsafe fn main_0() -> i32 {
2121
+ 1,
2222
)
2323
.to_vec();
24-
let file: [libc::c_char; 26] = std::mem::transmute(*b"test_stdcopy_ostream\xff.txt\0");
24+
let file: [libc::c_char; 27] = std::mem::transmute(*b"test_stdcopy_ostream\xc3\xa9.txt\0");
2525
{
2626
let mut ofs: ::std::fs::File = {
2727
use ::std::os::unix::ffi::OsStrExt;

0 commit comments

Comments
 (0)