2 * YAFFS: Yet another FFS. A NAND-flash specific file system.
4 * Copyright (C) 2002-2010 Aleph One Ltd.
5 * for Toby Churchill Ltd and Brightstar Engineering
7 * Created by Timothy Manning <timothy@yaffs.net>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
14 #include "quick_tests.h"
18 int simulate_power_failure = 0;
24 static unsigned int num_of_tests_pass=0;
25 static unsigned int num_of_tests_failed=0;
26 static unsigned int total_number_of_tests=(sizeof(test_list)/sizeof(test_template));
28 int main(int argc, char *argv[]){
34 init_quick_tests(argc, argv);
35 print_message("\n\nrunning quick tests for yaffs\n\n", 0);
37 for (x=0;x<total_number_of_tests;x++){
39 yaffs_set_error(0); /*reset the last error to 0 */
40 sprintf(message,"\nrunning test: %s \n",test_list[x].name_of_test);
41 print_message(message,3);
42 output=test_list[x].p_function(); /*run test*/
45 sprintf(message,"\ttest %s passed\n",test_list[x].name_of_test);
46 print_message(message,3);
49 /*test is assumed to have failed*/
50 //printf("test failed\n");
51 sprintf(message,"test: %s failed\n",test_list[x].name_of_test);
52 print_message(message,1);
53 num_of_tests_failed ++;
56 print_message("\n\n",1);
57 if (get_exit_on_error()){
63 output=test_list[x].p_function_clean(); /*clean the test*/
65 /* if the test failed to clean it's self then */
66 sprintf(message,"test: %s failed to clean\n",test_list[x].name_of_test);
67 print_message(message,1);
68 num_of_tests_failed ++;
72 if (get_exit_on_error()){
77 sprintf(message,"\ttest clean: %s passed\n",test_list[x].name_of_test);
78 print_message(message,3);
81 /*this is where the loop should break to*/
85 void quit_quick_tests(int exit_code)
89 if (num_of_tests_pass==total_number_of_tests && num_of_tests_failed==0){
92 printf("out of %d tests: %d passed %d failed\n\n\n",total_number_of_tests,num_of_tests_pass,num_of_tests_failed);
93 yaffs_unmount(YAFFS_MOUNT_POINT);
103 error_code=yaffs_get_error();
104 sprintf(message,"yaffs_error code %d\n",error_code);
105 print_message(message,1);
106 sprintf(message,"error is : %s\n",yaffs_error_to_str(error_code));
107 print_message(message,1);
110 void init_quick_tests(int argc, char *argv[])
114 for (x = 0; x < argc; x++){
115 if (0==strcmp(argv[x],"-h")){
117 printf("-h will print the commands available\n");
118 printf("-c will continue after a test failes else the program will exit\n");
119 printf("-v will print all messages\n");
120 printf("-q quiet mode only the number of tests passed and failed will be printed\n");
121 printf("-t [number] set yaffs_trace to number\n");
123 } else if (0==strcmp(argv[x],"-c")) {
124 set_exit_on_error(0);
125 } else if (0==strcmp(argv[x],"-q")) {
127 } else if (0==strcmp(argv[x],"-t")) {
128 trace = atoi(argv[x+1]);
129 } else if (0==strcmp(argv[x],"-v")) {
135 yaffs_set_trace(trace);