# yaffs_checkptrwtest.o\
-YAFFSTESTOBJS = $(COMMONTESTOBJS) quick_tests.o lib.o test_mount_yaffs.o test_yaffs_unlinking.o test_yaffs_open_file.o test_yaffs_ftruncate.o test_yaffs_truncate.o \
- test_yaffs_write.o test_yaffs_read.o test_yaffs_lseek.o test_yaffs_access.o test_yaffs_stat.o test_yaffs_open_file_ENOENT.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_ftruncate.o test_yaffs_truncate.o \
+ test_yaffs_write.o \
+ test_yaffs_read.o \
+ test_yaffs_lseek.o \
+ test_yaffs_access.o \
+ test_yaffs_stat.o
+
+
+YAFFSTESTOBJS = $(COMMONTESTOBJS) $(TESTFILES)
PYTONOSYMLINKS = yaffs_error_converter.c yaffs_error_converter.h
PYTHONOBJS = yaffs_error_converter.o
//{dummy_test_pass,dummy_test_pass_clean,"dummy_test_pass"},
//{dummy_test_fail,dummy_test_fail_clean,"dummy_test_fail"},
{mount_yaffs_test,mount_yaffs_test_clean,"mount_yaffs_test"},
- {test_yaffs_open_file,test_yaffs_open_file_clean,"test_yaffs_open_file"},
- {test_yaffs_open_file_ENOENT,test_yaffs_open_file_ENOENT_clean,"test_yaffs_open_file_ENOENT"},
+ {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_access,test_yaffs_access_clean,"test_yaffs_access"},
{test_yaffs_unlinking, test_yaffs_unlinking_clean,"test_yaffs_unlinking"},
#include <stdio.h>
#include "test_mount_yaffs.h"
-#include "test_yaffs_open_file.h"
-#include "test_yaffs_open_file_ENOENT.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_unlinking.h"
#include "test_yaffs_ftruncate.h"
#include "test_yaffs_truncate.h"
#define __test_yaffs_access_h__
#include "lib.h"
#include "yaffsfs.h"
-#include "test_yaffs_open_file.h"
+#include "test_yaffs_open.h"
#include "test_yaffs_lseek.h"
int test_yaffs_access(void);
int test_yaffs_access_clean(void);
static int handle=0;
int test_yaffs_ftruncate(void){
- handle=test_yaffs_open_file();
+ handle=test_yaffs_open();
if (handle>0){
return yaffs_ftruncate(handle,FILE_SIZE_TRUNCATED );
}
#define __test_yaffs_ftruncate_h__
#include "lib.h"
#include "yaffsfs.h"
-#include "test_yaffs_open_file.h"
+#include "test_yaffs_open.h"
int test_yaffs_ftruncate(void);
int test_yaffs_ftruncate_clean(void);
#endif
static int handle=0;
int test_yaffs_lseek(void){
- handle=test_yaffs_open_file();
+ handle=test_yaffs_open();
char text[20]="\0";
int output=0;
if (handle>0){
#define __test_yaffs_lseek_h__
#include "lib.h"
#include "yaffsfs.h"
-#include "test_yaffs_open_file.h"
+#include "test_yaffs_open.h"
int test_yaffs_lseek(void);
int test_yaffs_lseek_clean(void);
--- /dev/null
+#include "test_yaffs_open.h"
+
+static int handle=0;
+
+int test_yaffs_open(void){
+
+ handle=yaffs_open(FILE_PATH,O_CREAT | O_TRUNC| O_RDWR, FILE_MODE);
+ return handle;
+}
+
+
+int test_yaffs_open_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
+#ifndef __test_yaffs_open_h__
+#define __test_yaffs_open_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_open(void);
+int test_yaffs_open_clean(void);
+#endif
--- /dev/null
+#include "test_yaffs_open_EEXIST.h"
+
+static int handle=0;
+int test_yaffs_open_EEXIST(void){
+ int output=0;
+ int error_code=0;
+ /*printf("path %s\n",path); */
+ handle=yaffs_open(FILE_PATH, O_CREAT | O_EXCL | O_TRUNC| O_RDWR ,FILE_MODE );
+ if (handle==-1){
+ error_code=yaffs_get_error();
+ printf("EEXIST def %d, Error code %d\n",(- EEXIST),error_code);
+ if (abs(error_code)== EEXIST){
+ 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_EEXIST_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
+#ifndef __test_yaffs_open_EEXIST_h__
+#define __test_yaffs_open_EEXIST_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_open_EEXIST(void);
+int test_yaffs_open_EEXIST_clean(void);
+#endif
--- /dev/null
+#include "test_yaffs_open_EISDIR.h"
+
+/*EISDIR is caused by trying to open a directory */
+
+static int handle=0;
+int test_yaffs_open_EISDIR(void){
+ int output=0;
+ int error_code=0;
+ /*printf("path %s\n",path); */
+ handle=yaffs_open(YAFFS_MOUNT_POINT, O_CREAT | O_TRUNC| O_RDWR ,FILE_MODE );
+ 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("non existant directory 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_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
+#ifndef __test_yaffs_open_EISDIR_h__
+#define __test_yaffs_open_EISDIR_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_open_EISDIR(void);
+int test_yaffs_open_EISDIR_clean(void);
+#endif
--- /dev/null
+#include "test_yaffs_open_ENOENT.h"
+
+static int handle=0;
+int test_yaffs_open_ENOENT(void){
+ int output=0;
+ int error_code=0;
+ /*printf("path %s\n",path); */
+ handle=yaffs_open("/yaffs2/non_existant_file", O_TRUNC| O_RDWR,FILE_MODE );
+ if (handle==-1){
+ error_code=yaffs_get_error();
+ if (abs(error_code)==ENOENT){
+ 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;
+ }
+
+}
+int test_yaffs_open_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
+#ifndef __test_yaffs_open_ENOENT_h__
+#define __test_yaffs_open_ENOENT_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_open_ENOENT(void);
+int test_yaffs_open_ENOENT_clean(void);
+#endif
--- /dev/null
+#include "test_yaffs_open_ENOTDIR.h"
+
+static int handle=0;
+int test_yaffs_open_ENOTDIR(void){
+ int output=0;
+ int error_code=0;
+ /*printf("path %s\n",path); */
+ handle=yaffs_open("/nonexisting_dir/foo", O_TRUNC| O_RDWR,FILE_MODE );
+ if (handle==-1){
+ error_code=yaffs_get_error();
+ if (abs(error_code)==ENOTDIR){
+ return 1;
+ }
+ else {
+ printf("different error than expected\n");
+ return -1;
+ }
+ }
+ else if (output >=0){
+ printf("non existant directory opened.(which is a bad thing)\n");
+ return -1;
+ }
+
+}
+int test_yaffs_open_ENOTDIR_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
+#ifndef __test_yaffs_open_ENOTDIR_h__
+#define __test_yaffs_open_ENOTDIR_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_open_ENOTDIR(void);
+int test_yaffs_open_ENOTDIR_clean(void);
+#endif
+++ /dev/null
-#include "test_yaffs_open_file.h"
-
-
-int test_yaffs_open_file(void){
-
- int output=0;
-
- /*printf("path %s\n",path); */
- output=yaffs_open(FILE_PATH,O_CREAT | O_TRUNC| O_RDWR, FILE_MODE);
-
- return output;
-}
-int test_yaffs_open_file_clean(void){
- return 1;
-}
-
+++ /dev/null
-#ifndef __test_yaffs_open_file_h__
-#define __test_yaffs_open_file_h__
-
-#include "lib.h"
-#include "yaffsfs.h"
-
-int test_yaffs_open_file(void);
-int test_yaffs_open_file_clean(void);
-#endif
+++ /dev/null
-#include "test_yaffs_open_file_ENOENT.h"
-
-static int handle=0;
-int test_yaffs_open_file_ENOENT(void){
- int output=0;
- int error_code=0;
- /*printf("path %s\n",path); */
- handle=yaffs_open("/yaffs2/non_existant_file", O_TRUNC| O_RDWR,FILE_MODE );
- if (handle==-1){
- error_code=yaffs_get_error();
- if (error_code==ENOENT){
- return 1;
- }
- }
- else if (output >=0){
- printf("non existant file opened.(which is a bad thing)\n");
- return -1;
- }
-
-}
-int test_yaffs_open_file_ENOENT_clean(void){
- return 1;
-}
-
+++ /dev/null
-#ifndef __test_yaffs_open_file_ENOENT_h__
-#define __test_yaffs_open_file_ENOENT_h__
-
-#include "lib.h"
-#include "yaffsfs.h"
-
-int test_yaffs_open_file_ENOENT(void);
-int test_yaffs_open_file_ENOENT_clean(void);
-#endif
static int handle=0;
int test_yaffs_read(void){
- handle=test_yaffs_open_file();
+ handle=test_yaffs_open();
char text[20]="\0";
int output=0;
printf("handle %d\n",handle);
#define __test_yaffs_read_h__
#include "lib.h"
#include "yaffsfs.h"
-#include "test_yaffs_open_file.h"
+#include "test_yaffs_open.h"
int test_yaffs_read(void);
#define __test_yaffs_stat_h__
#include "lib.h"
#include "yaffsfs.h"
-#include "test_yaffs_open_file.h"
+#include "test_yaffs_open.h"
#include "test_yaffs_lseek.h"
int test_yaffs_stat(void);
int test_yaffs_stat_clean(void);
static int handle=0;
int test_yaffs_truncate(void){
- handle=test_yaffs_open_file();
+ handle=test_yaffs_open();
if (handle>0){
return yaffs_truncate(FILE_PATH,FILE_SIZE_TRUNCATED );
}
int test_yaffs_truncate_clean(void){
/* change file size back to orignal size */
- int handle=test_yaffs_open_file();
+ int handle=test_yaffs_open();
int output=0;
if (handle>0){
output= yaffs_truncate(FILE_PATH,FILE_SIZE );
#define __test_yaffs_truncate_h__
#include "lib.h"
#include "yaffsfs.h"
-#include "test_yaffs_open_file.h"
+#include "test_yaffs_open.h"
int test_yaffs_truncate(void);
int test_yaffs_truncate_clean(void);
#endif
}
int test_yaffs_unlinking_clean(void){
- return test_yaffs_open_file();
+ return test_yaffs_open();
}
#include "lib.h"
#include "yaffsfs.h"
-#include "test_yaffs_open_file.h"
+#include "test_yaffs_open.h"
#include "test_yaffs_access.h"
int test_yaffs_unlinking(void);
static int handle=0;
int test_yaffs_write(void){
- handle=test_yaffs_open_file();
+ handle=test_yaffs_open();
if (handle>0){
return yaffs_write(handle, FILE_TEXT, FILE_TEXT_NBYTES);
}
#define __test_yaffs_write_h__
#include "lib.h"
#include "yaffsfs.h"
-#include "test_yaffs_open_file.h"
+#include "test_yaffs_open.h"
int test_yaffs_write(void);
int test_yaffs_write_clean(void);
#endif