filename | test/testta.c |
changeset | 185:6755a04c447f |
next | 190:f7653df5e832 |
author | nkeynes |
date | Tue Jul 11 01:35:27 2006 +0000 (17 years ago) |
permissions | -rw-r--r-- |
last change | First commit of system test framework. 3 initial test cases (incomplete): testide, testmath, and testta |
view | annotate | diff | log | raw |
1 /**
2 * $Id: testta.c,v 1.1 2006-07-11 01:35:23 nkeynes Exp $
3 *
4 * Tile Accelerator test cases
5 *
6 * Copyright (c) 2006 Nathan Keynes.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
19 #include <stdio.h>
20 #include "testdata.h"
21 #include "pvr.h"
22 #include "lib.h"
23 #include "asic.h"
25 #define DMA_ALIGN(x) ((void *)((((unsigned int)(x))+0x1F)&0xFFFFFFE0))
27 #define OBJ_START 0x00010000
28 #define TILE_START 0x00060000
30 #define FLOAT(p) *((float *)(p))
32 int test_ta( test_data_t test_case )
33 {
34 char buf[1024];
35 unsigned int *p = DMA_ALIGN(buf);
36 unsigned int *data = p;
38 asic_clear();
40 memset( PVR_VRAM_BASE, 0, 0x00080000 );
41 ta_init(640,480, OBJ_START, 0x10000, TILE_START, 0x10000 );
43 test_data_block_t input = get_test_data(test_case, "input");
44 test_data_block_t output = get_test_data(test_case, "output");
45 if( input == NULL || output == NULL ) {
46 fprintf( stderr, "Skipping test case '%s': data incomplete\n", test_case->test_name );
47 return -1;
48 }
50 fprintf( stderr, "Before test start: %s\n", test_case->test_name );
51 if( pvr_dma_write( 0x10000000, input->data, input->length, 0 ) == -1 ) {
52 return -1;
53 }
54 if( asic_wait( EVENT_PVR_OPAQUE_DONE ) == -1 ) {
55 fprintf( stderr, "Timeout waiting for Opaque Done event\n" );
56 ta_dump_regs();
57 asic_dump( stderr );
58 }
60 char *result = (char *)(PVR_VRAM_BASE+OBJ_START);
61 int result_length = pvr_get_objbuf_size();
62 if( test_block_compare( output, result, result_length ) != 0 ) {
63 fprintf( stderr, "Test %s: Failed. Expected %d bytes:\n", test_case->test_name, output->length );
64 fwrite_dump( stderr, output->data, output->length );
65 fprintf( stderr, "but was %d bytes =>\n", result_length );
66 fwrite_dump( stderr, result, result_length );
67 return -1;
68 } else {
69 fprintf( stdout, "Test %s: OK\n", test_case->test_name );
70 return 0;
71 }
73 }
75 int main( int argc, char *argv[] )
76 {
77 int test_cases = 0;
78 int test_failures = 0;
79 test_data_t test_data = load_test_dataset(stdin);
80 test_data_t test_case = test_data;
82 asic_mask_all();
83 pvr_init();
85 while( test_case != NULL ) {
86 test_cases++;
87 int result = test_ta(test_case);
88 if( result != 0 ) {
89 test_failures++;
90 }
91 test_case = test_case->next;
92 }
93 free_test_dataset(test_data);
94 if( test_failures != 0 ) {
95 fprintf( stderr, "%d/%d test failures!\n", test_failures, test_cases );
96 return 1;
97 } else {
98 fprintf( stderr, "%d tests OK\n", test_cases );
99 return 0;
100 }
101 }
.