Search
lxdream.org :: lxdream :: r263:6f641270b2aa
lxdream 0.9.1
released Jun 29
Download Now
changeset263:6f641270b2aa
parent262:bc96e0b79308
child264:e3b8a3ab32b8
authornkeynes
dateWed Jan 03 09:05:13 2007 +0000 (13 years ago)
Extract test runner from testide into the generic testdata.c
Add initial display tests (PAL timings)
test/Makefile
test/testdata.c
test/testdata.h
test/testdisp.c
test/testide.c
1.1 --- a/test/Makefile Wed Jan 03 09:03:50 2007 +0000
1.2 +++ b/test/Makefile Wed Jan 03 09:05:13 2007 +0000
1.3 @@ -69,7 +69,7 @@
1.4 $(RUNTEST) testta < testta.data < testta2.data < testta3.data < testta4.data < testta5.data
1.5 $(RUNTEST) testregs
1.6
1.7 -build-tests: testsh4 testmath testide testta testregs testrend
1.8 +build-tests: testsh4 testmath testide testta testregs testrend testdisp
1.9
1.10 testsh4: crt0.so sh4/testsh4.so timer.so interrupt.so \
1.11 sh4/add.so sh4/addc.so sh4/addv.so sh4/and.so sh4/andi.so \
1.12 @@ -78,7 +78,7 @@
1.13 $(SH4CC) $(SH4LDFLAGS) $^ -o $@ $(SH4LIBS)
1.14 $(SH4OBJCOPY) testsh4 testsh4.bin
1.15
1.16 -testide: crt0.so testide.so ide.so lib.so
1.17 +testide: crt0.so testide.so ide.so lib.so testdata.so
1.18 $(SH4CC) $(SH4LDFLAGS) $^ -o $@ $(SH4LIBS)
1.19 $(SH4OBJCOPY) testide testide.bin
1.20
1.21 @@ -97,6 +97,10 @@
1.22 $(SH4CC) $(SH4LDFLAGS) $^ -o $@ $(SH4LIBS)
1.23 $(SH4OBJCOPY) testrend testrend.bin
1.24
1.25 +testdisp: crt0.so $(SHARED_OBJECTS) testdisp.so pvr.so asic.so lib.so testdata.so timer.so
1.26 + $(SH4CC) $(SH4LDFLAGS) $^ -o $@ $(SH4LIBS)
1.27 + $(SH4OBJCOPY) testdisp testdisp.bin
1.28 +
1.29 readdata: crt0.so readdata.so
1.30 $(SH4CC) $(SH4LDFLAGS) $^ -o $@ $(SH4LIBS)
1.31
2.1 --- a/test/testdata.c Wed Jan 03 09:03:50 2007 +0000
2.2 +++ b/test/testdata.c Wed Jan 03 09:05:13 2007 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: testdata.c,v 1.2 2006-08-02 04:13:15 nkeynes Exp $
2.6 + * $Id: testdata.c,v 1.3 2007-01-03 09:05:13 nkeynes Exp $
2.7 *
2.8 * Test data loader.
2.9 *
2.10 @@ -195,3 +195,19 @@
2.11 fclose(f);
2.12 return head;
2.13 }
2.14 +
2.15 +int run_tests( test_func_t *test_fns ) {
2.16 + int test_count, test_failures = 0;
2.17 +
2.18 + for( test_count=0; test_fns[test_count] != NULL; test_count++ ) {
2.19 + test_count++;
2.20 + if( test_fns[test_count]() != 0 ) {
2.21 + fprintf( stderr, "Test %d failed\n", test_count+1 );
2.22 + test_failures++;
2.23 + }
2.24 + }
2.25 +
2.26 + /* report */
2.27 + fprintf( stderr, "%d/%d tests passed!\n", test_count - test_failures, test_count );
2.28 + return test_failures;
2.29 +}
3.1 --- a/test/testdata.h Wed Jan 03 09:03:50 2007 +0000
3.2 +++ b/test/testdata.h Wed Jan 03 09:05:13 2007 +0000
3.3 @@ -1,5 +1,5 @@
3.4 /*
3.5 - * $Id: testdata.h,v 1.2 2006-08-02 04:13:15 nkeynes Exp $
3.6 + * $Id: testdata.h,v 1.3 2007-01-03 09:05:13 nkeynes Exp $
3.7 *
3.8 * Test data loader
3.9 *
3.10 @@ -32,6 +32,9 @@
3.11 struct test_data_block item[MAX_DATA_BLOCKS];
3.12 } *test_data_t;
3.13
3.14 +typedef int (*test_func_t)();
3.15 +int run_tests( test_func_t *tests );
3.16 +
3.17 test_data_t load_test_dataset( FILE *f );
3.18 void free_test_dataset( test_data_t dataset );
3.19 void dump_test_dataset( FILE *f, test_data_t dataset );
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/test/testdisp.c Wed Jan 03 09:05:13 2007 +0000
4.3 @@ -0,0 +1,166 @@
4.4 +/**
4.5 + * $Id: testdisp.c,v 1.1 2007-01-03 09:05:13 nkeynes Exp $
4.6 + *
4.7 + * Display (2D) tests. Mainly tests video timing / sync (obviously
4.8 + * it can't actually test display output since there's no way of
4.9 + * reading the results)
4.10 + *
4.11 + * These tests use TMU2 to determine absolute time
4.12 + * Copyright (c) 2006 Nathan Keynes.
4.13 + *
4.14 + * This program is free software; you can redistribute it and/or modify
4.15 + * it under the terms of the GNU General Public License as published by
4.16 + * the Free Software Foundation; either version 2 of the License, or
4.17 + * (at your option) any later version.
4.18 + *
4.19 + * This program is distributed in the hope that it will be useful,
4.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4.22 + * GNU General Public License for more details.
4.23 + */
4.24 +#include <stdlib.h>
4.25 +#include <stdio.h>
4.26 +#include "lib.h"
4.27 +#include "asic.h"
4.28 +
4.29 +#define PVR_BASE 0xA05F8000
4.30 +
4.31 +#define BORDERCOL (PVR_BASE+0x040)
4.32 +#define DISPCFG1 (PVR_BASE+0x044)
4.33 +#define DISPADDR1 (PVR_BASE+0x050)
4.34 +#define DISPADDR2 (PVR_BASE+0x054)
4.35 +#define DISPSIZE (PVR_BASE+0x05C)
4.36 +#define HPOSEVENT (PVR_BASE+0x0C8)
4.37 +#define VPOSEVENT (PVR_BASE+0x0CC)
4.38 +#define DISPCFG2 (PVR_BASE+0x0D0)
4.39 +#define HBORDER (PVR_BASE+0x0D4)
4.40 +#define VSYNC (PVR_BASE+0x0D8)
4.41 +#define VBORDER (PVR_BASE+0x0DC)
4.42 +#define HSYNC (PVR_BASE+0x0E0)
4.43 +#define DISPCFG3 (PVR_BASE+0x0E8)
4.44 +#define HPOS (PVR_BASE+0x0EC)
4.45 +#define VPOS (PVR_BASE+0x0F0)
4.46 +#define SYNCSTAT (PVR_BASE+0x10C)
4.47 +
4.48 +#define MAX_FRAME_WAIT 0x10000000
4.49 +
4.50 +#define WAIT_LINE( a ) if( wait_line(a) != 0 ) { fprintf(stderr, "Timeout at %s:%d:%s() waiting for line %d\n", __FILE__, __LINE__, __func__, a ); return -1; }
4.51 +#define WAIT_LASTLINE( a ) if( wait_lastline(a) != 0 ) { fprintf(stderr, "Last line check failed at %s:%d:%s() waiting for line %d\n", __FILE__, __LINE__, __func__, a ); return -1; }
4.52 +
4.53 +void dump_display_regs( FILE *out )
4.54 +{
4.55 + fprintf( out, "%08X DISPCFG1: %08X\n", DISPCFG1, long_read(DISPCFG1) );
4.56 + fprintf( out, "%08X DISPCFG2: %08X\n", DISPCFG2, long_read(DISPCFG2) );
4.57 + fprintf( out, "%08X DISPCFG3: %08X\n", DISPCFG3, long_read(DISPCFG3) );
4.58 + fprintf( out, "%08X DISPSIZE: %08X\n", DISPSIZE, long_read(DISPSIZE) );
4.59 + fprintf( out, "%08X HBORDER: %08X\n", HBORDER, long_read(HBORDER) );
4.60 + fprintf( out, "%08X VBORDER: %08X\n", VBORDER, long_read(VBORDER) );
4.61 + fprintf( out, "%08X HSYNC: %08X\n", HSYNC, long_read(HSYNC) );
4.62 + fprintf( out, "%08X VSYNC: %08X\n", VSYNC, long_read(VSYNC) );
4.63 + fprintf( out, "%08X DISPADDR1: %08X\n", DISPADDR1, long_read(DISPADDR1) );
4.64 + fprintf( out, "%08X DISPADDR2: %08X\n", DISPADDR2, long_read(DISPADDR2) );
4.65 + fprintf( out, "%08X HPOSEVENT: %08X\n", HPOSEVENT, long_read(HPOSEVENT) );
4.66 + fprintf( out, "%08X VPOSEVENT: %08X\n", VPOSEVENT, long_read(VPOSEVENT) );
4.67 + fprintf( out, "%08X HPOS: %08X\n", HPOS, long_read(HPOS) );
4.68 + fprintf( out, "%08X VPOS: %08X\n", VPOS, long_read(VPOS) );
4.69 + fprintf( out, "%08X SYNCSTAT: %08X\n", SYNCSTAT, long_read(SYNCSTAT) );
4.70 +}
4.71 +
4.72 +uint32_t pal_settings[] = {
4.73 + DISPCFG1, 0x00000001,
4.74 + DISPCFG2, 0x00000150,
4.75 + DISPCFG3, 0x00160000,
4.76 + DISPSIZE, 0x1413BD3F,
4.77 + HBORDER, 0x008D034B,
4.78 + VBORDER, 0x00120102,
4.79 + VSYNC, 0x0270035F,
4.80 + HSYNC, 0x07D6A53F,
4.81 + HPOS, 0x000000A4,
4.82 + VPOS, 0x00120012,
4.83 + 0, 0 };
4.84 +
4.85 +void apply_display_settings( uint32_t *regs ) {
4.86 + int i;
4.87 + for( i=0; regs[i] != 0; i+=2 ) {
4.88 + long_write( regs[i], regs[i+1] );
4.89 + }
4.90 +}
4.91 +
4.92 +/**
4.93 + * Wait until the given line is being displayed (ie is set in the syncstat
4.94 + * register).
4.95 + * @return 0 if the line is reached before timeout, otherwise -1.
4.96 + */
4.97 +int wait_line( int line )
4.98 +{
4.99 + int i;
4.100 + for( i=0; i< MAX_FRAME_WAIT; i++ ) {
4.101 + uint32_t sync = long_read(SYNCSTAT) & 0x03FF;
4.102 + if( sync == line ) {
4.103 + return 0;
4.104 + }
4.105 + }
4.106 + return -1;
4.107 +}
4.108 +
4.109 +/**
4.110 + * Wait until just after the last line of the frame is being displayed (according
4.111 + * to the syncstat register). After this function the current line will be 0.
4.112 + * @return 0 if the last line is the given line, otherwise -1.
4.113 + */
4.114 +int wait_lastline( int line )
4.115 +{
4.116 + int lastline = -1, i;
4.117 + for( i=0; i< MAX_FRAME_WAIT; i++ ) {
4.118 + uint32_t sync = long_read(SYNCSTAT) & 0x03FF;
4.119 + if( sync == 0 && lastline != -1 ) {
4.120 + CHECK_IEQUALS( line, lastline );
4.121 + return 0;
4.122 + }
4.123 + lastline = sync;
4.124 + }
4.125 + fprintf( stderr, "Timeout waiting for line %d\n", line );
4.126 + return -1;
4.127 +}
4.128 +
4.129 +int test_ntsc_timing() {
4.130 +
4.131 + return 0;
4.132 +}
4.133 +
4.134 +
4.135 +int test_pal_timing()
4.136 +{
4.137 + uint32_t line_time, field_time;
4.138 + /* Set PAL display mode */
4.139 + apply_display_settings( pal_settings );
4.140 +
4.141 + asic_clear();
4.142 +
4.143 + /* Check basic frame timings: 31.919 us per line, 19.945 ms per field */
4.144 + /* Wait for a line 0 (either frame) */
4.145 + WAIT_LINE(0);
4.146 + timer_start();
4.147 + WAIT_LINE(1);
4.148 + line_time = timer_gettime_us();
4.149 + WAIT_LASTLINE(624);
4.150 + field_time = timer_gettime_us();
4.151 + fprintf( stdout, "Line time: %dus, frame time: %dus\n", line_time, field_time );
4.152 + // CHECK_IEQUALS( 31, line_time );
4.153 + CHECK_IEQUALS( 19949, field_time );
4.154 + dump_display_regs( stdout );
4.155 + return 0;
4.156 +}
4.157 +
4.158 +
4.159 +/********************************* Main **************************************/
4.160 +
4.161 +typedef int (*test_func_t)();
4.162 +
4.163 +test_func_t test_fns[] = { test_ntsc_timing, test_pal_timing,
4.164 + NULL };
4.165 +
4.166 +int main()
4.167 +{
4.168 + return run_tests( test_fns );
4.169 +}
5.1 --- a/test/testide.c Wed Jan 03 09:03:50 2007 +0000
5.2 +++ b/test/testide.c Wed Jan 03 09:05:13 2007 +0000
5.3 @@ -1,5 +1,5 @@
5.4 /**
5.5 - * $Id: testide.c,v 1.5 2006-12-29 00:23:16 nkeynes Exp $
5.6 + * $Id: testide.c,v 1.6 2007-01-03 09:05:13 nkeynes Exp $
5.7 *
5.8 * IDE interface test cases. Covers all (known) IDE registers in the
5.9 * 5F7000 - 5F74FF range including DMA, but does not cover any GD-Rom
5.10 @@ -22,6 +22,7 @@
5.11
5.12 #include <stdlib.h>
5.13 #include <stdio.h>
5.14 +#include "testdata.h"
5.15 #include "lib.h"
5.16 #include "ide.h"
5.17 #include "asic.h"
5.18 @@ -552,8 +553,6 @@
5.19
5.20 /********************************* Main **************************************/
5.21
5.22 -typedef int (*test_func_t)();
5.23 -
5.24 test_func_t test_fns[] = { test_enable, test_reset, test_packet,
5.25 test_dma, test_dma_abort, test_read_pio,
5.26 test_read_toc,
5.27 @@ -563,17 +562,5 @@
5.28 {
5.29 int i;
5.30 ide_init();
5.31 -
5.32 - /* run tests */
5.33 - for( i=0; test_fns[i] != NULL; i++ ) {
5.34 - test_count++;
5.35 - if( test_fns[i]() != 0 ) {
5.36 - fprintf( stderr, "Test %d failed\n", i+1 );
5.37 - test_failures++;
5.38 - }
5.39 - }
5.40 -
5.41 - /* report */
5.42 - fprintf( stderr, "%d/%d tests passed!\n", test_count - test_failures, test_count );
5.43 - return test_failures;
5.44 + return run_tests( test_fns );
5.45 }
.