From: Timothy Manning Date: Tue, 26 Oct 2010 04:04:39 +0000 (+1300) Subject: yaffs Commiting some more yaffs tests showing bugs in yaffs. X-Git-Tag: linux-mainline-rc-01~1^2^2 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=ef24b90a2e00a9a3db2bab70261807037ccc0bd7 yaffs Commiting some more yaffs tests showing bugs in yaffs. Signed-off-by: Timothy Manning --- diff --git a/direct/timothy_tests/ENOENT_bug/Makefile b/direct/timothy_tests/ENOENT_bug/Makefile new file mode 100644 index 0000000..672a33f --- /dev/null +++ b/direct/timothy_tests/ENOENT_bug/Makefile @@ -0,0 +1,103 @@ +# Makefile for YAFFS direct stress tests +# +# +# YAFFS: Yet another Flash File System. A NAND-flash specific file system. +# +# Copyright (C) 2003-2010 Aleph One Ltd. +# +# +# Created by Charles Manning +# +# 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. +# +# NB Warning this Makefile does not include header dependencies. +# +# $Id: Makefile,v 1.7 2010-02-25 22:34:47 charles Exp $ + +#EXTRA_COMPILE_FLAGS = -DYAFFS_IGNORE_TAGS_ECC + +CFLAGS = -DCONFIG_YAFFS_DIRECT -DCONFIG_YAFFS_SHORT_NAMES_IN_RAM -DCONFIG_YAFFS_YAFFS2 +CFLAGS += -DCONFIG_YAFFS_PROVIDE_DEFS -DCONFIG_YAFFSFS_PROVIDE_VALUES +CFLAGS += -Wall -g $(EXTRA_COMPILE_FLAGS) -Wstrict-aliasing +#CFLAGS += -fno-strict-aliasing +CFLAGS += -O0 +CFLAGS += -Wextra -Wpointer-arith +#CFLAGS += -DCONFIG_YAFFS_VALGRIND_TEST + +#CFLAGS+= -Wshadow -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Wmissing-declarations +#CFLAGS+= -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Winline + + +COMMONTESTOBJS = yaffscfg2k.o yaffs_ecc.o yaffs_fileem.o yaffs_fileem2k.o yaffsfs.o yaffs_guts.o \ + yaffs_packedtags1.o yaffs_ramdisk.o yaffs_ramem2k.o \ + yaffs_tagscompat.o yaffs_packedtags2.o yaffs_tagsvalidity.o yaffs_nand.o \ + yaffs_checkptrw.o yaffs_qsort.o\ + yaffs_nameval.o \ + yaffs_norif1.o ynorsim.o \ + yaffs_allocator.o \ + yaffs_bitmap.o \ + yaffs_yaffs1.o \ + yaffs_yaffs2.o \ + yaffs_verify.o + +# yaffs_checkptrwtest.o\ + +YAFFSTESTOBJS = $(COMMONTESTOBJS) yaffs_tester.o message_buffer.o error_handler.o + + +ALLOBJS = $(sort $(YAFFSTESTOBJS)) + +YAFFSSYMLINKS = devextras.h yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffsinterface.h yportenv.h yaffs_tagscompat.c yaffs_tagscompat.h \ + yaffs_packedtags1.c yaffs_packedtags1.h yaffs_packedtags2.c yaffs_packedtags2.h yaffs_nandemul2k.h \ + yaffs_nand.c yaffs_nand.h yaffs_getblockinfo.h yaffs_list.h \ + yaffs_tagsvalidity.c yaffs_tagsvalidity.h yaffs_checkptrw.h yaffs_checkptrw.c \ + yaffs_nameval.c yaffs_nameval.h \ + yaffs_qsort.c yaffs_qsort.h yaffs_trace.h \ + yaffs_allocator.c yaffs_allocator.h \ + yaffs_yaffs1.c yaffs_yaffs1.h \ + yaffs_yaffs2.c yaffs_yaffs2.h \ + yaffs_bitmap.c yaffs_bitmap.h \ + yaffs_verify.c yaffs_verify.h + +YAFFSDIRECTSYMLINKS = yaffsfs.c yaffs_flashif.h yaffs_flashif2.h\ + yaffsfs.h yaffs_malloc.h ydirectenv.h \ + yaffs_flashif.c yaffscfg.h \ + yaffs_nandif.c yaffs_nandif.h + + +DIRECTEXTRASYMLINKS = yaffscfg2k.c yaffs_fileem2k.c yaffs_fileem2k.h\ + yaffs_fileem.c yaffs_norif1.c yaffs_norif1.h \ + yaffs_ramdisk.c yaffs_ramdisk.h yaffs_ramem2k.c \ + ynorsim.h ynorsim.c + +SYMLINKS = $(YAFFSSYMLINKS) $(YAFFSDIRECTSYMLINKS) $(DIRECTEXTRASYMLINKS) +#all: directtest2k boottest + +all: yaffs_tester + +$(ALLOBJS): %.o: %.c + gcc -c $(CFLAGS) -o $@ $< + + +$(YAFFSSYMLINKS): + ln -s ../../../$@ $@ + +$(YAFFSDIRECTSYMLINKS): + ln -s ../../$@ $@ + +$(DIRECTEXTRASYMLINKS): + ln -s ../../basic-test/$@ $@ + + +yaffs_tester: $(SYMLINKS) $(YAFFSTESTOBJS) + gcc $(CFLLAG) -o $@ $(YAFFSTESTOBJS) + + + + + + +clean: + rm -f yaffs_tester $(ALLOBJS) core $(SYMLINKS) log.txt diff --git a/direct/timothy_tests/ENOENT_bug/README.txt b/direct/timothy_tests/ENOENT_bug/README.txt new file mode 100644 index 0000000..04c00c4 --- /dev/null +++ b/direct/timothy_tests/ENOENT_bug/README.txt @@ -0,0 +1,7 @@ +This directory "freezes" the yaffs_tester programs in the state in which they produce a specific bug. + +ENOENT error when opening a new file with O_CREATE +To generate this error remove the emfile and use the seed 1288064149 + +./yaffs_tester -seed 1288064149 +For more information on this bug see the error.txt file diff --git a/direct/timothy_tests/ENOENT_bug/error_handler.c b/direct/timothy_tests/ENOENT_bug/error_handler.c new file mode 100644 index 0000000..d1670e6 --- /dev/null +++ b/direct/timothy_tests/ENOENT_bug/error_handler.c @@ -0,0 +1,83 @@ +/* + * 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 + * + * 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. + */ + +/* + * error_handler.c contains code for checking yaffs function calls for errors. + */ +#include "error_handler.h" + + +typedef struct error_codes_template { + int code; + char * text; +}error_entry; + +const error_entry error_list[] = { + { ENOMEM , "ENOMEM" }, + { EBUSY , "EBUSY"}, + { ENODEV , "ENODEV"}, + { EINVAL , "EINVAL"}, + { EBADF , "EBADF"}, + { EACCES , "EACCES"}, + { EXDEV , "EXDEV" }, + { ENOENT , "ENOENT"}, + { ENOSPC , "ENOSPC"}, + { ERANGE , "ERANGE"}, + { ENODATA, "ENODATA"}, + { ENOTEMPTY, "ENOTEMPTY"}, + { ENAMETOOLONG,"ENAMETOOLONG"}, + { ENOMEM , "ENOMEM"}, + { EEXIST , "EEXIST"}, + { ENOTDIR , "ENOTDIR"}, + { EISDIR , "EISDIR"}, + { 0, NULL } +}; + +const char * error_to_str(int err) +{ + error_entry *e = error_list; + if (err < 0) + err = -err; + while(e->code && e->text){ + if(err == e->code) + return e->text; + e++; + } + return "Unknown error code"; +} + +void yaffs_check_for_errors(char output, buffer *message_buffer,char error_message[],char success_message[]){ + char dummy[10]; + unsigned int x=0; + int yaffs_error=-1; + char error_found=0; + if (output==-1) + { + add_to_buffer(message_buffer, "\nerror##########",MESSAGE_LEVEL_ERROR,PRINT); + add_to_buffer(message_buffer, error_message,MESSAGE_LEVEL_ERROR,PRINT); + add_to_buffer(message_buffer, "error_code: ",MESSAGE_LEVEL_ERROR,PRINT); + yaffs_error=yaffs_get_error(); + if (MESSAGE_LEVEL_ERROR<=DEBUG_LEVEL) printf("%d\n",yaffs_error); /*cannot yet add int types to buffer. this is a quick fix*/ + add_to_buffer(message_buffer, error_to_str(yaffs_error),MESSAGE_LEVEL_ERROR,NPRINT); + append_to_buffer(message_buffer, "\n\n",MESSAGE_LEVEL_ERROR,PRINT); + + scanf("%c",dummy); /*this line causes a segmentation fault. Need a better way of waiting for a key press*/ + //print_buffer(message_buffer,PRINT_ALL); + + } + else{ + add_to_buffer(message_buffer, success_message,MESSAGE_LEVEL_BASIC_TASKS,PRINT); + } +} + + diff --git a/direct/timothy_tests/ENOENT_bug/error_handler.h b/direct/timothy_tests/ENOENT_bug/error_handler.h new file mode 100644 index 0000000..c07fdff --- /dev/null +++ b/direct/timothy_tests/ENOENT_bug/error_handler.h @@ -0,0 +1,23 @@ +/* + * 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 + * + * 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 __error_handler_h__ +#define __error_handler_h__ +#include +#include "message_buffer.h" +#include "yaffsfs.h" +#define DEBUG_LEVEL 5 /*set the debug level. this is used to display the relevent debug messages*/ +void yaffs_check_for_errors(char output, buffer *message_buffer, char error_message[], char success_message[]); +#endif diff --git a/direct/timothy_tests/ENOENT_bug/error_log.txt b/direct/timothy_tests/ENOENT_bug/error_log.txt new file mode 100644 index 0000000..24aac26 --- /dev/null +++ b/direct/timothy_tests/ENOENT_bug/error_log.txt @@ -0,0 +1,484 @@ +log file for yaffs tester +welcome to the yaffs tester +setting seed to 1288064149 +creating dir: /yaffs2/test_dir +created dir + + +joining paths:/yaffs2/test_dir and apple +joining paths:/yaffs2/test_dir and  +trying to open file: /yaffs2/test_dir/ +opened file +joining paths:/yaffs2/test_dir and  +trying to open file: /yaffs2/test_dir/ +opened file +joining paths:/yaffs2/test_dir and SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS +trying to open file: /yaffs2/test_dir/SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS +opened file +joining paths:/yaffs2/test_dir and &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +trying to open file: /yaffs2/test_dir/&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +opened file +joining paths:/yaffs2/test_dir and & +trying to open file: /yaffs2/test_dir/& +opened file +joining paths:/yaffs2/test_dir and ))))))))))))))))))))))))))))))))))))))))))) +trying to open file: /yaffs2/test_dir/))))))))))))))))))))))))))))))))))))))))))) +opened file +joining paths:/yaffs2/test_dir and ``````````````````````````````) +trying to open file: /yaffs2/test_dir/``````````````````````````````) +opened file +joining paths:/yaffs2/test_dir and bbbbbbbbbbbbbbb` +trying to open file: /yaffs2/test_dir/bbbbbbbbbbbbbbb` +opened file +joining paths:/yaffs2/test_dir and rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr +trying to open file: /yaffs2/test_dir/rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr +opened file +joining paths:/yaffs2/test_dir and TTTTTTTTTr +trying to open file: /yaffs2/test_dir/TTTTTTTTTr +opened file +joining paths:/yaffs2/test_dir and xxxxxxxxxxxxxr +trying to open file: /yaffs2/test_dir/xxxxxxxxxxxxxr +opened file +joining paths:/yaffs2/test_dir and r +trying to open file: /yaffs2/test_dir/ r +opened file +joining paths:/yaffs2/test_dir and 33333333333333333333 +trying to open file: /yaffs2/test_dir/33333333333333333333 +opened file +joining paths:/yaffs2/test_dir and =================3 +trying to open file: /yaffs2/test_dir/=================3 +opened file +joining paths:/yaffs2/test_dir and r +trying to open file: /yaffs2/test_dir/r +opened file +joining paths:/yaffs2/test_dir and <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +trying to open file: /yaffs2/test_dir/<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +opened file +joining paths:/yaffs2/test_dir and +trying to open file: /yaffs2/test_dir/ +opened file +joining paths:/yaffs2/test_dir and +trying to open file: /yaffs2/test_dir/ +opened file +joining paths:/yaffs2/test_dir and >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +trying to open file: /yaffs2/test_dir/>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +opened file +joining paths:/yaffs2/test_dir and > +trying to open file: /yaffs2/test_dir/> +opened file +joining paths:/yaffs2/test_dir and  +trying to open file: /yaffs2/test_dir/ +opened file +joining paths:/yaffs2/test_dir and yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy +trying to open file: /yaffs2/test_dir/yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy +opened file +joining paths:/yaffs2/test_dir and  +trying to open file: /yaffs2/test_dir/ +opened file +joining paths:/yaffs2/test_dir and  +trying to open file: /yaffs2/test_dir/  +opened file +joining paths:/yaffs2/test_dir and ppppppppppppppppppp +trying to open file: /yaffs2/test_dir/ppppppppppppppppppp +opened file +joining paths:/yaffs2/test_dir and jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj +trying to open file: /yaffs2/test_dir/jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj +opened file +joining paths:/yaffs2/test_dir and """""""j +trying to open file: /yaffs2/test_dir/"""""""j +opened file +joining paths:/yaffs2/test_dir and <<<<<<<<<<<<<<<<<<<<< + * + * 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. + */ + +/* + * message_buffer.c contains code for a message buffer . + */ + +#include "message_buffer.h" + +void append_to_buffer(buffer *p_Buffer, char *message,char message_level,char print){ + /*wrapper function for add_to_buffer_root_function*/ + add_to_buffer_root_function(p_Buffer,message, message_level,APPEND_MESSAGE,print); +} + +void add_to_buffer(buffer *p_Buffer, char *message,char message_level,char print){ + /*wrapper function for add_to_buffer_root_function*/ + add_to_buffer_root_function(p_Buffer,message, message_level,DO_NOT_APPEND_MESSAGE,print); +} + +void add_int_to_buffer(buffer *p_Buffer, int num,char message_level,char print){ + char message[20]; + sprintf(message, "%d",num); + add_to_buffer_root_function(p_Buffer,message, message_level,DO_NOT_APPEND_MESSAGE,print); +} + +void append_int_to_buffer(buffer *p_Buffer, int num,char message_level,char print){ + char message[20]; + sprintf(message, "%d",num); + add_to_buffer_root_function(p_Buffer,message, message_level,APPEND_MESSAGE,print); +} + + +void add_to_buffer_root_function(buffer *p_Buffer, char *message,char message_level,char append,char print){ + FILE *log_handle; + + if (append==APPEND_MESSAGE){ /* append current message*/ + strncat(p_Buffer->message[p_Buffer->head],message,BUFFER_MESSAGE_LENGTH); + } + else { + + /*move the head up one. the head always points at the last written data*/ + p_Buffer->head++; + + /*printf("p_Buffer->tail=%d\n",p_Buffer->tail);*/ + /*printf("p_Buffer->head=%d\n",p_Buffer->head);*/ + if (p_Buffer->head >=BUFFER_SIZE-1) { + /*printf("buffer overflow\n");*/ + p_Buffer->head -= (BUFFER_SIZE-1); /*wrap the head around the buffer*/ + /*printf("new p_Buffer->head=%d\n",p_Buffer->head);*/ + } + /*if the buffer is full then delete last entry by moving the tail*/ + if (p_Buffer->head==p_Buffer->tail){ + /*printf("moving buffer tail from %d to ",p_Buffer->tail);*/ + p_Buffer->tail++; + if (p_Buffer->tail >=BUFFER_SIZE) p_Buffer->tail -= BUFFER_SIZE;/*wrap the tail around the buffer*/ + /*printf("%d\n",p_Buffer->tail);*/ + + } + + p_Buffer->message_level[p_Buffer->head]=message_level; /*copy the message level*/ + strncpy(p_Buffer->message[p_Buffer->head],message,BUFFER_MESSAGE_LENGTH); /*copy the message*/ + /*printf("copied %s into p_Buffer->message[p_Buffer->head]: %s\n",message,p_Buffer->message[p_Buffer->head]); + printf("extra %s\n",p_Buffer->message[p_Buffer->head]);*/ + } + if ((p_Buffer->message_level[p_Buffer->head]<=DEBUG_LEVEL)&& (print==PRINT)){ + /*printf("printing buffer 1\n"); + // the print buffer function is not working this is just a quick fix + print_buffer(p_Buffer,1); //if the debug level is higher enough then print the new message + */ + printf("%s\n",p_Buffer->message[p_Buffer->head]); + log_handle=fopen(LOG_FILE,"a"); + if (log_handle!=NULL){ + fputs(p_Buffer->message[p_Buffer->head],log_handle); + fputs("\n",log_handle); + fclose(log_handle); + } + } +} + + + +void print_buffer(buffer *p_Buffer, int number_of_messages_to_print){ + int x=0; + int i=0; + printf("print buffer\n"); + printf("buffer head:%d\n",p_Buffer->head); + printf("buffer tail:%d\n",p_Buffer->tail); + + if (number_of_messages_to_print==PRINT_ALL) number_of_messages_to_print=BUFFER_SIZE; +// printf("number_of_messages_to_print=%d\n",number_of_messages_to_print); + for (i=0,x=0; (x>=p_Buffer->tail) && (imessage[p_Buffer->head]); + printf("printed buffer\n"); + } + +} + + + diff --git a/direct/timothy_tests/ENOENT_bug/message_buffer.h b/direct/timothy_tests/ENOENT_bug/message_buffer.h new file mode 100644 index 0000000..2f7984f --- /dev/null +++ b/direct/timothy_tests/ENOENT_bug/message_buffer.h @@ -0,0 +1,49 @@ +/* + * 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 + * + * 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 __message_buffer__ +#define __message_buffer__ + +#include +#include +#define PRINT 1 +#define NPRINT 0 +#define APPEND_MESSAGE 1 +#define DO_NOT_APPEND_MESSAGE 0 +#define PRINT_ALL -1 /*this is used to print all of the messages in a buffer*/ +#define BUFFER_MESSAGE_LENGTH 60 /*number of char in message*/ +#define BUFFER_SIZE 50 /*number of messages in buffer*/ +#define MESSAGE_LEVEL_ERROR 0 +#define MESSAGE_LEVEL_BASIC_TASKS 1 + +#define LOG_FILE "log.txt" +typedef struct buffer_template{ + char message[BUFFER_SIZE][BUFFER_MESSAGE_LENGTH]; + int head; + int tail; + char message_level[BUFFER_SIZE]; +}buffer; +#include "error_handler.h" /*include this for the debug level*/ + + +void print_buffer(buffer *p_Buffer,int number_of_messages_to_print); /*print messages in the buffer*/ +/*wrapper functions for add_to_buffer_root_function*/ +void add_to_buffer(buffer *p_Buffer, char *message,char message_level,char print); +void append_to_buffer(buffer *p_Buffer, char *message,char message_level,char print); +void add_int_to_buffer(buffer *p_Buffer, int num,char message_level,char print); +void append_int_to_buffer(buffer *p_Buffer, int num,char message_level,char print); + +void add_to_buffer_root_function(buffer *p_Buffer, char *message,char message_level,char append,char print); +#endif diff --git a/direct/timothy_tests/ENOENT_bug/yaffs_tester.c b/direct/timothy_tests/ENOENT_bug/yaffs_tester.c new file mode 100644 index 0000000..f87498c --- /dev/null +++ b/direct/timothy_tests/ENOENT_bug/yaffs_tester.c @@ -0,0 +1,193 @@ +/* + * 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 + * + * 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. + */ + +/* + * yaffs_tester.c designed to stress test yaffs2 direct. + */ + + +#include "yaffs_tester.h" + + + +int random_seed; +int simulate_power_failure = 0; + + +buffer message_buffer; /*create message_buffer */ + + + +int main(int argc, char *argv[]){ + char yaffs_test_dir[] ="/yaffs2/test_dir"; /*the path to the directory where all of the testing will take place*/ + char yaffs_mount_dir[]="/yaffs2/"; /*the path to the mount point which yaffs will mount*/ + + init(yaffs_test_dir,yaffs_mount_dir,argc,argv); + test(yaffs_test_dir); + yaffs_unmount(yaffs_mount_dir); + return 0; +} + + + +void init(char *yaffs_test_dir,char *yaffs_mount_dir,int argc, char *argv[]){ + char output=0; + int x=0; + int seed=-1; + FILE *log_handle; + /*these variables are already set to zero, but it is better not to take chances*/ + message_buffer.head=0; + message_buffer.tail=0; + + + log_handle=fopen(LOG_FILE,"w"); + if (log_handle!=NULL){ + fputs("log file for yaffs tester\n",log_handle); + fclose(log_handle); + } + add_to_buffer(&message_buffer,"welcome to the yaffs tester",MESSAGE_LEVEL_BASIC_TASKS,PRINT);/* print boot up message*/ + yaffs_start_up(); + yaffs_mount(yaffs_mount_dir); + for (x=0;x2 ; x++) + { + //printf("x=%d\n",x); + /* keep generating a charecter until the charecter is legal*/ + while((letter=='\0' )||(letter=='/')||(letter=='\\')){ + letter=(rand() % 126-32)+32; /*generate a number between 32 and 126 and uses it as a charecter (letter) */ + } + ptr[x]=letter; + //printf("charecter generated is %c\n",ptr[x]); + } + ptr[x+1]='\0'; /*adds NULL charecter to turn it into a string*/ + +} + diff --git a/direct/timothy_tests/ENOENT_bug/yaffs_tester.h b/direct/timothy_tests/ENOENT_bug/yaffs_tester.h new file mode 100644 index 0000000..30d5caa --- /dev/null +++ b/direct/timothy_tests/ENOENT_bug/yaffs_tester.h @@ -0,0 +1,36 @@ +/* + * 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 + * + * 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 __YAFFS_TESTER_H__ + #define __YAFFS_TESTER_H__ + +#include +#include +#include +#include + +#include "yaffsfs.h" /* it is in "yaffs2/direct/" link it in the Makefile */ +#include "message_buffer.h" +#include "error_handler.h" + + +#define MAX_FILE_NAME_SIZE 51 + +void init(char *yaffs_test_dir,char *yaffs_mount_dir,int argc, char *argv[]); /*sets up yaffs and mounts yaffs */ +void test(char *yaffs_test_dir); /*contains the test code*/ +void generate_random_string(char *ptr); /*generates a random string of letters to be used for a name*/ +void join_paths(char *path1,char *path2,char *newpath ); +void copy_array(char *from,char *to, unsigned int from_offset,unsigned int to_offset); +#endif diff --git a/direct/timothy_tests/dev/Makefile b/direct/timothy_tests/dev/Makefile index 82c9c37..672a33f 100644 --- a/direct/timothy_tests/dev/Makefile +++ b/direct/timothy_tests/dev/Makefile @@ -100,4 +100,4 @@ yaffs_tester: $(SYMLINKS) $(YAFFSTESTOBJS) clean: - rm -f yaffs_tester $(ALLOBJS) core $(SYMLINKS) + rm -f yaffs_tester $(ALLOBJS) core $(SYMLINKS) log.txt diff --git a/direct/timothy_tests/dev/error_handler.c b/direct/timothy_tests/dev/error_handler.c index 3474d01..d1670e6 100644 --- a/direct/timothy_tests/dev/error_handler.c +++ b/direct/timothy_tests/dev/error_handler.c @@ -16,21 +16,68 @@ */ #include "error_handler.h" -void yaffs_check_for_errors(char output, buffer *message_buffer,char error_message[],char success_message[]) + +typedef struct error_codes_template { + int code; + char * text; +}error_entry; + +const error_entry error_list[] = { + { ENOMEM , "ENOMEM" }, + { EBUSY , "EBUSY"}, + { ENODEV , "ENODEV"}, + { EINVAL , "EINVAL"}, + { EBADF , "EBADF"}, + { EACCES , "EACCES"}, + { EXDEV , "EXDEV" }, + { ENOENT , "ENOENT"}, + { ENOSPC , "ENOSPC"}, + { ERANGE , "ERANGE"}, + { ENODATA, "ENODATA"}, + { ENOTEMPTY, "ENOTEMPTY"}, + { ENAMETOOLONG,"ENAMETOOLONG"}, + { ENOMEM , "ENOMEM"}, + { EEXIST , "EEXIST"}, + { ENOTDIR , "ENOTDIR"}, + { EISDIR , "EISDIR"}, + { 0, NULL } +}; + +const char * error_to_str(int err) { - char dummy='0'; + error_entry *e = error_list; + if (err < 0) + err = -err; + while(e->code && e->text){ + if(err == e->code) + return e->text; + e++; + } + return "Unknown error code"; +} + +void yaffs_check_for_errors(char output, buffer *message_buffer,char error_message[],char success_message[]){ + char dummy[10]; + unsigned int x=0; + int yaffs_error=-1; + char error_found=0; if (output==-1) { add_to_buffer(message_buffer, "\nerror##########",MESSAGE_LEVEL_ERROR,PRINT); add_to_buffer(message_buffer, error_message,MESSAGE_LEVEL_ERROR,PRINT); add_to_buffer(message_buffer, "error_code: ",MESSAGE_LEVEL_ERROR,PRINT); - if (MESSAGE_LEVEL_ERROR<=DEBUG_LEVEL) printf("%d\n\n\n",yaffs_get_error()); /*cannot yet add int types to buffer. this is a quick fix*/ - scanf("%c",dummy); + yaffs_error=yaffs_get_error(); + if (MESSAGE_LEVEL_ERROR<=DEBUG_LEVEL) printf("%d\n",yaffs_error); /*cannot yet add int types to buffer. this is a quick fix*/ + add_to_buffer(message_buffer, error_to_str(yaffs_error),MESSAGE_LEVEL_ERROR,NPRINT); + append_to_buffer(message_buffer, "\n\n",MESSAGE_LEVEL_ERROR,PRINT); + + scanf("%c",dummy); /*this line causes a segmentation fault. Need a better way of waiting for a key press*/ //print_buffer(message_buffer,PRINT_ALL); } else{ add_to_buffer(message_buffer, success_message,MESSAGE_LEVEL_BASIC_TASKS,PRINT); - } - + } } + + diff --git a/direct/timothy_tests/dev/message_buffer.c b/direct/timothy_tests/dev/message_buffer.c index 5a5696e..1ff21e0 100644 --- a/direct/timothy_tests/dev/message_buffer.c +++ b/direct/timothy_tests/dev/message_buffer.c @@ -27,8 +27,22 @@ void add_to_buffer(buffer *p_Buffer, char *message,char message_level,char print add_to_buffer_root_function(p_Buffer,message, message_level,DO_NOT_APPEND_MESSAGE,print); } -void add_to_buffer_root_function(buffer *p_Buffer, char *message,char message_level,char append,char print){ +void add_int_to_buffer(buffer *p_Buffer, int num,char message_level,char print){ + char message[20]; + sprintf(message, "%d",num); + add_to_buffer_root_function(p_Buffer,message, message_level,DO_NOT_APPEND_MESSAGE,print); +} + +void append_int_to_buffer(buffer *p_Buffer, int num,char message_level,char print){ + char message[20]; + sprintf(message, "%d",num); + add_to_buffer_root_function(p_Buffer,message, message_level,APPEND_MESSAGE,print); +} + +void add_to_buffer_root_function(buffer *p_Buffer, char *message,char message_level,char append,char print){ + FILE *log_handle; + if (append==APPEND_MESSAGE){ /* append current message*/ strncat(p_Buffer->message[p_Buffer->head],message,BUFFER_MESSAGE_LENGTH); } @@ -64,6 +78,12 @@ void add_to_buffer_root_function(buffer *p_Buffer, char *message,char message_le print_buffer(p_Buffer,1); //if the debug level is higher enough then print the new message */ printf("%s\n",p_Buffer->message[p_Buffer->head]); + log_handle=fopen(LOG_FILE,"a"); + if (log_handle!=NULL){ + fputs(p_Buffer->message[p_Buffer->head],log_handle); + fputs("\n",log_handle); + fclose(log_handle); + } } } @@ -88,3 +108,5 @@ void print_buffer(buffer *p_Buffer, int number_of_messages_to_print){ } + + diff --git a/direct/timothy_tests/dev/message_buffer.h b/direct/timothy_tests/dev/message_buffer.h index eadddb7..2f7984f 100644 --- a/direct/timothy_tests/dev/message_buffer.h +++ b/direct/timothy_tests/dev/message_buffer.h @@ -27,6 +27,8 @@ #define BUFFER_SIZE 50 /*number of messages in buffer*/ #define MESSAGE_LEVEL_ERROR 0 #define MESSAGE_LEVEL_BASIC_TASKS 1 + +#define LOG_FILE "log.txt" typedef struct buffer_template{ char message[BUFFER_SIZE][BUFFER_MESSAGE_LENGTH]; int head; @@ -40,6 +42,8 @@ void print_buffer(buffer *p_Buffer,int number_of_messages_to_print); /*print me /*wrapper functions for add_to_buffer_root_function*/ void add_to_buffer(buffer *p_Buffer, char *message,char message_level,char print); void append_to_buffer(buffer *p_Buffer, char *message,char message_level,char print); +void add_int_to_buffer(buffer *p_Buffer, int num,char message_level,char print); +void append_int_to_buffer(buffer *p_Buffer, int num,char message_level,char print); void add_to_buffer_root_function(buffer *p_Buffer, char *message,char message_level,char append,char print); #endif diff --git a/direct/timothy_tests/dev/yaffs_tester.c b/direct/timothy_tests/dev/yaffs_tester.c index 3cab276..f87498c 100644 --- a/direct/timothy_tests/dev/yaffs_tester.c +++ b/direct/timothy_tests/dev/yaffs_tester.c @@ -28,28 +28,57 @@ buffer message_buffer; /*create message_buffer */ -int main(){ +int main(int argc, char *argv[]){ char yaffs_test_dir[] ="/yaffs2/test_dir"; /*the path to the directory where all of the testing will take place*/ char yaffs_mount_dir[]="/yaffs2/"; /*the path to the mount point which yaffs will mount*/ - init(yaffs_test_dir,yaffs_mount_dir); + init(yaffs_test_dir,yaffs_mount_dir,argc,argv); test(yaffs_test_dir); yaffs_unmount(yaffs_mount_dir); return 0; } -void init(char *yaffs_test_dir,char *yaffs_mount_dir){ + +void init(char *yaffs_test_dir,char *yaffs_mount_dir,int argc, char *argv[]){ char output=0; + int x=0; + int seed=-1; + FILE *log_handle; /*these variables are already set to zero, but it is better not to take chances*/ message_buffer.head=0; message_buffer.tail=0; - + + + log_handle=fopen(LOG_FILE,"w"); + if (log_handle!=NULL){ + fputs("log file for yaffs tester\n",log_handle); + fclose(log_handle); + } add_to_buffer(&message_buffer,"welcome to the yaffs tester",MESSAGE_LEVEL_BASIC_TASKS,PRINT);/* print boot up message*/ yaffs_start_up(); yaffs_mount(yaffs_mount_dir); + for (x=0;x #include - +#include +#include + #include "yaffsfs.h" /* it is in "yaffs2/direct/" link it in the Makefile */ #include "message_buffer.h" #include "error_handler.h" @@ -26,7 +28,7 @@ #define MAX_FILE_NAME_SIZE 51 -void init(char *yaffs_test_dir,char *yaffs_mount_dir); /*sets up yaffs and mounts yaffs */ +void init(char *yaffs_test_dir,char *yaffs_mount_dir,int argc, char *argv[]); /*sets up yaffs and mounts yaffs */ void test(char *yaffs_test_dir); /*contains the test code*/ void generate_random_string(char *ptr); /*generates a random string of letters to be used for a name*/ void join_paths(char *path1,char *path2,char *newpath ); diff --git a/direct/timothy_tests/dev/found_bugs.txt b/direct/timothy_tests/found_bugs.txt similarity index 66% rename from direct/timothy_tests/dev/found_bugs.txt rename to direct/timothy_tests/found_bugs.txt index 418f1dc..b64403e 100644 --- a/direct/timothy_tests/dev/found_bugs.txt +++ b/direct/timothy_tests/found_bugs.txt @@ -4,3 +4,6 @@ Error code 0 bug (run out of handles) By opening lots of files and not closing them yaffs can run out of handles. The error code given by yaffs_get_error() returns 0. this error is not defined in yportenv.h +ENOENT error when opening a new file with O_CREATE + remove the emfile and use seed 1288064149 to generate this error. + diff --git a/direct/timothy_tests/mkdir_with_slash_error/Makefile b/direct/timothy_tests/mkdir_with_slash_error/Makefile new file mode 100644 index 0000000..672a33f --- /dev/null +++ b/direct/timothy_tests/mkdir_with_slash_error/Makefile @@ -0,0 +1,103 @@ +# Makefile for YAFFS direct stress tests +# +# +# YAFFS: Yet another Flash File System. A NAND-flash specific file system. +# +# Copyright (C) 2003-2010 Aleph One Ltd. +# +# +# Created by Charles Manning +# +# 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. +# +# NB Warning this Makefile does not include header dependencies. +# +# $Id: Makefile,v 1.7 2010-02-25 22:34:47 charles Exp $ + +#EXTRA_COMPILE_FLAGS = -DYAFFS_IGNORE_TAGS_ECC + +CFLAGS = -DCONFIG_YAFFS_DIRECT -DCONFIG_YAFFS_SHORT_NAMES_IN_RAM -DCONFIG_YAFFS_YAFFS2 +CFLAGS += -DCONFIG_YAFFS_PROVIDE_DEFS -DCONFIG_YAFFSFS_PROVIDE_VALUES +CFLAGS += -Wall -g $(EXTRA_COMPILE_FLAGS) -Wstrict-aliasing +#CFLAGS += -fno-strict-aliasing +CFLAGS += -O0 +CFLAGS += -Wextra -Wpointer-arith +#CFLAGS += -DCONFIG_YAFFS_VALGRIND_TEST + +#CFLAGS+= -Wshadow -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Wmissing-declarations +#CFLAGS+= -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Winline + + +COMMONTESTOBJS = yaffscfg2k.o yaffs_ecc.o yaffs_fileem.o yaffs_fileem2k.o yaffsfs.o yaffs_guts.o \ + yaffs_packedtags1.o yaffs_ramdisk.o yaffs_ramem2k.o \ + yaffs_tagscompat.o yaffs_packedtags2.o yaffs_tagsvalidity.o yaffs_nand.o \ + yaffs_checkptrw.o yaffs_qsort.o\ + yaffs_nameval.o \ + yaffs_norif1.o ynorsim.o \ + yaffs_allocator.o \ + yaffs_bitmap.o \ + yaffs_yaffs1.o \ + yaffs_yaffs2.o \ + yaffs_verify.o + +# yaffs_checkptrwtest.o\ + +YAFFSTESTOBJS = $(COMMONTESTOBJS) yaffs_tester.o message_buffer.o error_handler.o + + +ALLOBJS = $(sort $(YAFFSTESTOBJS)) + +YAFFSSYMLINKS = devextras.h yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffsinterface.h yportenv.h yaffs_tagscompat.c yaffs_tagscompat.h \ + yaffs_packedtags1.c yaffs_packedtags1.h yaffs_packedtags2.c yaffs_packedtags2.h yaffs_nandemul2k.h \ + yaffs_nand.c yaffs_nand.h yaffs_getblockinfo.h yaffs_list.h \ + yaffs_tagsvalidity.c yaffs_tagsvalidity.h yaffs_checkptrw.h yaffs_checkptrw.c \ + yaffs_nameval.c yaffs_nameval.h \ + yaffs_qsort.c yaffs_qsort.h yaffs_trace.h \ + yaffs_allocator.c yaffs_allocator.h \ + yaffs_yaffs1.c yaffs_yaffs1.h \ + yaffs_yaffs2.c yaffs_yaffs2.h \ + yaffs_bitmap.c yaffs_bitmap.h \ + yaffs_verify.c yaffs_verify.h + +YAFFSDIRECTSYMLINKS = yaffsfs.c yaffs_flashif.h yaffs_flashif2.h\ + yaffsfs.h yaffs_malloc.h ydirectenv.h \ + yaffs_flashif.c yaffscfg.h \ + yaffs_nandif.c yaffs_nandif.h + + +DIRECTEXTRASYMLINKS = yaffscfg2k.c yaffs_fileem2k.c yaffs_fileem2k.h\ + yaffs_fileem.c yaffs_norif1.c yaffs_norif1.h \ + yaffs_ramdisk.c yaffs_ramdisk.h yaffs_ramem2k.c \ + ynorsim.h ynorsim.c + +SYMLINKS = $(YAFFSSYMLINKS) $(YAFFSDIRECTSYMLINKS) $(DIRECTEXTRASYMLINKS) +#all: directtest2k boottest + +all: yaffs_tester + +$(ALLOBJS): %.o: %.c + gcc -c $(CFLAGS) -o $@ $< + + +$(YAFFSSYMLINKS): + ln -s ../../../$@ $@ + +$(YAFFSDIRECTSYMLINKS): + ln -s ../../$@ $@ + +$(DIRECTEXTRASYMLINKS): + ln -s ../../basic-test/$@ $@ + + +yaffs_tester: $(SYMLINKS) $(YAFFSTESTOBJS) + gcc $(CFLLAG) -o $@ $(YAFFSTESTOBJS) + + + + + + +clean: + rm -f yaffs_tester $(ALLOBJS) core $(SYMLINKS) log.txt diff --git a/direct/timothy_tests/mkdir_with_slash_error/README.txt b/direct/timothy_tests/mkdir_with_slash_error/README.txt new file mode 100644 index 0000000..3b6e46e --- /dev/null +++ b/direct/timothy_tests/mkdir_with_slash_error/README.txt @@ -0,0 +1,12 @@ +Yaffs bug + +Yaffs' mkdir function will not work if the path ends in a slash. +i.e. /yaffs2/new_dir/ +This bug is known and is not likely to be fixed. +To get around this bug remove the slash on the end. +i.e. /yaffs2/new_dir + +Running the program with any seed will work. +./yaffs_tester + + diff --git a/direct/timothy_tests/mkdir_with_slash_error/error_handler.c b/direct/timothy_tests/mkdir_with_slash_error/error_handler.c new file mode 100644 index 0000000..d1670e6 --- /dev/null +++ b/direct/timothy_tests/mkdir_with_slash_error/error_handler.c @@ -0,0 +1,83 @@ +/* + * 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 + * + * 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. + */ + +/* + * error_handler.c contains code for checking yaffs function calls for errors. + */ +#include "error_handler.h" + + +typedef struct error_codes_template { + int code; + char * text; +}error_entry; + +const error_entry error_list[] = { + { ENOMEM , "ENOMEM" }, + { EBUSY , "EBUSY"}, + { ENODEV , "ENODEV"}, + { EINVAL , "EINVAL"}, + { EBADF , "EBADF"}, + { EACCES , "EACCES"}, + { EXDEV , "EXDEV" }, + { ENOENT , "ENOENT"}, + { ENOSPC , "ENOSPC"}, + { ERANGE , "ERANGE"}, + { ENODATA, "ENODATA"}, + { ENOTEMPTY, "ENOTEMPTY"}, + { ENAMETOOLONG,"ENAMETOOLONG"}, + { ENOMEM , "ENOMEM"}, + { EEXIST , "EEXIST"}, + { ENOTDIR , "ENOTDIR"}, + { EISDIR , "EISDIR"}, + { 0, NULL } +}; + +const char * error_to_str(int err) +{ + error_entry *e = error_list; + if (err < 0) + err = -err; + while(e->code && e->text){ + if(err == e->code) + return e->text; + e++; + } + return "Unknown error code"; +} + +void yaffs_check_for_errors(char output, buffer *message_buffer,char error_message[],char success_message[]){ + char dummy[10]; + unsigned int x=0; + int yaffs_error=-1; + char error_found=0; + if (output==-1) + { + add_to_buffer(message_buffer, "\nerror##########",MESSAGE_LEVEL_ERROR,PRINT); + add_to_buffer(message_buffer, error_message,MESSAGE_LEVEL_ERROR,PRINT); + add_to_buffer(message_buffer, "error_code: ",MESSAGE_LEVEL_ERROR,PRINT); + yaffs_error=yaffs_get_error(); + if (MESSAGE_LEVEL_ERROR<=DEBUG_LEVEL) printf("%d\n",yaffs_error); /*cannot yet add int types to buffer. this is a quick fix*/ + add_to_buffer(message_buffer, error_to_str(yaffs_error),MESSAGE_LEVEL_ERROR,NPRINT); + append_to_buffer(message_buffer, "\n\n",MESSAGE_LEVEL_ERROR,PRINT); + + scanf("%c",dummy); /*this line causes a segmentation fault. Need a better way of waiting for a key press*/ + //print_buffer(message_buffer,PRINT_ALL); + + } + else{ + add_to_buffer(message_buffer, success_message,MESSAGE_LEVEL_BASIC_TASKS,PRINT); + } +} + + diff --git a/direct/timothy_tests/mkdir_with_slash_error/error_handler.h b/direct/timothy_tests/mkdir_with_slash_error/error_handler.h new file mode 100644 index 0000000..c07fdff --- /dev/null +++ b/direct/timothy_tests/mkdir_with_slash_error/error_handler.h @@ -0,0 +1,23 @@ +/* + * 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 + * + * 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 __error_handler_h__ +#define __error_handler_h__ +#include +#include "message_buffer.h" +#include "yaffsfs.h" +#define DEBUG_LEVEL 5 /*set the debug level. this is used to display the relevent debug messages*/ +void yaffs_check_for_errors(char output, buffer *message_buffer, char error_message[], char success_message[]); +#endif diff --git a/direct/timothy_tests/mkdir_with_slash_error/message_buffer.c b/direct/timothy_tests/mkdir_with_slash_error/message_buffer.c new file mode 100644 index 0000000..1ff21e0 --- /dev/null +++ b/direct/timothy_tests/mkdir_with_slash_error/message_buffer.c @@ -0,0 +1,112 @@ +/* + * 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 + * + * 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. + */ + +/* + * message_buffer.c contains code for a message buffer . + */ + +#include "message_buffer.h" + +void append_to_buffer(buffer *p_Buffer, char *message,char message_level,char print){ + /*wrapper function for add_to_buffer_root_function*/ + add_to_buffer_root_function(p_Buffer,message, message_level,APPEND_MESSAGE,print); +} + +void add_to_buffer(buffer *p_Buffer, char *message,char message_level,char print){ + /*wrapper function for add_to_buffer_root_function*/ + add_to_buffer_root_function(p_Buffer,message, message_level,DO_NOT_APPEND_MESSAGE,print); +} + +void add_int_to_buffer(buffer *p_Buffer, int num,char message_level,char print){ + char message[20]; + sprintf(message, "%d",num); + add_to_buffer_root_function(p_Buffer,message, message_level,DO_NOT_APPEND_MESSAGE,print); +} + +void append_int_to_buffer(buffer *p_Buffer, int num,char message_level,char print){ + char message[20]; + sprintf(message, "%d",num); + add_to_buffer_root_function(p_Buffer,message, message_level,APPEND_MESSAGE,print); +} + + +void add_to_buffer_root_function(buffer *p_Buffer, char *message,char message_level,char append,char print){ + FILE *log_handle; + + if (append==APPEND_MESSAGE){ /* append current message*/ + strncat(p_Buffer->message[p_Buffer->head],message,BUFFER_MESSAGE_LENGTH); + } + else { + + /*move the head up one. the head always points at the last written data*/ + p_Buffer->head++; + + /*printf("p_Buffer->tail=%d\n",p_Buffer->tail);*/ + /*printf("p_Buffer->head=%d\n",p_Buffer->head);*/ + if (p_Buffer->head >=BUFFER_SIZE-1) { + /*printf("buffer overflow\n");*/ + p_Buffer->head -= (BUFFER_SIZE-1); /*wrap the head around the buffer*/ + /*printf("new p_Buffer->head=%d\n",p_Buffer->head);*/ + } + /*if the buffer is full then delete last entry by moving the tail*/ + if (p_Buffer->head==p_Buffer->tail){ + /*printf("moving buffer tail from %d to ",p_Buffer->tail);*/ + p_Buffer->tail++; + if (p_Buffer->tail >=BUFFER_SIZE) p_Buffer->tail -= BUFFER_SIZE;/*wrap the tail around the buffer*/ + /*printf("%d\n",p_Buffer->tail);*/ + + } + + p_Buffer->message_level[p_Buffer->head]=message_level; /*copy the message level*/ + strncpy(p_Buffer->message[p_Buffer->head],message,BUFFER_MESSAGE_LENGTH); /*copy the message*/ + /*printf("copied %s into p_Buffer->message[p_Buffer->head]: %s\n",message,p_Buffer->message[p_Buffer->head]); + printf("extra %s\n",p_Buffer->message[p_Buffer->head]);*/ + } + if ((p_Buffer->message_level[p_Buffer->head]<=DEBUG_LEVEL)&& (print==PRINT)){ + /*printf("printing buffer 1\n"); + // the print buffer function is not working this is just a quick fix + print_buffer(p_Buffer,1); //if the debug level is higher enough then print the new message + */ + printf("%s\n",p_Buffer->message[p_Buffer->head]); + log_handle=fopen(LOG_FILE,"a"); + if (log_handle!=NULL){ + fputs(p_Buffer->message[p_Buffer->head],log_handle); + fputs("\n",log_handle); + fclose(log_handle); + } + } +} + + + +void print_buffer(buffer *p_Buffer, int number_of_messages_to_print){ + int x=0; + int i=0; + printf("print buffer\n"); + printf("buffer head:%d\n",p_Buffer->head); + printf("buffer tail:%d\n",p_Buffer->tail); + + if (number_of_messages_to_print==PRINT_ALL) number_of_messages_to_print=BUFFER_SIZE; +// printf("number_of_messages_to_print=%d\n",number_of_messages_to_print); + for (i=0,x=0; (x>=p_Buffer->tail) && (imessage[p_Buffer->head]); + printf("printed buffer\n"); + } + +} + + + diff --git a/direct/timothy_tests/mkdir_with_slash_error/message_buffer.h b/direct/timothy_tests/mkdir_with_slash_error/message_buffer.h new file mode 100644 index 0000000..2f7984f --- /dev/null +++ b/direct/timothy_tests/mkdir_with_slash_error/message_buffer.h @@ -0,0 +1,49 @@ +/* + * 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 + * + * 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 __message_buffer__ +#define __message_buffer__ + +#include +#include +#define PRINT 1 +#define NPRINT 0 +#define APPEND_MESSAGE 1 +#define DO_NOT_APPEND_MESSAGE 0 +#define PRINT_ALL -1 /*this is used to print all of the messages in a buffer*/ +#define BUFFER_MESSAGE_LENGTH 60 /*number of char in message*/ +#define BUFFER_SIZE 50 /*number of messages in buffer*/ +#define MESSAGE_LEVEL_ERROR 0 +#define MESSAGE_LEVEL_BASIC_TASKS 1 + +#define LOG_FILE "log.txt" +typedef struct buffer_template{ + char message[BUFFER_SIZE][BUFFER_MESSAGE_LENGTH]; + int head; + int tail; + char message_level[BUFFER_SIZE]; +}buffer; +#include "error_handler.h" /*include this for the debug level*/ + + +void print_buffer(buffer *p_Buffer,int number_of_messages_to_print); /*print messages in the buffer*/ +/*wrapper functions for add_to_buffer_root_function*/ +void add_to_buffer(buffer *p_Buffer, char *message,char message_level,char print); +void append_to_buffer(buffer *p_Buffer, char *message,char message_level,char print); +void add_int_to_buffer(buffer *p_Buffer, int num,char message_level,char print); +void append_int_to_buffer(buffer *p_Buffer, int num,char message_level,char print); + +void add_to_buffer_root_function(buffer *p_Buffer, char *message,char message_level,char append,char print); +#endif diff --git a/direct/timothy_tests/mkdir_with_slash_error/yaffs_tester.c b/direct/timothy_tests/mkdir_with_slash_error/yaffs_tester.c new file mode 100644 index 0000000..4be10df --- /dev/null +++ b/direct/timothy_tests/mkdir_with_slash_error/yaffs_tester.c @@ -0,0 +1,193 @@ +/* + * 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 + * + * 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. + */ + +/* + * yaffs_tester.c designed to stress test yaffs2 direct. + */ + + +#include "yaffs_tester.h" + + + +int random_seed; +int simulate_power_failure = 0; + + +buffer message_buffer; /*create message_buffer */ + + + +int main(int argc, char *argv[]){ + char yaffs_test_dir[] ="/yaffs2/test_dir/"; /*the path to the directory where all of the testing will take place*/ + char yaffs_mount_dir[]="/yaffs2/"; /*the path to the mount point which yaffs will mount*/ + + init(yaffs_test_dir,yaffs_mount_dir,argc,argv); + test(yaffs_test_dir); + yaffs_unmount(yaffs_mount_dir); + return 0; +} + + + +void init(char *yaffs_test_dir,char *yaffs_mount_dir,int argc, char *argv[]){ + char output=0; + int x=0; + int seed=-1; + FILE *log_handle; + /*these variables are already set to zero, but it is better not to take chances*/ + message_buffer.head=0; + message_buffer.tail=0; + + + log_handle=fopen(LOG_FILE,"w"); + if (log_handle!=NULL){ + fputs("log file for yaffs tester\n",log_handle); + fclose(log_handle); + } + add_to_buffer(&message_buffer,"welcome to the yaffs tester",MESSAGE_LEVEL_BASIC_TASKS,PRINT);/* print boot up message*/ + yaffs_start_up(); + yaffs_mount(yaffs_mount_dir); + for (x=0;x2 ; x++) + { + //printf("x=%d\n",x); + /* keep generating a charecter until the charecter is legal*/ + while((letter=='\0' )||(letter=='/')||(letter=='\\')){ + letter=(rand() % 126-32)+32; /*generate a number between 32 and 126 and uses it as a charecter (letter) */ + } + ptr[x]=letter; + //printf("charecter generated is %c\n",ptr[x]); + } + ptr[x+1]='\0'; /*adds NULL charecter to turn it into a string*/ + +} + diff --git a/direct/timothy_tests/mkdir_with_slash_error/yaffs_tester.h b/direct/timothy_tests/mkdir_with_slash_error/yaffs_tester.h new file mode 100644 index 0000000..30d5caa --- /dev/null +++ b/direct/timothy_tests/mkdir_with_slash_error/yaffs_tester.h @@ -0,0 +1,36 @@ +/* + * 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 + * + * 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 __YAFFS_TESTER_H__ + #define __YAFFS_TESTER_H__ + +#include +#include +#include +#include + +#include "yaffsfs.h" /* it is in "yaffs2/direct/" link it in the Makefile */ +#include "message_buffer.h" +#include "error_handler.h" + + +#define MAX_FILE_NAME_SIZE 51 + +void init(char *yaffs_test_dir,char *yaffs_mount_dir,int argc, char *argv[]); /*sets up yaffs and mounts yaffs */ +void test(char *yaffs_test_dir); /*contains the test code*/ +void generate_random_string(char *ptr); /*generates a random string of letters to be used for a name*/ +void join_paths(char *path1,char *path2,char *newpath ); +void copy_array(char *from,char *to, unsigned int from_offset,unsigned int to_offset); +#endif diff --git a/direct/timothy_tests/running_out_of_handles_error/Makefile b/direct/timothy_tests/running_out_of_handles_error/Makefile index 82c9c37..672a33f 100644 --- a/direct/timothy_tests/running_out_of_handles_error/Makefile +++ b/direct/timothy_tests/running_out_of_handles_error/Makefile @@ -100,4 +100,4 @@ yaffs_tester: $(SYMLINKS) $(YAFFSTESTOBJS) clean: - rm -f yaffs_tester $(ALLOBJS) core $(SYMLINKS) + rm -f yaffs_tester $(ALLOBJS) core $(SYMLINKS) log.txt diff --git a/direct/timothy_tests/running_out_of_handles_error/README.txt b/direct/timothy_tests/running_out_of_handles_error/README.txt index 453feb3..d88b261 100644 --- a/direct/timothy_tests/running_out_of_handles_error/README.txt +++ b/direct/timothy_tests/running_out_of_handles_error/README.txt @@ -2,5 +2,9 @@ This directory "freezes" the yaffs_tester programs in the state in which they pr This yaffs_tester testes the bug "error code 0, when yaffs has run out of handles" the yaffs_tester program may crash with another error before running out of handles. -To fix this make clean the to reseed the rand function producing random names. +To fix this use remove the emkfile and use the seed 1288065181 +./yaffs_tester -seed 1288065181 + + +for more information on this bug see the error.txt file diff --git a/direct/timothy_tests/running_out_of_handles_error/error.txt b/direct/timothy_tests/running_out_of_handles_error/error.txt new file mode 100644 index 0000000..bb3b23e --- /dev/null +++ b/direct/timothy_tests/running_out_of_handles_error/error.txt @@ -0,0 +1,313 @@ +log file for yaffs tester +welcome to the yaffs tester +setting seed to 1288065181 +joining paths:/yaffs2/test_dir and apple +joining paths:/yaffs2/test_dir and ,,,,,,,, +trying to open file: /yaffs2/test_dir/,,,,,,,, +opened file +joining paths:/yaffs2/test_dir and 3333, +trying to open file: /yaffs2/test_dir/3333, +opened file +joining paths:/yaffs2/test_dir and qqqqqqqqqqqqqqqqqqqqqqqqqqq +trying to open file: /yaffs2/test_dir/qqqqqqqqqqqqqqqqqqqqqqqqqqq +opened file +joining paths:/yaffs2/test_dir and }}}}}}}}}}}}}}}}}}}}}}q +trying to open file: /yaffs2/test_dir/}}}}}}}}}}}}}}}}}}}}}}q +opened file +joining paths:/yaffs2/test_dir and +trying to open file: /yaffs2/test_dir/ +opened file +joining paths:/yaffs2/test_dir and +trying to open file: /yaffs2/test_dir/ +opened file +joining paths:/yaffs2/test_dir and 22222222222 +trying to open file: /yaffs2/test_dir/22222222222 +opened file +joining paths:/yaffs2/test_dir and zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz +trying to open file: /yaffs2/test_dir/zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz +opened file +joining paths:/yaffs2/test_dir and LLLLLLLLLLLLLLLLLLLLLLLLLLLLLL +trying to open file: /yaffs2/test_dir/LLLLLLLLLLLLLLLLLLLLLLLLLLLLLL +opened file +joining paths:/yaffs2/test_dir and  +trying to open file: /yaffs2/test_dir/ +opened file +joining paths:/yaffs2/test_dir and  +trying to open file: /yaffs2/test_dir/ +opened file +joining paths:/yaffs2/test_dir and %%%%%%%%% +trying to open file: /yaffs2/test_dir/%%%%%%%%% +opened file +joining paths:/yaffs2/test_dir and WWWWWWWWWWWWWWWW +trying to open file: /yaffs2/test_dir/WWWWWWWWWWWWWWWW +opened file +joining paths:/yaffs2/test_dir and mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm +trying to open file: /yaffs2/test_dir/mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm +opened file +joining paths:/yaffs2/test_dir and nnnnnnnnm +trying to open file: /yaffs2/test_dir/nnnnnnnnm +opened file +joining paths:/yaffs2/test_dir and bbbbbbbbbbbbbbbbbbbbbbbbbbbm +trying to open file: /yaffs2/test_dir/bbbbbbbbbbbbbbbbbbbbbbbbbbbm +opened file +joining paths:/yaffs2/test_dir and ffffffffffffffb +trying to open file: /yaffs2/test_dir/ffffffffffffffb +opened file +joining paths:/yaffs2/test_dir and f +trying to open file: /yaffs2/test_dir/f +opened file +joining paths:/yaffs2/test_dir and 22222222222222b +trying to open file: /yaffs2/test_dir/22222222222222b +opened file +joining paths:/yaffs2/test_dir and IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIm +trying to open file: /yaffs2/test_dir/IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIm +opened file +joining paths:/yaffs2/test_dir and yyyyyyyyyyI +trying to open file: /yaffs2/test_dir/yyyyyyyyyyI +opened file +joining paths:/yaffs2/test_dir and KKKKKKy +trying to open file: /yaffs2/test_dir/KKKKKKy +opened file +joining paths:/yaffs2/test_dir and vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvI +trying to open file: /yaffs2/test_dir/vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvI +opened file +joining paths:/yaffs2/test_dir and +++++++++++++++++++++++++++++++++m +trying to open file: /yaffs2/test_dir/+++++++++++++++++++++++++++++++++m +opened file +joining paths:/yaffs2/test_dir and YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY +trying to open file: /yaffs2/test_dir/YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY +opened file +joining paths:/yaffs2/test_dir and 2222222222222222222222222222222222222222222222Y +trying to open file: /yaffs2/test_dir/2222222222222222222222222222222222222222222 +opened file +joining paths:/yaffs2/test_dir and UUUUUUUUUUUUUUUUUUU2 +trying to open file: /yaffs2/test_dir/UUUUUUUUUUUUUUUUUUU2 +opened file +joining paths:/yaffs2/test_dir and U +trying to open file: /yaffs2/test_dir/U +opened file +joining paths:/yaffs2/test_dir and 2 +trying to open file: /yaffs2/test_dir/2 +opened file +joining paths:/yaffs2/test_dir and IIIIIIIIIIIIIIIIIIIII +trying to open file: /yaffs2/test_dir/IIIIIIIIIIIIIIIIIIIII +opened file +joining paths:/yaffs2/test_dir and AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +trying to open file: /yaffs2/test_dir/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA +opened file +joining paths:/yaffs2/test_dir and A +trying to open file: /yaffs2/test_dir/A +opened file +joining paths:/yaffs2/test_dir and +trying to open file: /yaffs2/test_dir/ +opened file +joining paths:/yaffs2/test_dir and VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV +trying to open file: /yaffs2/test_dir/VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV +opened file +joining paths:/yaffs2/test_dir and XXXXXXXXXXXXXXV +trying to open file: /yaffs2/test_dir/XXXXXXXXXXXXXXV +opened file +joining paths:/yaffs2/test_dir and HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHV +trying to open file: /yaffs2/test_dir/HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH +opened file +joining paths:/yaffs2/test_dir and DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDH +trying to open file: /yaffs2/test_dir/DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDH +opened file +joining paths:/yaffs2/test_dir and -------------------------------------D +trying to open file: /yaffs2/test_dir/-------------------------------------D +opened file +joining paths:/yaffs2/test_dir and rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrD +trying to open file: /yaffs2/test_dir/rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrD +opened file +joining paths:/yaffs2/test_dir and pppppppppr +trying to open file: /yaffs2/test_dir/pppppppppr +opened file +joining paths:/yaffs2/test_dir and |||||||||||||||||||||||||r +trying to open file: /yaffs2/test_dir/|||||||||||||||||||||||||r +opened file +joining paths:/yaffs2/test_dir and r +trying to open file: /yaffs2/test_dir/r +opened file +joining paths:/yaffs2/test_dir and MM +trying to open file: /yaffs2/test_dir/MM +opened file +joining paths:/yaffs2/test_dir and +trying to open file: /yaffs2/test_dir/ +opened file +joining paths:/yaffs2/test_dir and ppppppppp +trying to open file: /yaffs2/test_dir/ppppppppp +opened file +joining paths:/yaffs2/test_dir and ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +trying to open file: /yaffs2/test_dir/;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +opened file +joining paths:/yaffs2/test_dir and 55555; +trying to open file: /yaffs2/test_dir/55555; +opened file +joining paths:/yaffs2/test_dir and *******************************************H +trying to open file: /yaffs2/test_dir/******************************************* +opened file +joining paths:/yaffs2/test_dir and @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@* +trying to open file: /yaffs2/test_dir/@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@* +opened file +joining paths:/yaffs2/test_dir and fffffffffffffffffffffffff@ +trying to open file: /yaffs2/test_dir/fffffffffffffffffffffffff@ +opened file +joining paths:/yaffs2/test_dir and #############################@ +trying to open file: /yaffs2/test_dir/#############################@ +opened file +joining paths:/yaffs2/test_dir and YYYYYYYYYYYYYYYYYYY# +trying to open file: /yaffs2/test_dir/YYYYYYYYYYYYYYYYYYY# +opened file +joining paths:/yaffs2/test_dir and 8888888888888888888888888888888888 +trying to open file: /yaffs2/test_dir/8888888888888888888888888888888888 +opened file +joining paths:/yaffs2/test_dir and * +trying to open file: /yaffs2/test_dir/* +opened file +joining paths:/yaffs2/test_dir and  +trying to open file: /yaffs2/test_dir/  +opened file +joining paths:/yaffs2/test_dir and %%%%%%%%%%%%%%%%%%%%%%%% +trying to open file: /yaffs2/test_dir/%%%%%%%%%%%%%%%%%%%%%%%% +opened file +joining paths:/yaffs2/test_dir and % +trying to open file: /yaffs2/test_dir/% +opened file +joining paths:/yaffs2/test_dir and llllllllllllllllllllllllllllllllllllllllll* +trying to open file: /yaffs2/test_dir/llllllllllllllllllllllllllllllllllllllllll* +opened file +joining paths:/yaffs2/test_dir and ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] +trying to open file: /yaffs2/test_dir/]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] +opened file +joining paths:/yaffs2/test_dir and ] +trying to open file: /yaffs2/test_dir/] +opened file +joining paths:/yaffs2/test_dir and ] +trying to open file: /yaffs2/test_dir/] +opened file +joining paths:/yaffs2/test_dir and ] +trying to open file: /yaffs2/test_dir/] +opened file +joining paths:/yaffs2/test_dir and JJJ] +trying to open file: /yaffs2/test_dir/JJJ] +opened file +joining paths:/yaffs2/test_dir and DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD] +trying to open file: /yaffs2/test_dir/DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD] +opened file +joining paths:/yaffs2/test_dir and [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[] +trying to open file: /yaffs2/test_dir/[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ +opened file +joining paths:/yaffs2/test_dir and $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$[ +trying to open file: /yaffs2/test_dir/$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$[ +opened file +joining paths:/yaffs2/test_dir and 99999999999999999$ +trying to open file: /yaffs2/test_dir/99999999999999999$ +opened file +joining paths:/yaffs2/test_dir and [ +trying to open file: /yaffs2/test_dir/ [ +opened file +joining paths:/yaffs2/test_dir and YYYYYYYYYYYYYYY +trying to open file: /yaffs2/test_dir/YYYYYYYYYYYYYYY +opened file +joining paths:/yaffs2/test_dir and aaaaaaaaaaaaaaaaaaaaaaaa +trying to open file: /yaffs2/test_dir/aaaaaaaaaaaaaaaaaaaaaaaa +opened file +joining paths:/yaffs2/test_dir and &&&&&&&&&&&&&&&&&&&&&&&& +trying to open file: /yaffs2/test_dir/&&&&&&&&&&&&&&&&&&&&&&&& +opened file +joining paths:/yaffs2/test_dir and >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +trying to open file: /yaffs2/test_dir/>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +opened file +joining paths:/yaffs2/test_dir and BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB[ +trying to open file: /yaffs2/test_dir/BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB +opened file +joining paths:/yaffs2/test_dir and  +trying to open file: /yaffs2/test_dir/ +opened file +joining paths:/yaffs2/test_dir and ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +trying to open file: /yaffs2/test_dir/,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +opened file +joining paths:/yaffs2/test_dir and ===================================, +trying to open file: /yaffs2/test_dir/===================================, +opened file +joining paths:/yaffs2/test_dir and hhhhhh= +trying to open file: /yaffs2/test_dir/hhhhhh= +opened file +joining paths:/yaffs2/test_dir and h +trying to open file: /yaffs2/test_dir/h +opened file +joining paths:/yaffs2/test_dir and CCCCCCCC= +trying to open file: /yaffs2/test_dir/CCCCCCCC= +opened file +joining paths:/yaffs2/test_dir and 9999C +trying to open file: /yaffs2/test_dir/9999C +opened file +joining paths:/yaffs2/test_dir and qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq= +trying to open file: /yaffs2/test_dir/qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq= +opened file +joining paths:/yaffs2/test_dir and YYYYYYYYYYYq +trying to open file: /yaffs2/test_dir/YYYYYYYYYYYq +opened file +joining paths:/yaffs2/test_dir and AAAAAAAAAAAAAq +trying to open file: /yaffs2/test_dir/AAAAAAAAAAAAAq +opened file +joining paths:/yaffs2/test_dir and ddddddddddddddddddddddddddddddddddddddddd +trying to open file: /yaffs2/test_dir/ddddddddddddddddddddddddddddddddddddddddd +opened file +joining paths:/yaffs2/test_dir and [[[[[[[[[[[[[[[[[[[d +trying to open file: /yaffs2/test_dir/[[[[[[[[[[[[[[[[[[[d +opened file +joining paths:/yaffs2/test_dir and BBBBBBBBBBBBB[ +trying to open file: /yaffs2/test_dir/BBBBBBBBBBBBB[ +opened file +joining paths:/yaffs2/test_dir and 99999999999999999999999999999999d +trying to open file: /yaffs2/test_dir/99999999999999999999999999999999d +opened file +joining paths:/yaffs2/test_dir and >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>d +trying to open file: /yaffs2/test_dir/>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>d +opened file +joining paths:/yaffs2/test_dir and {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ +trying to open file: /yaffs2/test_dir/{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ +opened file +joining paths:/yaffs2/test_dir and 99999999999999999999999999999999999999999{ +trying to open file: /yaffs2/test_dir/99999999999999999999999999999999999999999{ +opened file +joining paths:/yaffs2/test_dir and KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK9 +trying to open file: /yaffs2/test_dir/KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK9 +opened file +joining paths:/yaffs2/test_dir and NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN9 +trying to open file: /yaffs2/test_dir/NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN9 +opened file +joining paths:/yaffs2/test_dir and NNNNNNNNNNNNNNNNNNNNNNNN +trying to open file: /yaffs2/test_dir/NNNNNNNNNNNNNNNNNNNNNNNN +opened file +joining paths:/yaffs2/test_dir and  +trying to open file: /yaffs2/test_dir/ +opened file +joining paths:/yaffs2/test_dir and mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm +trying to open file: /yaffs2/test_dir/mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm +opened file +joining paths:/yaffs2/test_dir and $$$$$$$$$$$$$$m +trying to open file: /yaffs2/test_dir/$$$$$$$$$$$$$$m +opened file +joining paths:/yaffs2/test_dir and 99999999999999999999999999999999999999999999999999 +trying to open file: /yaffs2/test_dir/9999999999999999999999999999999999999999999 +opened file +joining paths:/yaffs2/test_dir and nnnnnnnn9 +trying to open file: /yaffs2/test_dir/nnnnnnnn9 +opened file +joining paths:/yaffs2/test_dir and LLLLLLLLLLLLLLLLLLLLLLLLLLLLL9 +trying to open file: /yaffs2/test_dir/LLLLLLLLLLLLLLLLLLLLLLLLLLLLL9 +opened file +joining paths:/yaffs2/test_dir and ==========================L +trying to open file: /yaffs2/test_dir/==========================L +opened file +joining paths:/yaffs2/test_dir and YYYYYYYYYYYYYYYYYYYYYYYYYYYYY9 +trying to open file: /yaffs2/test_dir/YYYYYYYYYYYYYYYYYYYYYYYYYYYYY9 + +error########## +failed to open file +error_code: +Unknown error code + + diff --git a/direct/timothy_tests/running_out_of_handles_error/error_handler.c b/direct/timothy_tests/running_out_of_handles_error/error_handler.c index 3474d01..d1670e6 100644 --- a/direct/timothy_tests/running_out_of_handles_error/error_handler.c +++ b/direct/timothy_tests/running_out_of_handles_error/error_handler.c @@ -16,21 +16,68 @@ */ #include "error_handler.h" -void yaffs_check_for_errors(char output, buffer *message_buffer,char error_message[],char success_message[]) + +typedef struct error_codes_template { + int code; + char * text; +}error_entry; + +const error_entry error_list[] = { + { ENOMEM , "ENOMEM" }, + { EBUSY , "EBUSY"}, + { ENODEV , "ENODEV"}, + { EINVAL , "EINVAL"}, + { EBADF , "EBADF"}, + { EACCES , "EACCES"}, + { EXDEV , "EXDEV" }, + { ENOENT , "ENOENT"}, + { ENOSPC , "ENOSPC"}, + { ERANGE , "ERANGE"}, + { ENODATA, "ENODATA"}, + { ENOTEMPTY, "ENOTEMPTY"}, + { ENAMETOOLONG,"ENAMETOOLONG"}, + { ENOMEM , "ENOMEM"}, + { EEXIST , "EEXIST"}, + { ENOTDIR , "ENOTDIR"}, + { EISDIR , "EISDIR"}, + { 0, NULL } +}; + +const char * error_to_str(int err) { - char dummy='0'; + error_entry *e = error_list; + if (err < 0) + err = -err; + while(e->code && e->text){ + if(err == e->code) + return e->text; + e++; + } + return "Unknown error code"; +} + +void yaffs_check_for_errors(char output, buffer *message_buffer,char error_message[],char success_message[]){ + char dummy[10]; + unsigned int x=0; + int yaffs_error=-1; + char error_found=0; if (output==-1) { add_to_buffer(message_buffer, "\nerror##########",MESSAGE_LEVEL_ERROR,PRINT); add_to_buffer(message_buffer, error_message,MESSAGE_LEVEL_ERROR,PRINT); add_to_buffer(message_buffer, "error_code: ",MESSAGE_LEVEL_ERROR,PRINT); - if (MESSAGE_LEVEL_ERROR<=DEBUG_LEVEL) printf("%d\n\n\n",yaffs_get_error()); /*cannot yet add int types to buffer. this is a quick fix*/ - scanf("%c",dummy); + yaffs_error=yaffs_get_error(); + if (MESSAGE_LEVEL_ERROR<=DEBUG_LEVEL) printf("%d\n",yaffs_error); /*cannot yet add int types to buffer. this is a quick fix*/ + add_to_buffer(message_buffer, error_to_str(yaffs_error),MESSAGE_LEVEL_ERROR,NPRINT); + append_to_buffer(message_buffer, "\n\n",MESSAGE_LEVEL_ERROR,PRINT); + + scanf("%c",dummy); /*this line causes a segmentation fault. Need a better way of waiting for a key press*/ //print_buffer(message_buffer,PRINT_ALL); } else{ add_to_buffer(message_buffer, success_message,MESSAGE_LEVEL_BASIC_TASKS,PRINT); - } - + } } + + diff --git a/direct/timothy_tests/running_out_of_handles_error/found_bugs.txt b/direct/timothy_tests/running_out_of_handles_error/found_bugs.txt deleted file mode 100644 index 418f1dc..0000000 --- a/direct/timothy_tests/running_out_of_handles_error/found_bugs.txt +++ /dev/null @@ -1,6 +0,0 @@ -Found bugs in yaffs - -Error code 0 bug (run out of handles) - By opening lots of files and not closing them yaffs can run out of handles. - The error code given by yaffs_get_error() returns 0. this error is not defined in yportenv.h - diff --git a/direct/timothy_tests/running_out_of_handles_error/message_buffer.c b/direct/timothy_tests/running_out_of_handles_error/message_buffer.c index 5a5696e..1ff21e0 100644 --- a/direct/timothy_tests/running_out_of_handles_error/message_buffer.c +++ b/direct/timothy_tests/running_out_of_handles_error/message_buffer.c @@ -27,8 +27,22 @@ void add_to_buffer(buffer *p_Buffer, char *message,char message_level,char print add_to_buffer_root_function(p_Buffer,message, message_level,DO_NOT_APPEND_MESSAGE,print); } -void add_to_buffer_root_function(buffer *p_Buffer, char *message,char message_level,char append,char print){ +void add_int_to_buffer(buffer *p_Buffer, int num,char message_level,char print){ + char message[20]; + sprintf(message, "%d",num); + add_to_buffer_root_function(p_Buffer,message, message_level,DO_NOT_APPEND_MESSAGE,print); +} + +void append_int_to_buffer(buffer *p_Buffer, int num,char message_level,char print){ + char message[20]; + sprintf(message, "%d",num); + add_to_buffer_root_function(p_Buffer,message, message_level,APPEND_MESSAGE,print); +} + +void add_to_buffer_root_function(buffer *p_Buffer, char *message,char message_level,char append,char print){ + FILE *log_handle; + if (append==APPEND_MESSAGE){ /* append current message*/ strncat(p_Buffer->message[p_Buffer->head],message,BUFFER_MESSAGE_LENGTH); } @@ -64,6 +78,12 @@ void add_to_buffer_root_function(buffer *p_Buffer, char *message,char message_le print_buffer(p_Buffer,1); //if the debug level is higher enough then print the new message */ printf("%s\n",p_Buffer->message[p_Buffer->head]); + log_handle=fopen(LOG_FILE,"a"); + if (log_handle!=NULL){ + fputs(p_Buffer->message[p_Buffer->head],log_handle); + fputs("\n",log_handle); + fclose(log_handle); + } } } @@ -88,3 +108,5 @@ void print_buffer(buffer *p_Buffer, int number_of_messages_to_print){ } + + diff --git a/direct/timothy_tests/running_out_of_handles_error/message_buffer.h b/direct/timothy_tests/running_out_of_handles_error/message_buffer.h index eadddb7..2f7984f 100644 --- a/direct/timothy_tests/running_out_of_handles_error/message_buffer.h +++ b/direct/timothy_tests/running_out_of_handles_error/message_buffer.h @@ -27,6 +27,8 @@ #define BUFFER_SIZE 50 /*number of messages in buffer*/ #define MESSAGE_LEVEL_ERROR 0 #define MESSAGE_LEVEL_BASIC_TASKS 1 + +#define LOG_FILE "log.txt" typedef struct buffer_template{ char message[BUFFER_SIZE][BUFFER_MESSAGE_LENGTH]; int head; @@ -40,6 +42,8 @@ void print_buffer(buffer *p_Buffer,int number_of_messages_to_print); /*print me /*wrapper functions for add_to_buffer_root_function*/ void add_to_buffer(buffer *p_Buffer, char *message,char message_level,char print); void append_to_buffer(buffer *p_Buffer, char *message,char message_level,char print); +void add_int_to_buffer(buffer *p_Buffer, int num,char message_level,char print); +void append_int_to_buffer(buffer *p_Buffer, int num,char message_level,char print); void add_to_buffer_root_function(buffer *p_Buffer, char *message,char message_level,char append,char print); #endif diff --git a/direct/timothy_tests/running_out_of_handles_error/yaffs_tester.c b/direct/timothy_tests/running_out_of_handles_error/yaffs_tester.c index 3cab276..f87498c 100644 --- a/direct/timothy_tests/running_out_of_handles_error/yaffs_tester.c +++ b/direct/timothy_tests/running_out_of_handles_error/yaffs_tester.c @@ -28,28 +28,57 @@ buffer message_buffer; /*create message_buffer */ -int main(){ +int main(int argc, char *argv[]){ char yaffs_test_dir[] ="/yaffs2/test_dir"; /*the path to the directory where all of the testing will take place*/ char yaffs_mount_dir[]="/yaffs2/"; /*the path to the mount point which yaffs will mount*/ - init(yaffs_test_dir,yaffs_mount_dir); + init(yaffs_test_dir,yaffs_mount_dir,argc,argv); test(yaffs_test_dir); yaffs_unmount(yaffs_mount_dir); return 0; } -void init(char *yaffs_test_dir,char *yaffs_mount_dir){ + +void init(char *yaffs_test_dir,char *yaffs_mount_dir,int argc, char *argv[]){ char output=0; + int x=0; + int seed=-1; + FILE *log_handle; /*these variables are already set to zero, but it is better not to take chances*/ message_buffer.head=0; message_buffer.tail=0; - + + + log_handle=fopen(LOG_FILE,"w"); + if (log_handle!=NULL){ + fputs("log file for yaffs tester\n",log_handle); + fclose(log_handle); + } add_to_buffer(&message_buffer,"welcome to the yaffs tester",MESSAGE_LEVEL_BASIC_TASKS,PRINT);/* print boot up message*/ yaffs_start_up(); yaffs_mount(yaffs_mount_dir); + for (x=0;x #include - +#include +#include + #include "yaffsfs.h" /* it is in "yaffs2/direct/" link it in the Makefile */ #include "message_buffer.h" #include "error_handler.h" @@ -26,7 +28,7 @@ #define MAX_FILE_NAME_SIZE 51 -void init(char *yaffs_test_dir,char *yaffs_mount_dir); /*sets up yaffs and mounts yaffs */ +void init(char *yaffs_test_dir,char *yaffs_mount_dir,int argc, char *argv[]); /*sets up yaffs and mounts yaffs */ void test(char *yaffs_test_dir); /*contains the test code*/ void generate_random_string(char *ptr); /*generates a random string of letters to be used for a name*/ void join_paths(char *path1,char *path2,char *newpath );