⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.c

📁 wince host 和 target PCI驱动程序
💻 C
字号:
static char sccs_id[] = "@(#)test.c	1.9 3/26/96 10:47:59" ;/* * test.c * Simple test driver * * Just add your test name and address to the table... * * Special commands: *	?	Print out test table *	all	Run all tests in table  */#define _TEST_C_
#include "windows.h"
#include <stdio.h>#include <string.h>#include <time.h>#include "hwdefs.h"#include "testvars.h"#include "t_sdram.h"#include "t_mmio.h"/* disable some tests for release */#define  FULL_SUITE  0

/*
 * Test table
 */
typedef struct {
	int	(*func)(void) ;
	char	*name ;
	char	*desc ;
	} TEST_TBL ;
TEST_TBL test_tbl[] = {
		/* 
		TRC9703227 commented since the register values have changed now
		and no one has time to update these tests
		*/	{t_mmio_read,
		"mmio_read",
		"read/verify mmio registers initial value"},
	{t_sdram_addr,
		"sdram_addr",
		"test sdram with address @ address"},
	{t_sdram_walk0,
		"sdram_walk0",
		"test sdram with walking zeroes"},
	{t_sdram_walk1,
		"sdram_walk1",
		"test sdram with walking ones"},
	/*
	{t_mmio_walk1,
		"mmio_walk1",
		"test mmio with walking ones"},
	{t_mmio_walk0,
		"mmio_walk0",
		"test mmio with walking zeroes"},
	*/
	{t_mmio_display,
		"mmio_display",
		"display mmio registers"},
	} ;
#define	TEST_TBL_SIZE		(sizeof(test_tbl)/sizeof(TEST_TBL))
#define	TEST_TBL_PASSING_SIZE	5

/*
 * Local functions
 */
void	test_help(void) ;
int	test_run(TEST_TBL *, int) ;

/*
 * Test driver entry point
 */
void
TaskTest(
int	argc,
char	*argv[],
int32	*_sdram_base,
int32	*_mmio_base,
int32	_sdram_len
)
{
TEST_TBL	*tblp ;
int		count ;
char		*test_name ;


printf("\n") ;

if (argc < 1)
	{
	printf("need a test name\n") ;
	}
test_name = argv[0] ;

if ( test_name == NULL )
{
	return;
}

/*
 * Pass data to tests in globals
 * (yuck! but makes test coding easier)
 */
test_argc = argc ;
test_argv = argv ;
mmio_virt_base = _mmio_base ;
mmio_phys_base = 0xffd00000 ;
sdram_virt_base = _sdram_base ;
sdram_phys_base = 0xfa000000 ;
sdram_len = _sdram_len ;

/*
 * Check for help command
 */
if (strcmp(test_name, "?") == 0)
	{
	test_help() ;
	return ;
	}

/*
 * Check for all command
 */
if (strcmp(test_name, "all") == 0)
	{
	test_run(test_tbl, TEST_TBL_SIZE) ;
	return ;
	}

/*
 * Check for passing command
 */
if (strcmp(test_name, "passing") == 0)
	{
	test_run(test_tbl, TEST_TBL_PASSING_SIZE) ;
	return ;
	}

/*
 * Check for command in table
 */
tblp = test_tbl ;
count = TEST_TBL_SIZE ;
while (count-- != 0)
	{
	if (strcmp(test_name, tblp->name) == 0)
		{
		test_run(tblp, 1 ) ;
		return ;
		}
	tblp++ ;
	}

printf("test not found '%s', type 'TE ?' to see list of tests\n", test_name) ;
}

/*
 * Print out list of tests
 */
void
test_help()
{
TEST_TBL	*tblp ;
int		count ;
static char	*fmt = "    %-20s %s\n" ;

printf("tests available are:\n") ;
printf(fmt, "?", "print this message") ;
printf(fmt, "all", "run all tests") ;
printf(fmt, "passing", "run passing tests") ;
tblp = test_tbl ;
count = TEST_TBL_SIZE ;
while (count-- != 0)
	{
	printf(fmt, tblp->name, tblp->desc) ;
	tblp++ ;
	}
}

/*
 * Run tests (single or multiple)
 */
int
test_run(
TEST_TBL	*tblp,
int		size
)
{
time_t		time_start ;
time_t		time_end ;
time_t		time_elapsed ;
time_t		all_start ;
time_t		all_end ;
time_t		all_elapsed ;
int		errors ;
int		all_errors ;
int		count ;

unsigned long IterationCount;

IterationCount = GetPrivateProfileInt (
	"Device.0", "IterationCount", 1, "tmman.ini" );
 

all_start = time(NULL) ;
count = size ;
all_errors = 0 ;

while (count-- != 0)
	{
		while( IterationCount-- != 0 )
		{
			time_start = time(NULL) ;
			errors = tblp->func() ;
			time_end = time(NULL) ;
			time_elapsed = time_end - time_start ;

			if (errors != 0)
				{
				printf("%s failed, %d secs\n", tblp->name, time_elapsed) ;
				}
				else
				{
				printf("%s passed, %d secs\n", tblp->name, time_elapsed) ;
				}
		}
	all_errors += errors ;
	tblp++ ;
	}

all_end = time(NULL) ;
all_elapsed = all_end - all_start ;
if (size != 1)
	{
	if (all_errors != 0)
		{
		printf("overall status: failed, %d secs\n", all_elapsed) ;
		}
	    else
		{
		printf("overall status: passed, %d secs\n", all_elapsed) ;
		}
	}

return all_errors ;
}

/*
 * printf
 * Need printf definition because x86 does not support
 * printf over a serial line
 */

#include <stdarg.h>

void ctc_outstring(char *) ;

int
printf(
const	char	*fmt,
...
)
{
va_list	arg_ptr ;
char	bfr[512] ;

va_start(arg_ptr, fmt) ;
vsprintf(bfr, fmt, arg_ptr) ;
va_end(arg_ptr) ;

ctc_outstring(bfr) ;
return 0 ;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -