From: Timothy Manning Date: Mon, 15 Nov 2010 01:17:30 +0000 (+1300) Subject: yaffs Added command line arguments to quick tests. X-Git-Tag: linux-mainline-patchset-4~99 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=8d1e14f0254f27ca2b96089a24628548d176944e yaffs Added command line arguments to quick tests. Signed-off-by: Timothy Manning --- diff --git a/direct/timothy_tests/quick_tests/Makefile b/direct/timothy_tests/quick_tests/Makefile index bf82726..001f512 100644 --- a/direct/timothy_tests/quick_tests/Makefile +++ b/direct/timothy_tests/quick_tests/Makefile @@ -45,8 +45,8 @@ COMMONTESTOBJS = yaffscfg2k.o yaffs_ecc.o yaffs_fileem.o yaffs_fileem2k.o yaffsf # yaffs_checkptrwtest.o\ TESTFILES = quick_tests.o lib.o \ - test_yaffs_mount.o test_yaffs_mount_ENODEV.o test_yaffs_mount_ENAMETOOLONG.o test_yaffs_mount_ENOENT.o test_yaffs_mount_EBUSY.o \ - test_yaffs_unmount.o test_yaffs_unmount_ENOENT.o test_yaffs_unmount_ENAMETOOLONG.o test_yaffs_unmount_EBUSY.o \ + test_yaffs_mount.o test_yaffs_mount_ENODEV.o test_yaffs_mount_ENAMETOOLONG.o test_yaffs_mount_EBUSY.o \ + test_yaffs_unmount.o test_yaffs_unmount_ENODEV.o test_yaffs_unmount_ENAMETOOLONG.o test_yaffs_unmount_EBUSY.o \ test_yaffs_open.o test_yaffs_open_ENOENT.o test_yaffs_open_ENOTDIR.o test_yaffs_open_EEXIST.o test_yaffs_open_EISDIR.o test_yaffs_open_ENAMETOOLONG.o \ test_yaffs_open_EINVAL.o test_yaffs_open_EINVAL2.o \ test_yaffs_unlink.o test_yaffs_unlink_EISDIR.o test_yaffs_unlink_ENOENT.o test_yaffs_unlink_ENAMETOOLONG.o test_yaffs_unlink_ENOTDIR.o\ diff --git a/direct/timothy_tests/quick_tests/README.txt b/direct/timothy_tests/quick_tests/README.txt index 25b995e..3018fd6 100644 --- a/direct/timothy_tests/quick_tests/README.txt +++ b/direct/timothy_tests/quick_tests/README.txt @@ -13,7 +13,7 @@ Tests made test_yaffs_mount test_yaffs_mount_ENODEV test_yaffs_mount_ENAMETOOLONG - test_yaffs_mount_ENOENT + test_yaffs_mount_ENODEV test_yaffs_mount_EBUSY //caused by trying to mount a new mount point with a mount point already mounted. test_yaffs_access @@ -68,7 +68,7 @@ Tests made test_yaffs_unlink_ENOTDIR test_yaffs_unmount - test_yaffs_unmount_ENOENT + test_yaffs_unmount_ENODEV test_yaffs_unmount_ENAMETOOLONG test_yaffs_umount_EBUSY //cause by having a file handle open and then trying to unmount yaffs. diff --git a/direct/timothy_tests/quick_tests/lib.c b/direct/timothy_tests/quick_tests/lib.c index a7219c5..8c7608e 100644 --- a/direct/timothy_tests/quick_tests/lib.c +++ b/direct/timothy_tests/quick_tests/lib.c @@ -13,6 +13,25 @@ #include "lib.h" +static int EXIT_ON_ERROR = 1; +static int PRINT_LEVEL = 1; //This sets the level of detail which is printed. There are 3 levels 0,1,2 and 3 + //0 just prints the number of tests passed and failed. + //1 is the basic print level. it will print the details of a failed test. + //2 will print if a test passes and cleans. +void set_print_level(int new_level) +{ + PRINT_LEVEL=new_level; +} + +void set_exit_on_error(int num) +{ + EXIT_ON_ERROR=num; +} + +int get_exit_on_error(void) +{ + return EXIT_ON_ERROR; +} void join_paths(char *path1,char *path2,char *new_path ) { diff --git a/direct/timothy_tests/quick_tests/lib.h b/direct/timothy_tests/quick_tests/lib.h index 2efd08e..51b5794 100644 --- a/direct/timothy_tests/quick_tests/lib.h +++ b/direct/timothy_tests/quick_tests/lib.h @@ -19,11 +19,7 @@ #include #include -#define EXIT_ON_ERROR 0 -#define PRINT_LEVEL 2 //This sets the level of detail which is printed. There are 3 levels 0,1,2 and 3 - //0 just prints the number of tests passed and failed. - //1 is the basic print level. it will print the details of a failed test. - //2 will print if a test passes and cleans. + #define YAFFS_MOUNT_POINT "/yaffs2/" #define FILE_NAME "foo" @@ -39,4 +35,7 @@ void join_paths(char *path1,char *path2,char *new_path ); void print_message(char *message,char print_level); +void set_print_level(int new_level); +void set_exit_on_error(int num); +int get_exit_on_error(void); #endif diff --git a/direct/timothy_tests/quick_tests/quick_tests.c b/direct/timothy_tests/quick_tests/quick_tests.c index 17bce3b..a58fc08 100644 --- a/direct/timothy_tests/quick_tests/quick_tests.c +++ b/direct/timothy_tests/quick_tests/quick_tests.c @@ -25,13 +25,13 @@ static unsigned int num_of_tests_pass=0; static unsigned int num_of_tests_failed=0; static unsigned int total_number_of_tests=(sizeof(test_list)/sizeof(test_template)); -int main(){ +int main(int argc, char *argv[]){ int output=0; char message[30]; message[0]='\0'; + unsigned int x=0; - unsigned int x=0; - init_quick_tests(); + init_quick_tests(argc, argv); print_message("\n\nrunning quick tests for yaffs\n\n", 0); //printf("testing yaffs\n"); @@ -56,7 +56,7 @@ int main(){ get_error(); print_message("\n\n",1); - if (EXIT_ON_ERROR){ + if (get_exit_on_error()){ quit_quick_tests(1); } @@ -71,7 +71,7 @@ int main(){ num_of_tests_pass--; get_error(); printf("\n\n"); - if (EXIT_ON_ERROR){ + if (get_exit_on_error()){ quit_quick_tests(1); } @@ -109,9 +109,31 @@ void get_error(void) print_message(message,1); } -void init_quick_tests(void) +void init_quick_tests(int argc, char *argv[]) { + int trace=0; + int x=0; + for (x = 0; x < argc; x++){ + if (0==strcmp(argv[x],"-h")){ + printf("help\n"); + printf("-h will print the commands available\n"); + printf("-c will continue after a test failes else the program will exit\n"); + printf("-v will print all messages\n"); + printf("-q quiet mode only the number of tests passed and failed will be printed\n"); + printf("-t [number] set yaffs_trace to number\n"); + exit(0); + } else if (0==strcmp(argv[x],"-c")) { + set_exit_on_error(0); + } else if (0==strcmp(argv[x],"-q")) { + set_print_level(-3); + } else if (0==strcmp(argv[x],"-t")) { + trace = atoi(argv[x+1]); + } else if (0==strcmp(argv[x],"-v")) { + set_print_level(5); + } + + } yaffs_start_up(); - yaffs_set_trace(0); + yaffs_set_trace(trace); } diff --git a/direct/timothy_tests/quick_tests/quick_tests.h b/direct/timothy_tests/quick_tests/quick_tests.h index b44bf9b..dacb276 100644 --- a/direct/timothy_tests/quick_tests/quick_tests.h +++ b/direct/timothy_tests/quick_tests/quick_tests.h @@ -20,11 +20,10 @@ #include "test_yaffs_mount.h" #include "test_yaffs_mount_ENODEV.h" #include "test_yaffs_mount_ENAMETOOLONG.h" -#include "test_yaffs_mount_ENOENT.h" #include "test_yaffs_mount_EBUSY.h" #include "test_yaffs_unmount.h" -#include "test_yaffs_unmount_ENOENT.h" +#include "test_yaffs_unmount_ENODEV.h" #include "test_yaffs_unmount_ENAMETOOLONG.h" #include "test_yaffs_unmount_EBUSY.h" @@ -113,11 +112,10 @@ test_template test_list[]={ {test_yaffs_mount,test_yaffs_mount_clean,"test_yaffs_mount"}, {test_yaffs_mount_ENODEV,test_yaffs_mount_ENODEV_clean,"test_yaffs_mount_ENODEV"}, {test_yaffs_mount_ENAMETOOLONG,test_yaffs_mount_ENAMETOOLONG_clean,"test_yaffs_mount_ENAMETOOLONG"}, - {test_yaffs_mount_ENOENT,test_yaffs_mount_ENOENT_clean,"test_yaffs_mount_ENOENT"}, {test_yaffs_mount_EBUSY,test_yaffs_mount_EBUSY_clean,"test_yaffs_mount_EBUSY"}, {test_yaffs_unmount,test_yaffs_unmount_clean,"test_yaffs_unmount"}, - {test_yaffs_unmount_ENOENT,test_yaffs_unmount_ENOENT_clean,"test_yaffs_unmount_ENOENT"}, + {test_yaffs_unmount_ENODEV,test_yaffs_unmount_ENODEV_clean,"test_yaffs_unmount_ENODEV"}, {test_yaffs_unmount_ENAMETOOLONG,test_yaffs_unmount_ENAMETOOLONG_clean,"test_yaffs_unmount_ENAMETOOLONG"}, {test_yaffs_unmount_EBUSY,test_yaffs_unmount_EBUSY_clean,"test_yaffs_unmount_EBUSY"}, @@ -152,7 +150,7 @@ test_template test_list[]={ {test_yaffs_write,test_yaffs_write_clean,"test_yaffs_write"}, {test_yaffs_write_EBADF,test_yaffs_write_EBADF_clean,"test_yaffs_write_EBADF"}, - {test_yaffs_write_EFBIG,test_yaffs_write_EFBIG_clean,"test_yaffs_write_EFBIG"}, +// {test_yaffs_write_EFBIG,test_yaffs_write_EFBIG_clean,"test_yaffs_write_EFBIG"}, {test_yaffs_read,test_yaffs_read_clean,"test_yaffs_read"}, {test_yaffs_read_EBADF,test_yaffs_read_EBADF_clean,"test_yaffs_read_EBADF"}, @@ -187,7 +185,7 @@ test_template test_list[]={ {test_yaffs_fchmod_EBADF,test_yaffs_fchmod_EBADF_clean,"test_yaffs_fchmod_EBADF"} }; -void init_quick_tests(void); +void init_quick_tests(int argc, char *argv[]); void quit_quick_tests(int exit_code); void get_error(void); #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL.c b/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL.c index 0596ca9..8c49892 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL.c @@ -35,5 +35,5 @@ int test_yaffs_chmod_EINVAL(void) int test_yaffs_chmod_EINVAL_clean(void) { - return 1; + return test_yaffs_chmod(); } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL.h b/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL.h index 42d02ec..ba3e5a5 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL.h @@ -18,6 +18,7 @@ #include "lib.h" #include "yaffsfs.h" +#include "test_yaffs_chmod.h" int test_yaffs_chmod_EINVAL(void); int test_yaffs_chmod_EINVAL_clean(void); diff --git a/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL2.c b/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL2.c index 5e2d534..a5b6bb1 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL2.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL2.c @@ -35,5 +35,5 @@ int test_yaffs_chmod_EINVAL2(void) int test_yaffs_chmod_EINVAL2_clean(void) { - return 1; + return test_yaffs_chmod(); } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL2.h b/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL2.h index 2029750..663b717 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL2.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL2.h @@ -18,6 +18,7 @@ #include "lib.h" #include "yaffsfs.h" +#include "test_yaffs_chmod.h" int test_yaffs_chmod_EINVAL2(void); int test_yaffs_chmod_EINVAL2_clean(void); diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mount_ENOENT.c b/direct/timothy_tests/quick_tests/test_yaffs_mount_ENOENT.c deleted file mode 100644 index 3f64d8a..0000000 --- a/direct/timothy_tests/quick_tests/test_yaffs_mount_ENOENT.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * YAFFS: Yet another FFS. A NAND-flash specific file system. - * - * Copyright (C) 2002-2010 Aleph One Ltd. - * for Toby Churchill Ltd and Brightstar Engineering - * - * Created by Timothy Manning - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#include "test_yaffs_mount_ENOENT.h" - - -int test_yaffs_mount_ENOENT(void) -{ - int output = 0; - int error_code = 0; - - /* if a second file system is mounted then yaffs will return EBUSY. so first unmount yaffs */ - output = test_yaffs_unmount(); - if (output < 0){ - print_message("yaffs failed to unmount\n", 2); - return -1; - } - - output = yaffs_mount("/non_existaint_mount_point/"); - if (output == -1){ - error_code = yaffs_get_error(); - if (abs(error_code) == ENODEV){ - return 1; - } else { - print_message("different error than expected\n", 2); - return -1; - } - } else { - print_message("non existant mount point mounted.(which is a bad thing)\n",2); - return -1; - } - -} - -int test_yaffs_mount_ENOENT_clean(void) -{ - return test_yaffs_mount(); -} - diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unmount_ENOENT.c b/direct/timothy_tests/quick_tests/test_yaffs_unmount_ENODEV.c similarity index 60% rename from direct/timothy_tests/quick_tests/test_yaffs_unmount_ENOENT.c rename to direct/timothy_tests/quick_tests/test_yaffs_unmount_ENODEV.c index 75753cd..7472451 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_unmount_ENOENT.c +++ b/direct/timothy_tests/quick_tests/test_yaffs_unmount_ENODEV.c @@ -11,28 +11,31 @@ * published by the Free Software Foundation. */ -#include "test_yaffs_mount_ENOENT.h" +#include "test_yaffs_unmount_ENODEV.h" -int test_yaffs_unmount_ENOENT(void) +static int handle = 0; + +int test_yaffs_unmount_ENODEV(void) { int output=0; int error_code=0; - output=yaffs_unmount("/non_existaint_mount_point/"); - if (output==-1){ - error_code=yaffs_get_error(); - if (abs(error_code)==EINVAL){ + handle = yaffs_unmount("/nonexisting_mount_point/"); + if (handle==-1){ + error_code = yaffs_get_error(); + if (abs(error_code) == ENODEV){ return 1; } else { print_message("different error than expected\n",2); return -1; } - } else { - print_message("non existant mount point unmounted.(which is a bad thing)\n",2); + } else if (output >=0){ + print_message("non existant directory opened.(which is a bad thing)\n",2); return -1; } } -int test_yaffs_unmount_ENOENT_clean(void) + +int test_yaffs_unmount_ENODEV_clean(void) { return 1; } diff --git a/direct/timothy_tests/quick_tests/test_yaffs_mount_ENOENT.h b/direct/timothy_tests/quick_tests/test_yaffs_unmount_ENODEV.h similarity index 72% rename from direct/timothy_tests/quick_tests/test_yaffs_mount_ENOENT.h rename to direct/timothy_tests/quick_tests/test_yaffs_unmount_ENODEV.h index 1c7ad75..630ccbd 100644 --- a/direct/timothy_tests/quick_tests/test_yaffs_mount_ENOENT.h +++ b/direct/timothy_tests/quick_tests/test_yaffs_unmount_ENODEV.h @@ -13,15 +13,13 @@ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL. */ -#ifndef __test_yaffs_mount_ENOENT_h__ -#define __test_yaffs_mount_ENOENT_h__ +#ifndef __test_yaffs_unmount_ENODEV_h__ +#define __test_yaffs_unmount_ENODEV_h__ #include "lib.h" #include "yaffsfs.h" -#include "test_yaffs_unmount.h" -#include "test_yaffs_mount.h" -int test_yaffs_mount_ENOENT(void); -int test_yaffs_mount_ENOENT_clean(void); +int test_yaffs_unmount_ENODEV(void); +int test_yaffs_unmount_ENODEV_clean(void); #endif diff --git a/direct/timothy_tests/quick_tests/test_yaffs_unmount_ENOENT.h b/direct/timothy_tests/quick_tests/test_yaffs_unmount_ENOENT.h deleted file mode 100644 index f6faa64..0000000 --- a/direct/timothy_tests/quick_tests/test_yaffs_unmount_ENOENT.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * YAFFS: Yet another Flash File System . A NAND-flash specific file system. - * - * Copyright (C) 2002-2010 Aleph One Ltd. - * for Toby Churchill Ltd and Brightstar Engineering - * - * Created by Timothy Manning - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 2.1 as - * published by the Free Software Foundation. - * - * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL. - */ - -#ifndef __test_yaffs_unmount_ENOENT_h__ -#define __test_yaffs_unmount_ENOENT_h__ - -#include "lib.h" -#include "yaffsfs.h" -#include "test_yaffs_unmount.h" -#include "test_yaffs_mount.h" - -int test_yaffs_unmount_ENOENT(void); -int test_yaffs_unmount_ENOENT_clean(void); - -#endif