int main( int argc, char * const argv[] ) #endif { if( argc != 2 ) { fprintf( stderr, "Unsupported number of arguments.\n" ); return( EXIT_FAILURE ); } /* Case 0: single open and close of a file using filename */ fprintf( stdout, "Testing single open close of: %s with access: read\t", argv[ 1 ] ); if( pff_test_single_open_close_file( argv[ 1 ], LIBPFF_OPEN_READ, 1 ) != 1 ) { fprintf( stderr, "Unable to test single open close.\n" ); return( EXIT_FAILURE ); } fprintf( stdout, "Testing single open close of: NULL with access: read\t" ); if( pff_test_single_open_close_file( NULL, LIBPFF_OPEN_READ, -1 ) != 1 ) { fprintf( stderr, "Unable to test single open close.\n" ); return( EXIT_FAILURE ); } fprintf( stdout, "Testing single open close of: %s with access: write\t", argv[ 1 ] ); if( pff_test_single_open_close_file( argv[ 1 ], LIBPFF_OPEN_WRITE, -1 ) != 1 ) { fprintf( stderr, "Unable to test single open close.\n" ); return( EXIT_FAILURE ); } /* Case 1: multiple open and close of a file using filename */ fprintf( stdout, "Testing multi open close of: %s with access: read\t", argv[ 1 ] ); if( pff_test_multi_open_close_file( argv[ 1 ], LIBPFF_OPEN_READ, 1 ) != 1 ) { fprintf( stderr, "Unable to test multi open close.\n" ); return( EXIT_FAILURE ); } return( EXIT_SUCCESS ); }
int main( int argc, char * const argv[] ) #endif { libcstring_system_character_t *source = NULL; libcstring_system_integer_t option = 0; while( ( option = libcsystem_getopt( argc, argv, _LIBCSTRING_SYSTEM_STRING( "" ) ) ) != (libcstring_system_integer_t) -1 ) { switch( option ) { case (libcstring_system_integer_t) '?': default: fprintf( stderr, "Invalid argument: %" PRIs_LIBCSTRING_SYSTEM ".\n", argv[ optind - 1 ] ); return( EXIT_FAILURE ); } } if( optind == argc ) { fprintf( stderr, "Missing source file or device.\n" ); return( EXIT_FAILURE ); } source = argv[ optind ]; #if defined( HAVE_DEBUG_OUTPUT ) && defined( PFF_TEST_OPEN_CLOSE_VERBOSE ) libpff_notify_set_verbose( 1 ); libpff_notify_set_stream( stderr, NULL ); #endif /* Case 0: single open and close of a file using filename */ fprintf( stdout, "Testing single open close of: %s with access: read\t", source ); if( pff_test_single_open_close_file( source, LIBPFF_OPEN_READ, 1 ) != 1 ) { fprintf( stderr, "Unable to test single open close.\n" ); return( EXIT_FAILURE ); } fprintf( stdout, "Testing single open close of: NULL with access: read\t" ); if( pff_test_single_open_close_file( NULL, LIBPFF_OPEN_READ, -1 ) != 1 ) { fprintf( stderr, "Unable to test single open close.\n" ); return( EXIT_FAILURE ); } fprintf( stdout, "Testing single open close of: %s with access: write\t", source ); if( pff_test_single_open_close_file( source, LIBPFF_OPEN_WRITE, -1 ) != 1 ) { fprintf( stderr, "Unable to test single open close.\n" ); return( EXIT_FAILURE ); } /* Case 1: multiple open and close of a file using filename */ fprintf( stdout, "Testing multi open close of: %s with access: read\t", source ); if( pff_test_multi_open_close_file( source, LIBPFF_OPEN_READ, 1 ) != 1 ) { fprintf( stderr, "Unable to test multi open close.\n" ); return( EXIT_FAILURE ); } return( EXIT_SUCCESS ); }