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.o test_yaffs_unmount_ENOENT.o test_yaffs_unmount_ENAMETOOLONG.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_truncate.o test_yaffs_truncate_ENOTDIR.o test_yaffs_truncate_EISDIR.o test_yaffs_truncate_ENOENT.o test_yaffs_truncate_EINVAL.o \
test_yaffs_truncate_EFBIG.o\
test_yaffs_write.o \
- test_yaffs_read.o test_yaffs_read_EBADF.o \
+ test_yaffs_read.o test_yaffs_read_EBADF.o test_yaffs_read_EINVAL.o\
test_yaffs_lseek.o test_yaffs_lseek_EBADF.o test_yaffs_lseek_EINVAL.o test_yaffs_lseek_EFBIG.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_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_ENIVAL
test_yaffs_access_ENOTDIR
test_yaffs_access_ENOENT
test_yaffs_read
test_yaffs_read_EBADF
+ test_yaffs_read_EINVAL
test_yaffs_stat
test_yaffs_unlink_ENOENT
test_yaffs_unmount
+ test_yaffs_unmount_ENOENT
+ test_yaffs_unmount_ENAMETOOLONG
+
test_yaffs_write
- add a test where a directory is moved. /fluffy/box. move "fluffy" to "/fluffy/frog".
+
Tests to add
test_yaffs_mount_EACCES //Cannot be generated with yaffs.
test_yaffs_mount_EMFILE //Cannot be generated with yaffs.
test_yaffs_mount_ENOTDIR //Cannot be generated with yaffs.
- test_yaffs_umount_ENODEV
- test_yaffs_umount_ENAMETOOLONG
- test_yaffs_umount_ENOENT
- test_yaffs_umount_EBUSY
+ test_yaffs_umount_ENODEV //Cannot be generated with yaffs.
+ test_yaffs_umount_ENOENT //Cannot be generated with yaffs.
+ test_yaffs_umount_EBUSY //when files are open and yaffs is unmounted.
test_yaffs_open_EACCES
test_yaffs_open_ENOSPC
test_yaffs_close //This function has already been called by the time this test is reached.
-
- test_yaffs_read_EINVAL //test exists but is not finshed yet.
+ test_yaffs_stat_EBADF
+ test_yaffs_stat_ELOOP
+ test_yaffs_stat_EACCES
+ test_yaffs_stat_ENAMETOOLONG
+ test_yaffs_stat_ENOTDIR
+
test_yaffs_read_EISDIR //Cannot be generated with yaffs.
test what happens if you read off the end of the file?
+ test_yaffs_write_EBADF
+ test_yaffs_write_EFBIG
+ test_yaffs_write_EINVAL
+ What happens when you run out of space?
+
test_yaffs_unlink_EACCES
test_yaffs_unlink_ELOOP
test_yaffs_unlink_ENOMEM
What happens if a handle is opened to a file and the file is then deleted?
Check to see if yaffs generates an error code for no reason.
What happens when a file is opened with no modes set?
+ Add a test where a directory is moved. /fluffy/box. move "fluffy" to "/fluffy/frog".
+ What happens when yaffs is unmounted twice?
+ What happens when open a handle, unmount yaffs and then try to use the handle?
How to add a test
First create the test .c and .h file.
ENODEV. yaffs_mount should be returning ENAMETOOLONG.
When the name is passed into the yaffs_mount function the length of the
mount point decreases from around 10000000 to 200. This needs to be investigated.
+
+ Bug with unmounting a too long non-existing mountpoint.
+ The error returned is ENODEV. It should be ENAMETOOLONG.
ENOTDIR ERRORS
Bug with lseeking to a very large size (size =100000000000000000000000000000000000000) without causing an error.
Should cause the error EINVAL.
+ Bug with unmounting a non-existing mountpoint. The function returns ENODEV
+ but should be returning EINVAL.
+
+ Bug with reading -1 bytes of a file without an error (test is in test_yaffs_read_EINVAL).
+ It should return EINVAL.
+
+ Unmount2 forcing the unmount needs to break the handles so they return EBADF.
+
Current WARNINGS
- <<WHAT FUNCTIONS>>
WARNING- If yaffs is unmounted then most of yaffs' functions return ENODIR.
- some function return EBADF instead.
+ But some function return EBADF instead.
+ Functions which return ENOTDIR: open, close, access, unlink, lseek, write, read
+
+ Functions which return ENOENT: access, stat
+
+
WARNING-the function yaffs_open does not check the mode passed to it.
This means that yaffs open does not return EINVAL if a bad mode is passed to it.
#include "test_yaffs_mount_EBUSY.h"
#include "test_yaffs_unmount.h"
+#include "test_yaffs_unmount_ENOENT.h"
+#include "test_yaffs_unmount_ENAMETOOLONG.h"
#include "test_yaffs_open.h"
#include "test_yaffs_open_EISDIR.h"
#include "test_yaffs_read.h"
#include "test_yaffs_read_EBADF.h"
+#include "test_yaffs_read_EINVAL.h"
#include "test_yaffs_lseek.h"
#include "test_yaffs_lseek_EBADF.h"
test_template test_list[]={
- {test_yaffs_mount,test_yaffs_mount_clean,"test_yaffs_mount"},
+/* {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_ENAMETOOLONG,test_yaffs_unmount_ENAMETOOLONG_clean,"test_yaffs_unmount_ENAMETOOLONG"},
+*/
{test_yaffs_open,test_yaffs_open_clean,"test_yaffs_open"},
{test_yaffs_open_EISDIR,test_yaffs_open_EISDIR_clean,"test_yaffs_open_EISDIR"},
{test_yaffs_open_EEXIST,test_yaffs_open_EEXIST_clean,"test_yaffs_open_EEXIST"},
{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_EINVAL,test_yaffs_read_EINVAL_clean,"test_yaffs_read_EINVAL"},
{test_yaffs_stat,test_yaffs_stat_clean,"test_yaffs_stat"},
#include "test_yaffs_lseek_EFBIG.h"
-static int handle=0;
+static int handle=-1;
int test_yaffs_lseek_EFBIG(void){
handle=test_yaffs_open();
int error_code=0;
- int output=yaffs_lseek(handle, 100000000000000000000000000000000000000, SEEK_SET);
+ int output=0;
+
+ if (handle<0){
+ printf("failed to open file\n");
+ return -1;
+ }
+
+ yaffs_lseek(handle, 100000000000000000000000000000000000000, SEEK_SET);
if (output<0){
error_code=yaffs_get_error();
#include "test_yaffs_lseek_EINVAL.h"
-int handle=0;
+int handle=-1;
int test_yaffs_lseek_EINVAL(void){
handle=test_yaffs_open();
int error_code=0;
- int output=yaffs_lseek(handle, 0, -1);
+ int output=0;
+
+ if (handle<0){
+ printf("failed to open file\n");
+ return -1;
+ }
+
+
+ output=yaffs_lseek(handle, 0, -1);
if (output<0){
error_code=yaffs_get_error();
#include "test_yaffs_read.h"
-static int handle=0;
+static int handle=-1;
int test_yaffs_read(void){
handle=test_yaffs_open();
}
int test_yaffs_read_clean(void){
- return yaffs_close(handle);
+ if (handle>=0){
+ return yaffs_close(handle);
+ }
+ else {
+ return 1; /* no handle was opened so there is no need to close a handle */
+ }
}
* published by the Free Software Foundation.
*/
-#include "test_yaffs_read_EBADF.h"
+#include "test_yaffs_read_EINVAL.h"
static int handle=0;
-int test_yaffs_read_EBADF(void){
+int test_yaffs_read_EINVAL(void){
+ int error_code=0;
handle=test_yaffs_open();
char text[20]="\0";
int output=0;
- //printf("handle %d\n",handle);
+
if (handle>=0){
- output=yaffs_read(-1, text, FILE_TEXT_NBYTES);
- //printf("yaffs_test_read output: %d\n",output);
- //printf("text in file is: '%s' expected text is '%s'\n",text,FILE_TEXT);
+ output=yaffs_read(handle, text, -1);
+
if (output<0){
- if (0==memcmp(text,FILE_TEXT,FILE_TEXT_NBYTES)){
+ error_code=yaffs_get_error();
+ if (abs(error_code)== EINVAL){
return 1;
}
else {
- printf("returned error does not match the the expected error\n");
+ printf("different error than expected\n");
return -1;
}
}
}
-int test_yaffs_read_EBADF_clean(void){
- return yaffs_close(handle);
+int test_yaffs_read_EINVAL_clean(void){
+ if (handle>=0){
+ return yaffs_close(handle);
+ }
+ else {
+ return 1; /* no handle was opened so there is no need to close a handle */
+ }
}
* Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
*/
-#ifndef __test_yaffs_read_EBADF_h__
-#define __test_yaffs_read_EBADF_h__
+#ifndef __test_yaffs_read_EINVAL_h__
+#define __test_yaffs_read_EINVAL_h__
#include "lib.h"
#include "yaffsfs.h"
#include "test_yaffs_open.h"
-int test_yaffs_read_EBADF(void);
-int test_yaffs_read_EBADF_clean(void);
+int test_yaffs_read_EINVAL(void);
+int test_yaffs_read_EINVAL_clean(void);
#endif
int mode=0;
int size=0;
mode =yaffs_test_stat_mode();
-/* printf("\nmode %o\n",mode);
- printf("expected mode %o \n",FILE_MODE);
- printf("anding together %o\n",FILE_MODE & mode);
- printf("%d\n",FILE_MODE == (FILE_MODE & mode));
-*/ if (FILE_MODE == (FILE_MODE & mode)){
- mode=1;
+
+ if (mode>=0){
+
+ if (FILE_MODE == (FILE_MODE & mode)){
+ mode=1;
+ }
+ else {
+ printf("mode did not match expected file mode\n");
+ return -1;
+ }
}
else {
- printf("mode did not match expected file mode\n");
- return -1;
+ mode =-1;
}
+
size=yaffs_test_stat_size();
- if (size==FILE_SIZE){
- size=1;
+ if (size >=0){
+ if (size==FILE_SIZE){
+ size=1;
+ }
+ else {
+ printf("file size %d, expected file size %d\n",size,FILE_SIZE);
+ printf("mode did not match expected file mode\n");
+ return -1;
+ }
}
else {
- printf("file size %d, expected file size %d\n",size,FILE_SIZE);
- printf("mode did not match expected file mode\n");
- return -1;
- }
-
- if (mode && size){
+ size =-1;
+ }
+
+
+ if ((mode>0) && (size>0)){
return 1;
}
else {
return stat.st_mode;
}
else {
- printf("failed to stat file\n") ;
+ printf("failed to stat file mode\n") ;
return -1;
}
}
return stat.st_size;
}
else {
- printf("failed to stat file\n") ;
+ printf("failed to stat file size\n") ;
return -1;
}
}
return 1;
}
else {
- printf("recieved a different error than expected\n");
+ printf("received a different error than expected\n");
return -1;
}
}
return 1;
}
else {
- printf("recieved a different error than expected\n");
+ printf("received a different error than expected\n");
return -1;
}
}
return 1;
}
else {
- printf("recieved a different error than expected\n");
+ printf("received a different error than expected\n");
return -1;
}
}
return 1;
}
else {
- printf("recieved a different error than expected\n");
+ printf("received a different error than expected\n");
return -1;
}
}
return 1;
}
else {
- printf("recieved a different error than expected\n");
+ printf("received a different error than expected\n");
return -1;
}
}
#include "test_yaffs_unlink_ENAMETOOLONG.h"
-static int handle=0;
+
int test_yaffs_unlink_ENAMETOOLONG(void){
int output=0;
int error_code=0;
printf("directory unlinked opened.(which is a bad thing)\n");
return -1;
}
- /* the program should not get here but the compiler is complaining */
- return -1;
}
+
int test_yaffs_unlink_ENAMETOOLONG_clean(void){
- if (handle >=0){
- return yaffs_close(handle);
- }
- else {
- return 1; /* the file failed to open so there is no need to close it*/
- }
+ return 1;
}
--- /dev/null
+/*
+ * 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_unmount_ENAMETOOLONG.h"
+
+
+
+
+int test_yaffs_unmount_ENAMETOOLONG(void){
+ int output=0;
+ int x;
+ int error_code=0;
+ int file_name_length=1000000;
+ char file_name[file_name_length];
+
+
+
+ for (x=0; x<file_name_length -1; x++){
+ file_name[x]='a';
+ }
+ file_name[file_name_length-2]='\0';
+
+ //printf("file name: %s\n",file_name);
+
+
+ output=yaffs_unmount(file_name);
+
+ if (output<0){
+ error_code=yaffs_get_error();
+ if (abs(error_code)== ENAMETOOLONG){
+ return 1;
+ }
+ else {
+ printf("different error than expected\n");
+ return -1;
+ }
+ }
+ else {
+ printf("mounted a too long mount point name.(which is a bad thing)\n");
+ return -1;
+ }
+ /* the program should not get here but the compiler is complaining */
+ return -1;
+}
+
+int test_yaffs_unmount_ENAMETOOLONG_clean(void){
+ return 1;
+}
+
--- /dev/null
+/*
+ * 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_ENAMETOOLONG_h__
+#define __test_yaffs_unmount_ENAMETOOLONG_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_mount.h"
+#include "test_yaffs_unmount.h"
+
+
+int test_yaffs_unmount_ENAMETOOLONG(void);
+int test_yaffs_unmount_ENAMETOOLONG_clean(void);
+#endif
--- /dev/null
+/*
+ * 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_unmount_ENOENT(void){
+ int output=0;
+ int error_code=0;
+ /*printf("path %s\n",path); */
+
+
+
+ output=yaffs_unmount("/non_existaint_mount_point/");
+ if (output==-1){
+ error_code=yaffs_get_error();
+ if (abs(error_code)==EINVAL){
+ return 1;
+ }
+ else {
+ printf("different error than expected\n");
+ return -1;
+ }
+ }
+ else {
+ printf("non existant mount point unmounted.(which is a bad thing)\n");
+ return -1;
+ }
+
+}
+int test_yaffs_unmount_ENOENT_clean(void){
+ return 1;
+}
+
--- /dev/null
+/*
+ * 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
}
int test_yaffs_write_clean(void){
- return yaffs_close(handle);
+ if (handle>=0){
+ return yaffs_close(handle);
+ }
+ else {
+ return 1; /* no handle was opened so there is no need to close a handle */
+ }
}