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_stat_ENOENT.o test_yaffs_stat_ENOTDIR.o \
test_yaffs_fstat.o test_yaffs_fstat_EBADF.o \
- test_yaffs_close_EBADF.o
+ test_yaffs_close_EBADF.o\
+ test_yaffs_chmod.o test_yaffs_chmod_ENOENT.o test_yaffs_chmod_ENOTDIR.o test_yaffs_chmod_EINVAL.o \
+ test_yaffs_chmod_EINVAL2.o\
+ test_yaffs_fchmod.o test_yaffs_fchmod_EBADF.o
YAFFSTESTOBJS = $(COMMONTESTOBJS) $(TESTFILES)
Tests made
+ test_yaffs_chmod
+ test_yaffs_chmod_ENOENT
+ test_yaffs_chmod_ENOTDIR
+
+ test_yaffs_fchmod
+ test_yaffs_fchmod_EBADF
+
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_mount_EBUSY //caused by trying to mount a new mount point with a mount point already mounted.
test_yaffs_access
test_yaffs_access_ENIVAL
test_yaffs_open_ENOENT
test_yaffs_open_ENOTDIR
test_yaffs_open_EINVAL
- test_yaffs_open_EINVAL2 //the function open has two modes which can be set, so two tests modes are needed.
+ test_yaffs_open_EINVAL2 //the function open has two modes which can be set, so two tests are needed.
test_yaffs_read
test_yaffs_read_EBADF
test_yaffs_unlink_ENAMETOOLONG
test_yaffs_unlink_ENOENT
test_yaffs_unlink_ENOTDIR
- test_yaffs_unlink_ENOENT
test_yaffs_unmount
test_yaffs_unmount_ENOENT
Tests to add
+ test_yaffs_chmod_EACCES
+ test_yaffs_chmod_ELOOP
+ test_yaffs_chmod_ENAMETOOLONG
+
+
+ test_yaffs_fchmod_EACCES
+ test_yaffs_fchmod_ELOOP
+
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.
test_yaffs_open_EACCES
test_yaffs_open_ENOSPC
- test_yaffs_open_ELOOP //Too many symbolic links were encountered in resolving pathname
+ test_yaffs_open_ELOOP
test yaffs_open_running_out_of_handles error
test_yaffs_close //This function has already been called by the time this test is reached.
What happens when open a handle, unmount yaffs and then try to use the handle?
+ What happens when a mount point is mounted using mount2 with read only mode set and then a file is chmoded?
+
How to add a test
First create the test .c and .h file.
The file name and test function name should be the same.
Bug when trying to stat a file in a non-existing directory. The error
returned is ENOENT, it should be ENOTDIR
+ Bug when trying to chmod a file in a non-existing directory. The error
+ returned is ENOENT, it should be ENOTDIR
+
+
+
+ There may be a bug with trying to chmoding a file with the mode set to 0.
+ The chmod function does not return an error which means that it is unknown what modes the file is chmoded to.
+ When yaffs_open is used on the file the error EACCES is returned. It is possible that yaffs has changed the mode
+ to read only.
+
Bug with truncating to a very large size. The yaffs_truncate function truncates the file to a massive size without any errors.
The function should return the error EINVAL.
It should return EINVAL. This is because it was reading an empty file.
When text is added to the file a read of -1 bytes tries to read 4 gig of data
- Bug when writing a file. the writhing to the file causes the file size to exceed the size of yaffs file system memory.
+ Bug when writing a file. The writing to the file causes the file size to exceed the size of yaffs file system memory.
Output of test:
test_yaffs_write_EFBIG
AddrToChunk of offset -2147483648 gives chunk -1048576 start 0
#include "lib.h"
-void join_paths(char *path1,char *path2,char *new_path ){
+void join_paths(char *path1,char *path2,char *new_path )
+{
//strcat(new_path,path1); /*since all functions have this then pull it out*/
if ( (path1[(sizeof(path1)/sizeof(char))-2]=='/') && path2[0]!='/') {
//char new_path[(sizeof(path1)/sizeof(char))+(sizeof(path2)/sizeof(char))];
//strcpy(new_path,strcat(path1,path2));
//return new_path;
- }
- else if ((path1[(sizeof(path1)/sizeof(char))-2]!='/') && path2[0]=='/') {
+ } else if ((path1[(sizeof(path1)/sizeof(char))-2]!='/') && path2[0]=='/') {
/*paths are compatiable. concatanate them*/
strcat(new_path,path1);
strcat(new_path,path2);
- }
- else if ((path1[(sizeof(path1)/sizeof(char))-2]!='/') && path2[0]!='/') {
+ } else if ((path1[(sizeof(path1)/sizeof(char))-2]!='/') && path2[0]!='/') {
/*need to add a "/". */
strcat(new_path,path1);
strcat(new_path,"/");
strcat(new_path,path2);
-
- }
- else if ((path1[(sizeof(path1)/sizeof(char))-2]=='/') && path2[0]=='/') {
+ } else if ((path1[(sizeof(path1)/sizeof(char))-2]=='/') && path2[0]=='/') {
/*need to remove a "/". */
/*yaffs does not mind the extra slash. */
strcat(new_path,path1);
strcat(new_path,path2);
- }
- else{
+ } else {
//error
//return -1;
}
}
+void print_message(char *message,char print_level)
+{
+ if (print_level <= PRINT_LEVEL){
+ printf(message);
+ }
+}
+
+
+
#ifndef _lib_h__
#define _lib_h__
-
+#include <stdio.h>
#include <string.h>
+
+#define EXIT_ON_ERROR 0
+#define PRINT_LEVEL 2 //This sets the level of detail which is printed. There are 3 levels 0,1,2 and 3
+ //0 just prints the number of tests passed and failed.
+ //1 is the basic print level. it will print the details of a failed test.
+ //2 will print if a test passes and cleans.
+
#define YAFFS_MOUNT_POINT "/yaffs2/"
#define FILE_NAME "foo"
#define FILE_SIZE 10
#define FILE_PATH "/yaffs2/foo"
void join_paths(char *path1,char *path2,char *new_path );
+void print_message(char *message,char print_level);
#endif
int main(){
int output=0;
-
+ char message[30];
+ message[0]='\0';
unsigned int x=0;
init_quick_tests();
- printf("\n\nrunning quick tests for yaffs\n\n");
+ print_message("\n\nrunning quick tests for yaffs\n\n", 0);
//printf("testing yaffs\n");
//printf("len function %d",(sizeof(test_list)/sizeof(test_template)));
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);
+ sprintf(message,"\nrunning test: %s \n",test_list[x].name_of_test);
+ print_message(message,2);
output=test_list[x].p_function(); /*run test*/
if (output>=0){
/*test has passed*/
- printf("\ttest %s passed\n",test_list[x].name_of_test);
+ sprintf(message,"\ttest %s passed\n",test_list[x].name_of_test);
+ print_message(message,2);
num_of_tests_pass++;
- }
- else {
+ } else {
/*test is assumed to have failed*/
//printf("test failed\n");
- printf("test: %s failed\n",test_list[x].name_of_test);
+ sprintf(message,"test: %s failed\n",test_list[x].name_of_test);
+ print_message(message,1);
num_of_tests_failed ++;
-
- if (EXIT_ON_ERROR){
- get_error();
- printf("\n\n");
+
+ get_error();
+ print_message("\n\n",1);
+ if (EXIT_ON_ERROR){
quit_quick_tests(1);
}
- else {
- get_error();
- 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 */
- printf("test: %s failed to clean\n",test_list[x].name_of_test);
+ sprintf(message,"test: %s failed to clean\n",test_list[x].name_of_test);
+ print_message(message,1);
num_of_tests_failed ++;
num_of_tests_pass--;
get_error();
}
} else {
- printf("\ttest clean: %s passed\n",test_list[x].name_of_test);
+ sprintf(message,"\ttest clean: %s passed\n",test_list[x].name_of_test);
+ print_message(message,2);
}
}
/*this is where the loop should break to*/
quit_quick_tests(0);
- /* the progame should never get here*/
- return 0;
}
-void quit_quick_tests(int exit_code){
-
+void quit_quick_tests(int exit_code)
+{
+ char message[30];
+ message[0]='\0';
if (num_of_tests_pass==total_number_of_tests && num_of_tests_failed==0){
printf("\t OK \n");
}
- printf("tests: %d passed %d failed\n\n\n",num_of_tests_pass,num_of_tests_failed);
+ printf("tests: %d passed %d failed out of %d tests\n\n\n",num_of_tests_pass,num_of_tests_failed,total_number_of_tests);
yaffs_unmount(YAFFS_MOUNT_POINT);
exit(exit_code);
}
-void get_error(void){
+void get_error(void)
+{
int error_code=0;
+ char message[30];
+ message[0]='\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));
+ sprintf(message,"yaffs_error code %d\n",error_code);
+ print_message(message,1);
+ sprintf(message,"error is : %s\n",yaffs_error_to_str(error_code));
+ print_message(message,1);
}
-void init_quick_tests(void){
- yaffs_start_up();;
+void init_quick_tests(void)
+{
+ yaffs_start_up();
yaffs_set_trace(0);
}
#include "test_yaffs_fstat.h"
#include "test_yaffs_fstat_EBADF.h"
+#include "test_yaffs_chmod.h"
+#include "test_yaffs_chmod_ENOENT.h"
+#include "test_yaffs_chmod_ENOTDIR.h"
+#include "test_yaffs_chmod_EINVAL.h"
+#include "test_yaffs_chmod_EINVAL2.h"
+
+#include "test_yaffs_fchmod.h"
+#include "test_yaffs_fchmod_EBADF.h"
+
#include "yaffsfs.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*/
{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"},
- {test_yaffs_truncate_EFBIG,test_yaffs_truncate_EFBIG_clean,"test_yaffs_truncate_EFBIG"}
+ {test_yaffs_truncate_EFBIG,test_yaffs_truncate_EFBIG_clean,"test_yaffs_truncate_EFBIG"},
+
+ {test_yaffs_chmod,test_yaffs_chmod_clean,"test_yaffs_chmod"},
+ {test_yaffs_chmod_ENOENT,test_yaffs_chmod_ENOENT_clean,"test_yaffs_chmod_ENOENT"},
+ {test_yaffs_chmod_ENOTDIR,test_yaffs_chmod_ENOTDIR_clean,"test_yaffs_chmod_ENOTDIR"},
+ {test_yaffs_chmod_EINVAL,test_yaffs_chmod_EINVAL_clean,"test_yaffs_chmod_EINVAL"},
+ {test_yaffs_chmod_EINVAL2,test_yaffs_chmod_EINVAL2_clean,"test_yaffs_chmod_EINVAL2"},
+
+ {test_yaffs_fchmod,test_yaffs_fchmod_clean,"test_yaffs_fchmod"},
+ {test_yaffs_fchmod_EBADF,test_yaffs_fchmod_EBADF_clean,"test_yaffs_fchmod_EBADF"}
};
void init_quick_tests(void);
#include "test_yaffs_access.h"
-int test_yaffs_access(void){
+int test_yaffs_access(void)
+{
return yaffs_access(FILE_PATH,0);
}
-int test_yaffs_access_clean(void){
+int test_yaffs_access_clean(void)
+{
return 1;
}
#define __test_yaffs_access_h__
#include "lib.h"
#include "yaffsfs.h"
-#include "test_yaffs_open.h"
-#include "test_yaffs_lseek.h"
int test_yaffs_access(void);
int test_yaffs_access_clean(void);
#endif
#include "test_yaffs_access_EINVAL.h"
-int test_yaffs_access_EINVAL(void){
+int test_yaffs_access_EINVAL(void)
+{
int output=0;
int error=0;
+
output= yaffs_access(FILE_PATH,255);
if (output<0){
error=yaffs_get_error();
if ( abs(error)== EINVAL){
return 1;
- }
- else {
- printf("error does not match expected error\n");
+ } else {
+ print_message("error does not match expected error\n",2);
return -1;
}
- }
- else{
- printf("accessed an existing file with bad mode (which is a bad thing\n");
+ } else{
+ print_message("accessed an existing file with bad mode (which is a bad thing\n",2);
+
return -1;
}
}
-int test_yaffs_access_EINVAL_clean(void){
+int test_yaffs_access_EINVAL_clean(void)
+{
return 1;
}
#define __test_yaffs_access_EINVAL_h__
#include "lib.h"
#include "yaffsfs.h"
-#include "test_yaffs_open.h"
-#include "test_yaffs_lseek.h"
int test_yaffs_access_EINVAL(void);
int test_yaffs_access_EINVAL_clean(void);
#endif
#include "test_yaffs_access_ENOENT.h"
-int test_yaffs_access_ENOENT(void){
+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");
+ } else {
+ print_message("different error than expected\n",2);
return -1;
}
- }
- else {
- printf("non existant file accessed.(which is a bad thing)\n");
+ } else {
+ print_message("non existant file accessed.(which is a bad thing)\n",2);
return -1;
}
}
-int test_yaffs_access_ENOENT_clean(void){
+int test_yaffs_access_ENOENT_clean(void)
+{
return 1;
}
#include "test_yaffs_access_ENOTDIR.h"
static int handle=0;
-int test_yaffs_access_ENOTDIR(void){
+
+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");
+ } else {
+ print_message("different error than expected\n",2);
return -1;
}
- }
- else {
- printf("non existant directory accessed.(which is a bad thing)\n");
+ } else {
+ print_message("non existant directory accessed.(which is a bad thing)\n",2);
return -1;
}
}
-int test_yaffs_access_ENOTDIR_clean(void){
+int test_yaffs_access_ENOTDIR_clean(void)
+{
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_chmod.h"
+
+int test_yaffs_chmod(void)
+{
+ int output=yaffs_chmod(FILE_PATH,S_IREAD|S_IWRITE);
+
+ if (output>=0){
+ /* there were no errors */
+ return 1;
+ } else {
+ print_message("failed to chmod the file\n",2);
+ return -1;
+ }
+
+}
+
+int test_yaffs_chmod_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_chmod_h__
+#define __test_yaffs_chmod_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_chmod(void);
+int test_yaffs_chmod_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_chmod_EINVAL.h"
+
+int test_yaffs_chmod_EINVAL(void)
+{
+ int error=0;
+ int output=yaffs_chmod("/non_existing_directory/foo",0);
+
+ if (output<0){
+ error=yaffs_get_error();
+ if (abs(error)==EINVAL){
+ return 1;
+ } else {
+ print_message("different error than expected\n",2);
+ return -1;
+ }
+ } else {
+ print_message("chmoded the file (which is a bad thing)\n",2);
+ return -1;
+ }
+
+}
+
+int test_yaffs_chmod_EINVAL_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_chmod_EINVAL_h__
+#define __test_yaffs_chmod_EINVAL_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_chmod_EINVAL(void);
+int test_yaffs_chmod_EINVAL_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_chmod_EINVAL2.h"
+
+int test_yaffs_chmod_EINVAL2(void)
+{
+ int error=0;
+ int output=yaffs_chmod("/non_existing_directory/foo",255);
+
+ if (output<0){
+ error=yaffs_get_error();
+ if (abs(error)==EINVAL){
+ return 1;
+ } else {
+ print_message("different error than expected\n",2);
+ return -1;
+ }
+ } else {
+ print_message("chmoded the file (which is a bad thing)\n",2);
+ return -1;
+ }
+
+}
+
+int test_yaffs_chmod_EINVAL2_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_chmod_EINVAL2_h__
+#define __test_yaffs_chmod_EINVAL2_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_chmod_EINVAL2(void);
+int test_yaffs_chmod_EINVAL2_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_chmod_ENOENT.h"
+
+int test_yaffs_chmod_ENOENT(void)
+{
+ int error=0;
+ int output=yaffs_chmod("/yaffs2/non_existing_file",S_IREAD|S_IWRITE);
+
+ if (output<0){
+ error=yaffs_get_error();
+ if (abs(error)==ENOENT){
+ return 1;
+ } else {
+ print_message("different error than expected\n",2);
+ return -1;
+ }
+ } else {
+ print_message("chmoded the file (which is a bad thing)\n",2);
+ return -1;
+ }
+
+}
+
+int test_yaffs_chmod_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_chmod_ENOENT_h__
+#define __test_yaffs_chmod_ENOENT_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_chmod_ENOENT(void);
+int test_yaffs_chmod_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_chmod_ENOTDIR.h"
+
+int test_yaffs_chmod_ENOTDIR(void)
+{
+ int error=0;
+ int output=yaffs_chmod("/non_existing_directory/foo",S_IREAD|S_IWRITE);
+
+ if (output<0){
+ error=yaffs_get_error();
+ if (abs(error)==ENOTDIR){
+ return 1;
+ } else {
+ print_message("different error than expected\n",2);
+ return -1;
+ }
+ } else {
+ print_message("chmoded the file (which is a bad thing)\n",2);
+ return -1;
+ }
+
+}
+
+int test_yaffs_chmod_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_chmod_ENOTDIR_h__
+#define __test_yaffs_chmod_ENOTDIR_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_chmod_ENOTDIR(void);
+int test_yaffs_chmod_ENOTDIR_clean(void);
+
+#endif
#include "test_yaffs_open.h"
-static int handle=0;
-
-int test_yaffs_close_EBADF(void){
- int output=0;
- int error_code=0;
- handle=test_yaffs_open();
- if (handle>=0){
- output=yaffs_close(handle);
- if (output>=0){
- output=yaffs_close(handle);
- if (output<0){
- /*error has happened */
- error_code=yaffs_get_error();
- //printf("EBADF def %d, Error code %d\n",(- EBADF),error_code);
- if (abs(error_code)== EBADF){
+static int handle = 0;
+
+int test_yaffs_close_EBADF(void)
+{
+ int output = 0;
+ int error_code = 0;
+
+ handle = test_yaffs_open();
+ if (handle >= 0){
+ output = yaffs_close(handle);
+ if (output >= 0){
+ output = yaffs_close(handle);
+ if (output < 0){
+ error_code = yaffs_get_error();
+ if (abs(error_code) == EBADF){
return 1;
- }
- else {
- printf("different error than expected\n");
+ } else {
+ print_message("different error than expected\n",2);
return -1;
}
- }
- else {
- printf("closed the same handle twice. (which is a bad thing)\n");
+ } else {
+ print_message("closed the same handle twice. (which is a bad thing)\n", 2);
return -1;
}
- }
- else {
- printf("failed to close the handle the firs time\n");
+ } else {
+ print_message("failed to close the handle the firs time\n", 2);
return -1;
}
- }
- else {
- printf("failed to open file\n");
+ } else {
+ print_message("failed to open file\n", 2);
return -1;
}
}
-int test_yaffs_close_EBADF_clean(void){
- /* there is nothing that needs to be recreated */
- return 1;
+int test_yaffs_close_EBADF_clean(void)
+{
+ if (handle <= 0){
+ return yaffs_close(handle);
+ } else {
+ 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_fchmod.h"
+
+static int handle = -1;
+
+int test_yaffs_fchmod(void)
+{
+ int output = 0;
+
+ handle = test_yaffs_open();
+
+ if (handle < 0){
+ print_message("failed to open file\n",2);
+ return -1;
+ }
+
+ output = yaffs_fchmod(handle,S_IREAD||S_IWRITE);
+
+ if (output>=0){
+ /* there were no errors */
+ return 1;
+ } else {
+ print_message("failed to chmod the file\n",2);
+ return -1;
+ }
+
+}
+
+int test_yaffs_fchmod_clean(void)
+{
+ if (handle >= 0) {
+ printf("handle %d\n",handle);
+ return yaffs_close(handle);
+ }
+ 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_fchmod_h__
+#define __test_yaffs_fchmod_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_fchmod(void);
+int test_yaffs_fchmod_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_fchmod_EBADF.h"
+
+static int handle = -1;
+
+int test_yaffs_fchmod_EBADF(void)
+{
+ int error = 0;
+ int output = 0;
+
+ handle = test_yaffs_open();
+
+ if (handle < 0){
+ print_message("failed to open file\n",2);
+ return -1;
+ }
+
+ output = yaffs_fchmod(-1,S_IREAD||S_IWRITE);
+
+ if (output<0){
+ error=yaffs_get_error();
+ if (abs(error)==EBADF){
+ return 1;
+ } else {
+ print_message("different error than expected\n",2);
+ return -1;
+ }
+ } else {
+ print_message("chmoded an non-existing file (which is a bad thing)\n",2);
+ return -1;
+ }
+
+
+}
+
+int test_yaffs_fchmod_EBADF_clean(void)
+{
+ if (handle >= 0) {
+ printf("handle %d\n",handle);
+ return yaffs_close(handle);
+ }
+ 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_fchmod_EBADF_h__
+#define __test_yaffs_fchmod_EBADF_h__
+
+#include "lib.h"
+#include "yaffsfs.h"
+
+int test_yaffs_fchmod_EBADF(void);
+int test_yaffs_fchmod_EBADF_clean(void);
+
+#endif
#include "test_yaffs_fstat.h"
-static int handle=0;
-int test_yaffs_fstat(void){
+static int handle = -1;
+int test_yaffs_fstat(void)
+{
struct yaffs_stat stat;
- handle=test_yaffs_open();
- if (handle>=0){
- return yaffs_fstat(handle , &stat);;
- }
- else {
- printf("error opening file\n");
+ handle = test_yaffs_open();
+
+ if (handle >= 0){
+ return yaffs_fstat(handle , &stat);
+ } else {
+ print_message( "error opening file\n", 2 );
return -1;
}
}
-int test_yaffs_fstat_clean(void){
- if (handle<0){
+int test_yaffs_fstat_clean(void)
+{
+ if (handle <= 0){
return yaffs_close(handle);
}
return 1;
#ifndef __test_yaffs_fstat_h__
#define __test_yaffs_fstat_h__
+
#include "lib.h"
#include "yaffsfs.h"
#include "test_yaffs_open.h"
+
int test_yaffs_fstat(void);
int test_yaffs_fstat_clean(void);
#endif
#include "test_yaffs_fstat_EBADF.h"
-int test_yaffs_fstat_EBADF(void){
- int output=0;
+int test_yaffs_fstat_EBADF(void)
+{
+ int output = 0;
struct yaffs_stat stat;
- int error_code=0;
- output=yaffs_fstat(-1 , &stat);
- if (output<0){
- error_code=yaffs_get_error();
- //printf("EISDIR def %d, Error code %d\n", EISDIR,error_code);
- if (abs(error_code)== EBADF){
+ int error_code = 0;
+
+ output = yaffs_fstat(-1 , &stat);
+ if (output < 0){
+ error_code = yaffs_get_error();
+ if (abs(error_code) == EBADF){
return 1;
- }
- else {
- printf("different error than expected\n");
+ } else {
+ print_message("different error than expected\n", 2);
return -1;
}
- }
- else {
- printf("non existant file truncated.(which is a bad thing)\n");
+ } else {
+ print_message("non existant file truncated.(which is a bad thing)\n", 2 );
return -1;
}
}
-int test_yaffs_fstat_EBADF_clean(void){
- return 1;
-
+int test_yaffs_fstat_EBADF_clean(void)
+{
+ return 1;
}
#ifndef __test_yaffs_fstat_EBADF_h__
#define __test_yaffs_fstat_EBADF_h__
+
#include "lib.h"
#include "yaffsfs.h"
#include "test_yaffs_open.h"
+
int test_yaffs_fstat_EBADF(void);
int test_yaffs_fstat_EBADF_clean(void);
+
#endif
#include "test_yaffs_ftruncate.h"
-static int handle=0;
-int test_yaffs_ftruncate(void){
- handle=test_yaffs_open();
- if (handle>=0){
+static int handle = -1;
+
+int test_yaffs_ftruncate(void)
+{
+ handle = test_yaffs_open();
+ if (handle >= 0){
return yaffs_ftruncate(handle,FILE_SIZE_TRUNCATED );
- }
- else {
- printf("error opening file\n");
+ } else {
+ print_message("error opening file\n", 2);
return -1;
}
}
-int test_yaffs_ftruncate_clean(void){
+int test_yaffs_ftruncate_clean(void)
+{
/* change file size back to orignal size */
- int output=0;
- if (handle>=0){
- output=yaffs_ftruncate(handle,FILE_SIZE );
- if (output>=0){
+ int output = 0;
+ if (handle >= 0){
+ output = yaffs_ftruncate(handle,FILE_SIZE );
+ if (output >= 0){
return yaffs_close(handle);
- }
- else {
- printf("failed to truncate file\n");
+ } else {
+ print_message("failed to truncate file\n", 2);
return -1;
}
+ } else {
+ /* the file was not opened so the file could not be truncated */
+ return 1;
}
- else {
- printf("error opening file in clean function\n");
- return -1;
- }
-
}
#ifndef __test_yaffs_ftruncate_h__
#define __test_yaffs_ftruncate_h__
+
#include "lib.h"
#include "yaffsfs.h"
#include "test_yaffs_open.h"
+
int test_yaffs_ftruncate(void);
-int test_yaffs_ftruncate_clean(void);
+int test_yaffs_ftruncate_clean(void);
+
#endif
#include "test_yaffs_ftruncate_EBADF.h"
-static int handle=0;
-int test_yaffs_ftruncate_EBADF(void){
- int output=0;
- int error_code=0;
- output= yaffs_ftruncate(-1,FILE_SIZE_TRUNCATED );
- if (output<0){
+static int handle = 0;
+
+int test_yaffs_ftruncate_EBADF(void)
+{
+ int output = 0;
+ int error_code = 0;
+ output = yaffs_ftruncate(-1,FILE_SIZE_TRUNCATED );
+ if (output < 0){
error_code=yaffs_get_error();
//printf("EISDIR def %d, Error code %d\n", EISDIR,error_code);
- if (abs(error_code)== EBADF){
+ if (abs(error_code) == EBADF){
return 1;
- }
- else {
- printf("different error than expected\n");
+ } else {
+ print_message("different error than expected\n", 2);
return -1;
}
- }
- else {
- printf("non existant file truncated.(which is a bad thing)\n");
+ } else {
+ print_message("non existant file truncated.(which is a bad thing)\n", 2);
return -1;
}
}
-int test_yaffs_ftruncate_EBADF_clean(void){
+int test_yaffs_ftruncate_EBADF_clean(void)
+{
return 1;
-
}
#ifndef __test_yaffs_ftruncate_EBADF_h__
#define __test_yaffs_ftruncate_EBADF_h__
+
#include "lib.h"
#include "yaffsfs.h"
#include "test_yaffs_open.h"
+
int test_yaffs_ftruncate_EBADF(void);
int test_yaffs_ftruncate_EBADF_clean(void);
+
#endif
#include "test_yaffs_ftruncate_EFBIG.h"
-static int handle=0;
-int test_yaffs_ftruncate_EFBIG(void){
- int output=0;
- int error_code=0;
- handle=test_yaffs_open();
- if (handle>=0){
- output=yaffs_ftruncate(handle,10000000000000000000000000000000);
- if (output<0){
- error_code=yaffs_get_error();
- //printf("EISDIR def %d, Error code %d\n", EISDIR,error_code);
- if (abs(error_code)== EINVAL){ /* yaffs uses the error EINVAL instead of EFBIG */
+static int handle = -1;
+
+int test_yaffs_ftruncate_EFBIG(void)
+{
+ int output = 0;
+ int error_code = 0;
+ handle = test_yaffs_open();
+
+ if (handle >= 0){
+ output = yaffs_ftruncate(handle,10000000000000000000000000000000);
+ if (output < 0){
+ error_code = yaffs_get_error();
+ if (abs(error_code) == EINVAL){ /* yaffs uses the error EINVAL instead of EFBIG */
return 1;
- }
- else {
- printf("different error than expected\n");
+ } else {
+ print_message("different error than expected\n", 2);
return -1;
}
- }
- else {
- printf("file truncated to a very large size.(which is a bad thing)\n");
+ } else {
+ print_message("file truncated to a very large size.(which is a bad thing)\n", 2);
return -1;
}
- }
- else {
- printf("error opening file\n");
+ } else {
+ print_message("error opening file\n", 2);
return -1;
}
-
-
-
}
int test_yaffs_ftruncate_EFBIG_clean(void){
- return 1;
-
+ /* change file size back to orignal size */
+ int output = 0;
+ if (handle >= 0){
+ output = yaffs_ftruncate(handle,FILE_SIZE );
+ if (output >= 0){
+ return yaffs_close(handle);
+ } else {
+ print_message("failed to truncate file\n", 2);
+ return -1;
+ }
+ } else {
+ /* the file was not opened so the file could not be truncated */
+ return 1;
+ }
}
#ifndef __test_yaffs_ftruncate_EFBIG_h__
#define __test_yaffs_ftruncate_EFBIG_h__
+
#include "lib.h"
#include "yaffsfs.h"
#include "test_yaffs_open.h"
+
int test_yaffs_ftruncate_EFBIG(void);
int test_yaffs_ftruncate_EFBIG_clean(void);
+
#endif
#include "test_yaffs_ftruncate_EINVAL.h"
-static int handle=0;
-int test_yaffs_ftruncate_EINVAL(void){
+static int handle = -1;
+
+int test_yaffs_ftruncate_EINVAL(void)
+{
int output=0;
int error_code=0;
handle=test_yaffs_open();
- if (handle>=0){
- output=yaffs_ftruncate(handle,-1 );
+
+ if (handle >= 0){
+ output = yaffs_ftruncate(handle,-1 );
if (output<0){
- error_code=yaffs_get_error();
- //printf("EISDIR def %d, Error code %d\n", EISDIR,error_code);
- if (abs(error_code)== EINVAL){
+ error_code = yaffs_get_error();
+ if (abs(error_code) == EINVAL){
return 1;
- }
- else {
- printf("different error than expected\n");
+ } else {
+ print_message("different error than expected\n", 2);
return -1;
}
- }
- else {
- printf("file truncated to a negative size.(which is a bad thing)\n");
+ } else {
+ print_message("file truncated to a negative size.(which is a bad thing)\n", 2);
return -1;
}
- }
- else {
- printf("error opening file\n");
+ } else {
+ print_message("error opening file\n", 2);
return -1;
- }
-
-
-
+ }
}
-int test_yaffs_ftruncate_EINVAL_clean(void){
- if (handle<0){
- return yaffs_close(handle);
+int test_yaffs_ftruncate_EINVAL_clean(void)
+{
+ /* change file size back to orignal size */
+ int output = 0;
+ if (handle >= 0){
+ output = yaffs_ftruncate(handle,FILE_SIZE );
+ if (output >= 0){
+ return yaffs_close(handle);
+ } else {
+ print_message("failed to truncate file\n", 2);
+ return -1;
+ }
+ } else {
+ /* the file was not opened so the file could not be truncated */
+ return 1;
}
- return 1;
-
}
#ifndef __test_yaffs_ftruncate_EINVAL_h__
#define __test_yaffs_ftruncate_EINVAL_h__
+
#include "lib.h"
#include "yaffsfs.h"
#include "test_yaffs_open.h"
+
int test_yaffs_ftruncate_EINVAL(void);
int test_yaffs_ftruncate_EINVAL_clean(void);
+
#endif
#include "test_yaffs_lseek.h"
-static int handle=0;
-int test_yaffs_lseek(void){
- handle=test_yaffs_open();
+static int handle = -1;
+
+int test_yaffs_lseek(void)
+{
int output=0;
- if (handle>=0){
- output=yaffs_lseek(handle, 0, SEEK_SET);
- if (output==0){
+ handle = test_yaffs_open();
+
+
+ if (handle >= 0){
+ output = yaffs_lseek(handle, 0, SEEK_SET);
+ if (output == 0){
return 1;
- }
- else {
+ } else {
if (output<0){
- printf("lseek failed to seek\n");
- }
- else {
- printf("lseek returned a different position to the expeced position\n");
+ print_message("lseek failed to seek\n",2);
+ } else {
+ print_message("lseek returned a different position to the expeced position\n", 2);
return -1;
}
}
- }
- else {
- printf("error opening file\n");
+ } else {
+ print_message("error opening file\n", 2);
return -1;
}
}
-int test_yaffs_lseek_clean(void){
+int test_yaffs_lseek_clean(void)
+{
if (handle>=0){
return yaffs_close(handle);
- }
- else {
+ } else {
return 1; /* no handle was opened so there is no need to close a handle */
}
#ifndef __test_yaffs_lseek_h__
#define __test_yaffs_lseek_h__
+
#include "lib.h"
#include "yaffsfs.h"
#include "test_yaffs_open.h"
int test_yaffs_lseek(void);
int test_yaffs_lseek_clean(void);
int test_yaffs_lseek_to_beginning(void);
+
#endif
#include "test_yaffs_lseek_EBADF.h"
-int test_yaffs_lseek_EBADF(void){
+int test_yaffs_lseek_EBADF(void)
+{
int error_code=0;
int output=yaffs_lseek(-1, 0, SEEK_SET);
+
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");
+ } else {
+ print_message("different error than expected\n", 2);
return -1;
}
- }
- else {
- printf("lseeked to a negative position\n");
+ } else {
+ print_message("lseeked to a negative position\n", 2);
+ return -1;
}
}
-int test_yaffs_lseek_EBADF_clean(void){
+int test_yaffs_lseek_EBADF_clean(void)
+{
return 1;
}
#ifndef __test_yaffs_lseek_EBADF_h__
#define __test_yaffs_lseek_EBADF_h__
+
#include "lib.h"
#include "yaffsfs.h"
-#include "test_yaffs_open.h"
int test_yaffs_lseek_EBADF(void);
int test_yaffs_lseek_EBADF_clean(void);
#include "test_yaffs_lseek_EFBIG.h"
-static int handle=-1;
+static int handle = -1;
-int test_yaffs_lseek_EFBIG(void){
- handle=test_yaffs_open();
- int error_code=0;
- int output=0;
+int test_yaffs_lseek_EFBIG(void)
+{
+ handle = test_yaffs_open();
+ int error_code = 0;
+ int output = 0;
- if (handle<0){
- printf("failed to open file\n");
+ if (handle < 0){
+ print_message("failed to open file\n",2);
return -1;
}
- yaffs_lseek(handle, 100000000000000000000000000000000000000, SEEK_SET);
+ output = yaffs_lseek(handle, 100000000000000000000000000000000000000, SEEK_SET);
- if (output<0){
- error_code=yaffs_get_error();
- //printf("EISDIR def %d, Error code %d\n", ENOTDIR,error_code);
- if (abs(error_code)==EINVAL){
+ if (output < 0){
+ error_code = yaffs_get_error();
+ if (abs(error_code) == EINVAL){
return 1;
- }
- else {
- printf("different error than expected\n");
+ } else {
+ print_message("different error than expected\n", 2);
return -1;
}
- }
- else {
- printf("lseeked to a very large size (which is a bad thing)\n");
+ } else {
+ print_message("lseeked to a very large size (which is a bad thing)\n", 2);
return -1;
}
}
-int test_yaffs_lseek_EFBIG_clean(void){
- if (handle>=0){
+int test_yaffs_lseek_EFBIG_clean(void)
+{
+ if (handle >= 0){
return yaffs_close(handle);
- }
- else {
+ } else {
return -1; /* no handle was opened so there is no need to close a handle */
}
}
#ifndef __test_yaffs_lseek_EFBIG_h__
#define __test_yaffs_lseek_EFBIG_h__
+
#include "lib.h"
#include "yaffsfs.h"
#include "test_yaffs_open.h"
int handle=-1;
-int test_yaffs_lseek_EINVAL(void){
- handle=test_yaffs_open();
- int error_code=0;
- int output=0;
-
- if (handle<0){
- printf("failed to open file\n");
+int test_yaffs_lseek_EINVAL(void)
+{
+ handle = test_yaffs_open();
+ int error_code = 0;
+ int output = 0;
+
+ if (handle < 0){
+ print_message("failed to open file\n", 2);
return -1;
}
-
- output=yaffs_lseek(handle, 0, -1);
+ output = yaffs_lseek(handle, 0, -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){
+ if (output < 0){
+ error_code = yaffs_get_error();
+ if (abs(error_code) == EINVAL){
return 1;
- }
- else {
- printf("different error than expected\n");
+ } else {
+ print_message("different error than expected\n", 2);
return -1;
}
- }
- else {
- printf("lseeked to a negative position (which is a bad thing)\n");
+ } else {
+ print_message("lseeked to a negative position (which is a bad thing)\n", 2);
return -1;
}
}
-int test_yaffs_lseek_EINVAL_clean(void){
- if (handle>=0){
+int test_yaffs_lseek_EINVAL_clean(void)
+{
+ if (handle >= 0){
return yaffs_close(handle);
- }
- else {
+ } else {
return 1; /* no handle was opened so there is no need to close a handle */
}
}
#ifndef __test_yaffs_lseek_EINVAL_h__
#define __test_yaffs_lseek_EINVAL_h__
+
#include "lib.h"
#include "yaffsfs.h"
#include "test_yaffs_open.h"
#include "test_yaffs_mount.h"
-int test_yaffs_mount(void){
- int output=0;
- output=yaffs_mount(YAFFS_MOUNT_POINT);
- /*printf("output %d",output);*/
+int test_yaffs_mount(void)
+{
+ int output = 0;
+ output = yaffs_mount(YAFFS_MOUNT_POINT);
return output;
}
-int test_yaffs_mount_clean(void){
- return 1;
-
+int test_yaffs_mount_clean(void)
+{
+ return 1;
}
int test_yaffs_mount(void);
int test_yaffs_mount_clean(void);
+
#endif
#include "test_yaffs_mount_EBUSY.h"
-int test_yaffs_mount_EBUSY(void){
+int test_yaffs_mount_EBUSY(void)
+{
int output=0;
int error_code=0;
//printf("EISDIR def %d, Error code %d\n", ENOTDIR,error_code);
if (abs(error_code)==EBUSY){
return 1;
- }
- else {
- printf("different error than expected\n");
+ } else {
+ print_message("different error than expected\n",2);
return -1;
}
- }
- else if (output >=0){
- printf("mounted the same mount point twice.(which is a bad thing)\n");
+ } else {
+ print_message("mounted the same mount point twice.(which is a bad thing)\n", 2);
return -1;
}
-
}
-int test_yaffs_mount_EBUSY_clean(void){
+
+int test_yaffs_mount_EBUSY_clean(void)
+{
return 1;
}
int test_yaffs_mount_EBUSY(void);
int test_yaffs_mount_EBUSY_clean(void);
+
#endif
-int test_yaffs_mount_ENAMETOOLONG(void){
- int output=0;
- int x;
- int error_code=0;
- int file_name_length=1000000;
+int test_yaffs_mount_ENAMETOOLONG(void)
+{
+ int output = 0;
+ int x = 0;
+ int error_code = 0;
+ int file_name_length = 1000000;
char file_name[file_name_length];
/* if a second file system is mounted then yaffs will return EBUSY. so first unmount yaffs */
- output=test_yaffs_unmount();
+ output = test_yaffs_unmount();
if (output<0){
- printf("yaffs failed to unmount\n");
+ print_message("yaffs failed to unmount\n", 2);
return -1;
}
-
+ /* set up the file name */
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_mount(file_name);
error_code=yaffs_get_error();
if (abs(error_code)== ENAMETOOLONG){
return 1;
- }
- else {
- printf("different error than expected\n");
+ } else {
+ print_message("different error than expected\n", 2);
return -1;
}
- }
- else {
- printf("mounted a too long mount point name.(which is a bad thing)\n");
+ } else {
+ print_message("mounted a too long mount point name.(which is a bad thing)\n", 2);
return -1;
}
- /* the program should not get here but the compiler is complaining */
- return -1;
}
-int test_yaffs_mount_ENAMETOOLONG_clean(void){
+
+int test_yaffs_mount_ENAMETOOLONG_clean(void)
+{
return test_yaffs_mount();
}
int test_yaffs_mount_ENAMETOOLONG(void);
int test_yaffs_mount_ENAMETOOLONG_clean(void);
+
#endif
#include "test_yaffs_mount_ENODEV.h"
-static int handle=0;
-int test_yaffs_mount_ENODEV(void){
+static int handle = 0;
+
+int test_yaffs_mount_ENODEV(void)
+{
int output=0;
int error_code=0;
- /*printf("path %s\n",path); */
- handle=yaffs_mount("/nonexisting_mount_point/");
+
+ handle = yaffs_mount("/nonexisting_mount_point/");
if (handle==-1){
- error_code=yaffs_get_error();
- //printf("EISDIR def %d, Error code %d\n", ENOTDIR,error_code);
- if (abs(error_code)==ENODEV){
+ error_code = yaffs_get_error();
+ if (abs(error_code) == ENODEV){
return 1;
- }
- else {
- printf("different error than expected\n");
+ } else {
+ print_message("different error than expected\n",2);
return -1;
}
- }
- else if (output >=0){
- printf("non existant directory opened.(which is a bad thing)\n");
+ } else if (output >=0){
+ print_message("non existant directory opened.(which is a bad thing)\n",2);
return -1;
}
-
}
-int test_yaffs_mount_ENODEV_clean(void){
+
+int test_yaffs_mount_ENODEV_clean(void)
+{
return 1;
}
int test_yaffs_mount_ENODEV(void);
int test_yaffs_mount_ENODEV_clean(void);
+
#endif
#include "test_yaffs_mount_ENOENT.h"
-int test_yaffs_mount_ENOENT(void){
- int output=0;
- int error_code=0;
- /*printf("path %s\n",path); */
-
+int test_yaffs_mount_ENOENT(void)
+{
+ int output = 0;
+ int error_code = 0;
/* if a second file system is mounted then yaffs will return EBUSY. so first unmount yaffs */
- output=test_yaffs_unmount();
- if (output<0){
- printf("yaffs failed to unmount\n");
+ output = test_yaffs_unmount();
+ if (output < 0){
+ print_message("yaffs failed to unmount\n", 2);
return -1;
}
- output=yaffs_mount("/non_existaint_mount_point/");
- if (output==-1){
- error_code=yaffs_get_error();
- if (abs(error_code)==ENODEV){
+ output = yaffs_mount("/non_existaint_mount_point/");
+ if (output == -1){
+ error_code = yaffs_get_error();
+ if (abs(error_code) == ENODEV){
return 1;
- }
- else {
- printf("different error than expected\n");
+ } else {
+ print_message("different error than expected\n", 2);
return -1;
}
- }
- else {
- printf("non existant mount point mounted.(which is a bad thing)\n");
+ } else {
+ print_message("non existant mount point mounted.(which is a bad thing)\n",2);
return -1;
}
}
-int test_yaffs_mount_ENOENT_clean(void){
+
+int test_yaffs_mount_ENOENT_clean(void)
+{
return test_yaffs_mount();
}
int test_yaffs_mount_ENOENT(void);
int test_yaffs_mount_ENOENT_clean(void);
+
#endif
#include "test_yaffs_open.h"
-static int handle=0;
+static int handle = 0;
-int test_yaffs_open(void){
-
- handle=yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE);
+int test_yaffs_open(void)
+{
+ handle = yaffs_open(FILE_PATH,O_CREAT | O_RDWR, FILE_MODE);
return handle;
}
-int test_yaffs_open_clean(void){
- if (handle >=0){
+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*/
+ } else {
+ return 1; /* the file failed to open so there is no need to close it */
}
}
int test_yaffs_open(void);
int test_yaffs_open_clean(void);
+
#endif
#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){
+static int handle = -1;
+
+int test_yaffs_open_EEXIST(void)
+{
+ int error_code = 0;
+
+ handle = yaffs_open(FILE_PATH, O_CREAT | O_EXCL | O_TRUNC| O_RDWR ,FILE_MODE );
+ if (handle == -1){
+ error_code = yaffs_get_error();
+ if (abs(error_code) == EEXIST){
return 1;
- }
- else {
- printf("different error than expected\n");
+ } else {
+ print_message("different error than expected\n",2);
return -1;
}
- }
- else if (output >=0){
- printf("non existant file opened.(which is a bad thing)\n");
+ } else {
+ print_message("non existant file opened.(which is a bad thing)\n",2);
return -1;
}
- /* the program should not get here but the compiler is complaining */
- return -1;
}
-int test_yaffs_open_EEXIST_clean(void){
+
+int test_yaffs_open_EEXIST_clean(void)
+{
if (handle >=0){
return yaffs_close(handle);
- }
- else {
+ } else {
return 1; /* the file failed to open so there is no need to close it*/
}
}
int test_yaffs_open_EEXIST(void);
int test_yaffs_open_EEXIST_clean(void);
+
#endif
#include "test_yaffs_open_EINVAL.h"
-static int handle=0;
-int test_yaffs_open_EINVAL(void){
- int output=0;
- int error_code=0;
- /*printf("path %s\n",path); */
+static int handle = -1;
+
+int test_yaffs_open_EINVAL(void)
+{
+ int error_code = 0;
+
handle=yaffs_open(FILE_PATH, 255,FILE_MODE);
- if (handle==-1){
- error_code=yaffs_get_error();
- if (abs(error_code)== EEXIST){ /* yaffs open does not check the mode.
+ if (handle == -1){
+ error_code = yaffs_get_error();
+ if (abs(error_code) == EEXIST){ /* yaffs open does not check the mode which is passed into the functon.
so yaffs open does not return EINVAL.
This causes the error EEXIST to happen instead
because both O_CREAT and O_EXCL are set */
return 1;
- }
- else {
- printf("different error than expected\n");
+ } else {
+ print_message("different error than expected\n",2);
return -1;
}
- }
- else {
- printf(" file opened with bad mode.(which is a bad thing)\n");
+ } else {
+ print_message(" file opened with bad mode.(which is a bad thing)\n",2);
return -1;
}
- /* the program should not get here but the compiler is complaining */
- return -1;
}
-int test_yaffs_open_EINVAL_clean(void){
- if (handle >=0){
+
+int test_yaffs_open_EINVAL_clean(void)
+{
+ if (handle >= 0){
return yaffs_close(handle);
- }
- else {
+ } else {
return 1; /* the file failed to open so there is no need to close it*/
}
}
int test_yaffs_open_EINVAL(void);
int test_yaffs_open_EINVAL_clean(void);
+
#endif
#include "test_yaffs_open_EINVAL2.h"
-static int handle=0;
-int test_yaffs_open_EINVAL2(void){
- int output=0;
- int error_code=0;
- /*printf("path %s\n",path); */
+static int handle = -1;
+
+int test_yaffs_open_EINVAL2(void)
+{
+
handle=yaffs_open(FILE_PATH, O_CREAT | O_RDWR ,255);
- if (handle==-1){
- printf("file not opened with bad creation mod set (which is a bad thing)\n");
+
+ /* yaffs_open does not check the modes passed into it. This means that the file should open */
+ if (handle < 0){
+ print_message("file not opened with bad creation mode set (which is a bad thing)\n",2);
return -1;
- }
- else {
+ } else {
/* file opened */
return 1;
}
-
}
-int test_yaffs_open_EINVAL2_clean(void){
- if (handle >=0){
+
+int test_yaffs_open_EINVAL2_clean(void)
+{
+ if (handle >= 0){
return yaffs_close(handle);
- }
- else {
+ } else {
return 1; /* the file failed to open so there is no need to close it*/
}
}
int test_yaffs_open_EINVAL2(void);
int test_yaffs_open_EINVAL2_clean(void);
+
#endif
/*EISDIR is caused by trying to open a directory */
-static int handle=0;
-int test_yaffs_open_EISDIR(void){
- int output=0;
+static int handle = -1;
+
+int test_yaffs_open_EISDIR(void)
+{
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){
+ 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");
+ } else {
+ print_message("different error than expected\n", 2);
return -1;
}
- }
- else {
- printf("non existant directory opened.(which is a bad thing)\n");
+ } else {
+ print_message("non existant directory opened.(which is a bad thing)\n", 2);
return -1;
}
}
-int test_yaffs_open_EISDIR_clean(void){
+int test_yaffs_open_EISDIR_clean(void)
+{
if (handle >=0){
return yaffs_close(handle);
- }
- else {
+ } else {
return 1; /* the file failed to open so there is no need to close it*/
}
}
int test_yaffs_open_EISDIR(void);
int test_yaffs_open_EISDIR_clean(void);
+
#endif
-static int handle=0;
-int test_yaffs_open_ENAMETOOLONG(void){
- int output=0;
- int x;
- int error_code=0;
- int file_name_length=1000000;
+static int handle = -1;
+
+int test_yaffs_open_ENAMETOOLONG(void)
+{
+ int output = 0;
+ int x = 0;
+ 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';
+ 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 );
+ if (handle == -1){
+ error_code = yaffs_get_error();
- handle=yaffs_open(file_name, O_CREAT | O_TRUNC| O_RDWR ,FILE_MODE );
-
- if (handle==-1){
- error_code=yaffs_get_error();
- //printf("ENAMETOOLONG def %d, Error code %d\n", ENAMETOOLONG,error_code);
- if (abs(error_code)== ENAMETOOLONG){
+ if (abs(error_code) == ENAMETOOLONG){
return 1;
- }
- else {
- printf("different error than expected\n");
+ } else {
+ print_message("different error than expected\n",2);
return -1;
}
- }
- else if (output >=0){
- printf("handle %d \n",handle);
- printf("non existant file opened.(which is a bad thing)\n");
+ } else {
+ //printf("handle %d \n",handle);
+ print_message("non existant file opened.(which is a bad thing)\n", 2);
return -1;
}
- /* the program should not get here but the compiler is complaining */
- return -1;
}
-int test_yaffs_open_ENAMETOOLONG_clean(void){
+int test_yaffs_open_ENAMETOOLONG_clean(void)
+{
if (handle >=0){
return yaffs_close(handle);
}
int test_yaffs_open_ENAMETOOLONG(void);
int test_yaffs_open_ENAMETOOLONG_clean(void);
+
#endif
#include "test_yaffs_open_ENOENT.h"
-static int handle=0;
-int test_yaffs_open_ENOENT(void){
- int output=0;
- int error_code=0;
+static int handle = -1;
+
+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){
+ 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");
+ print_message("different error than expected\n",2);
return -1;
}
- }
- else if (output >=0){
- printf("non existant file opened.(which is a bad thing)\n");
+ } else {
+ print_message("non existant file opened.(which is a bad thing)\n",2);
return -1;
}
-
}
-int test_yaffs_open_ENOENT_clean(void){
+
+int test_yaffs_open_ENOENT_clean(void)
+{
if (handle >=0){
return yaffs_close(handle);
}
int test_yaffs_open_ENOENT(void);
int test_yaffs_open_ENOENT_clean(void);
+
#endif
#include "test_yaffs_open_ENOTDIR.h"
-static int handle=0;
-int test_yaffs_open_ENOTDIR(void){
- int output=0;
+static int handle = -1;
+
+int test_yaffs_open_ENOTDIR(void)
+{
int error_code=0;
- /*printf("path %s\n",path); */
+
handle=yaffs_open("/nonexisting_dir/foo", O_TRUNC| O_RDWR,FILE_MODE );
- if (handle==-1){
+ if (handle <0){
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");
+ print_message("different error than expected\n",2);
return -1;
}
}
- else if (output >=0){
- printf("non existant directory opened.(which is a bad thing)\n");
+ else {
+ print_message("non existing directory opened.(which is a bad thing)\n",2);
return -1;
}
-
}
-int test_yaffs_open_ENOTDIR_clean(void){
+
+int test_yaffs_open_ENOTDIR_clean(void)
+{
if (handle >=0){
return yaffs_close(handle);
}
int test_yaffs_open_ENOTDIR(void);
int test_yaffs_open_ENOTDIR_clean(void);
+
#endif
static int handle=-1;
-int test_yaffs_read(void){
- handle=test_yaffs_open();
- char text[20]="\0";
+int test_yaffs_read(void)
+{
+ char text[20] = "\0";
int output=0;
- //printf("handle %d\n",handle);
+
+ handle = test_yaffs_open();
if (handle>=0){
output=yaffs_read(handle, 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);
if (output>0){
if (0==memcmp(text,FILE_TEXT,FILE_TEXT_NBYTES)){
return 1;
- }
- else {
- printf("returned text does not match the the expected text that should be in the file\n");
+ } else {
+ print_message("returned text does not match the the expected text that should be in the file\n", 2);
return -1;
}
- }
- else{
- printf("error reading file\n");
+ } else{
+ print_message("error reading file\n", 2);
return -1;
}
- }
- else {
- printf("error opening file\n");
+ } else {
+ print_message("error opening file\n", 2);
return -1;
}
-
}
-int test_yaffs_read_clean(void){
+int test_yaffs_read_clean(void)
+{
if (handle>=0){
return yaffs_close(handle);
}
int test_yaffs_read(void);
int test_yaffs_read_clean(void);
+
#endif
#include "test_yaffs_read_EBADF.h"
-int test_yaffs_read_EBADF(void){
+int test_yaffs_read_EBADF(void)
+{
int error_code=0;
int output=0;
char text[100];
text[0] ='\0';
+
output=yaffs_read(-1, text, FILE_TEXT_NBYTES);
if (output<0){
- error_code=yaffs_get_error();
- if (abs(error_code)==EBADF){
+ error_code = yaffs_get_error();
+ if (abs(error_code) == EBADF){
return 1;
- }
- else {
- printf("returned error does not match the the expected error\n");
+ } else {
+ print_message("returned error does not match the the expected error\n",2);
return -1;
}
- }
- else{
- printf("read a non-existing file (which is a bad thing)\n");
+ } else{
+ print_message("read a non-existing file (which is a bad thing)\n",2);
return -1;
}
}
-int test_yaffs_read_EBADF_clean(void){
+int test_yaffs_read_EBADF_clean(void)
+{
return 1;
}
#ifndef __test_yaffs_read_EBADF_h__
#define __test_yaffs_read_EBADF_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);
+
#endif
#include "test_yaffs_read_EINVAL.h"
-static int handle=0;
-
+static int handle = -1;
static char *file_name = NULL;
-int test_yaffs_read_EINVAL(void){
- int error_code=0;
+
+int test_yaffs_read_EINVAL(void)
+{
+ int error_code = 0;
handle=test_yaffs_open();
char text[2000000]="\0";
int output=0;
if (handle<0){
- printf("could not open file\n");
+ print_message("could not open file\n",2);
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");
+ print_message("could not write text to the file\n",2);
return -1;
}
if (handle>=0){
output=yaffs_read(handle, text, -1);
-
if (output<0){
error_code=yaffs_get_error();
if (abs(error_code)== EINVAL){
return 1;
- }
- else {
- printf("different error than expected\n");
+ } else {
+ print_message("different error than expected\n",2);
return -1;
}
- }
- else{
- printf("read a negative number of bytes (which is a bad thing)\n");
+ } else{
+ print_message("read a negative number of bytes (which is a bad thing)\n",2);
return -1;
}
- }
- else {
- printf("error opening file\n");
+ } else {
+ print_message("error opening file\n",2);
return -1;
}
-
}
-int test_yaffs_read_EINVAL_clean(void){
+int test_yaffs_read_EINVAL_clean(void)
+{
int output=0;
if (handle>=0){
output=test_yaffs_read_EINVAL_init_clean();
if (output>=0){
return 1;
} else {
- printf("could not close the handle\n");
+ print_message("could not close the handle\n",2);
return -1;
}
} else {
- printf("failed to fix the file\n");
+ print_message("failed to fix the file\n",2);
return -1;
}
+ } else {
+ print_message("no open handle\n",2);
}
-
}
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");
+ print_message("unable to create file text\n",2);
return -1;
}
if (handle>=0){
output= yaffs_write(handle, file_name, file_name_length-1);
if (output<0){
- printf("could not write text to file\n");
+ print_message("could not write text to file\n",2);
return -1;
} else {
}
} else {
- printf("error opening file\n");
+ print_message("error opening file\n",2);
return -1;
}
if (output>=0){
return 1;
} else {
- printf("failed to write to file\n");
+ print_message("failed to write to file\n",2);
return -1;
}
} else {
- printf("failed to truncate file\n");
+ print_message("failed to truncate file\n",2);
return -1;
}
#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_EINVAL_clean(void);
int test_yaffs_read_EINVAL_init(void);
int test_yaffs_read_EINVAL_init_clean(void);
+
#endif
#include "test_yaffs_stat.h"
-int test_yaffs_stat(void){
+int test_yaffs_stat(void)
+{
+ char message[20];
int mode=0;
int size=0;
- mode =yaffs_test_stat_mode();
-
+ message[0]='\0';
+
+ mode =yaffs_test_stat_mode();
if (mode>=0){
-
if (FILE_MODE == (FILE_MODE & mode)){
mode=1;
- }
- else {
- printf("mode did not match expected file mode\n");
+ } else {
+ print_message("mode did not match expected file mode\n",2);
return -1;
}
- }
- else {
+ } else {
mode =-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");
+ } else {
+ sprintf(message,"file size %d, expected file size %d\n",size,FILE_SIZE);
+ print_message(message,2);
+ print_message("mode did not match expected file mode\n",2);
return -1;
}
- }
- else {
+ } else {
size =-1;
}
if ((mode>0) && (size>0)){
return 1;
- }
- else {
- /* a test failed*/
+ } else {
+ /* one of the tests failed*/
return -1;
}
-
}
-int test_yaffs_stat_clean(void){
+int test_yaffs_stat_clean(void)
+{
return 1;
}
-int yaffs_test_stat_mode(void){
+int yaffs_test_stat_mode(void)
+{
struct yaffs_stat stat;
int output=0;
output=yaffs_stat(FILE_PATH, &stat);
//printf("output: %d\n",output);
if (output>=0){
return stat.st_mode;
- }
- else {
- printf("failed to stat file mode\n") ;
+ } else {
+ print_message("failed to stat file mode\n",2) ;
return -1;
}
}
output=yaffs_stat(FILE_PATH, &stat);
if (output>=0){
return stat.st_size;
- }
- else {
- printf("failed to stat file size\n") ;
+ } else {
+ print_message("failed to stat file size\n",2) ;
return -1;
}
}
#ifndef __test_yaffs_stat_h__
#define __test_yaffs_stat_h__
+
#include "lib.h"
#include "yaffsfs.h"
#include "test_yaffs_open.h"
#include "test_yaffs_lseek.h"
+
int test_yaffs_stat(void);
int test_yaffs_stat_clean(void);
int yaffs_test_stat_mode(void);
int yaffs_test_stat_size(void);
+
#endif
#include "test_yaffs_stat_ENOENT.h"
-int test_yaffs_stat_ENOENT(void){
+int test_yaffs_stat_ENOENT(void)
+{
int error_code=0;
struct yaffs_stat stat;
int output=0;
char text[100];
text[0] ='\0';
- output=yaffs_stat("/yaffs2/non-existing_file", &stat);;
+ output=yaffs_stat("/yaffs2/non-existing_file", &stat);
if (output<0){
error_code=yaffs_get_error();
if (abs(error_code)==ENOENT){
return 1;
- }
- else {
- printf("returned error does not match the the expected error\n");
+ } else {
+ print_message("returned error does not match the the expected error\n",2);
return -1;
}
- }
- else{
- printf("stated a non-existing file (which is a bad thing)\n");
+ } else{
+ print_message("stated a non-existing file (which is a bad thing)\n",2);
return -1;
}
}
-int test_yaffs_stat_ENOENT_clean(void){
+int test_yaffs_stat_ENOENT_clean(void)
+{
return 1;
}
#ifndef __test_yaffs_stat_ENOENT_h__
#define __test_yaffs_stat_ENOENT_h__
+
#include "lib.h"
#include "yaffsfs.h"
#include "test_yaffs_open.h"
-
int test_yaffs_stat_ENOENT(void);
int test_yaffs_stat_ENOENT_clean(void);
+
#endif
#include "test_yaffs_stat_ENOTDIR.h"
-int test_yaffs_stat_ENOTDIR(void){
+int test_yaffs_stat_ENOTDIR(void)
+{
int error_code=0;
struct yaffs_stat stat;
int output=0;
error_code=yaffs_get_error();
if (abs(error_code)==ENOTDIR){
return 1;
- }
- else {
- printf("returned error does not match the the expected error\n");
+ } else {
+ print_message("returned error does not match the the expected error\n",2);
return -1;
}
- }
- else{
- printf("stated a non-existing file (which is a bad thing)\n");
+ } else {
+ print_message("stated a non-existing file (which is a bad thing)\n",2);
return -1;
}
}
-int test_yaffs_stat_ENOTDIR_clean(void){
+int test_yaffs_stat_ENOTDIR_clean(void)
+{
return 1;
}
#ifndef __test_yaffs_stat_ENOTDIR_h__
#define __test_yaffs_stat_ENOTDIR_h__
+
#include "lib.h"
#include "yaffsfs.h"
#include "test_yaffs_open.h"
-
int test_yaffs_stat_ENOTDIR(void);
int test_yaffs_stat_ENOTDIR_clean(void);
+
#endif
*/
#include "test_yaffs_truncate.h"
-static int handle=0;
+static int handle = -1;
-int test_yaffs_truncate(void){
- handle=test_yaffs_open();
- if (handle>=0){
+int test_yaffs_truncate(void)
+{
+ handle = test_yaffs_open();
+ if (handle >= 0){
return yaffs_truncate(FILE_PATH,FILE_SIZE_TRUNCATED );
- }
- else {
- printf("error opening file");
+ } else {
+ print_message("error opening file",2);
return -1;
}
}
-int test_yaffs_truncate_clean(void){
+int test_yaffs_truncate_clean(void)
+{
/* change file size back to orignal size */
int output=0;
- if (handle>=0){
+ if (handle >= 0){
output= yaffs_truncate(FILE_PATH,FILE_SIZE );
if (output>=0){
return yaffs_close(handle);
+ } else {
+ print_message("failed to truncate file\n",2);
+ return -1;
}
- }
- else {
- printf("error opening file in clean function");
+ } else {
+ print_message("error opening file in clean function\n",2);
return -1;
}
#ifndef __test_yaffs_truncate_h__
#define __test_yaffs_truncate_h__
+
#include "lib.h"
#include "yaffsfs.h"
#include "test_yaffs_open.h"
+
int test_yaffs_truncate(void);
int test_yaffs_truncate_clean(void);
+
#endif
*/
#include "test_yaffs_truncate_EFBIG.h"
-static int handle=0;
+static int handle = -1;
-int test_yaffs_truncate_EFBIG(void){
+int test_yaffs_truncate_EFBIG(void)
+{
int error=0;
int output=0;
handle=test_yaffs_open();
error=yaffs_get_error();
if (abs(error)==EINVAL){ /*in yaffs EINVAL is used instead of EFBIG */
return 1;
- }
- else {
- printf("received a different error than expected\n");
+ } else {
+ print_message("received a different error than expected\n",2);
return -1;
}
- }
- else{
- printf("truncated a file to a massive size\n");
+ } else{
+ print_message("truncated a file to a massive size\n",2);
return -1;
}
- }
- else {
- printf("error opening file");
+ } else {
+ print_message("error opening file\n",2);
return -1;
}
}
-int test_yaffs_truncate_EFBIG_clean(void){
+int test_yaffs_truncate_EFBIG_clean(void)
+{
return 1;
}
#ifndef __test_yaffs_truncate_EFBIG_h__
#define __test_yaffs_truncate_EFBIG_h__
+
#include "lib.h"
#include "yaffsfs.h"
#include "test_yaffs_open.h"
+
int test_yaffs_truncate_EFBIG(void);
int test_yaffs_truncate_EFBIG_clean(void);
+
#endif
*/
#include "test_yaffs_truncate_EINVAL.h"
-static int handle=0;
+static int handle=-1;
-int test_yaffs_truncate_EINVAL(void){
+int test_yaffs_truncate_EINVAL(void)
+{
int error=0;
int output=0;
handle=test_yaffs_open();
error=yaffs_get_error();
if (abs(error)==EINVAL){
return 1;
- }
- else {
- printf("received a different error than expected\n");
+ } else {
+ print_message("received a different error than expected\n",2);
return -1;
}
- }
- else{
- printf("truncated a file with a bad mode set.\n");
+ } else{
+ print_message("truncated a file with a bad mode set.\n",2);
return -1;
}
- }
- else {
- printf("error opening file");
+ } else {
+ print_message("error opening file",2);
return -1;
}
}
-int test_yaffs_truncate_EINVAL_clean(void){
+int test_yaffs_truncate_EINVAL_clean(void)
+{
return 1;
}
#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
*/
#include "test_yaffs_truncate.h"
-static int handle=0;
+static int handle= -1;
-int test_yaffs_truncate_EISDIR(void){
- int error=0;
- int output=0;
- handle=test_yaffs_open();
+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){
+ output = yaffs_truncate("/yaffs2/",10);
+ if (output < 0){
+ error = yaffs_get_error();
+ if (abs(error) == EISDIR){
return 1;
- }
- else {
- printf("received a different error than expected\n");
+ } else {
+ print_message("received a different error than expected\n",2);
return -1;
}
- }
- else{
- printf("truncated a directory\n");
+ } else{
+ print_message("truncated a directory\n",2);
return -1;
}
- }
- else {
- printf("error opening file");
+ } else {
+ print_message("error opening file\n",2);
return 1;
}
}
-int test_yaffs_truncate_EISDIR_clean(void){
+int test_yaffs_truncate_EISDIR_clean(void)
+{
return 1;
}
#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
*/
#include "test_yaffs_truncate_ENOENT.h"
-static int handle=0;
+static int handle = -1;
-int test_yaffs_truncate_ENOENT(void){
+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 );
error=yaffs_get_error();
if (abs(error)==ENOENT){
return 1;
- }
- else {
- printf("received a different error than expected\n");
+ } else {
+ print_message("received a different error than expected\n",2);
return -1;
}
- }
- else{
- printf("truncated a nonexisting file\n");
+ } else{
+ print_message("truncated a nonexisting file\n",2);
return -1;
- }
-
- }
- else {
- printf("error opening file");
+ }
+ } else {
+ print_message("error opening file",2);
return -1;
}
}
-int test_yaffs_truncate_ENOENT_clean(void){
+int test_yaffs_truncate_ENOENT_clean(void)
+{
return 1;
}
#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);
+int test_yaffs_truncate_ENOENT_clean(void);
+
#endif
*/
#include "test_yaffs_truncate_ENOTDIR.h"
-static int handle=0;
-int test_yaffs_truncate_ENOTDIR(void){
+static int handle = -1;
+
+int test_yaffs_truncate_ENOTDIR(void)
+{
int error=0;
int output=0;
handle=test_yaffs_open();
error=yaffs_get_error();
if (abs(error)==ENOTDIR){
return 1;
- }
- else {
- printf("received a different error than expected\n");
+ } else {
+ print_message("received a different error than expected\n",2);
return -1;
}
- }
- else{
- printf("truncated a nonexisting file\n");
+ } else{
+ print_message("truncated a nonexisting file\n",2);
return -1;
}
- }
- else {
- printf("error opening file");
+ } else {
+ print_message("error opening file\n",2);
return -1;
}
}
-int test_yaffs_truncate_ENOTDIR_clean(void){
+int test_yaffs_truncate_ENOTDIR_clean(void)
+{
return 1;
}
#include "test_yaffs_unlink.h"
-int test_yaffs_unlink(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*/
- }
- else {
- printf("failed to unlink file\n") ;
+ } else {
+ print_message("failed to unlink file\n",2) ;
return -1;
}
}
-int test_yaffs_unlink_clean(void){
+int test_yaffs_unlink_clean(void)
+{
return test_yaffs_open();
}
int test_yaffs_unlink(void);
int test_yaffs_unlink_clean(void);
+
#endif
/*EISDIR is caused by trying to unlink a directory */
-static int handle=0;
-int test_yaffs_unlink_EISDIR(void){
- int output=0;
+static int handle=-1;
+
+int test_yaffs_unlink_EISDIR(void)
+{
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");
+ } else {
+ print_message("different error than expected\n",2);
return -1;
}
}
- else if (output >=0){
- printf("directory unlinked opened.(which is a bad thing)\n");
+ else {
+ print_message("directory unlinked opened.(which is a bad thing)\n",2);
return -1;
}
- /* the program should not get here but the compiler is complaining */
- return -1;
+
}
-int test_yaffs_unlink_EISDIR_clean(void){
+int test_yaffs_unlink_EISDIR_clean(void)
+{
if (handle >=0){
return yaffs_close(handle);
- }
- else {
+ }else {
return 1; /* the file failed to open so there is no need to close it*/
}
}
int test_yaffs_unlink_EISDIR(void);
int test_yaffs_unlink_EISDIR_clean(void);
+
#endif
-int test_yaffs_unlink_ENAMETOOLONG(void){
+int test_yaffs_unlink_ENAMETOOLONG(void)
+{
int output=0;
int error_code=0;
int x=0;
}
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");
+ } else {
+ print_message("different error than expected\n",2);
return -1;
}
- }
- else {
- printf("directory unlinked opened.(which is a bad thing)\n");
+ } else {
+ print_message("directory unlinked opened.(which is a bad thing)\n",2);
return -1;
}
}
-int test_yaffs_unlink_ENAMETOOLONG_clean(void){
+int test_yaffs_unlink_ENAMETOOLONG_clean(void)
+{
return 1;
}
#include "test_yaffs_unlink_ENOENT.h"
-static int handle=0;
-int test_yaffs_unlink_ENOENT(void){
- int output=0;
+static int handle=-1;
+
+int test_yaffs_unlink_ENOENT(void)
+{
int error_code=0;
- /*printf("path %s\n",path); */
+
handle=yaffs_unlink("/yaffs2/non_existant_file");
if (handle==-1){
error_code=yaffs_get_error();
- if (abs(error_code)==ENOENT){
+ if (abs(error_code) == ENOENT){
return 1;
- }
- else {
- printf("different error than expected\n");
+ } else {
+ print_message("different error than expected\n",2);
return -1;
}
- }
- else if (output >=0){
- printf("non existant file unlinked.(which is a bad thing)\n");
+ } else {
+ print_message("non existant file unlinked.(which is a bad thing)\n",2);
return -1;
}
}
-int test_yaffs_unlink_ENOENT_clean(void){
- if (handle >=0){
+int test_yaffs_unlink_ENOENT_clean(void)
+{
+ if (handle >= 0){
return test_yaffs_open();
- }
- else {
+ } else {
return 1; /* the file failed to open so there is no need to close it*/
}
}
int test_yaffs_unlink_ENOENT(void);
int test_yaffs_unlink_ENOENT_clean(void);
+
#endif
#include "test_yaffs_open_ENOTDIR.h"
-int test_yaffs_unlink_ENOTDIR(void){
+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");
+ } else {
+ print_message("different error than expected\n",2);
return -1;
}
- }
- else {
- printf("non existant directory opened.(which is a bad thing)\n");
+ } else {
+ print_message("non existant directory opened.(which is a bad thing)\n",2);
return -1;
}
}
-int test_yaffs_unlink_ENOTDIR_clean(void){
+int test_yaffs_unlink_ENOTDIR_clean(void)
+{
return 1;
}
int test_yaffs_unlink_ENOTDIR(void);
int test_yaffs_unlink_ENOTDIR_clean(void);
+
#endif
#include "test_yaffs_unmount.h"
-int test_yaffs_unmount(void){
- int output=0;
- output=yaffs_unmount(YAFFS_MOUNT_POINT);
- /*printf("output %d",output);*/
- return output;
+int test_yaffs_unmount(void)
+{
+ return yaffs_unmount(YAFFS_MOUNT_POINT);
}
-int test_yaffs_unmount_clean(void){
- return test_yaffs_mount();
-
+int test_yaffs_unmount_clean(void)
+{
+ return test_yaffs_mount();
}
int test_yaffs_unmount(void);
int test_yaffs_unmount_clean(void);
+
#endif
#include "test_yaffs_mount_EBUSY.h"
static int handle=-1;
-int test_yaffs_unmount_EBUSY(void){
+
+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");
+ } else {
+ print_message("different error than expected\n",2);
return -1;
}
- }
- else {
- printf("non existant mount point unmounted.(which is a bad thing)\n");
+ } else {
+ print_message("non existant mount point unmounted.(which is a bad thing)\n",2);
return -1;
}
}
-int test_yaffs_unmount_EBUSY_clean(void){
+int test_yaffs_unmount_EBUSY_clean(void)
+{
if (handle>=0){
return yaffs_close(handle);
- }
- else {
+ } else {
return 1;
}
}
int test_yaffs_unmount_EBUSY(void);
int test_yaffs_unmount_EBUSY_clean(void);
+
#endif
#include "test_yaffs_unmount_ENAMETOOLONG.h"
-
-
-
-int test_yaffs_unmount_ENAMETOOLONG(void){
+int test_yaffs_unmount_ENAMETOOLONG(void)
+{
int output=0;
- int x;
+ int x=0;
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");
+ } else {
+ print_message("different error than expected\n",2);
return -1;
}
- }
- else {
- printf("mounted a too long mount point name.(which is a bad thing)\n");
+ } else {
+ print_message("mounted a too long mount point name.(which is a bad thing)\n",2);
return -1;
}
- /* the program should not get here but the compiler is complaining */
- return -1;
}
-int test_yaffs_unmount_ENAMETOOLONG_clean(void){
+int test_yaffs_unmount_ENAMETOOLONG_clean(void)
+{
return 1;
}
int test_yaffs_unmount_ENAMETOOLONG(void);
int test_yaffs_unmount_ENAMETOOLONG_clean(void);
+
#endif
#include "test_yaffs_mount_ENOENT.h"
-
-int test_yaffs_unmount_ENOENT(void){
+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");
+ } else {
+ print_message("different error than expected\n",2);
return -1;
}
- }
- else {
- printf("non existant mount point unmounted.(which is a bad thing)\n");
+ } else {
+ print_message("non existant mount point unmounted.(which is a bad thing)\n",2);
return -1;
}
-
}
-int test_yaffs_unmount_ENOENT_clean(void){
+int test_yaffs_unmount_ENOENT_clean(void)
+{
return 1;
}
int test_yaffs_unmount_ENOENT(void);
int test_yaffs_unmount_ENOENT_clean(void);
+
#endif
#include "test_yaffs_write.h"
-static int handle=0;
-int test_yaffs_write(void){
+static int handle=-1;
+
+int test_yaffs_write(void)
+{
handle=test_yaffs_open();
if (handle>=0){
return yaffs_write(handle, FILE_TEXT, FILE_TEXT_NBYTES);
- }
- else {
+ } else {
printf("error opening file\n");
return -1;
}
-
}
-int test_yaffs_write_clean(void){
+int test_yaffs_write_clean(void)
+{
if (handle>=0){
return yaffs_close(handle);
- }
- else {
+ } else {
return 1; /* no handle was opened so there is no need to close a handle */
}
}
#ifndef __test_yaffs_write_h__
#define __test_yaffs_write_h__
+
#include "lib.h"
#include "yaffsfs.h"
#include "test_yaffs_open.h"
+
int test_yaffs_write(void);
int test_yaffs_write_clean(void);
+
#endif
#include "test_yaffs_write_EBADF.h"
-static int handle=0;
-int test_yaffs_write_EBADF(void){
+static int handle= -1;
+
+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);
//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");
+ } else {
+ print_message("different error than expected\n",2);
return -1;
}
- }
- else {
- printf("wrote to a bad handle.(which is a bad thing)\n");
+ } else {
+ print_message("wrote to a bad handle.(which is a bad thing)\n",2);
return -1;
}
- }
- else {
- printf("error opening file\n");
+ } else {
+ print_message("error opening file\n",2);
return -1;
}
-
}
-int test_yaffs_write_EBADF_clean(void){
+int test_yaffs_write_EBADF_clean(void)
+{
if (handle>=0){
return yaffs_close(handle);
- }
- else {
+ } else {
return 1; /* no handle was opened so there is no need to close a handle */
}
}
#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