# yaffs_checkptrwtest.o\
TESTFILES = quick_tests.o lib.o \
- test_mount_yaffs.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_unlinking.o \
+ test_yaffs_mount.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_write.o \
test_yaffs_read.o \
the yaffs_open function has been covered by tests
the yaffs_close function has been covered by tests
-
-
+tests made
+ test_yaffs_mount
+ test_yaffs_access
+ test_yaffs_close
+ 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_unlink_EISDIR
+ test_yaffs_unlink_ENAMETOOLONG
+ test_yaffs_unlink_ENOENT
+ test_yaffs_unlink_ENOTDIR
+ test_yaffs_write
tests to add
+ test_yaffs_mount_EACCES
+ test_yaffs_mount_EINVAL
+ test_yaffs_mount_ELOOP
+ test_yaffs_mount_EMFILE
+ test_yaffs_mount_ENAMETOOLONG
+ test_yaffs_mount_ENOENT
+ test_yaffs_mount_ENOTDIR
test_yaffs_open_EACCES
test_yaffs_open_ENOSPC
test_yaffs_open_ELOOP Too many symbolic links were encountered in resolving pathname
test_yaffs_close
test yaffs_open_running_out_of_handles error
+ test_yaffs_unlink_EACCES
+ test_yaffs_unlink_ELOOP
+ test_yaffs_unlink_ENOENT
+ test_yaffs_unlink_ENOMEM
check to see if an error code is generated when there isn't an error
+ 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.
How to add a test
BUGS
Needing to include int random_seed; and int simulate_power_failure = 0; in any main program using yaffsfs.h
- ENOSPC error in programs test_yaffs_open_ENOTDIR and test_yaffs_open_ENOENT.
- ENOENT been returned by yaffs_read but the handle is good and the yaffs_open function does not return an error.
+ 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.
+
+ FIXED-ENOSPC error in programs test_yaffs_open_ENOTDIR and test_yaffs_open_ENOENT.
+ FIXED-ENOENT been returned by yaffs_read but the handle is good and the yaffs_open function does not return an error.
else {
/*test is assumed to have failed*/
//printf("test failed\n");
- printf("test: %s failed\n",test_list[x].fail_message);
+ printf("test: %s failed\n",test_list[x].name_of_test);
num_of_tests_failed ++;
- quit_quick_tests(1);
-
+
+ if (EXIT_ON_ERROR){
+ printf("\n\n");
+ quit_quick_tests(1);
+ }
+ else {
+ get_error();
+ printf("\n\n");
+ }
}
output=test_list[x].p_function_clean(); /*clean the test*/
if (output <0){
/* if the test failed to clean it's self then */
- printf("test: %s failed to clean\n",test_list[x].fail_message);
+ printf("test: %s failed to clean\n",test_list[x].name_of_test);
num_of_tests_failed ++;
num_of_tests_pass--;
quit_quick_tests(1);
}
void quit_quick_tests(int exit_code){
- int error_code=0;
+
if (num_of_tests_pass==total_number_of_tests && num_of_tests_failed==0){
printf("\t OK \n");
}
else {
- error_code=yaffs_get_error();
- printf("yaffs_error code %d\n",error_code);
- printf("error is : %s\n",yaffs_error_to_str(error_code));
+ get_error();
}
printf("tests: %d passed %d failed\n\n\n",num_of_tests_pass,num_of_tests_failed);
yaffs_unmount(YAFFS_MOUNT_POINT);
exit(exit_code);
}
+void get_error(void){
+ int error_code=0;
+ error_code=yaffs_get_error();
+ printf("yaffs_error code %d\n",error_code);
+ printf("error is : %s\n",yaffs_error_to_str(error_code));
+}
+
void init_quick_tests(void){
yaffs_start_up();;
yaffs_set_trace(0);
#define __quick_tests_h__
#include <stdio.h>
-#include "test_mount_yaffs.h"
+#include "test_yaffs_mount.h"
#include "test_yaffs_open.h"
#include "test_yaffs_open_EISDIR.h"
#include "test_yaffs_open_EEXIST.h"
#include "test_yaffs_open_ENOENT.h"
#include "test_yaffs_open_ENOTDIR.h"
+#include "test_yaffs_open_ENAMETOOLONG.h"
#include "test_yaffs_close_EBADF.h"
-#include "test_yaffs_unlinking.h"
+#include "test_yaffs_unlink.h"
+#include "test_yaffs_unlink_EISDIR.h"
+#include "test_yaffs_unlink_ENOENT.h"
+#include "test_yaffs_unlink_ENAMETOOLONG.h"
+#include "test_yaffs_unlink_ENOTDIR.h"
+
#include "test_yaffs_ftruncate.h"
#include "test_yaffs_truncate.h"
#include "test_yaffs_write.h"
#include "yaffs_error_converter.h"
#include "lib.h"
+
+#define EXIT_ON_ERROR 0
+
typedef struct test {
int (*p_function)(void); /*pointer to test function*/
int (*p_function_clean)(void);
/*char pass_message[50]; will not need a pass message*/
- char *fail_message; /*pointer to fail message, needs to include name of test*/
+ char *name_of_test; /*pointer to fail message, needs to include name of test*/
}test_template;
test_template test_list[]={
- {mount_yaffs_test,mount_yaffs_test_clean,"mount_yaffs_test"},
+ {test_yaffs_mount,test_yaffs_mount_clean,"test_yaffs_mount"},
{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_open_ENOTDIR,test_yaffs_open_ENOTDIR_clean,"test_yaffs_open_ENOTDIR"},
{test_yaffs_open_ENOENT,test_yaffs_open_ENOENT_clean,"test_yaffs_open_ENOENT"},
+ {test_yaffs_open_ENAMETOOLONG,test_yaffs_open_ENAMETOOLONG_clean,"test_yaffs_open_ENAMETOOLONG"},
{test_yaffs_close_EBADF,test_yaffs_close_EBADF_clean,"test_yaffs_close_EBADF"},
{test_yaffs_access,test_yaffs_access_clean,"test_yaffs_access"},
- {test_yaffs_unlinking, test_yaffs_unlinking_clean,"test_yaffs_unlinking"},
+
+ {test_yaffs_unlink, test_yaffs_unlink_clean,"test_yaffs_unlink"},
+ {test_yaffs_unlink_EISDIR,test_yaffs_unlink_EISDIR_clean,"test_yaffs_unlink_EISDIR"},
+ {test_yaffs_unlink_ENOENT,test_yaffs_unlink_ENOENT_clean,"test_yaffs_unlink_ENOENT"},
+ {test_yaffs_unlink_ENAMETOOLONG,test_yaffs_unlink_ENAMETOOLONG_clean,"test_yaffs_unlink_ENAMETOOLONG"},
+ {test_yaffs_unlink_ENOTDIR,test_yaffs_unlink_ENOTDIR_clean,"test_yaffs_unlink_ENOTDIR"},
+
{test_yaffs_lseek,test_yaffs_lseek_clean,"test_yaffs_lseek"},
{test_yaffs_write,test_yaffs_write_clean,"test_yaffs_write"},
void init_quick_tests(void);
void quit_quick_tests(int exit_code);
+void get_error(void);
#endif
* published by the Free Software Foundation.
*/
-#include "test_mount_yaffs.h"
+#include "test_yaffs_mount.h"
-int mount_yaffs_test(void){
+int test_yaffs_mount(void){
int output=0;
output=yaffs_mount(YAFFS_MOUNT_POINT);
/*printf("output %d",output);*/
return output;
}
-int mount_yaffs_test_clean(void){
+int test_yaffs_mount_clean(void){
return 1;
}
* Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
*/
-#ifndef __mount_yaffs_test__
-#define __mount_yaffs_test__
+#ifndef __test_yaffs_mount__
+#define __test_yaffs_mount__
#include "yaffsfs.h"
#include "lib.h"
-int mount_yaffs_test(void);
-int mount_yaffs_test_clean(void);
+int test_yaffs_mount(void);
+int test_yaffs_mount_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_open_ENAMETOOLONG.h"
+
+
+
+static int handle=0;
+int test_yaffs_open_ENAMETOOLONG(void){
+ int output=0;
+ int x;
+ int error_code=0;
+ int file_name_length=1000000;
+ char file_name[file_name_length];
+
+ strcat(file_name,YAFFS_MOUNT_POINT);
+ for (x=strlen(YAFFS_MOUNT_POINT); x<file_name_length -1; x++){
+ file_name[x]='a';
+ }
+ file_name[file_name_length-2]='\0';
+
+ //printf("file name: %s\n",file_name);
+
+
+ handle=yaffs_open(file_name, O_CREAT | O_TRUNC| O_RDWR ,FILE_MODE );
+ printf("handle %d \n",handle);
+ if (handle==-1){
+ error_code=yaffs_get_error();
+ //printf("ENAMETOOLONG def %d, Error code %d\n", ENAMETOOLONG,error_code);
+ if (abs(error_code)== ENAMETOOLONG){
+ return 1;
+ }
+ else {
+ printf("different error than expected\n");
+ return -1;
+ }
+ }
+ else if (output >=0){
+ printf("non existant file 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_open_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*/
+ }
+}
+
--- /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_open_ENAMETOOLONG_h__
+#define __test_yaffs_open_ENAMETOOLONG_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_open_ENAMETOOLONG(void);
+int test_yaffs_open_ENAMETOOLONG_clean(void);
+#endif
* published by the Free Software Foundation.
*/
-#include "test_yaffs_unlinking.h"
+#include "test_yaffs_unlink.h"
-int test_yaffs_unlinking(void){
+int test_yaffs_unlink(void){
int output=yaffs_unlink(FILE_PATH);
if (output>=0){
return (-test_yaffs_access()); /*return negative access. we do not want the file to be there*/
}
}
-int test_yaffs_unlinking_clean(void){
+int test_yaffs_unlink_clean(void){
return test_yaffs_open();
}
* Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
*/
-#ifndef __test_yaffs_unlinking_h__
-#define __test_yaffs_unlinking_h__
+#ifndef __test_yaffs_unlink_h__
+#define __test_yaffs_unlink_h__
#include "lib.h"
#include "yaffsfs.h"
#include "test_yaffs_open.h"
#include "test_yaffs_access.h"
-int test_yaffs_unlinking(void);
-int test_yaffs_unlinking_clean(void);
+int test_yaffs_unlink(void);
+int test_yaffs_unlink_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_unlink_EISDIR.h"
+
+/*EISDIR is caused by trying to unlink a directory */
+
+static int handle=0;
+int test_yaffs_unlink_EISDIR(void){
+ int output=0;
+ int error_code=0;
+ /*printf("path %s\n",path); */
+ handle=yaffs_unlink(YAFFS_MOUNT_POINT);
+ if (handle==-1){
+ error_code=yaffs_get_error();
+ //printf("EISDIR def %d, Error code %d\n", EISDIR,error_code);
+ if (abs(error_code)== EISDIR){
+ return 1;
+ }
+ else {
+ printf("different error than expected\n");
+ return -1;
+ }
+ }
+ else if (output >=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_EISDIR_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*/
+ }
+}
+
--- /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_unlink_EISDIR_h__
+#define __test_yaffs_unlink_EISDIR_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_unlink_EISDIR(void);
+int test_yaffs_unlink_EISDIR_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_unlink_ENAMETOOLONG.h"
+
+
+static int handle=0;
+int test_yaffs_unlink_ENAMETOOLONG(void){
+ int output=0;
+ int error_code=0;
+ int x=0;
+ int file_name_length=1000000;
+ char file_name[file_name_length];
+
+ strcat(file_name,YAFFS_MOUNT_POINT);
+ for (x=strlen(YAFFS_MOUNT_POINT); x<file_name_length -1; x++){
+ file_name[x]='a';
+ }
+ file_name[file_name_length-2]='\0';
+
+ /*printf("path %s\n",path); */
+ output=yaffs_unlink(file_name);
+ if (output==-1){
+ error_code=yaffs_get_error();
+ //printf("EISDIR def %d, Error code %d\n", EISDIR,error_code);
+ if (abs(error_code)== EISDIR){
+ return 1;
+ }
+ else {
+ printf("different error than expected\n");
+ return -1;
+ }
+ }
+ else if (output >=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*/
+ }
+}
+
--- /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_unlink_ENAMETOOLONG_h__
+#define __test_yaffs_unlink_ENAMETOOLONG_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_unlink_ENAMETOOLONG(void);
+int test_yaffs_unlink_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_unlink_EISDIR.h"
+
+/*EISDIR is caused by trying to unlink a directory */
+
+static int handle=0;
+int test_yaffs_unlink_ENOENT(void){
+ int output=0;
+ int error_code=0;
+ /*printf("path %s\n",path); */
+ handle=yaffs_unlink("/yaffs2/non_existant_file");
+ if (handle==-1){
+ error_code=yaffs_get_error();
+ //printf("ENOENT def %d, Error code %d\n", EISDIR,error_code);
+ if (abs(error_code)== ENOENT){
+ return 1;
+ }
+ else {
+ printf("different error than expected\n");
+ return -1;
+ }
+ }
+ else if (output >=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_ENOENT_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*/
+ }
+}
+
--- /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_unlink_ENOENT_h__
+#define __test_yaffs_unlink_ENOENT_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_unlink_ENOENT(void);
+int test_yaffs_unlink_ENOENT_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_open_ENOTDIR.h"
+
+
+int test_yaffs_unlink_ENOTDIR(void){
+ int output=0;
+ int error_code=0;
+ /*printf("path %s\n",path); */
+ output=yaffs_unlink("/nonexisting_dir/foo");
+ 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 opened.(which is a bad thing)\n");
+ return -1;
+ }
+
+
+}
+int test_yaffs_unlink_ENOTDIR_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_unlink_ENOTDIR_h__
+#define __test_yaffs_unlink_ENOTDIR_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_unlink_ENOTDIR(void);
+int test_yaffs_unlink_ENOTDIR_clean(void);
+#endif