@@ -47,7 +47,7 @@ pub fn test_time_0() {
4747pub fn test_clock_gettime_1 ( ) {
4848 let ts: Value < libcc2rs:: Timespec > = Rc :: new ( RefCell :: new ( Default :: default ( ) ) ) ;
4949 assert ! (
50- ( ( ( match nix:: time:: clock_gettime( nix:: time:: ClockId :: from_raw ( 0 ) ) {
50+ ( ( ( match nix:: time:: clock_gettime( nix:: time:: ClockId :: CLOCK_REALTIME ) {
5151 Ok ( __ts) => {
5252 ( ts. as_pointer( ) ) . with_mut( |__t| {
5353 * __t. tv_sec. borrow_mut( ) = __ts. tv_sec( ) as i64 ;
@@ -283,137 +283,6 @@ pub fn test_strftime_4() {
283283 != 0 )
284284 ) ;
285285}
286- pub fn test_gettimeofday_5 ( ) {
287- let tv: Value < libcc2rs:: Timeval > = Rc :: new ( RefCell :: new ( Default :: default ( ) ) ) ;
288- assert ! (
289- ( ( ( match nix:: time:: clock_gettime( nix:: time:: ClockId :: CLOCK_REALTIME ) {
290- Ok ( __ts) => {
291- ( tv. as_pointer( ) ) . with_mut( |__tv| {
292- * __tv. tv_sec. borrow_mut( ) = __ts. tv_sec( ) as i64 ;
293- * __tv. tv_usec. borrow_mut( ) = ( __ts. tv_nsec( ) / 1000 ) as i64 ;
294- } ) ;
295- 0
296- }
297- Err ( __e) => {
298- libcc2rs:: cpp2rust_errno( ) . write( __e as i32 ) ;
299- -1
300- }
301- } == 0 ) as i32 )
302- != 0 )
303- ) ;
304- assert ! ( ( ( ( ( * ( * tv. borrow( ) ) . tv_sec. borrow( ) ) > 1500000000_i64 ) as i32 ) != 0 ) ) ;
305- assert ! (
306- ( ( ( ( ( ( ( * ( * tv. borrow( ) ) . tv_usec. borrow( ) ) >= 0_i64 ) as i32 ) != 0 )
307- && ( ( ( ( * ( * tv. borrow( ) ) . tv_usec. borrow( ) ) < 1000000_i64 ) as i32 ) != 0 ) )
308- as i32 )
309- != 0 )
310- ) ;
311- }
312- pub fn test_utimes_6 ( ) {
313- let path: Value < Ptr < u8 > > = Rc :: new ( RefCell :: new ( Ptr :: from_string_literal (
314- b"/tmp/cpp2rust_utimes_test.tmp" ,
315- ) ) ) ;
316- let fp: Value < Ptr < :: std:: fs:: File > > = Rc :: new ( RefCell :: new (
317- match Ptr :: from_string_literal ( b"wb" ) . to_rust_string ( ) {
318- v if v == "rb" => std:: fs:: OpenOptions :: new ( )
319- . read ( true )
320- . open ( ( * path. borrow ( ) ) . to_rust_string ( ) )
321- . ok ( )
322- . map_or ( Ptr :: null ( ) , |f| Ptr :: alloc ( f) ) ,
323- v if v == "wb" => std:: fs:: OpenOptions :: new ( )
324- . write ( true )
325- . create ( true )
326- . truncate ( true )
327- . open ( ( * path. borrow ( ) ) . to_rust_string ( ) )
328- . ok ( )
329- . map_or ( Ptr :: null ( ) , |f| Ptr :: alloc ( f) ) ,
330- _ => panic ! ( "unsupported mode" ) ,
331- } ,
332- ) ) ;
333- assert ! ( ( ( ( !( ( * fp. borrow( ) ) . is_null( ) ) ) as i32 ) != 0 ) ) ;
334- assert ! (
335- ( ( ( {
336- ( * fp. borrow( ) ) . delete( ) ;
337- 0
338- } == 0 ) as i32 )
339- != 0 )
340- ) ;
341- let times: Value < Box < [ libcc2rs:: Timeval ] > > = Rc :: new ( RefCell :: new (
342- ( 0 ..2 )
343- . map ( |_| Default :: default ( ) )
344- . collect :: < Box < [ libcc2rs:: Timeval ] > > ( ) ,
345- ) ) ;
346- ( * ( * times. borrow ( ) ) [ ( 0 ) as usize ] . tv_sec . borrow_mut ( ) ) = 1000000000_i64 ;
347- ( * ( * times. borrow ( ) ) [ ( 0 ) as usize ] . tv_usec . borrow_mut ( ) ) = 0_i64 ;
348- ( * ( * times. borrow ( ) ) [ ( 1 ) as usize ] . tv_sec . borrow_mut ( ) ) = 1000000001_i64 ;
349- ( * ( * times. borrow ( ) ) [ ( 1 ) as usize ] . tv_usec . borrow_mut ( ) ) = 0_i64 ;
350- assert ! (
351- ( ( ( {
352- let __times = ( times. as_pointer( ) as Ptr <libcc2rs:: Timeval >) ;
353- let __at = __times. with( |__tv| {
354- nix:: sys:: time:: TimeVal :: new(
355- * __tv. tv_sec. borrow( ) as :: libc:: time_t,
356- * __tv. tv_usec. borrow( ) as :: libc:: suseconds_t,
357- )
358- } ) ;
359- let __mt = __times. offset( 1 ) . with( |__tv| {
360- nix:: sys:: time:: TimeVal :: new(
361- * __tv. tv_sec. borrow( ) as :: libc:: time_t,
362- * __tv. tv_usec. borrow( ) as :: libc:: suseconds_t,
363- )
364- } ) ;
365- match nix:: sys:: stat:: utimes( ( * path. borrow( ) ) . to_rust_string( ) . as_str( ) , & __at, & __mt) {
366- Ok ( ( ) ) => 0 ,
367- Err ( __e) => {
368- libcc2rs:: cpp2rust_errno( ) . write( __e as i32 ) ;
369- -1
370- }
371- }
372- } == 0 ) as i32 )
373- != 0 )
374- ) ;
375- assert ! (
376- ( ( ( {
377- let __times = ( times. as_pointer( ) as Ptr <libcc2rs:: Timeval >) ;
378- let __at = __times. with( |__tv| {
379- nix:: sys:: time:: TimeVal :: new(
380- * __tv. tv_sec. borrow( ) as :: libc:: time_t,
381- * __tv. tv_usec. borrow( ) as :: libc:: suseconds_t,
382- )
383- } ) ;
384- let __mt = __times. offset( 1 ) . with( |__tv| {
385- nix:: sys:: time:: TimeVal :: new(
386- * __tv. tv_sec. borrow( ) as :: libc:: time_t,
387- * __tv. tv_usec. borrow( ) as :: libc:: suseconds_t,
388- )
389- } ) ;
390- match nix:: sys:: stat:: utimes(
391- Ptr :: from_string_literal( b"/tmp/cpp2rust_utimes_test_missing.tmp" )
392- . to_rust_string( )
393- . as_str( ) ,
394- & __at,
395- & __mt,
396- ) {
397- Ok ( ( ) ) => 0 ,
398- Err ( __e) => {
399- libcc2rs:: cpp2rust_errno( ) . write( __e as i32 ) ;
400- -1
401- }
402- }
403- } == -1_i32 ) as i32 )
404- != 0 )
405- ) ;
406- assert ! (
407- ( ( ( match nix:: unistd:: unlink( ( * path. borrow( ) ) . to_rust_string( ) . as_str( ) ) {
408- Ok ( ( ) ) => 0 ,
409- Err ( __e) => {
410- libcc2rs:: cpp2rust_errno( ) . write( __e as i32 ) ;
411- -1
412- }
413- } == 0 ) as i32 )
414- != 0 )
415- ) ;
416- }
417286pub fn main ( ) {
418287 std:: process:: exit ( main_0 ( ) ) ;
419288}
@@ -422,7 +291,5 @@ fn main_0() -> i32 {
422291 ( { test_clock_gettime_1 ( ) } ) ;
423292 ( { test_gmtime_r_3 ( ) } ) ;
424293 ( { test_strftime_4 ( ) } ) ;
425- ( { test_gettimeofday_5 ( ) } ) ;
426- ( { test_utimes_6 ( ) } ) ;
427294 return 0 ;
428295}
0 commit comments