filename | test/sh4/testsh4.c |
changeset | 555:309c97260912 |
prev | 533:9764673fd4a5 |
next | 808:da414654f3fa |
author | nkeynes |
date | Fri Feb 08 00:06:56 2008 +0000 (16 years ago) |
permissions | -rw-r--r-- |
last change | Fix LDS/STS to FPUL/FPSCR to check the FPU disabled bit. Fixes the linux 2.4.0-test8 kernel boot (this wasn't exactly very well documented in the original manual) |
view | annotate | diff | log | raw |
1 #include <stdio.h>
2 #include "../lib.h"
4 int total_tests = 0;
5 int total_fails = 0;
7 int test_print_result( char *testname, int failed, int total )
8 {
9 fprintf( stdout, "%s: %d/%d tests passed\n", testname, total-failed, total );
10 total_tests += total;
11 total_fails += failed;
12 return failed;
13 }
15 void test_print_failure( char *testname, int number, char *message )
16 {
17 if( message == NULL ) {
18 fprintf( stderr, "%s: Test %d failed!\n", testname, number );
19 } else {
20 fprintf( stderr, "%s: Test %d failed: %s\n", testname, number, message );
21 }
22 }
24 extern unsigned int interrupt_pc;
25 extern unsigned int interrupt_count;
27 int assert_exception_caught( char *testname, int number, unsigned int expectedpc )
28 {
29 if( interrupt_count == 0 ) {
30 fprintf( stderr, "%s: Test %d failed: Expected exception not delivered\n",
31 testname, number );
32 return 1;
33 } else if( interrupt_count != 1 ) {
34 fprintf( stderr, "%s: Test %d failed: Expected exception delivered %d times!\n",
35 testname, number, interrupt_count );
36 return 1;
37 } else if( interrupt_pc != expectedpc ) {
38 fprintf( stderr, "%s: Test %d failed: Expected exception at PC %08X, but was %08X\n",
39 testname, number, expectedpc, interrupt_pc );
40 return 1;
41 } else {
42 return 0;
43 }
44 }
46 int assert_tlb_exception_caught( char *testname, int number, unsigned int expectedpc,
47 unsigned int vpn )
48 {
49 if( assert_exception_caught(testname, number, expectedpc) == 1 ) {
50 return 1;
51 }
53 unsigned int pteh = long_read(0xFF000000);
54 if( (pteh & 0xFFFFFC00) != (vpn & 0xFFFFFC00) ) {
55 fprintf(stderr, "%s: Test %d failed: Expected PTEH.VPN = %08X, but was %08X\n",
56 testname, number, (vpn>>10), (pteh>>10) );
57 return 1;
58 }
60 unsigned int tea = long_read(0xFF00000C);
61 if( tea != vpn ) {
62 fprintf(stderr, "%s: Test %d failed: Expected TEA = %08X, but was %08X\n",
63 testname, number, vpn, tea );
64 return 1;
65 }
66 return 0;
67 }
69 int main()
70 {
71 fprintf( stdout, "Instruction tests...\n" );
72 install_interrupt_handler();
73 test_add();
74 test_addc();
75 test_addv();
76 test_and();
77 test_andi();
78 test_bf();
79 test_bt();
80 test_bsr();
81 test_cmp();
82 test_cmpstr();
83 test_div0();
84 test_div1();
85 test_float();
86 test_fmov();
87 test_ftrc();
88 test_mac();
89 test_rot();
90 test_shl();
91 test_shld();
92 test_sub();
93 test_subc();
94 test_trapa();
95 test_tas();
96 test_xtrct();
97 fprintf( stdout, "--> %d/%d instruction tests passed (%d%%)\n\n",
98 total_tests-total_fails, total_tests,
99 ((total_tests-total_fails)*100)/total_tests );
101 fprintf( stdout, "Exception tests...\n" );
102 test_slot_illegal();
103 test_undefined();
104 test_tlb();
105 remove_interrupt_handler();
107 fprintf( stdout, "Total: %d/%d tests passed (%d%%)\n", total_tests-total_fails,
108 total_tests, ((total_tests-total_fails)*100)/total_tests );
109 return total_fails;
110 }
.