yaffs Yet more tests for quick tests.
authorTimothy Manning <tfhmanning@gmail.com>
Mon, 8 Nov 2010 03:08:59 +0000 (16:08 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Mon, 8 Nov 2010 03:08:59 +0000 (16:08 +1300)
Signed-off-by: Timothy Manning <tfhmanning@gmail.com>
17 files changed:
direct/timothy_tests/quick_tests/Makefile
direct/timothy_tests/quick_tests/README.txt
direct/timothy_tests/quick_tests/current_bugs.txt
direct/timothy_tests/quick_tests/quick_tests.h
direct/timothy_tests/quick_tests/test_yaffs_access_ENOENT.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_access_ENOENT.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_access_ENOTDIR.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_access_ENOTDIR.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_mount_ENOENT.c
direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_truncate_EISDIR.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_truncate_EISDIR.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOENT.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOENT.h [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOTDIR.c [new file with mode: 0644]
direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOTDIR.h [new file with mode: 0644]

index 0fbfbc566a36c4064c6114f5ba450c57c23bf96c..3567b88b2ce8733754ba910cc70c6d3823b02979 100644 (file)
@@ -49,11 +49,12 @@ TESTFILES =         quick_tests.o lib.o \
                test_yaffs_unmount.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_unlink.o  test_yaffs_unlink_EISDIR.o test_yaffs_unlink_ENOENT.o test_yaffs_unlink_ENAMETOOLONG.o test_yaffs_unlink_ENOTDIR.o\
-               test_yaffs_ftruncate.o test_yaffs_truncate.o \
+               test_yaffs_ftruncate.o \
+               test_yaffs_truncate.o test_yaffs_truncate_ENOTDIR.o test_yaffs_truncate_EISDIR.o test_yaffs_truncate_ENOENT.o test_yaffs_truncate_EINVAL.o \
                test_yaffs_write.o \
                test_yaffs_read.o \
                test_yaffs_lseek.o \
-               test_yaffs_access.o test_yaffs_access_EINVAL.o \
+               test_yaffs_access.o test_yaffs_access_EINVAL.o test_yaffs_access_ENOTDIR.o test_yaffs_access_ENOENT.o\
                test_yaffs_stat.o \
                test_yaffs_close_EBADF.o
                  
@@ -120,4 +121,4 @@ quick_tests: $(SYMLINKS) $(ALLOBJS)
 
 
 clean:
-       rm -f quick_tests  $(ALLOBJS) core $(SYMLINKS) log.txt 
+       rm -f quick_tests  $(ALLOBJS) core $(SYMLINKS) 
index fbf7b60d1ec96545a2a1c2d26b20b673f4a587ff..51344782d0da30aa90e6ff76017bb5d10c71802c 100644 (file)
@@ -2,36 +2,50 @@
 Made by Timothy Manning <timothy@yaffs.net> on 04/11/2010
 
 
-tests made
+Tests made
        test_yaffs_mount
        test_yaffs_mount_ENODEV
        test_yaffs_mount_ENAMETOOLONG
        test_yaffs_mount_ENOENT
        test_yaffs_mount_EBUSY          //called when trying to mount a new mount point with a mount point already mounted.
+
        test_yaffs_access
+       test_yaffs_access_ENIVAL        //when the mode is incorrect.
+       test_yaffs_access_ENOTDIR
+       test_yaffs_access_ENOENT
+
        test_yaffs_close_EBADF
        test_yaffs_ftruncate
        test_yaffs_lseek
+
        test_yaffs_open
        test_yaffs_open_EEXIST
        test_yaffs_open_EISDIR
        test_yaffs_open_ENAMETOOLONG
        test_yaffs_open_ENOENT
        test_yaffs_open_ENOTDIR
+
        test_yaffs_read
        test_yaffs_stat
+
        test_yaffs_truncate
+       test_yaffs_truncate_ENOTDIR
+       test_yaffs_truncate_EISDIR
+       test_yaffs_truncate_ENOENT
+       test_yaffs_truncate_ENIVAL
+
        test_yaffs_unlink
        test_yaffs_unlink_EISDIR
        test_yaffs_unlink_ENAMETOOLONG
        test_yaffs_unlink_ENOENT
        test_yaffs_unlink_ENOTDIR
        test_yaffs_unlink_ENOENT
+
        test_yaffs_unmount
        test_yaffs_write
 
 
-tests to add
+Tests to add
        test_yaffs_mount_EACCES         //Cannot be generated with yaffs.
        test_yaffs_mount_EINVAL         //Cannot be generated with yaffs.
        test_yaffs_mount_ELOOP          //Cannot be generated with yaffs.
@@ -57,9 +71,7 @@ tests to add
        test_yaffs_access_EACCESS
        test_yaffs_access_ELOOP
        test_yaffs_access_ENAMETOOLONG
-       test_yaffs_access_ENOENT
-       test_yaffs_access_ENOTDIR
-       test_yaffs_access_ENIVAL        //mode is incorrect.
+       test_yaffs_access_ENOENT_generated_with_a_dangling_symbloic_link
 
        test_yaffs_ftruncate_EACCES
        test_yaffs_ftruncate_EFBIG
@@ -72,12 +84,8 @@ tests to add
 
        test_yaffs_truncate_EACCES
        test_yaffs_truncate_EFBIG
-       test_yaffs_truncate_ENIVAL
-       test_yaffs_truncate_EISDIR
        test_yaffs_truncate_ELOOP
        test_yaffs_truncate_ENAMETOOLONG
-       test_yaffs_truncate_ENOENT
-       test_yaffs_truncate_ENOTDIR
        test_yaffs_truncate_EPERM
 
        check to see if an error code is generated when there isn't an error.
@@ -91,14 +99,19 @@ How to add a test
        Test_yaffs_[function of yaffs which is been tested]_[error trying to be generated]
        
        The .c file needs to contain two functions.
-       The first function needs to contain the code for the main test and will return -1 on a failure and 0 or greater on a success.
-       The second function needs contain the code for cleaning up after the test. Cleaning up may include closing some open handles, recreating a file, ect. 
+       The first function needs to contain the code for the main test and will 
+       return -1 on a failure and 0 or greater on a success.
+       The second function needs contain the code for cleaning up after the test. 
+       Cleaning up may include closing some open handles, recreating a file, ect. 
        This second function needs to return -1 on a failure and 0 or greater on success.
 
-       The name of first function needs to be called the same as the file name (without the .c or .h)
-       The second function's name needs be the same as the first function but with "_clean" added on the end.
+       The name of first function needs to be called the same as the file 
+       name (without the .c or .h)
+       The second function's name needs be the same as the first function but 
+       with "_clean" added on the end.
        
-       So if a test is been created for the yaffs function yaffs_foo() then create these files
+       So if a test is been created for the yaffs function yaffs_foo() then 
+       create these files
        test_yaffs_foo.c
                Contains int test_yaffs_foo(void); int test_yaffs_foo_clean(void);
        test_yaffs_foo.h
@@ -106,11 +119,15 @@ How to add a test
 
        Next write the test code in these files then add these files to the Makefile.
 
-       Add the name of the test files' object file (test_yaffs_foo.o ) to the TESTFILES tag around line 50 of the Makefile.    
+       Add the name of the test files' object file (test_yaffs_foo.o ) to the 
+       TESTFILES tag around line 50 of the Makefile.   
 
        Now add the test functions to the test_list[] array in quick_tests.h
-       The order of the tests matters. The idea is to test each yaffs_function individualy and only using tested yaffs_components before using this new yaffs_function. 
-       This array consists of: {[test function], [the clean function], [name of the tests which will be printed when the test fails]}, 
+       The order of the tests matters. The idea is to test each yaffs_function 
+       individualy and only using tested yaffs_components before using this new 
+       yaffs_function. 
+       This array consists of: 
+       {[test function], [the clean function], [name of the tests which will be printed when the test fails]}, 
        
        So add this line to the test_list[]: {test_yaffs_foo, test_yaffs_foo_clean, "test_yaffs_foo"},
 
@@ -120,7 +137,8 @@ How to add a test
 
 
 
-       PS: yaffs_foo() is a made up function for this README (in case you want to find this function in yaffs). 
+       PS: yaffs_foo() is a made up function for this README (in case you want 
+       to find this function in yaffs). 
 
 
 
index 9243fd28eef15b1720d07491d8b5a8e0f2f18a97..3ecd20c8b69583bc65eb81550b9e8485f1331fe2 100644 (file)
@@ -2,13 +2,36 @@
 Made by Timothy Manning <timothy@yaffs.net> on 08/11/2010
 
 
-Current BUGS AND WARNINGS
-       bug with opening a file with a name of 1,000,000 char long with no errors.
-       bug with unlinking a file with 1,000,000 get the error ENOENT but should be geting ENAMETOOLONG. 
-       bug with mounting a too long non-existant mount point is returning ENODEV. there are two errors here, ENOENT and ENAMETOOLONG.
-       bug with mounting a non-existing mount point get the error ENODEV. should be getting ENOENT.
+Current BUGS 
+       Bug with opening a file with a name of 1,000,000 char long with no errors.
 
-       bug when trying to use yaffs_access on an existing file with mode 255 the error returned is EACCES it should be EINVAL(note there is no quick test file yet).
+       Bug with unlinking a file with 1,000,000 get the error ENOENT but should
+       be geting ENAMETOOLONG. 
 
-       WARNING- If yaffs is unmounted then most functions return ENODIR.
+       Bug with mounting a too long non-existant mount point is returning 
+       ENODEV. there are two errors here, ENOENT and ENAMETOOLONG.
+       The ENODEV is the error which yaffs gives instead of ENOENT.
+       BBut the mount function should just return ENAMETOOLONG.
 
+       Bug when mounting a non-existing mount point. The error code returned is 
+       ENODEV.
+
+       Bug when trying to use yaffs_access on an existing file with mode 255 
+       the error returned is EACCES it should be EINVAL(note there is no quick test file yet).
+
+       Bug when trying to access a non-existing directory the error ENOENT is 
+       returned. It should be ENOTDIR.
+
+       Bug when trying to truncate a file in a non-existing directory. The error
+       returned is ENOENT it should be ENOTDIR.
+
+       Bug truncating a file to a size of -1 does not cause an error. 
+
+
+Current WARNINGS
+       WARNING- If yaffs is unmounted then most of yaffs' functions return ENODIR. 
+       some function return EBADF instead.
+
+       WARNING- When mounting a non-existing mount point the error ENODEV is returned.
+       The quick tests have been altered to accommodate this error code.    
+       With standard access function in linux the error returned is ENOENT.
index 18a35b1c630601315561b19661b3aaacf4cad00b..ecde8046435486559388de1ebf8a720f542281ee 100644 (file)
 #include "test_yaffs_unlink_ENOENT.h"
 
 #include "test_yaffs_ftruncate.h"
+
 #include "test_yaffs_truncate.h"
+#include "test_yaffs_truncate_ENOTDIR.h"
+#include "test_yaffs_truncate_EISDIR.h"
+#include "test_yaffs_truncate_ENOENT.h"
+#include "test_yaffs_truncate_EINVAL.h"
+
 #include "test_yaffs_write.h"
 #include "test_yaffs_read.h"
 #include "test_yaffs_lseek.h"
 
 #include "test_yaffs_access.h"
 #include "test_yaffs_access_EINVAL.h"
+#include "test_yaffs_access_ENOTDIR.h"
+#include "test_yaffs_access_ENOENT.h"
 
 #include "test_yaffs_stat.h"
 #include "yaffsfs.h"
@@ -70,7 +78,7 @@ typedef struct test {
 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_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"},
 
@@ -87,6 +95,8 @@ test_template test_list[]={
 
        {test_yaffs_access,test_yaffs_access_clean,"test_yaffs_access"},
        {test_yaffs_access_EINVAL,test_yaffs_access_EINVAL_clean,"test_yaffs_access_EINVAL"},
+       {test_yaffs_access_ENOTDIR,test_yaffs_access_ENOTDIR_clean,"test_yaffs_access_ENOTDIR"},
+       {test_yaffs_access_ENOENT,test_yaffs_access_ENOENT_clean,"test_yaffs_access_ENOENT"},
 
        {test_yaffs_unlink, test_yaffs_unlink_clean,"test_yaffs_unlink"},
        {test_yaffs_unlink_EISDIR,test_yaffs_unlink_EISDIR_clean,"test_yaffs_unlink_EISDIR"},
@@ -103,8 +113,12 @@ test_template test_list[]={
 
        {test_yaffs_stat,test_yaffs_stat_clean,"test_yaffs_stat"},
        {test_yaffs_ftruncate,test_yaffs_ftruncate_clean,"test_yaffs_ftruncate"},
-       {test_yaffs_truncate,test_yaffs_truncate_clean,"test_yaffs_truncate"}
 
+       {test_yaffs_truncate,test_yaffs_truncate_clean,"test_yaffs_truncate"},
+       {test_yaffs_truncate_ENOTDIR,test_yaffs_truncate_ENOTDIR_clean,"test_yaffs_truncate_ENOTDIR"},
+       {test_yaffs_truncate_EISDIR,test_yaffs_truncate_EISDIR_clean,"test_yaffs_truncate_EISDIR"},
+       {test_yaffs_truncate_EINVAL,test_yaffs_truncate_EINVAL_clean,"test_yaffs_truncate_EINVAL"},
+       {test_yaffs_truncate_ENOENT,test_yaffs_truncate_ENOENT_clean,"test_yaffs_truncate_ENOENT"}
        };
 
 void init_quick_tests(void);
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_ENOENT.c b/direct/timothy_tests/quick_tests/test_yaffs_access_ENOENT.c
new file mode 100644 (file)
index 0000000..610e4ee
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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_access_ENOENT.h"
+
+
+int test_yaffs_access_ENOENT(void){
+       int output=0;
+       int error_code=0;
+       /*printf("path %s\n",path); */
+       output=yaffs_access("/yaffs2/non_existant_file",0);
+       if (output==-1){
+               error_code=yaffs_get_error();
+               if (abs(error_code)==ENOENT){
+                       return 1;
+               }
+               else {
+                       printf("different error than expected\n");
+                       return -1;
+               }
+       }
+       else {
+               printf("non existant file accessed.(which is a bad thing)\n");
+               return -1;
+       }
+
+}
+int test_yaffs_access_ENOENT_clean(void){
+       return 1;
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_ENOENT.h b/direct/timothy_tests/quick_tests/test_yaffs_access_ENOENT.h
new file mode 100644 (file)
index 0000000..ed24f95
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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_access_ENOENT_h__
+#define __test_yaffs_access_ENOENT_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_access_ENOENT(void);
+int test_yaffs_access_ENOENT_clean(void);
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_ENOTDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_access_ENOTDIR.c
new file mode 100644 (file)
index 0000000..ad2402c
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * 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_access_ENOTDIR.h"
+
+static int handle=0;
+int test_yaffs_access_ENOTDIR(void){
+       int output=0;
+       int error_code=0;
+       /*printf("path %s\n",path); */
+       output=yaffs_access("/nonexisting_dir/foo",0);
+       if (output==-1){
+               error_code=yaffs_get_error();
+               //printf("EISDIR def %d, Error code %d\n", ENOTDIR,error_code);
+               if (abs(error_code)==ENOTDIR){
+                       return 1;
+               }
+               else {
+                       printf("different error than expected\n");
+                       return -1;
+               }
+       }
+       else {
+               printf("non existant directory accessed.(which is a bad thing)\n");
+               return -1;
+       }
+
+}
+int test_yaffs_access_ENOTDIR_clean(void){
+       return 1;
+}
+
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_access_ENOTDIR.h b/direct/timothy_tests/quick_tests/test_yaffs_access_ENOTDIR.h
new file mode 100644 (file)
index 0000000..0f18c90
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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_access_ENOTDIR_h__
+#define __test_yaffs_access_ENOTDIR_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_access_ENOTDIR(void);
+int test_yaffs_access_ENOTDIR_clean(void);
+#endif
index 061a13fffe55d8457d2fb0846748382a035dd817..01040fdf7b8c3a2def06e6ffd8393baa5e30a80d 100644 (file)
@@ -30,7 +30,7 @@ int test_yaffs_mount_ENOENT(void){
        output=yaffs_mount("/non_existaint_mount_point/");
        if (output==-1){
                error_code=yaffs_get_error();
-               if (abs(error_code)==ENOENT){
+               if (abs(error_code)==ENODEV){
                        return 1;
                }
                else {
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.c b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.c
new file mode 100644 (file)
index 0000000..1fcfafe
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * 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_truncate_EINVAL.h"
+static int handle=0;
+
+int test_yaffs_truncate_EINVAL(void){
+       int error=0;
+       int output=0;
+       handle=test_yaffs_open();
+       if (handle>=0){
+               output= yaffs_truncate("/yaffs2/foo",-1 );
+               if (output<0){
+                       error=yaffs_get_error();
+                       if (abs(error)==EINVAL){
+                               return 1;
+                       }
+                       else {
+                               printf("recieved a different error than expected\n");
+                               return -1;
+                       }
+               }
+               else{
+                       printf("truncated a file with a bad mode set.\n");
+                       return -1;
+               }
+                       
+       }
+       else {
+               printf("error opening file");
+               return -1;
+       }
+}
+
+int test_yaffs_truncate_EINVAL_clean(void){
+       return -1;
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.h b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EINVAL.h
new file mode 100644 (file)
index 0000000..f78af54
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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_truncate_EINVAL_h__
+#define __test_yaffs_truncate_EINVAL_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+int test_yaffs_truncate_EINVAL(void);
+int test_yaffs_truncate_EINVAL_clean(void); 
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EISDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EISDIR.c
new file mode 100644 (file)
index 0000000..051e1a7
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * 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_truncate.h"
+static int handle=0;
+
+int test_yaffs_truncate_EISDIR(void){
+       int error=0;
+       int output=0;
+       handle=test_yaffs_open();
+       if (handle>=0){
+               output= yaffs_truncate("/yaffs2/",10);
+               if (output<0){
+                       error=yaffs_get_error();
+                       if (abs(error)==EISDIR){
+                               return 1;
+                       }
+                       else {
+                               printf("recieved a different error than expected\n");
+                               return -1;
+                       }
+               }
+               else{
+                       printf("truncated a directory\n");
+                       return -1;
+               }
+                       
+       }
+       else {
+               printf("error opening file");
+               return 1;
+       }
+}
+
+int test_yaffs_truncate_EISDIR_clean(void){
+       return 1;
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_EISDIR.h b/direct/timothy_tests/quick_tests/test_yaffs_truncate_EISDIR.h
new file mode 100644 (file)
index 0000000..7299c6d
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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_truncate_EISDIR_h__
+#define __test_yaffs_truncate_EISDIR_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+int test_yaffs_truncate_EISDIR(void);
+int test_yaffs_truncate_EISDIR_clean(void); 
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOENT.c b/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOENT.c
new file mode 100644 (file)
index 0000000..6258aea
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * 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_truncate_ENOENT.h"
+static int handle=0;
+
+int test_yaffs_truncate_ENOENT(void){
+       int error=0;
+       int output=0;
+       handle=test_yaffs_open();
+       if (handle>=0){
+               output= yaffs_truncate("/yaffs2/non_existing_file",FILE_SIZE_TRUNCATED );
+               if (output<0){
+                       error=yaffs_get_error();
+                       if (abs(error)==ENOENT){
+                               return 1;
+                       }
+                       else {
+                               printf("recieved a different error than expected\n");
+                               return -1;
+                       }
+               }
+               else{
+                       printf("truncated a nonexisting file\n");
+                       return -1;
+               }
+                       
+       }
+       else {
+               printf("error opening file");
+               return -1;
+       }
+}
+
+int test_yaffs_truncate_ENOENT_clean(void){
+       return 1;
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOENT.h b/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOENT.h
new file mode 100644 (file)
index 0000000..1a74d87
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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_truncate_ENOENT_h__
+#define __test_yaffs_truncate_ENOENT_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+int test_yaffs_truncate_ENOENT(void);
+int test_yaffs_truncate_ENOENT_clean(void); 
+#endif
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOTDIR.c b/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOTDIR.c
new file mode 100644 (file)
index 0000000..2cc71b5
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * 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_truncate_ENOTDIR.h"
+static int handle=0;
+
+int test_yaffs_truncate_ENOTDIR(void){
+       int error=0;
+       int output=0;
+       handle=test_yaffs_open();
+       if (handle>=0){
+               output= yaffs_truncate("/non_existing_dir/foo",FILE_SIZE_TRUNCATED );
+               if (output<0){
+                       error=yaffs_get_error();
+                       if (abs(error)==ENOTDIR){
+                               return 1;
+                       }
+                       else {
+                               printf("recieved a different error than expected\n");
+                               return -1;
+                       }
+               }
+               else{
+                       printf("truncated a nonexisting file\n");
+                       return -1;
+               }
+                       
+       }
+       else {
+               printf("error opening file");
+               return -1;
+       }
+}
+
+int test_yaffs_truncate_ENOTDIR_clean(void){
+       return 1;
+}
diff --git a/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOTDIR.h b/direct/timothy_tests/quick_tests/test_yaffs_truncate_ENOTDIR.h
new file mode 100644 (file)
index 0000000..24120d4
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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_truncate_ENOTDIR_h__
+#define __test_yaffs_truncate_ENOTDIR_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+int test_yaffs_truncate_ENOTDIR(void);
+int test_yaffs_truncate_ENOTDIR_clean(void); 
+#endif