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