yaffs Added command line arguments to quick tests.
authorTimothy Manning <tfhmanning@gmail.com>
Mon, 15 Nov 2010 01:17:30 +0000 (14:17 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Mon, 15 Nov 2010 01:20:55 +0000 (14:20 +1300)
Signed-off-by: Timothy Manning <tfhmanning@gmail.com>
14 files changed:
direct/timothy_tests/quick_tests/Makefile
direct/timothy_tests/quick_tests/README.txt
direct/timothy_tests/quick_tests/lib.c
direct/timothy_tests/quick_tests/lib.h
direct/timothy_tests/quick_tests/quick_tests.c
direct/timothy_tests/quick_tests/quick_tests.h
direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL.c
direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL.h
direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL2.c
direct/timothy_tests/quick_tests/test_yaffs_chmod_EINVAL2.h
direct/timothy_tests/quick_tests/test_yaffs_mount_ENOENT.c [deleted file]
direct/timothy_tests/quick_tests/test_yaffs_unmount_ENODEV.c [moved from direct/timothy_tests/quick_tests/test_yaffs_unmount_ENOENT.c with 60% similarity]
direct/timothy_tests/quick_tests/test_yaffs_unmount_ENODEV.h [moved from direct/timothy_tests/quick_tests/test_yaffs_mount_ENOENT.h with 72% similarity]
direct/timothy_tests/quick_tests/test_yaffs_unmount_ENOENT.h [deleted file]

index bf827268c2e8c326b4eac2e996b654a66cb43af8..001f512d89c675125c7466f3e31d826d2f05a005 100644 (file)
@@ -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 \
 #               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\
                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\
index 25b995e0b08cb827580cc14df22f578304ed32e0..3018fd63e14dd614043c051aef3df73d113e08c6 100644 (file)
@@ -13,7 +13,7 @@ Tests made
        test_yaffs_mount
        test_yaffs_mount_ENODEV
        test_yaffs_mount_ENAMETOOLONG
        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
        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_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.
 
        test_yaffs_unmount_ENAMETOOLONG
        test_yaffs_umount_EBUSY //cause by having a file handle open and then trying to unmount yaffs.
 
index a7219c59f31d303f31ac2757902ae2fba19278d9..8c7608e563081c0a3e315803408cd02a430482a8 100644 (file)
 
 #include "lib.h"
 
 
 #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 )
 {
 
 void join_paths(char *path1,char *path2,char *new_path )
 {
index 2efd08e2d7236c550e7fe65bb328b577fec060ce..51b5794602bc9abf167e7eb04843c81be5f53133 100644 (file)
 #include <stdio.h>
 #include <string.h>
 
 #include <stdio.h>
 #include <string.h>
 
-#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"
 
 #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 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
 #endif
index 17bce3b7321eddd6e4f52904ad2fb2c1fd313523..a58fc0881dd23f78de4b5154a40c2c8abc85ecdf 100644 (file)
@@ -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));
 
 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';
        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");
 
        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);
                
                        get_error();
                        print_message("\n\n",1);
-                       if (EXIT_ON_ERROR){     
+                       if (get_exit_on_error()){       
                                quit_quick_tests(1);
                        }
 
                                quit_quick_tests(1);
                        }
 
@@ -71,7 +71,7 @@ int main(){
                        num_of_tests_pass--;
                        get_error();
                        printf("\n\n");
                        num_of_tests_pass--;
                        get_error();
                        printf("\n\n");
-                       if (EXIT_ON_ERROR){
+                       if (get_exit_on_error()){
                                quit_quick_tests(1);
                        }
                        
                                quit_quick_tests(1);
                        }
                        
@@ -109,9 +109,31 @@ void get_error(void)
        print_message(message,1);
 }
 
        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_start_up();
-       yaffs_set_trace(0);
+       yaffs_set_trace(trace);
 
 }
 
 }
index b44bf9b67b268af1cb063372931e2207a04d2bcd..dacb276cacafed0b31887503dd343742f684a010 100644 (file)
 #include "test_yaffs_mount.h"
 #include "test_yaffs_mount_ENODEV.h"
 #include "test_yaffs_mount_ENAMETOOLONG.h"
 #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_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"
 
 #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,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_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"},
 
        {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,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"},
 
        {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"}
        };
 
        {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
 void quit_quick_tests(int exit_code);
 void get_error(void);
 #endif
index 0596ca92e38d6cb76a9c45a8f6e9d05082a3ec9b..8c49892d05d6e95d3d4745dff8afb9adcc28ddc4 100644 (file)
@@ -35,5 +35,5 @@ int test_yaffs_chmod_EINVAL(void)
 
 int test_yaffs_chmod_EINVAL_clean(void)
 {
 
 int test_yaffs_chmod_EINVAL_clean(void)
 {
-       return 1;
+       return test_yaffs_chmod();
 }
 }
index 42d02ecc183848be15e16c3df58e126bada4ce9b..ba3e5a5b7aeae1e930848c5635a35e29333613dd 100644 (file)
@@ -18,6 +18,7 @@
        
 #include "lib.h"
 #include "yaffsfs.h"
        
 #include "lib.h"
 #include "yaffsfs.h"
+#include "test_yaffs_chmod.h"
 
 int test_yaffs_chmod_EINVAL(void);     
 int test_yaffs_chmod_EINVAL_clean(void);
 
 int test_yaffs_chmod_EINVAL(void);     
 int test_yaffs_chmod_EINVAL_clean(void);
index 5e2d534b9d0c31da13104344fb29cd359d2f6c5e..a5b6bb17ff94acd4b3cc4cf91dc83d7c9ebc8a15 100644 (file)
@@ -35,5 +35,5 @@ int test_yaffs_chmod_EINVAL2(void)
 
 int test_yaffs_chmod_EINVAL2_clean(void)
 {
 
 int test_yaffs_chmod_EINVAL2_clean(void)
 {
-       return 1;
+       return test_yaffs_chmod();
 }
 }
index 202975035cfc908195387bb584dc8a4e7a2bb25e..663b71777b833f9d7484dfb8baef3143abe2f2fb 100644 (file)
@@ -18,6 +18,7 @@
        
 #include "lib.h"
 #include "yaffsfs.h"
        
 #include "lib.h"
 #include "yaffsfs.h"
+#include "test_yaffs_chmod.h"
 
 int test_yaffs_chmod_EINVAL2(void);    
 int test_yaffs_chmod_EINVAL2_clean(void);
 
 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 (file)
index 3f64d8a..0000000
+++ /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 <timothy@yaffs.net>
- *
- * 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();
-}
-
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 75753cda0a96e886e68f3fe09bd1dce5e9a20abe..7472451905c21cbc9740db13336bac02eeced57a 100644 (file)
  * published by the Free Software Foundation.
  */
 
  * 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;
 
 {
        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;
                }
                        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;
        }
 }
                return -1;
        }
 }
-int test_yaffs_unmount_ENOENT_clean(void)
+
+int test_yaffs_unmount_ENODEV_clean(void)
 {
        return 1;
 }
 {
        return 1;
 }
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 1c7ad758f2f145622f0e2451c90d97cb9eafca9f..630ccbdb33ac04996bc17b0d7a12599fb25da379 100644 (file)
  * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
  */
 
  * 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 "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
 
 #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 (file)
index f6faa64..0000000
+++ /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 <timothy@yaffs.net>
- *
- * 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