Search
lxdream.org :: lxdream/test/testta.c :: diff
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
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/test/testta.c Tue Jul 11 01:35:27 2006 +0000
1.3 @@ -0,0 +1,101 @@
1.4 +/**
1.5 + * $Id: testta.c,v 1.1 2006-07-11 01:35:23 nkeynes Exp $
1.6 + *
1.7 + * Tile Accelerator test cases
1.8 + *
1.9 + * Copyright (c) 2006 Nathan Keynes.
1.10 + *
1.11 + * This program is free software; you can redistribute it and/or modify
1.12 + * it under the terms of the GNU General Public License as published by
1.13 + * the Free Software Foundation; either version 2 of the License, or
1.14 + * (at your option) any later version.
1.15 + *
1.16 + * This program is distributed in the hope that it will be useful,
1.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.19 + * GNU General Public License for more details.
1.20 + */
1.21 +
1.22 +#include <stdio.h>
1.23 +#include "testdata.h"
1.24 +#include "pvr.h"
1.25 +#include "lib.h"
1.26 +#include "asic.h"
1.27 +
1.28 +#define DMA_ALIGN(x) ((void *)((((unsigned int)(x))+0x1F)&0xFFFFFFE0))
1.29 +
1.30 +#define OBJ_START 0x00010000
1.31 +#define TILE_START 0x00060000
1.32 +
1.33 +#define FLOAT(p) *((float *)(p))
1.34 +
1.35 +int test_ta( test_data_t test_case )
1.36 +{
1.37 + char buf[1024];
1.38 + unsigned int *p = DMA_ALIGN(buf);
1.39 + unsigned int *data = p;
1.40 +
1.41 + asic_clear();
1.42 +
1.43 + memset( PVR_VRAM_BASE, 0, 0x00080000 );
1.44 + ta_init(640,480, OBJ_START, 0x10000, TILE_START, 0x10000 );
1.45 +
1.46 + test_data_block_t input = get_test_data(test_case, "input");
1.47 + test_data_block_t output = get_test_data(test_case, "output");
1.48 + if( input == NULL || output == NULL ) {
1.49 + fprintf( stderr, "Skipping test case '%s': data incomplete\n", test_case->test_name );
1.50 + return -1;
1.51 + }
1.52 +
1.53 + fprintf( stderr, "Before test start: %s\n", test_case->test_name );
1.54 + if( pvr_dma_write( 0x10000000, input->data, input->length, 0 ) == -1 ) {
1.55 + return -1;
1.56 + }
1.57 + if( asic_wait( EVENT_PVR_OPAQUE_DONE ) == -1 ) {
1.58 + fprintf( stderr, "Timeout waiting for Opaque Done event\n" );
1.59 + ta_dump_regs();
1.60 + asic_dump( stderr );
1.61 + }
1.62 +
1.63 + char *result = (char *)(PVR_VRAM_BASE+OBJ_START);
1.64 + int result_length = pvr_get_objbuf_size();
1.65 + if( test_block_compare( output, result, result_length ) != 0 ) {
1.66 + fprintf( stderr, "Test %s: Failed. Expected %d bytes:\n", test_case->test_name, output->length );
1.67 + fwrite_dump( stderr, output->data, output->length );
1.68 + fprintf( stderr, "but was %d bytes =>\n", result_length );
1.69 + fwrite_dump( stderr, result, result_length );
1.70 + return -1;
1.71 + } else {
1.72 + fprintf( stdout, "Test %s: OK\n", test_case->test_name );
1.73 + return 0;
1.74 + }
1.75 +
1.76 +}
1.77 +
1.78 +int main( int argc, char *argv[] )
1.79 +{
1.80 + int test_cases = 0;
1.81 + int test_failures = 0;
1.82 + test_data_t test_data = load_test_dataset(stdin);
1.83 + test_data_t test_case = test_data;
1.84 +
1.85 + asic_mask_all();
1.86 + pvr_init();
1.87 +
1.88 + while( test_case != NULL ) {
1.89 + test_cases++;
1.90 + int result = test_ta(test_case);
1.91 + if( result != 0 ) {
1.92 + test_failures++;
1.93 + }
1.94 + test_case = test_case->next;
1.95 + }
1.96 + free_test_dataset(test_data);
1.97 + if( test_failures != 0 ) {
1.98 + fprintf( stderr, "%d/%d test failures!\n", test_failures, test_cases );
1.99 + return 1;
1.100 + } else {
1.101 + fprintf( stderr, "%d tests OK\n", test_cases );
1.102 + return 0;
1.103 + }
1.104 +}
.