1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#include "test.h"
test_return_t
check_edges( const char *filename, test_edge_sequence_t *edges,
int flags_mask )
{
libspectrum_byte *buffer = NULL;
size_t filesize = 0;
libspectrum_tape *tape;
test_return_t r = TEST_FAIL;
test_edge_sequence_t *ptr = edges;
if( read_file( &buffer, &filesize, filename ) ) return TEST_INCOMPLETE;
tape = libspectrum_tape_alloc();
if( libspectrum_tape_read( tape, buffer, filesize, LIBSPECTRUM_ID_UNKNOWN,
filename ) != LIBSPECTRUM_ERROR_NONE ) {
libspectrum_tape_free( tape );
libspectrum_free( buffer );
return TEST_INCOMPLETE;
}
libspectrum_free( buffer );
while( 1 ) {
libspectrum_dword tstates;
int flags;
libspectrum_error e;
e = libspectrum_tape_get_next_edge( &tstates, &flags, tape );
if( e ) {
libspectrum_tape_free( tape );
return TEST_INCOMPLETE;
}
flags &= flags_mask;
if( tstates != ptr->length || flags != ptr->flags ) {
fprintf( stderr, "%s: expected %u tstates and flags %d, got %u tstates and flags %d\n",
progname, ptr->length, ptr->flags, tstates, flags );
break;
}
if( tstates != ptr->length ) {
fprintf( stderr, "%s: expected %u tstates, got %u tstates\n", progname,
ptr->length, tstates );
break;
}
if( --ptr->count == 0 ) {
ptr++;
if( ptr->length == -1 ) {
r = TEST_PASS;
break;
}
}
}
if( libspectrum_tape_free( tape ) ) return TEST_INCOMPLETE;
return r;
}
|