@@ -48,7 +48,7 @@ pub fn test_close_0() {
4848}
4949pub 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}
177177pub 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}
273273pub 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}
401401pub 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}
537537pub 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() {
558606pub 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