yaffs commiting quick tests to git.
[yaffs2.git] / direct / timothy_tests / quick_tests / quick_tests.c
1 #include "quick_tests.h"
2
3 #include "yaffsfs.h"
4 int random_seed;
5 int simulate_power_failure = 0;
6
7
8
9 typedef struct test {
10         int (*p_function)(void);        /*pointer to test function*/
11         void (*p_function_clean)(void);
12         /*char pass_message[50]; will not need a pass message*/
13         char *fail_message;     /*pointer to fail message, needs to include name of test*/
14 }test_template;
15
16
17 int dummy_test_pass(void){
18         //printf("running dummy_test_pass\n");
19         return 1;
20 }
21 void dummy_test_pass_clean(void){
22         
23 }
24 int dummy_test_fail(void){
25         //printf("running dummy_test_fail\n");
26         return 0;
27 }
28 void dummy_test_fail_clean(void){
29 }
30 test_template test_list[]={
31         {dummy_test_pass,dummy_test_pass_clean,"dummy_test_pass"},
32         {dummy_test_fail,dummy_test_fail_clean,"dummy_test_fail"},
33         {mount_yaffs_test,mount_yaffs_test_clean,"mount_yaffs_test"}
34         };
35
36
37 int main(){
38         int output=0;
39         unsigned int num_of_tests_pass=0;
40         int num_of_tests_failed=0;
41         unsigned int total_number_of_tests=(sizeof(test_list)/sizeof(test_template));
42         unsigned int x=0;       
43         init_quick_tests();
44         printf("quick tests for yaffs\n");
45         //printf("testing yaffs\n");
46
47         //printf("len function %d",(sizeof(test_list)/sizeof(test_template)));
48         for (x=0;x<total_number_of_tests;x++){
49                 //printf("x %d\n",x);
50                 output=test_list[x].p_function();       /*run test*/
51                 if (output>0){
52                         /*test has passed*/
53                         num_of_tests_pass++;
54                 }
55                 else {
56                         /*test is assumed to have failed*/
57                         //printf("test failed\n");
58                         printf("test: %s failed\n",test_list[x].fail_message);          
59                         num_of_tests_failed ++; 
60                 }
61                 test_list[x].p_function_clean();        /*run test*/
62                         
63         }
64         if (num_of_tests_pass==total_number_of_tests){
65                 printf("\t OK \n");
66         }
67         printf("tests: %d passed %d failed\n",num_of_tests_pass,num_of_tests_failed);
68         return 0;
69 }
70
71 void init_quick_tests(void){
72         yaffs_start_up();;
73         //yaffs_set_trace(0);
74
75 }