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 bf82726..001f512 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 25b995e..3018fd6 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 a7219c5..8c7608e 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 2efd08e..51b5794 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 17bce3b..a58fc08 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 b44bf9b..dacb276 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 0596ca9..8c49892 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 42d02ec..ba3e5a5 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 5e2d534..a5b6bb1 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 2029750..663b717 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();
-}
-
  * 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;
 }
  * 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