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.o test_yaffs_unmount_ENOENT.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_ftruncate.o test_yaffs_ftruncate_EBADF.o test_yaffs_ftruncate_EINVAL.o test_yaffs_ftruncate_EFBIG.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_write.o test_yaffs_write_EBADF.o test_yaffs_write_EFBIG.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_read_EBADF
test_yaffs_read_EINVAL
+
test_yaffs_stat
test_yaffs_truncate
test_yaffs_unmount
test_yaffs_unmount_ENOENT
test_yaffs_unmount_ENAMETOOLONG
+ test_yaffs_umount_EBUSY //cause by having a file handle open and then trying to unmount yaffs.
test_yaffs_write
+ test_yaffs_write_EBADF
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_stat_ENOTDIR
test_yaffs_read_EISDIR //Cannot be generated with yaffs.
+ test_yaffs_read_EFBIG
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?
Unmount2 forcing the unmount needs to break the handles so they return EBADF.
+ A read of -1 bytes tries to read 4 gig of data
Current WARNINGS
for (x=0;x<total_number_of_tests;x++){
//printf("x %d\n",x);
yaffs_set_error(0); /*reset the last error to 0 */
+ printf("\nrunning test: %s \n",test_list[x].name_of_test);
output=test_list[x].p_function(); /*run test*/
if (output>=0){
/*test has passed*/
printf("\n\n");
}
}
+ output=0;
output=test_list[x].p_function_clean(); /*clean the test*/
if (output <0){
/* if the test failed to clean it's self then */
quit_quick_tests(1);
}
+ } else {
+ printf("\ttest clean: %s passed\n",test_list[x].name_of_test);
}
-
}
/*this is where the loop should break to*/
quit_quick_tests(0);
#include "test_yaffs_unmount.h"
#include "test_yaffs_unmount_ENOENT.h"
#include "test_yaffs_unmount_ENAMETOOLONG.h"
+#include "test_yaffs_unmount_EBUSY.h"
#include "test_yaffs_open.h"
#include "test_yaffs_open_EISDIR.h"
#include "test_yaffs_truncate_EFBIG.h"
#include "test_yaffs_write.h"
+#include "test_yaffs_write_EBADF.h"
+#include "test_yaffs_write_EFBIG.h"
#include "test_yaffs_read.h"
#include "test_yaffs_read_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_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_unmount_EBUSY,test_yaffs_unmount_EBUSY_clean,"test_yaffs_unmount_EBUSY"},
+
{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_lseek_EFBIG,test_yaffs_lseek_EFBIG_clean,"test_yaffs_lseek_EFBIG"},
{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_read,test_yaffs_read_clean,"test_yaffs_read"},
{test_yaffs_read_EBADF,test_yaffs_read_EBADF_clean,"test_yaffs_read_EBADF"},
static int handle=0;
+static char *file_name = NULL;
int test_yaffs_read_EINVAL(void){
int error_code=0;
handle=test_yaffs_open();
- char text[20]="\0";
- int output=0;
+ char text[2000000]="\0";
+ int output=0;
+
+ if (handle<0){
+ printf("could not open file\n");
+ return -1;
+ }
+
+ /*there needs a large amout of test in the file in order to trigger EINVAL */
+ output=test_yaffs_read_EINVAL_init();
+ if (output<0){
+ printf("could not write text to the file\n");
+ return -1;
+ }
if (handle>=0){
output=yaffs_read(handle, text, -1);
}
}
else{
- printf("read a non-existing file (which is a bad thing)\n");
+ printf("read a negative number of bytes (which is a bad thing)\n");
return -1;
}
}
}
int test_yaffs_read_EINVAL_clean(void){
+ int output=0;
if (handle>=0){
- return yaffs_close(handle);
+ output=test_yaffs_read_EINVAL_init_clean();
+ if(output>=0){
+ output=yaffs_close(handle);
+ if (output>=0){
+ return 1;
+ } else {
+ printf("could not close the handle\n");
+ return -1;
+ }
+ } else {
+ printf("failed to fix the file\n");
+ return -1;
+ }
}
- else {
- return 1; /* no handle was opened so there is no need to close a handle */
- }
+
}
+
+int test_yaffs_read_EINVAL_init(void)
+{
+ int output=0;
+ int error_code=0;
+ int x=0;
+
+ int file_name_length=1000000;
+
+ file_name = malloc(file_name_length);
+ if(!file_name){
+ printf("unable to create file text\n");
+ return -1;
+ }
+
+ 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';
+
+
+
+ if (handle>=0){
+ output= yaffs_write(handle, file_name, file_name_length-1);
+ if (output<0){
+ printf("could not write text to file\n");
+ return -1;
+ } else {
+
+ return 1;
+ }
+
+ } else {
+ printf("error opening file\n");
+ return -1;
+ }
+
+}
+
+int test_yaffs_read_EINVAL_init_clean(void)
+{
+ int output=1;
+ if(file_name){
+ free(file_name);
+ file_name = NULL;
+ }
+
+
+ output= yaffs_truncate(FILE_PATH,FILE_SIZE );
+ if (output>=0){
+ output=test_yaffs_write();
+ if (output>=0){
+ return 1;
+ } else {
+ printf("failed to write to file\n");
+ return -1;
+ }
+ } else {
+ printf("failed to truncate file\n");
+ return -1;
+ }
+
+}
+
#include "lib.h"
#include "yaffsfs.h"
#include "test_yaffs_open.h"
+#include "test_yaffs_write.h"
+#include "test_yaffs_truncate.h"
int test_yaffs_read_EINVAL(void);
int test_yaffs_read_EINVAL_clean(void);
+int test_yaffs_read_EINVAL_init(void);
+int test_yaffs_read_EINVAL_init_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_EBUSY.h"
+
+static int handle=-1;
+int test_yaffs_unmount_EBUSY(void){
+ int output=0;
+ int error_code=0;
+ /*printf("path %s\n",path); */
+ handle=yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE);
+ if (handle<0){
+ printf("failed to open file\n");
+ return -1;
+ }
+
+
+ output=yaffs_unmount(YAFFS_MOUNT_POINT);
+ if (output==-1){
+ error_code=yaffs_get_error();
+ if (abs(error_code)==EBUSY){
+ 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_EBUSY_clean(void){
+ if (handle>=0){
+ return yaffs_close(handle);
+ }
+ else {
+ 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_EBUSY_h__
+#define __test_yaffs_unmount_EBUSY_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_unmount.h"
+#include "test_yaffs_mount.h"
+
+int test_yaffs_unmount_EBUSY(void);
+int test_yaffs_unmount_EBUSY_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_write_EBADF.h"
+
+static int handle=0;
+int test_yaffs_write_EBADF(void){
+ int output=0;
+ int error_code=0;
+ handle=test_yaffs_open();
+ if (handle>=0){
+ output= yaffs_write(-1, FILE_TEXT, FILE_TEXT_NBYTES);
+ if (output<0){
+ error_code=yaffs_get_error();
+ //printf("EISDIR def %d, Error code %d\n", ENOTDIR,error_code);
+ if (abs(error_code)==EBADF){
+ return 1;
+ }
+ else {
+ printf("different error than expected\n");
+ return -1;
+ }
+ }
+ else {
+ printf("wrote to a bad handle.(which is a bad thing)\n");
+ return -1;
+ }
+
+ }
+ else {
+ printf("error opening file\n");
+ return -1;
+ }
+
+}
+
+int test_yaffs_write_EBADF_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 */
+ }
+}
--- /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_write_EBADF_h__
+#define __test_yaffs_write_EBADF_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+int test_yaffs_write_EBADF(void);
+int test_yaffs_write_EBADF_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_write_EFBIG.h"
+
+static int handle=0;
+static char *file_name = NULL;
+int test_yaffs_write_EFBIG(void)
+{
+ int output=0;
+ int error_code=0;
+ handle=test_yaffs_open();
+ int x=0;
+
+ long int file_name_length=100000000000;
+
+ file_name = malloc(file_name_length);
+ if(!file_name){
+ printf("unable to create file text\n");
+ return -1;
+ }
+
+ 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';
+
+
+
+ if (handle>=0){
+ output= yaffs_write(handle, file_name, file_name_length-1);
+ if (output<0){
+ error_code=yaffs_get_error();
+ //printf("EISDIR def %d, Error code %d\n", ENOTDIR,error_code);
+ if (abs(error_code)==EINVAL){
+ return 1;
+ } else {
+ printf("different error than expected\n");
+ return -1;
+ }
+ } else {
+ printf("wrote a large amount of text to a file.(which is a bad thing)\n");
+ return -1;
+ }
+
+ } else {
+ printf("error opening file\n");
+ return -1;
+ }
+
+}
+
+int test_yaffs_write_EFBIG_clean(void)
+{
+ int output=1;
+ if(file_name){
+ free(file_name);
+ file_name = NULL;
+ }
+
+ if (handle>=0){
+ output=yaffs_close(handle);
+ }
+
+
+ output= test_yaffs_truncate_clean();
+ if (output>=0){
+ output=test_yaffs_write();
+ if (output>=0){
+ return 1;
+ } else {
+ printf("failed to write to file\n");
+ return -1;
+ }
+ } else {
+ printf("failed to truncate file\n");
+ 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_write_EFBIG_h__
+#define __test_yaffs_write_EFBIG_h__
+#include "lib.h"
+#include "yaffsfs.h"
+#include "test_yaffs_open.h"
+#include "test_yaffs_write.h"
+#include "test_yaffs_truncate.h"
+
+int test_yaffs_write_EFBIG(void);
+int test_yaffs_write_EFBIG_clean(void);
+#endif