mirror of
https://github.com/mauiaaron/apple2.git
synced 2025-01-12 21:30:07 +00:00
Tweaks to disk boot trace test
This commit is contained in:
parent
4c9c1fb62a
commit
acc3deb264
@ -121,7 +121,7 @@ void c_init_6()
|
||||
}
|
||||
|
||||
#ifdef TESTING
|
||||
void c_begin_test_6(const char *read_file, const char *write_file) {
|
||||
void c_begin_disk_trace_6(const char *read_file, const char *write_file) {
|
||||
if (read_file) {
|
||||
test_read_fp = fopen(read_file, "w");
|
||||
}
|
||||
@ -130,7 +130,7 @@ void c_begin_test_6(const char *read_file, const char *write_file) {
|
||||
}
|
||||
}
|
||||
|
||||
void c_end_test_6() {
|
||||
void c_end_disk_trace_6(void) {
|
||||
if (test_read_fp) {
|
||||
fflush(test_read_fp);
|
||||
fclose(test_read_fp);
|
||||
@ -289,6 +289,7 @@ unsigned char c_read_nibblized_6_6()
|
||||
#ifdef TESTING
|
||||
if (test_read_fp) {
|
||||
fputc(ch, test_read_fp);
|
||||
fflush(test_read_fp);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -465,6 +466,7 @@ unsigned char c_read_normal_6()
|
||||
#ifdef TESTING
|
||||
if (test_read_fp) {
|
||||
fputc(value, test_read_fp);
|
||||
fflush(test_read_fp);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -493,6 +495,7 @@ void c_write_nibblized_6_6()
|
||||
#ifdef TESTING
|
||||
if (test_write_fp) {
|
||||
fputc(disk6.disk_byte, test_write_fp);
|
||||
fflush(test_write_fp);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -605,6 +608,7 @@ void c_write_normal_6()
|
||||
#ifdef TESTING
|
||||
if (test_write_fp) {
|
||||
fwrite(disk6.disk_data, 1, 256, test_write_fp);
|
||||
fflush(test_write_fp);
|
||||
}
|
||||
#endif
|
||||
fflush( disk6.disk[disk6.drive].fp );
|
||||
|
@ -67,4 +67,9 @@ disk_write_latch(),
|
||||
disk_read_prepare_in(),
|
||||
disk_read_prepare_out();
|
||||
|
||||
#ifdef TESTING
|
||||
void c_begin_disk_trace_6(const char *read_file, const char *write_file);
|
||||
void c_end_disk_trace_6(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -79,6 +79,8 @@ TEST setup_boot_disk(void) {
|
||||
PASS();
|
||||
}
|
||||
|
||||
#define EXPECTED_DISK_TRACE_FILE_SIZE 60961
|
||||
#define EXPECTED_DISK_TRACE_SHA "D21CC686571ADE868A909B5A7044A973DE70DFFB"
|
||||
TEST test_boot_disk_bytes() {
|
||||
setup_boot_disk();
|
||||
|
||||
@ -87,12 +89,12 @@ TEST test_boot_disk_bytes() {
|
||||
asprintf(&disk, "%s/a2_read_disk_test.raw", homedir);
|
||||
if (disk) {
|
||||
unlink(disk);
|
||||
c_begin_test_6(disk, NULL);
|
||||
c_begin_disk_trace_6(disk, NULL);
|
||||
}
|
||||
|
||||
BOOT_TO_DOS();
|
||||
|
||||
c_end_test_6();
|
||||
c_end_disk_trace_6();
|
||||
c_eject_6(0);
|
||||
|
||||
do {
|
||||
@ -100,19 +102,16 @@ TEST test_boot_disk_bytes() {
|
||||
char mdstr[(SHA_DIGEST_LENGTH*2)+1];
|
||||
|
||||
FILE *fp = fopen(disk, "r");
|
||||
fseek(fp, 0L, SEEK_END);
|
||||
long nbytes = ftell(fp);
|
||||
fseek(fp, 0L, SEEK_SET);
|
||||
char *buf = malloc(nbytes);
|
||||
if (fread(buf, 1, nbytes, fp) != nbytes) {
|
||||
char *buf = malloc(EXPECTED_DISK_TRACE_FILE_SIZE);
|
||||
if (fread(buf, 1, EXPECTED_DISK_TRACE_FILE_SIZE, fp) != EXPECTED_DISK_TRACE_FILE_SIZE) {
|
||||
ASSERT(false);
|
||||
}
|
||||
fclose(fp); fp = NULL;
|
||||
SHA1(buf, nbytes, md);
|
||||
SHA1(buf, EXPECTED_DISK_TRACE_FILE_SIZE, md);
|
||||
FREE(buf);
|
||||
|
||||
sha1_to_str(md, mdstr);
|
||||
ASSERT(strcmp(mdstr, "D21CC686571ADE868A909B5A7044A973DE70DFFB") == 0);
|
||||
ASSERT(strcmp(mdstr, EXPECTED_DISK_TRACE_SHA) == 0);
|
||||
} while(0);
|
||||
|
||||
unlink(disk);
|
||||
|
Loading…
x
Reference in New Issue
Block a user