2a17f75ff5c217a9564cba7bf0932b401186ce72
[yaffs2.git] / direct / yaffs_test.c
1 /*
2  * YAFFS: Yet another FFS. A NAND-flash specific file system. 
3  *
4  * Copyright (C) 2002 Aleph One Ltd.
5  *   for Toby Churchill Ltd and Brightstar Engineering
6  *
7  * Created by Charles Manning <charles@aleph1.co.uk>
8  *
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.
12  *
13  */
14
15
16
17
18 #include <stdio.h>
19 #include <string.h>
20 #include <unistd.h>
21 #include <fcntl.h>
22
23 #include "yaffsfs.h"
24
25 #include "nor_stress.h"
26
27
28
29 int random_seed;
30 int simulate_power_failure = 0;
31
32 void BadUsage(void)
33 {
34         printf("usage root_dir test_id seed \n");
35         printf(" test_id: fw_update fw_update_init\n");
36         exit(2);
37 }
38 int main(int argc, const char *argv[])
39 {
40         yaffs_StartUp();
41         if(argc == 4) {
42                 random_seed = atoi(argv[3]);
43                 if(random_seed <= 0)
44                         BadUsage();
45                         
46                 if(!strcmp(argv[2],"fw_update_init")){
47                         NorStressTestInitialise(argv[1]);
48                 }
49                 else if(!strcmp(argv[2],"fw_update")){
50                         printf("Running stress on %s with seed %d\n",argv[1],random_seed);
51                         simulate_power_failure = 1;
52                         NorStressTestRun(argv[1]);
53                 }
54                 else 
55                         BadUsage();
56         }
57         else
58                 BadUsage();
59         return 0;
60 }