From 121c055437f23d9d6bc7b57d36ecf128b447013f Mon Sep 17 00:00:00 2001 From: Timothy Manning Date: Fri, 16 Dec 2011 13:28:52 +1300 Subject: Have updated yaffs direct tests and added README files to the tests. Signed-off-by: Timothy Manning --- direct/timothy_tests/dev/Makefile | 120 ---- direct/timothy_tests/dev/error_handler.c | 84 --- direct/timothy_tests/dev/error_handler.h | 23 - direct/timothy_tests/dev/message_buffer.c | 112 ---- direct/timothy_tests/dev/message_buffer.h | 49 -- direct/timothy_tests/dev/yaffs_tester.c | 375 ------------- direct/timothy_tests/dev/yaffs_tester.h | 48 -- direct/timothy_tests/handle_tests/Makefile | 6 +- direct/timothy_tests/handle_tests/README.txt | 7 + .../timothy_tests/is_yaffs_working_tests/Makefile | 115 ++++ .../is_yaffs_working_tests/README.txt | 11 + .../is_yaffs_working_tests/test_1_yaffs_mount.c | 97 ++++ direct/timothy_tests/linux_tests/Makefile | 15 +- direct/timothy_tests/linux_tests/README.txt | 26 +- direct/timothy_tests/linux_tests/linux_test.c | 4 + direct/timothy_tests/mirror_tests/Makefile | 117 ---- direct/timothy_tests/mirror_tests/README.txt | 24 - direct/timothy_tests/mirror_tests/current_bugs.txt | 5 - direct/timothy_tests/mirror_tests/lib.c | 141 ----- direct/timothy_tests/mirror_tests/lib.h | 53 -- .../timothy_tests/mirror_tests/linux_test_open.c | 38 -- .../timothy_tests/mirror_tests/linux_test_open.h | 24 - .../mirror_tests/linux_test_truncate.c | 27 - .../mirror_tests/linux_test_truncate.h | 27 - .../timothy_tests/mirror_tests/linux_test_unlink.c | 33 -- .../timothy_tests/mirror_tests/linux_test_unlink.h | 26 - .../timothy_tests/mirror_tests/linux_test_write.c | 37 -- .../timothy_tests/mirror_tests/linux_test_write.h | 27 - direct/timothy_tests/mirror_tests/mirror_tests.c | 601 --------------------- direct/timothy_tests/mirror_tests/mirror_tests.h | 61 --- .../timothy_tests/mirror_tests/yaffs_test_open.c | 38 -- .../timothy_tests/mirror_tests/yaffs_test_open.h | 26 - .../mirror_tests/yaffs_test_truncate.c | 27 - .../mirror_tests/yaffs_test_truncate.h | 26 - .../timothy_tests/mirror_tests/yaffs_test_unlink.c | 34 -- .../timothy_tests/mirror_tests/yaffs_test_unlink.h | 26 - .../timothy_tests/mirror_tests/yaffs_test_write.c | 85 --- .../timothy_tests/mirror_tests/yaffs_test_write.h | 27 - direct/timothy_tests/quick_tests/Makefile | 10 +- direct/timothy_tests/quick_tests/README.txt | 16 +- direct/timothy_tests/quick_tests/current_bugs.txt | 28 - direct/timothy_tests/stress_tester/Makefile | 122 +++++ direct/timothy_tests/stress_tester/README.txt | 8 + direct/timothy_tests/stress_tester/error_handler.c | 84 +++ direct/timothy_tests/stress_tester/error_handler.h | 23 + .../timothy_tests/stress_tester/message_buffer.c | 112 ++++ .../timothy_tests/stress_tester/message_buffer.h | 49 ++ direct/timothy_tests/stress_tester/yaffs_tester.c | 384 +++++++++++++ direct/timothy_tests/stress_tester/yaffs_tester.h | 48 ++ direct/timothy_tests/threading/Makefile | 6 +- direct/timothy_tests/threading/README.txt | 12 + .../yaffs_and_linux_mirror_tests/Makefile | 119 ++++ .../yaffs_and_linux_mirror_tests/README.txt | 27 + .../yaffs_and_linux_mirror_tests/lib.c | 141 +++++ .../yaffs_and_linux_mirror_tests/lib.h | 53 ++ .../yaffs_and_linux_mirror_tests/linux_test_open.c | 38 ++ .../yaffs_and_linux_mirror_tests/linux_test_open.h | 24 + .../linux_test_truncate.c | 27 + .../linux_test_truncate.h | 27 + .../linux_test_unlink.c | 33 ++ .../linux_test_unlink.h | 26 + .../linux_test_write.c | 37 ++ .../linux_test_write.h | 27 + .../yaffs_and_linux_mirror_tests/mirror_tests.c | 601 +++++++++++++++++++++ .../yaffs_and_linux_mirror_tests/mirror_tests.h | 61 +++ .../yaffs_and_linux_mirror_tests/yaffs_test_open.c | 38 ++ .../yaffs_and_linux_mirror_tests/yaffs_test_open.h | 26 + .../yaffs_test_truncate.c | 27 + .../yaffs_test_truncate.h | 26 + .../yaffs_test_unlink.c | 34 ++ .../yaffs_test_unlink.h | 26 + .../yaffs_test_write.c | 85 +++ .../yaffs_test_write.h | 27 + 73 files changed, 2666 insertions(+), 2388 deletions(-) delete mode 100644 direct/timothy_tests/dev/Makefile delete mode 100644 direct/timothy_tests/dev/error_handler.c delete mode 100644 direct/timothy_tests/dev/error_handler.h delete mode 100644 direct/timothy_tests/dev/message_buffer.c delete mode 100644 direct/timothy_tests/dev/message_buffer.h delete mode 100644 direct/timothy_tests/dev/yaffs_tester.c delete mode 100644 direct/timothy_tests/dev/yaffs_tester.h create mode 100644 direct/timothy_tests/handle_tests/README.txt create mode 100644 direct/timothy_tests/is_yaffs_working_tests/Makefile create mode 100644 direct/timothy_tests/is_yaffs_working_tests/README.txt create mode 100644 direct/timothy_tests/is_yaffs_working_tests/test_1_yaffs_mount.c delete mode 100644 direct/timothy_tests/mirror_tests/Makefile delete mode 100644 direct/timothy_tests/mirror_tests/README.txt delete mode 100644 direct/timothy_tests/mirror_tests/current_bugs.txt delete mode 100644 direct/timothy_tests/mirror_tests/lib.c delete mode 100644 direct/timothy_tests/mirror_tests/lib.h delete mode 100644 direct/timothy_tests/mirror_tests/linux_test_open.c delete mode 100644 direct/timothy_tests/mirror_tests/linux_test_open.h delete mode 100644 direct/timothy_tests/mirror_tests/linux_test_truncate.c delete mode 100644 direct/timothy_tests/mirror_tests/linux_test_truncate.h delete mode 100644 direct/timothy_tests/mirror_tests/linux_test_unlink.c delete mode 100644 direct/timothy_tests/mirror_tests/linux_test_unlink.h delete mode 100644 direct/timothy_tests/mirror_tests/linux_test_write.c delete mode 100644 direct/timothy_tests/mirror_tests/linux_test_write.h delete mode 100644 direct/timothy_tests/mirror_tests/mirror_tests.c delete mode 100644 direct/timothy_tests/mirror_tests/mirror_tests.h delete mode 100644 direct/timothy_tests/mirror_tests/yaffs_test_open.c delete mode 100644 direct/timothy_tests/mirror_tests/yaffs_test_open.h delete mode 100644 direct/timothy_tests/mirror_tests/yaffs_test_truncate.c delete mode 100644 direct/timothy_tests/mirror_tests/yaffs_test_truncate.h delete mode 100644 direct/timothy_tests/mirror_tests/yaffs_test_unlink.c delete mode 100644 direct/timothy_tests/mirror_tests/yaffs_test_unlink.h delete mode 100644 direct/timothy_tests/mirror_tests/yaffs_test_write.c delete mode 100644 direct/timothy_tests/mirror_tests/yaffs_test_write.h delete mode 100644 direct/timothy_tests/quick_tests/current_bugs.txt create mode 100644 direct/timothy_tests/stress_tester/Makefile create mode 100644 direct/timothy_tests/stress_tester/README.txt create mode 100644 direct/timothy_tests/stress_tester/error_handler.c create mode 100644 direct/timothy_tests/stress_tester/error_handler.h create mode 100644 direct/timothy_tests/stress_tester/message_buffer.c create mode 100644 direct/timothy_tests/stress_tester/message_buffer.h create mode 100644 direct/timothy_tests/stress_tester/yaffs_tester.c create mode 100644 direct/timothy_tests/stress_tester/yaffs_tester.h create mode 100644 direct/timothy_tests/threading/README.txt create mode 100644 direct/timothy_tests/yaffs_and_linux_mirror_tests/Makefile create mode 100644 direct/timothy_tests/yaffs_and_linux_mirror_tests/README.txt create mode 100644 direct/timothy_tests/yaffs_and_linux_mirror_tests/lib.c create mode 100644 direct/timothy_tests/yaffs_and_linux_mirror_tests/lib.h create mode 100644 direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_open.c create mode 100644 direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_open.h create mode 100644 direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_truncate.c create mode 100644 direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_truncate.h create mode 100644 direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_unlink.c create mode 100644 direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_unlink.h create mode 100644 direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_write.c create mode 100644 direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_write.h create mode 100644 direct/timothy_tests/yaffs_and_linux_mirror_tests/mirror_tests.c create mode 100644 direct/timothy_tests/yaffs_and_linux_mirror_tests/mirror_tests.h create mode 100644 direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_open.c create mode 100644 direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_open.h create mode 100644 direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_truncate.c create mode 100644 direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_truncate.h create mode 100644 direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_unlink.c create mode 100644 direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_unlink.h create mode 100644 direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_write.c create mode 100644 direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_write.h diff --git a/direct/timothy_tests/dev/Makefile b/direct/timothy_tests/dev/Makefile deleted file mode 100644 index 6e774ab..0000000 --- a/direct/timothy_tests/dev/Makefile +++ /dev/null @@ -1,120 +0,0 @@ -# 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_osglue.o yaffs_hweight.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_nand.o \ - yaffs_checkptrw.o yaffs_qsort.o\ - yaffs_nameval.o yaffs_attribs.o \ - yaffs_norif1.o ynorsim.o \ - yaffs_allocator.o \ - yaffs_bitmap.o \ - yaffs_yaffs1.o \ - yaffs_yaffs2.o \ - yaffs_verify.o - - -SSCOMMONTESTOBJS = 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_nand.o \ - yaffs_attribs.o yaffs_allocator.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 = yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffs_tagscompat.c yaffs_tagscompat.h \ - yaffs_packedtags1.c yaffs_packedtags1.h yaffs_packedtags2.c yaffs_packedtags2.h \ - yaffs_nand.c yaffs_nand.h yaffs_getblockinfo.h \ - yaffs_checkptrw.h yaffs_checkptrw.c \ - yaffs_nameval.c yaffs_nameval.h \ - yaffs_trace.h yaffs_attribs.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_osglue.h ydirectenv.h \ - yaffs_flashif.c yaffscfg.h yaffs_qsort.c \ - yaffs_nandemul2k.h yaffs_list.h \ - yaffs_attribs.c \ - yaffs_nandif.c yaffs_nandif.h yportenv.h \ - yaffs_hweight.c yaffs_hweight.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 yaffs_osglue.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/dev/error_handler.c b/direct/timothy_tests/dev/error_handler.c deleted file mode 100644 index a9152f3..0000000 --- a/direct/timothy_tests/dev/error_handler.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * YAFFS: Yet another FFS. A NAND-flash specific file system. - * - * Copyright (C) 2002-2011 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,NPRINT); - yaffs_error=yaffs_get_error(); - append_int_to_buffer(message_buffer, yaffs_error,MESSAGE_LEVEL_ERROR,PRINT); - - 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); - quit_program(); - //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/error_handler.h b/direct/timothy_tests/dev/error_handler.h deleted file mode 100644 index 979f020..0000000 --- a/direct/timothy_tests/dev/error_handler.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * YAFFS: Yet another Flash File System . A NAND-flash specific file system. - * - * Copyright (C) 2002-2011 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/dev/message_buffer.c b/direct/timothy_tests/dev/message_buffer.c deleted file mode 100644 index adefbf8..0000000 --- a/direct/timothy_tests/dev/message_buffer.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * YAFFS: Yet another FFS. A NAND-flash specific file system. - * - * Copyright (C) 2002-2011 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/dev/message_buffer.h b/direct/timothy_tests/dev/message_buffer.h deleted file mode 100644 index 55f9e10..0000000 --- a/direct/timothy_tests/dev/message_buffer.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * YAFFS: Yet another Flash File System . A NAND-flash specific file system. - * - * Copyright (C) 2002-2011 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/dev/yaffs_tester.c b/direct/timothy_tests/dev/yaffs_tester.c deleted file mode 100644 index 65d2d17..0000000 --- a/direct/timothy_tests/dev/yaffs_tester.c +++ /dev/null @@ -1,375 +0,0 @@ -/* - * YAFFS: Yet another FFS. A NAND-flash specific file system. - * - * Copyright (C) 2002-2011 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 */ - -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*/ - - -int main(int argc, char *argv[]){ - - - 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;xnumber_of_open_handles,MESSAGE_LEVEL_BASIC_TASKS,PRINT); - if (P_open_handles_array->number_of_open_handleshandle[x]!=-3 && xhandle[x]=output; - P_open_handles_array->path[x][0]='\0'; - strcat(P_open_handles_array->path[x],path); - add_to_buffer(&message_buffer,"yaffs handle: ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); - append_int_to_buffer(&message_buffer,output,MESSAGE_LEVEL_BASIC_TASKS,PRINT); - add_to_buffer(&message_buffer,"stored handle: ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); - - //yaffs_open will return a null pointer if it cannot open a file. check for errors will not work. - yaffs_check_for_errors(output, &message_buffer,"failed to open file","opened file"); - - P_open_handles_array->number_of_open_handles++; - } - else close_random_file(P_open_handles_array); - -} - -void write_to_random_file(handle_regster *P_open_handles_array){ - int number_of_lines_of_text=0; - int length=100; - char text[length+1]; - text[0]='\0'; - int seek=0; - int x=0; - int output=0; - if (P_open_handles_array->number_of_open_handles>0){ - - while (P_open_handles_array->handle[x]==-3){ /*find a random open handle*/ - x=rand() % (MAX_NUMBER_OF_OPENED_HANDLES-1); - } - add_to_buffer(&message_buffer,"\n\ntrying to write to ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); - append_to_buffer(&message_buffer,P_open_handles_array->path[x],MESSAGE_LEVEL_BASIC_TASKS,PRINT); - - stat_file(P_open_handles_array->path[x]); - number_of_lines_of_text=rand() %1000; - add_to_buffer(&message_buffer,"writing ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); - append_int_to_buffer(&message_buffer,number_of_lines_of_text,MESSAGE_LEVEL_BASIC_TASKS,NPRINT); - append_to_buffer(&message_buffer," lines of text",MESSAGE_LEVEL_BASIC_TASKS,PRINT); - - - for (;number_of_lines_of_text>0;number_of_lines_of_text--) - { - generate_random_string(text,length); - seek=rand()%1000; - add_to_buffer(&message_buffer,"trying to seek to ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); - append_int_to_buffer(&message_buffer,seek,MESSAGE_LEVEL_BASIC_TASKS,PRINT); - output=yaffs_lseek(P_open_handles_array->handle[x],seek,SEEK_SET); - yaffs_check_for_errors(output, &message_buffer,"failed to seek","seeked file"); - add_to_buffer(&message_buffer,"trying to write to file",MESSAGE_LEVEL_BASIC_TASKS,PRINT); - output=yaffs_write(P_open_handles_array->handle[x], text, strlen(text)); - yaffs_check_for_errors(output, &message_buffer,"failed to write text","wrote text"); - - } - } -} - -void truncate_random_file(handle_regster *P_open_handles_array){ - int x=0; - int truncate_size=0; - int output=0; - - if (P_open_handles_array->number_of_open_handles>0){ - add_to_buffer(&message_buffer,"\n\ntruncate function ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); - while (P_open_handles_array->handle[x]==-3){ /*find a random open handle*/ - x=rand() % (MAX_NUMBER_OF_OPENED_HANDLES-1); - } - add_to_buffer(&message_buffer,"trying to truncate ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); - append_to_buffer(&message_buffer,P_open_handles_array->path[x],MESSAGE_LEVEL_BASIC_TASKS,PRINT); - - stat_file(P_open_handles_array->path[x]); - truncate_size=rand() %10000; - output=yaffs_ftruncate(P_open_handles_array->handle[x], truncate_size); - yaffs_check_for_errors(output, &message_buffer,"failed to truncate file","truncated file"); - } -} - -void close_random_file(handle_regster *P_open_handles_array){ - /*run out of space on the handle pointer array*/ - /*make space*/ - int x=0; - int output=0; - int start=0; - if (P_open_handles_array->number_of_open_handles>0){ - start=rand() % (MAX_NUMBER_OF_OPENED_HANDLES-1); - for (x=start;P_open_handles_array->handle[x] !=-3 &&(x+1>start ||xMAX_NUMBER_OF_OPENED_HANDLES-1) x=0; - - } - if (P_open_handles_array->handle[x]!=-3) - { - add_to_buffer(&message_buffer,"\n\ntrying to close file: ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); - append_to_buffer(&message_buffer,P_open_handles_array->path[x],MESSAGE_LEVEL_BASIC_TASKS,PRINT); - add_to_buffer(&message_buffer,"file handle: ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); - append_int_to_buffer(&message_buffer,P_open_handles_array->handle[x],MESSAGE_LEVEL_BASIC_TASKS,PRINT); - - stat_file(P_open_handles_array->path[x]); - output=yaffs_close(P_open_handles_array->handle[x]); - - if (output==-1) yaffs_check_for_errors(output, &message_buffer,"failed to close file","closed file"); - else { - yaffs_check_for_errors(output, &message_buffer,"failed to close file","closed file"); - P_open_handles_array->handle[x]=-3; - P_open_handles_array->path[x][0]='\0'; - P_open_handles_array->number_of_open_handles--; - } - } - else { - add_to_buffer(&message_buffer,"\n\ntried to close file but could not find a open file ",MESSAGE_LEVEL_BASIC_TASKS,PRINT); - } - } -} - -void stat_file(char *path){ - int output=0; - struct yaffs_stat stat; - if (yaffs_access(path,0)==0){ - add_to_buffer(&message_buffer,"file exists, trying to stat: ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); - add_to_buffer(&message_buffer,path,MESSAGE_LEVEL_BASIC_TASKS,PRINT); - output=yaffs_lstat(path,&stat); - yaffs_check_for_errors(output, &message_buffer,"failed to stat file","statted file"); - //stat.st_ino,(int)stat.st_size,stat.st_mode - add_to_buffer(&message_buffer,"yaffs inode: ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); - append_int_to_buffer(&message_buffer,stat.st_ino,MESSAGE_LEVEL_BASIC_TASKS,NPRINT); - append_to_buffer(&message_buffer," file size: ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); - append_int_to_buffer(&message_buffer,(int)stat.st_size,MESSAGE_LEVEL_BASIC_TASKS,NPRINT); - append_to_buffer(&message_buffer," file mode: ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); - append_int_to_buffer(&message_buffer,stat.st_mode,MESSAGE_LEVEL_BASIC_TASKS,PRINT); - } - else{ - add_to_buffer(&message_buffer,path,MESSAGE_LEVEL_BASIC_TASKS,NPRINT); - append_to_buffer(&message_buffer," does not exist,could not stat",MESSAGE_LEVEL_BASIC_TASKS,PRINT); - } -} - -void test(char*yaffs_test_dir){ - struct yaffs_stat stat; - int output=0; - //char name[MAX_FILE_NAME_SIZE+3 ]="apple\0"; - //char path[MAX_FILE_NAME_SIZE]; - handle_regster open_handles_array; - //int handle_pointers[MAX_NUMBER_OF_OPENED_HANDLES]; - //int number_of_opened_handles=0; - int x=0; - - - open_handles_array.number_of_open_handles=0; - 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/dev/yaffs_tester.h b/direct/timothy_tests/dev/yaffs_tester.h deleted file mode 100644 index a703175..0000000 --- a/direct/timothy_tests/dev/yaffs_tester.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * YAFFS: Yet another Flash File System . A NAND-flash specific file system. - * - * Copyright (C) 2002-2011 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_NUMBER_OF_OPENED_HANDLES 50 -#define MAX_FILE_NAME_SIZE 51 - -typedef struct handle_regster_template{ - int handle[MAX_NUMBER_OF_OPENED_HANDLES]; - char path[MAX_NUMBER_OF_OPENED_HANDLES][100]; - int number_of_open_handles; -}handle_regster; - - -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,int length_of_str); /*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); -void stat_file(char *path); -void write_to_random_file(handle_regster *P_open_handles_array); -void close_random_file(handle_regster *P_open_handles_array); -void quit_program(); -void truncate_random_file(handle_regster *P_open_handles_array); -#endif diff --git a/direct/timothy_tests/handle_tests/Makefile b/direct/timothy_tests/handle_tests/Makefile index 8ca9c1d..a2e9a5e 100644 --- a/direct/timothy_tests/handle_tests/Makefile +++ b/direct/timothy_tests/handle_tests/Makefile @@ -42,7 +42,8 @@ COMMONTESTOBJS = yaffscfg2k.o yaffs_osglue.o yaffs_hweight.o \ yaffs_yaffs1.o \ yaffs_yaffs2.o \ yaffs_verify.o \ - yaffs_error.o + yaffs_error.o \ + yaffs_summary.o # yaffs_checkptrwtest.o\ @@ -66,7 +67,8 @@ YAFFSSYMLINKS = yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffs_tagscomp yaffs_yaffs1.c yaffs_yaffs1.h \ yaffs_yaffs2.c yaffs_yaffs2.h \ yaffs_bitmap.c yaffs_bitmap.h \ - yaffs_verify.c yaffs_verify.h + yaffs_verify.c yaffs_verify.h \ + yaffs_summary.c yaffs_summary.h YAFFSDIRECTSYMLINKS = yaffsfs.c yaffs_flashif.h yaffs_flashif2.h\ yaffsfs.h ydirectenv.h \ diff --git a/direct/timothy_tests/handle_tests/README.txt b/direct/timothy_tests/handle_tests/README.txt new file mode 100644 index 0000000..bce7a6c --- /dev/null +++ b/direct/timothy_tests/handle_tests/README.txt @@ -0,0 +1,7 @@ +handle_tests.c opens and closes random handles, in an effot to stress test yaffs. + +Command line options: + No commands. + +compile command: make +run command: ./handle_test diff --git a/direct/timothy_tests/is_yaffs_working_tests/Makefile b/direct/timothy_tests/is_yaffs_working_tests/Makefile new file mode 100644 index 0000000..8cc1f44 --- /dev/null +++ b/direct/timothy_tests/is_yaffs_working_tests/Makefile @@ -0,0 +1,115 @@ +# 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_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_osglue.o yaffs_hweight.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_nand.o \ + yaffs_checkptrw.o yaffs_qsort.o\ + yaffs_nameval.o yaffs_attribs.o \ + yaffs_norif1.o ynorsim.o \ + yaffs_allocator.o \ + yaffs_bitmap.o \ + yaffs_yaffs1.o \ + yaffs_yaffs2.o \ + yaffs_verify.o \ + yaffs_error.o \ + yaffs_summary.o + +# yaffs_checkptrwtest.o\ + +TESTFILES = test_1_yaffs_mount.o + + + + +YAFFSTESTOBJS = $(COMMONTESTOBJS) $(TESTFILES) + + +ALLOBJS = $(sort $(YAFFSTESTOBJS)) $(PYTHONOBJS) + +YAFFSSYMLINKS = yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffs_tagscompat.c yaffs_tagscompat.h \ + yaffs_packedtags1.c yaffs_packedtags1.h yaffs_packedtags2.c yaffs_packedtags2.h \ + yaffs_nand.c yaffs_nand.h yaffs_getblockinfo.h \ + yaffs_checkptrw.h yaffs_checkptrw.c \ + yaffs_nameval.c yaffs_nameval.h \ + yaffs_trace.h yaffs_attribs.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 \ + yaffs_summary.c yaffs_summary.h + +YAFFSDIRECTSYMLINKS = yaffsfs.c yaffs_flashif.h yaffs_flashif2.h\ + yaffsfs.h ydirectenv.h \ + yaffs_flashif.c yaffscfg.h yaffs_qsort.c \ + yaffs_nandemul2k.h yaffs_list.h \ + yaffs_attribs.c yaffs_osglue.h \ + yaffs_nandif.c yaffs_nandif.h yportenv.h \ + yaffs_hweight.h yaffs_hweight.c \ + yaffs_error.c + + +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 yaffs_osglue.c + +SYMLINKS = $(YAFFSSYMLINKS) $(YAFFSDIRECTSYMLINKS) $(DIRECTEXTRASYMLINKS) $(PYTONOSYMLINKS) +#all: directtest2k boottest + +all: test_1_yaffs_mount + +$(ALLOBJS): %.o: %.c + gcc -c $(CFLAGS) -o $@ $< + +$(PYTONOSYMLINKS): + ln -s ../../python/$@ $@ + +$(YAFFSSYMLINKS): + ln -s ../../../$@ $@ + +$(YAFFSDIRECTSYMLINKS): + ln -s ../../$@ $@ + +$(DIRECTEXTRASYMLINKS): + ln -s ../../basic-test/$@ $@ + + +test_1_yaffs_mount: $(SYMLINKS) $(ALLOBJS) + gcc $(CFLLAG) -o $@ $(ALLOBJS) + + + +clean: + rm -f test_1_yaffs_mount $(ALLOBJS) core $(SYMLINKS) diff --git a/direct/timothy_tests/is_yaffs_working_tests/README.txt b/direct/timothy_tests/is_yaffs_working_tests/README.txt new file mode 100644 index 0000000..0cdddbd --- /dev/null +++ b/direct/timothy_tests/is_yaffs_working_tests/README.txt @@ -0,0 +1,11 @@ +is_yaffs_working_tests folder contains the very simple tests to check that yaffs has been installed properly. + +test_1_yaffs_mount.c mounts yaffs, creates a file, unmounts and then mounts yaffs and checks that the file is still there. + + + +compile command: make +run command: ./test_1_yaffs_mount + +command line options: + No commands. diff --git a/direct/timothy_tests/is_yaffs_working_tests/test_1_yaffs_mount.c b/direct/timothy_tests/is_yaffs_working_tests/test_1_yaffs_mount.c new file mode 100644 index 0000000..b7726ba --- /dev/null +++ b/direct/timothy_tests/is_yaffs_working_tests/test_1_yaffs_mount.c @@ -0,0 +1,97 @@ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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. + */ + + +#include "yaffsfs.h" +#define YAFFS_MOUNT_POINT "/yaffs2/" +#define FILE_PATH "/yaffs2/foo.txt" + +int random_seed; +int simulate_power_failure = 0; + + +int main() +{ + int output = 0; + int output2 = 0; + yaffs_start_up(); + + printf("\n\n starting test\n"); + yaffs_set_trace(0); + output = yaffs_mount(YAFFS_MOUNT_POINT); + + if (output>=0){ + printf("yaffs mounted: %s\n",YAFFS_MOUNT_POINT); + } else { + printf("error\n yaffs failed to mount: %s\nerror\n",YAFFS_MOUNT_POINT); + return (0); + } + //now create a file. + output = yaffs_open(FILE_PATH,O_CREAT | O_RDWR, S_IREAD | S_IWRITE); + if (output>=0){ + printf("file created: %s\n",FILE_PATH); + } else { + printf("error\n yaffs failed to create the file: %s\nerror\n",FILE_PATH); + return (0); + } + output2 = yaffs_close(output); + if (output2>=0){ + printf("file closed: %s\n",FILE_PATH); + } else { + printf("error\n yaffs failed to close the file: %s\nerror\n",FILE_PATH); + return (0); + } + //unmount and remount the mount point. + output = yaffs_unmount(YAFFS_MOUNT_POINT); + if (output>=0){ + printf("yaffs unmounted: %s\n",YAFFS_MOUNT_POINT); + } else { + printf("error\n yaffs failed to unmount: %s\nerror\n",YAFFS_MOUNT_POINT); + return (0); + } + output = yaffs_mount(YAFFS_MOUNT_POINT); + if (output>=0){ + printf("yaffs mounted: %s\n",YAFFS_MOUNT_POINT); + } else { + printf("error\n yaffs failed to mount: %s\nerror\n",YAFFS_MOUNT_POINT); + return (0); + } + //now open the existing file. + output = yaffs_open(FILE_PATH, O_RDWR, S_IREAD | S_IWRITE); + if (output>=0){ + printf("file created: %s\n",FILE_PATH); + } else { + printf("error\n yaffs failed to create the file: %s\nerror\n",FILE_PATH); + return (0); + } + //close the file. + output2 = yaffs_close(output); + if (output2>=0){ + printf("file closed: %s\n",FILE_PATH); + } else { + printf("error\n yaffs failed to close the file: %s\nerror\n",FILE_PATH); + return (0); + } + + //unmount the mount point. + output = yaffs_unmount(YAFFS_MOUNT_POINT); + if (output>=0){ + printf("yaffs unmounted: %s\n",YAFFS_MOUNT_POINT); + } else { + printf("error\n yaffs failed to unmount: %s\nerror\n",YAFFS_MOUNT_POINT); + return (0); + } + + printf("test passed. yay!\n"); + +} diff --git a/direct/timothy_tests/linux_tests/Makefile b/direct/timothy_tests/linux_tests/Makefile index 6910788..c80ef4d 100644 --- a/direct/timothy_tests/linux_tests/Makefile +++ b/direct/timothy_tests/linux_tests/Makefile @@ -33,8 +33,8 @@ CFLAGS += -Wextra -Wpointer-arith COMMONTESTOBJS = yaffscfg2k.o yaffs_osglue.o yaffs_hweight.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_tagscompat.o yaffs_packedtags2.o yaffs_nand.o \ + yaffs_checkptrw.o yaffs_qsort.o \ yaffs_nameval.o yaffs_attribs.o \ yaffs_norif1.o ynorsim.o \ yaffs_allocator.o \ @@ -42,8 +42,9 @@ COMMONTESTOBJS = yaffscfg2k.o yaffs_osglue.o yaffs_hweight.o \ yaffs_yaffs1.o \ yaffs_yaffs2.o \ yaffs_verify.o \ - yaffs_error.o - + yaffs_error.o \ + yaffs_summary.o +# yaffs_tagsvalidity.o # yaffs_checkptrwtest.o\ TESTFILES = linux_test.o lib.o @@ -59,14 +60,16 @@ ALLOBJS = $(sort $(YAFFSTESTOBJS)) $(PYTHONOBJS) YAFFSSYMLINKS = yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffs_tagscompat.c yaffs_tagscompat.h \ yaffs_packedtags1.c yaffs_packedtags1.h yaffs_packedtags2.c yaffs_packedtags2.h \ yaffs_nand.c yaffs_nand.h yaffs_getblockinfo.h \ - yaffs_tagsvalidity.c yaffs_tagsvalidity.h yaffs_checkptrw.h yaffs_checkptrw.c \ + yaffs_checkptrw.h yaffs_checkptrw.c \ yaffs_nameval.c yaffs_nameval.h \ yaffs_trace.h yaffs_attribs.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 + yaffs_verify.c yaffs_verify.h \ + yaffs_summary.c yaffs_summary.h +#yaffs_tagsvalidity.c yaffs_tagsvalidity.h YAFFSDIRECTSYMLINKS = yaffsfs.c yaffs_flashif.h yaffs_flashif2.h\ yaffsfs.h ydirectenv.h \ diff --git a/direct/timothy_tests/linux_tests/README.txt b/direct/timothy_tests/linux_tests/README.txt index 0c3fa84..be8b831 100644 --- a/direct/timothy_tests/linux_tests/README.txt +++ b/direct/timothy_tests/linux_tests/README.txt @@ -1,11 +1,17 @@ +linux_test.c tests yaffs running under linux using the nandsim generator. + + +If a segmentation fault happens during the test then check that +the nandsim has been initilised properly. + How to initilise the nandsim $ make $ sudo -s ...password.. -# now have a root shell +# now you have a root shell $ ./linux-tests/initnandsim 128MiB-2048 $ insmod yaffs2multi.ko $ mkdir /mnt/y @@ -24,7 +30,19 @@ How to clean the folder $ rm -rf /mnt/y -The test must be run in sudo to work +The test must be run in sudo to work to allow the files to be +created in the root folders. -$ make -$ sudo ./linux_test +compile command: make +run command: sudo ./linux_test + +command line options: + -h display the command line options. + -s [number] seeds the rand with the number. + -p [number] sets the print level to the number. + the higher the number the more low level commands are printed. + the number should be between 0 and 5. + -v verbose mode. everything is printed. + -q quite mode. nothing is printed. + + diff --git a/direct/timothy_tests/linux_tests/linux_test.c b/direct/timothy_tests/linux_tests/linux_test.c index 429e74f..e450236 100644 --- a/direct/timothy_tests/linux_tests/linux_test.c +++ b/direct/timothy_tests/linux_tests/linux_test.c @@ -149,6 +149,10 @@ dir_struct * scan_dir(void) open_dir=opendir(ROOT_PATH); + if (open_dir < 0){ + sprintf(message,"failed to find the directory: %s",ROOT_PATH); + print_message(1,message); + } dir_data=readdir(open_dir); while(dir_data){ dir->path_list=linked_list_add_node(HEAD,dir->path_list); diff --git a/direct/timothy_tests/mirror_tests/Makefile b/direct/timothy_tests/mirror_tests/Makefile deleted file mode 100644 index 05e41f4..0000000 --- a/direct/timothy_tests/mirror_tests/Makefile +++ /dev/null @@ -1,117 +0,0 @@ -# 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_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_osglue.o yaffs_hweight.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_nand.o \ - yaffs_checkptrw.o yaffs_qsort.o\ - yaffs_nameval.o yaffs_attribs.o \ - yaffs_norif1.o ynorsim.o \ - yaffs_allocator.o \ - yaffs_bitmap.o \ - yaffs_yaffs1.o \ - yaffs_yaffs2.o \ - yaffs_verify.o \ - yaffs_error.o - -# yaffs_checkptrwtest.o\ - -TESTFILES = mirror_tests.o lib.o\ - linux_test_open.o yaffs_test_open.o\ - linux_test_truncate.o yaffs_test_truncate.o \ - linux_test_unlink.o yaffs_test_unlink.o \ - linux_test_write.o yaffs_test_write.o - - - - -YAFFSTESTOBJS = $(COMMONTESTOBJS) $(TESTFILES) - - -ALLOBJS = $(sort $(YAFFSTESTOBJS)) $(PYTHONOBJS) - -YAFFSSYMLINKS = yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffs_tagscompat.c yaffs_tagscompat.h \ - yaffs_packedtags1.c yaffs_packedtags1.h yaffs_packedtags2.c yaffs_packedtags2.h \ - yaffs_nand.c yaffs_nand.h yaffs_getblockinfo.h \ - yaffs_checkptrw.h yaffs_checkptrw.c \ - yaffs_nameval.c yaffs_nameval.h \ - yaffs_trace.h yaffs_attribs.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 ydirectenv.h \ - yaffs_flashif.c yaffscfg.h yaffs_qsort.c \ - yaffs_nandemul2k.h yaffs_list.h \ - yaffs_attribs.c yaffs_osglue.h \ - yaffs_nandif.c yaffs_nandif.h yportenv.h \ - yaffs_hweight.h yaffs_hweight.c \ - yaffs_error.c - - -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 yaffs_osglue.c - -SYMLINKS = $(YAFFSSYMLINKS) $(YAFFSDIRECTSYMLINKS) $(DIRECTEXTRASYMLINKS) $(PYTONOSYMLINKS) -#all: directtest2k boottest - -all: mirror_tests - -$(ALLOBJS): %.o: %.c - gcc -c $(CFLAGS) -o $@ $< - -$(PYTONOSYMLINKS): - ln -s ../../python/$@ $@ - -$(YAFFSSYMLINKS): - ln -s ../../../$@ $@ - -$(YAFFSDIRECTSYMLINKS): - ln -s ../../$@ $@ - -$(DIRECTEXTRASYMLINKS): - ln -s ../../basic-test/$@ $@ - - -mirror_tests: $(SYMLINKS) $(ALLOBJS) - gcc $(CFLLAG) -o $@ $(ALLOBJS) - - - -clean: - rm -f mirror_tests $(ALLOBJS) core $(SYMLINKS) diff --git a/direct/timothy_tests/mirror_tests/README.txt b/direct/timothy_tests/mirror_tests/README.txt deleted file mode 100644 index 1edc620..0000000 --- a/direct/timothy_tests/mirror_tests/README.txt +++ /dev/null @@ -1,24 +0,0 @@ -Made by Timothy Manning on 24/12/10 - - - mirror_tests is designed to check that yaffs behaves the same way as linux. - This is done by applying the same command to both linux and yaffs and - then checking the output of the functions. - The default place for creating linux files is direct/timothy_tests/mirror_tests/tests/ - This directory is removed and is recreated at the beginning of each test, - However some of the files may be read only and cannot be deleted. - It is much better to remove this directory via the command line. - - rm test/*;rmdir test/;./mirror_tests -n 100 -v - -Command line arguments - -yaffs_path [PATH] //sets the path for yaffs. - -linux_path [PATH] //sets the path for linux. - -p [NUMBER] //sets the print level for mirror_tests. - -v //verbose mode everything is printed - -q //quiet mode nothing is printed. - -n [number] //sets the number of random tests to run. - -s [number] //seeds rand with the number - -t [number] //sets yaffs_trace to the number - -clean //removes emfile and test dir - diff --git a/direct/timothy_tests/mirror_tests/current_bugs.txt b/direct/timothy_tests/mirror_tests/current_bugs.txt deleted file mode 100644 index 8e3251a..0000000 --- a/direct/timothy_tests/mirror_tests/current_bugs.txt +++ /dev/null @@ -1,5 +0,0 @@ - -BUGS - NO Bugs. - - diff --git a/direct/timothy_tests/mirror_tests/lib.c b/direct/timothy_tests/mirror_tests/lib.c deleted file mode 100644 index 079ed25..0000000 --- a/direct/timothy_tests/mirror_tests/lib.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * YAFFS: Yet another FFS. A NAND-flash specific file system. - * - * Copyright (C) 2002-2011 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. - */ - -#include "lib.h" - -static int EXIT_ON_ERROR = 1; -static int 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. -void set_print_level(int new_level) -{ - PRINT_LEVEL=new_level; -} -int get_print_level(void) -{ - return PRINT_LEVEL; -} - -void set_exit_on_error(int num) -{ - EXIT_ON_ERROR=num; -} - -int get_exit_on_error(void) -{ - return EXIT_ON_ERROR; -} - -void display_error(void) -{ - -} - -void get_error_yaffs(void) -{ - int error_code=0; - char message[30]; - message[0]='\0'; - - error_code=yaffs_get_error(); - sprintf(message,"yaffs_error code %d\n",error_code); - print_message(1,message); - sprintf(message,"error is : %s\n",yaffs_error_to_str(error_code)); - print_message(1,message); -} - -void get_error_linux(void) -{ - int error_code=0; - char message[30]; - message[0]='\0'; - - error_code=errno; - sprintf(message,"linux_error code %d\n",error_code); - print_message(1,message); - strcpy(message,"error code"); - sprintf(message,"error is : %s\n",yaffs_error_to_str(error_code)); - //perror(message); - print_message(1,message); -} -void generate_random_string(char *ptr,int length_of_str){ - unsigned int x; - unsigned int length=((rand() %(length_of_str-3))+3); /*creates a int with the number of charecters been between 1 and 51*/ - char letter='\0'; - strcpy(ptr,""); - //printf("generating string\n"); - //printf("string length is %d\n",length); - for (x=0; x <= (length-2) &&length>2 ; x++) - { - //printf("x=%d\n",x); - /* keep generating a charecter until the charecter is legal*/ - while((letter=='\0' )||(letter=='/')||(letter=='\\')){ - letter=(rand() % 125-59)+58; /*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*/ - -} - -void join_paths(char *path1,char *path2,char *new_path ) -{ - char message[100]; - print_message(3,"joining paths\n"); - sprintf(message,"path1: %s\n",path1); - print_message(3,message); - sprintf(message,"path2: %s\n",path2); - print_message(3,message); - strcpy(new_path,""); - //strcat(new_path,path1); /*since all functions have this then pull it out*/ - if ( (path1[(sizeof(path1)/sizeof(char))-2]=='/') && path2[0]!='/') { - /*paths are compatiable. concatanate them. note -2 is because of \0*/ - strcat(new_path,path1); - strcat(new_path,path2); - //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]=='/') { - /*paths are compatiable. concatanate them*/ - strcat(new_path,path1); - strcat(new_path,path2); - - } 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]=='/') { - /*need to remove a "/". */ - /*yaffs does not mind the extra slash. */ - strcat(new_path,path1); - strcat(new_path,path2); - - } else { - //error - //return -1; - } -} - -void print_message(char print_level,char *message) -{ - if (print_level <= PRINT_LEVEL){ - printf(message); - } -} - - - diff --git a/direct/timothy_tests/mirror_tests/lib.h b/direct/timothy_tests/mirror_tests/lib.h deleted file mode 100644 index 0b33479..0000000 --- a/direct/timothy_tests/mirror_tests/lib.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * YAFFS: Yet another Flash File System . A NAND-flash specific file system. - * - * Copyright (C) 2002-2011 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 _lib_h__ -#define _lib_h__ - -#include -#include -#include "yaffsfs.h" -#include - -typedef struct arg_temp2{ - char char1; - char char2; - char string1[100]; - char string2[100]; - int int1; - int int2; -} arg_temp; - - -typedef struct test_dir_temp -{ - int type_of_test; //used to tell if it is LINUX of YAFFS - char root_path[200]; -} test_dir; -test_dir yaffs_struct,linux_struct; - - - -void generate_random_string(char *ptr,int length_of_str); -void join_paths(char *path1,char *path2,char *new_path ); -void print_message(char print_level, char *message); -void set_print_level(int new_level); -int get_print_level(void); -void set_exit_on_error(int num); -int get_exit_on_error(void); -void display_error(void); -void get_error_yaffs(void); -void get_error_linux(void); -#endif diff --git a/direct/timothy_tests/mirror_tests/linux_test_open.c b/direct/timothy_tests/mirror_tests/linux_test_open.c deleted file mode 100644 index 871dc56..0000000 --- a/direct/timothy_tests/mirror_tests/linux_test_open.c +++ /dev/null @@ -1,38 +0,0 @@ -/* - * YAFFS: Yet another FFS. A NAND-flash specific file system. - * - * Copyright (C) 2002-2011 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. - */ - -#include "linux_test_open.h" - -int linux_test_open(arg_temp *args_struct) -{ - char path[250]; - char message[150]; - int output; - join_paths(linux_struct.root_path,args_struct->string1, path ); - sprintf(message,"file path: %s\n",path); - print_message(3,message); - - output= open(path,args_struct->char1 & (O_TRUNC|O_EXCL|O_CREAT|O_APPEND) ,args_struct->char2& (S_IREAD|S_IWRITE)); - if (output>=0){ - output=close(output); - if (output<0) { - print_message(3,"failed to close handle\n"); - return -1; - } else { - return 1; - } - } else { - print_message(3,"failed to open file\n"); - return -1; - } -} diff --git a/direct/timothy_tests/mirror_tests/linux_test_open.h b/direct/timothy_tests/mirror_tests/linux_test_open.h deleted file mode 100644 index 6274934..0000000 --- a/direct/timothy_tests/mirror_tests/linux_test_open.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * YAFFS: Yet another Flash File System . A NAND-flash specific file system. - * - * Copyright (C) 2002-2011 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 __linux_test_open_h__ -#define __linux_test_open_h__ -#include -#include -#include -#include "lib.h" - -int linux_test_open(arg_temp *args_struct); -#endif diff --git a/direct/timothy_tests/mirror_tests/linux_test_truncate.c b/direct/timothy_tests/mirror_tests/linux_test_truncate.c deleted file mode 100644 index 94e8959..0000000 --- a/direct/timothy_tests/mirror_tests/linux_test_truncate.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * YAFFS: Yet another FFS. A NAND-flash specific file system. - * - * Copyright (C) 2002-2011 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. - */ - -#include "linux_test_truncate.h" - -int linux_test_truncate(arg_temp *args_struct) -{ - char path[200]; - char message[200]; - int output=0; - join_paths(linux_struct.root_path,args_struct->string1, path ); - sprintf(message,"file path: %s\n",path); - print_message(3,message); - - output=truncate(path,args_struct->int1); - return output; -} diff --git a/direct/timothy_tests/mirror_tests/linux_test_truncate.h b/direct/timothy_tests/mirror_tests/linux_test_truncate.h deleted file mode 100644 index 7ef91d0..0000000 --- a/direct/timothy_tests/mirror_tests/linux_test_truncate.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * YAFFS: Yet another Flash File System . A NAND-flash specific file system. - * - * Copyright (C) 2002-2011 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 __linux_test_truncate_h__ -#define __linux_test_truncate_h__ -#include -#include -#include -#include -#include "yaffsfs.h" -#include "lib.h" - -int linux_test_truncate(arg_temp *args_struct); - -#endif diff --git a/direct/timothy_tests/mirror_tests/linux_test_unlink.c b/direct/timothy_tests/mirror_tests/linux_test_unlink.c deleted file mode 100644 index 575e7ae..0000000 --- a/direct/timothy_tests/mirror_tests/linux_test_unlink.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * YAFFS: Yet another FFS. A NAND-flash specific file system. - * - * Copyright (C) 2002-2011 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. - */ - -#include "linux_test_unlink.h" - -int linux_test_unlink(arg_temp *args_struct) -{ - char path[250]; - char message[150]; - int output; - join_paths(linux_struct.root_path,args_struct->string1, path ); - sprintf(message,"file path: %s\n",path); - print_message(3,message); - - output= unlink(path); - - if (output<0) { - print_message(3,"failed to unlink file\n"); - return -1; - } else { - return 1; - } -} diff --git a/direct/timothy_tests/mirror_tests/linux_test_unlink.h b/direct/timothy_tests/mirror_tests/linux_test_unlink.h deleted file mode 100644 index 7572aa8..0000000 --- a/direct/timothy_tests/mirror_tests/linux_test_unlink.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * YAFFS: Yet another Flash File System . A NAND-flash specific file system. - * - * Copyright (C) 2002-2011 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 __linux_test_unlink_h__ -#define __linux_test_unlink_h__ -#include -#include -#include -#include "yaffsfs.h" -#include "lib.h" - -int linux_test_unlink(arg_temp *args_struct); - -#endif diff --git a/direct/timothy_tests/mirror_tests/linux_test_write.c b/direct/timothy_tests/mirror_tests/linux_test_write.c deleted file mode 100644 index b46c211..0000000 --- a/direct/timothy_tests/mirror_tests/linux_test_write.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * YAFFS: Yet another FFS. A NAND-flash specific file system. - * - * Copyright (C) 2002-2011 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. - */ - -#include "linux_test_write.h" - -int linux_test_write(arg_temp *args_struct) -{ - char path[200]; - char message[200]; - int output=0; - int handle=-1; - join_paths(linux_struct.root_path,args_struct->string1, path ); - sprintf(message,"trying to write to: %s\nwith mode set to %o \n",path,args_struct->char1 ); - print_message(3,message); - printf("mode S_IREAD %d S_IWRITE %d\n",(args_struct->char2 & S_IREAD),(args_struct->char2 & S_IWRITE)); - handle=open(path,((args_struct->char1 &(O_TRUNC|O_EXCL|O_CREAT|O_APPEND))|O_RDWR),(args_struct->char2&(S_IREAD|S_IWRITE))); - printf("handle %d\n",handle); - if (handle<0){ - print_message(3,"failed to open a handle\n"); - return -1; //handle failed to open - } - sprintf(message,"trying to write: %d bytes into the file\n",strlen(args_struct->string2)); - print_message(3,message); - output=write(handle,args_struct->string2,strlen(args_struct->string2)); - close(handle); - return output; -} diff --git a/direct/timothy_tests/mirror_tests/linux_test_write.h b/direct/timothy_tests/mirror_tests/linux_test_write.h deleted file mode 100644 index 611fe7d..0000000 --- a/direct/timothy_tests/mirror_tests/linux_test_write.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * YAFFS: Yet another Flash File System . A NAND-flash specific file system. - * - * Copyright (C) 2002-2011 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 __linux_test_write_h__ -#define __linux_test_write_h__ -#include -#include -#include -#include -#include "yaffsfs.h" -#include "lib.h" - -int linux_test_write(arg_temp *args_struct); - -#endif diff --git a/direct/timothy_tests/mirror_tests/mirror_tests.c b/direct/timothy_tests/mirror_tests/mirror_tests.c deleted file mode 100644 index cd4e5f2..0000000 --- a/direct/timothy_tests/mirror_tests/mirror_tests.c +++ /dev/null @@ -1,601 +0,0 @@ -/* - * YAFFS: Yet another FFS. A NAND-flash specific file system. - * - * Copyright (C) 2002-2011 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. - */ - -#include "mirror_tests.h" - -int random_seed; -int simulate_power_failure = 0; - -int num_of_random_tests=1; - - - -typedef struct test_list_temp2{ - char *test_name; - int (*test_pointer)(arg_temp *args_struct); -}test_list_temp; - -typedef struct test_temp2 { - int num_of_tests; - test_list_temp test_list[]; -}test_temp; - -test_temp yaffs_tests={ - 4, - {{"yaffs_test_open",yaffs_test_open}, - {"yaffs_test_truncate",yaffs_test_truncate}, - {"yaffs_test_unlink",yaffs_test_unlink}, - {"yaffs_test_write",yaffs_test_write} - } -}; - -test_temp linux_tests={ - 4, - {{"linux_test_open",linux_test_open}, - {"linux_test_truncate",linux_test_truncate}, - {"linux_test_unlink",linux_test_unlink}, - {"linux_test_write",linux_test_write} - } -}; - -const struct option long_options[]={ - {"help", 0,NULL,'h'}, - {"yaffs_path", 1,NULL,'y'}, - {"linux_path", 1,NULL,'l'}, - {"print_level", 1,NULL,'p'}, - {"quiet", 0,NULL,'q'}, - {"number", 1,NULL,'n'}, - {"seed", 1,NULL,'s'}, - {"trace", 1,NULL,'t'}, - {"clean", 0,NULL,'c'}, - {"verbose", 0,NULL,'v'} -}; - -const char short_options[]="hy:l:p:qn:s:t:cv"; - - -int main(int argc, char *argv[]) -{ - char message[100]; - -// yaffs_tests.num_of_tests=(sizeof(yaffs_tests)/sizeof(test_temp)); -// linux_tests.num_of_tests=(sizeof(linux_tests)/sizeof(test_temp)); - - init(argc,argv); - print_message(1,"running mirror_tests\n"); - sprintf(message,"linux_root_path: %s\n",linux_struct.root_path); - print_message(3,message); - sprintf(message,"yaffs_root_path: %s\n",yaffs_struct.root_path); - print_message(3,message); - sprintf(message,"linux_num_of_tests: %d\n",linux_tests.num_of_tests); - print_message(3,message); - sprintf(message,"yaffs_num_of_tests: %d\n",yaffs_tests.num_of_tests); - print_message(3,message); - - run_random_test(num_of_random_tests); - //compare_linux_and_yaffs(); - yaffs_unmount("yaffs2"); - return 0; -} - -void init(int argc, char *argv[]) -{ - char dir[200]; - dir[0]='\0'; - int x=-1; - char message[100]; - int new_option; - - x=(unsigned)time(NULL); - sprintf(message,"seeding srand with: %d\n",x); - print_message(2,message); - srand(x); - yaffs_set_trace(0); - linux_struct.type_of_test =LINUX; - yaffs_struct.type_of_test =YAFFS; - - sprintf(message,"current absolute path is: %s\n",getcwd(dir,200)); - print_message(3,message); - strcpy(dir,getcwd(dir,200)); - - strcat(dir,"/test/"); - printf("dir: %s\n",dir); - strcpy(linux_struct.root_path,dir); - strcpy(yaffs_struct.root_path,"yaffs2/test/"); - - - do { - new_option=getopt_long(argc,argv,short_options,long_options,NULL); - if (new_option=='h'){ - printf("mirror_tests help\n"); - printf("arguments:\n"); - printf("\t-yaffs_path [PATH] //sets the path for yaffs.\n"); - printf("\t-linux_path [PATH] //sets the path for linux.\n"); - printf("\t-p [NUMBER] //sets the print level for mirror_tests.\n"); - printf("\t-v //verbose mode everything is printed\n"); - printf("\t-q //quiet mode nothing is printed.\n"); - printf("\t-n [number] //sets the number of random tests to run.\n"); - printf("\t-s [number] //seeds rand with the number\n"); - printf("\t-t [number] //sets yaffs_trace to the number\n"); - printf("\t-clean //removes emfile and test dir\n"); - exit(0); - } else if (new_option=='y'){ - strcpy(yaffs_struct.root_path, optarg); - } else if (new_option=='l'){ - strcpy(linux_struct.root_path, optarg); - } else if (new_option=='p'){ - set_print_level(atoi(optarg)); - } else if (new_option=='v'){ - set_print_level(5); - } else if (new_option=='q'){ - set_print_level(-1); - } else if (new_option=='n'){ - num_of_random_tests=atoi(optarg); - } else if (new_option=='s'){ - srand(atoi(argv[x+1])); - } else if (new_option=='t'){ - yaffs_set_trace(atoi(optarg)); - } else if (new_option=='c'){ - clean_dir(); - exit(0); - } else if (new_option==-1){ - - } else if (new_option=='?') { - printf("bad argument\n"); - exit(0); - } - - } while(new_option!=-1); - clean_dir(); - yaffs_start_up(); - print_message(2,"\nmounting yaffs\n"); - x=yaffs_mount("yaffs2"); - if (x<0) { - print_message(3,"failed to mount yaffs\n"); - get_error_yaffs(); - } else { - print_message(3,"mounted yaffs\n"); - } - - - print_message(3,"\nmaking linux test dir\n"); - x=mkdir(linux_struct.root_path,0777); - if (x<0) { - print_message(1,"failed to make dir\n"); - get_error_linux(); - } else { - print_message(3,"made dir\n"); - } - - print_message(3,"\nmaking yaffs test dir\n"); - x=yaffs_mkdir(yaffs_struct.root_path,0777); - if (x<0) { - print_message(1,"failed to make dir\n"); - get_error_yaffs(); - } else { - print_message(3,"made dir\n"); - } -} - -int run_random_test(int num_of_random_tests) -{ - int y=0; - int x=-1; - int id=0; - int test_id=-1; - int num_of_tests_before_check=1; - char message[200]; - arg_temp args_struct; - for (y=0;(y*num_of_tests_before_check)=4){ - get_error_yaffs(); - get_error_linux(); - } - - if ((abs(yaffs_get_error())!=abs(errno)) && - (abs(yaffs_get_error())!=EISDIR && abs(errno) != 0) && - (abs(yaffs_get_error())!=ENOENT && abs(errno) != EACCES)&& - (abs(yaffs_get_error())!=EINVAL && abs(errno) != EBADF) - ){ - print_message(2,"\ndifference in returned errors######################################\n"); - get_error_yaffs(); - get_error_linux(); - if (get_exit_on_error()){ - exit(0); - } - } - } - //check_mode(&args_struct); - compare_linux_and_yaffs(&args_struct); - //check_mode(&args_struct); - - } - compare_linux_and_yaffs(&args_struct); -} - -int select_test_id(int test_len) -{ - int id=0; - //printf("test_len = %d\n",test_len); - id=(rand() % test_len ); - //printf("id %d\n",id); - return id; - -} - -int check_mode(arg_temp *args_struct) -{ - char path[200]; - char message[200]; - int output=0; - - struct yaffs_stat yaffs_stat_struct; - join_paths(yaffs_struct.root_path,args_struct->string1, path ); - sprintf(message,"\ntrying to stat to: %s\n",path); - print_message(3,message); - output=yaffs_stat(path,&yaffs_stat_struct); - if (output < 0){ - sprintf(message,"failed to stat the file\n"); - print_message(3,message); - get_error_yaffs(); - } else { - sprintf(message,"stated the file\n"); - print_message(3,message); - sprintf(message," yaffs file mode is %d\n",(yaffs_stat_struct.st_mode & (S_IREAD| S_IWRITE))); - print_message(3,message); - sprintf(message,"mode S_IREAD %d S_IWRITE %d\n",(yaffs_stat_struct.st_mode & S_IREAD),(yaffs_stat_struct.st_mode & S_IWRITE)); - print_message(3,message); - } - return 1; -} - -int check_mode_file(char *path) -{ - char message[200]; - int output=0; - - struct yaffs_stat yaffs_stat_struct; - - sprintf(message,"\ntrying to stat to: %s\n",path); - print_message(3,message); - output=yaffs_stat(path,&yaffs_stat_struct); - if (output < 0){ - sprintf(message,"failed to stat the file\n"); - print_message(3,message); - get_error_yaffs(); - } else { - sprintf(message,"stated the file\n"); - print_message(3,message); - sprintf(message," yaffs file mode is %d\n",(yaffs_stat_struct.st_mode & (S_IREAD| S_IWRITE))); - print_message(3,message); - sprintf(message,"mode S_IREAD %d S_IWRITE %d\n\n",(yaffs_stat_struct.st_mode & S_IREAD),(yaffs_stat_struct.st_mode & S_IWRITE)); - print_message(3,message); - } - return 1; -} - -int compare_linux_and_yaffs(arg_temp *args_struct) -{ - int x=0,y=0; - char l_path[200]; - char y_path[200]; - char file_name[200]; - int exit_bool=0; - int number_of_files_in_yaffs=0; - int number_of_files_in_linux=0; - char message[200]; - char **yaffs_file_list=NULL; - char **linux_file_list=NULL; - - struct yaffs_stat yaffs_stat_struct; - struct stat linux_stat_struct; - yaffs_DIR *yaffs_open_dir; - yaffs_dirent *yaffs_current_file; - - DIR *linux_open_dir; - struct dirent *linux_current_file; - - l_path[0]='\0'; - y_path[0]='\0'; - file_name[0]='\0'; - message[0]='\0'; - print_message(2,"\n\n\n comparing folders\n"); -// check_mode_file("yaffs2/test/YY"); - //find out the number of files in the directory - yaffs_open_dir = yaffs_opendir(yaffs_struct.root_path); - if (yaffs_open_dir) { - for (x=0;yaffs_readdir(yaffs_open_dir);x++){} - number_of_files_in_yaffs=x; - sprintf(message,"number of files in yaffs dir= %d\n",number_of_files_in_yaffs); - print_message(2,message); - yaffs_rewinddir(yaffs_open_dir); - } else { - print_message(3,"failed to open yaffs test dir\n"); - } - //create array - yaffs_file_list= (char **)malloc(x*sizeof(char*)); - for (x=0;xd_name = %s\n",yaffs_current_file->d_name); - if (yaffs_current_file){ - strcpy(yaffs_file_list[x],yaffs_current_file->d_name); - - } - yaffs_current_file =yaffs_readdir(yaffs_open_dir); - } - yaffs_closedir(yaffs_open_dir); - } else { - print_message(3,"failed to populate yaffs test list\n"); - } - - - //find out the number of files in the directory - linux_open_dir = opendir(linux_struct.root_path); - if (linux_open_dir){ - for (x=0;readdir(linux_open_dir);x++){} - number_of_files_in_linux=(x-2); - sprintf(message,"number of files in linux dir= %d\n",(number_of_files_in_linux)); - print_message(2,message); - //the -2 is because linux shows 2 extra files which are automaticly created. - - rewinddir(linux_open_dir); - } else { - print_message(3,"failed to open linux test dir\n"); - } - - //create array - linux_file_list= (char **)malloc(number_of_files_in_linux*sizeof(char*)); - - for (x=0;xd_name); - print_message(7,"opened file: "); - print_message(7,message); - print_message(7,"\n"); - } - if (linux_current_file && - 0!=strcmp(message,".")&& - 0!=strcmp(message,"..")){ - strcpy(file_name,linux_current_file->d_name); - //sprintf("file opened: %s\n",linux_current_file->d_name); - //print_message(3,message); - print_message(7,"added file to list\n"); - strcpy(linux_file_list[y],file_name); - sprintf(message,"file added to list: %s\n",linux_file_list[y]); - print_message(7,message); - y++; - } - linux_current_file =readdir(linux_open_dir); - } - closedir(linux_open_dir); - } else { - print_message(3,"failed to populate linux test dir\n"); - } - - - //match the files in both folders - for (x=0;x=0&& - stat(l_path,&linux_stat_struct)>=0){ - sprintf(message," yaffs file mode is %d\n",(yaffs_stat_struct.st_mode & (S_IREAD| S_IWRITE))); - print_message(3,message); - sprintf(message,"mode S_IREAD %d S_IWRITE %d\n",(yaffs_stat_struct.st_mode & S_IREAD),(yaffs_stat_struct.st_mode & S_IWRITE)); - print_message(3,message); - sprintf(message," linux file mode is %d\n",(linux_stat_struct.st_mode & (S_IREAD|S_IWRITE))); - print_message(3,message); - sprintf(message,"mode S_IREAD %d S_IWRITE %d\n",(linux_stat_struct.st_mode & S_IREAD),(linux_stat_struct.st_mode & S_IWRITE)); - print_message(3,message); - if ((yaffs_stat_struct.st_mode & (S_IREAD| S_IWRITE))== - ( linux_stat_struct.st_mode & (S_IREAD|S_IWRITE))){ - print_message(2,"file modes match\n"); - } else { - print_message(2,"file modes do not match\n"); - exit_bool=1; - } - linux_file_list[y][0]=NULL; - yaffs_file_list[x][0]=NULL; - } else { - print_message(2,"failed to stat one of the files\n"); - get_error_yaffs(); - get_error_linux(); - } - - //read file contents - - - break; - } - } - } - - //print remaining files - for (x=0;xd_name); -// generate_array_of_objects_in_yaffs(); -// generate_array_of_objects_in_linux(); - //first do a check to see if both sides have the same objects on both sides. - //then stat all of the files and compare size and mode - //read the text of each file and compare them. - - //show the diffrences by printing them. - return 1; - -} - -void generate_random_numbers(arg_temp *args_struct) -{ - char string[51]; - args_struct->char1= (rand() % 255); - args_struct->char2= (rand() % 255); - args_struct->int1= (rand() % 100000); - args_struct->int2= (rand() % 100000); - generate_random_string(string,50); - strcpy(args_struct->string1, string); - generate_random_string(string,50); - strcpy(args_struct->string2, string); -} - -void run_yaffs_test(int id,arg_temp *args_struct) -{ - char message[200]; - int output =0; - print_message(3,"\n"); - //printf("id = %d\n",id); - sprintf(message,"running_test %s\n",yaffs_tests.test_list[id].test_name); - print_message(3,message); - output=yaffs_tests.test_list[id].test_pointer(args_struct); - if (output<0) { - sprintf(message,"test_failed %s\n",yaffs_tests.test_list[id].test_name); - print_message(3,message); - } else { - print_message(3,"test_passed\n"); - } -} - -void run_linux_test(int id,arg_temp *args_struct) -{ - char message[200]; - int output =0; - print_message(3,"\n"); - //printf("id = %d\n",id); - sprintf(message,"running_test %s\n",linux_tests.test_list[id].test_name); - print_message(3,message); - output=linux_tests.test_list[id].test_pointer(args_struct); - if (output<0) { - sprintf(message,"test_failed %s\n",linux_tests.test_list[id].test_name); - print_message(3,message); - } else { - print_message(3,"test_passed\n"); - } -} - - -void clean_dir(void) -{ - char string[200]; - char file[200]; - char message[200]; - DIR *linux_open_dir; - struct dirent *linux_current_file; - int x=0,output=0; - - getcwd(string,200); - strcat(string,"/emfile-2k-0"); - sprintf(message,"\n\nunlinking emfile at this path: %s\n",string); - print_message(3,message); - unlink(string); - - - linux_open_dir = opendir(linux_struct.root_path); - if (linux_open_dir){ - - do - { - - linux_current_file =readdir(linux_open_dir); - if (NULL!=linux_current_file){ - - strcpy(file,linux_struct.root_path); - strcat(file,linux_current_file->d_name); - sprintf(message,"unlinking file %s\n",file); - print_message(3,message); - print_message(3,"chmoding file\n"); - output=chmod(file,(S_IRUSR|S_IWUSR)); - if (output<0) { - get_error_linux(); - } - print_message(3,"unlinking file\n"); - output=unlink(file); - if (output<0) { - get_error_linux(); - } - } - } while(linux_current_file); - closedir(linux_open_dir); - rmdir(linux_struct.root_path); - } - -} diff --git a/direct/timothy_tests/mirror_tests/mirror_tests.h b/direct/timothy_tests/mirror_tests/mirror_tests.h deleted file mode 100644 index 9d30833..0000000 --- a/direct/timothy_tests/mirror_tests/mirror_tests.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * YAFFS: Yet another Flash File System . A NAND-flash specific file system. - * - * Copyright (C) 2002-2011 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 __mirror_tests_h__ -#define __mirror_tests_h__ - -#include -#include -#include //used for getting the current directory. -#include -#include -#include "yaffsfs.h" -#include "lib.h" -#include -#include -#include - -#include "linux_test_open.h" -#include "yaffs_test_open.h" -#include "linux_test_truncate.h" -#include "yaffs_test_truncate.h" -#include "linux_test_unlink.h" -#include "yaffs_test_unlink.h" -#include "linux_test_write.h" -#include "yaffs_test_write.h" - -#define LINUX 1 -#define YAFFS 2 - - - - - -void init(int argc, char *argv[]); -int run_random_test(int num_of_random_tests); -int compare_linux_and_yaffs(arg_temp *args_struct); - -int select_test_id(int test_len); -void generate_random_numbers(arg_temp *args_struct); -void run_yaffs_test(int id,arg_temp *args_struct); -void run_linux_test(int id,arg_temp *args_struct); -void clean_dir(void); -int select_test_id(int test_len); -int check_mode(arg_temp *args_struct); -int check_mode_file(char *path); -//void generate_array_of_objects_in_yaffs(void); -//void generate_array_of_objects_in_linux(void); - -#endif diff --git a/direct/timothy_tests/mirror_tests/yaffs_test_open.c b/direct/timothy_tests/mirror_tests/yaffs_test_open.c deleted file mode 100644 index daeb8a4..0000000 --- a/direct/timothy_tests/mirror_tests/yaffs_test_open.c +++ /dev/null @@ -1,38 +0,0 @@ -/* - * YAFFS: Yet another FFS. A NAND-flash specific file system. - * - * Copyright (C) 2002-2011 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. - */ - -#include "yaffs_test_open.h" - -int yaffs_test_open(arg_temp *args_struct) -{ - char path[200]; - char message[100]; - int output=0; - join_paths(yaffs_struct.root_path,args_struct->string1, path ); - sprintf(message,"file path: %s\n",path); - print_message(3,message); - - output=yaffs_open(path,args_struct->char1 &(O_TRUNC|O_EXCL|O_CREAT|O_APPEND),args_struct->char2&(S_IREAD|S_IWRITE)); - if (output>=0){ - output= yaffs_close(output); - if (output<0) { - print_message(3,"failed to close handle\n"); - return -1; - } else { - return 1; - } - } else { - print_message(3,"failed to open file\n"); - return -1; - } -} diff --git a/direct/timothy_tests/mirror_tests/yaffs_test_open.h b/direct/timothy_tests/mirror_tests/yaffs_test_open.h deleted file mode 100644 index d64bd29..0000000 --- a/direct/timothy_tests/mirror_tests/yaffs_test_open.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * YAFFS: Yet another Flash File System . A NAND-flash specific file system. - * - * Copyright (C) 2002-2011 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_test_open_h__ -#define __yaffs_test_open_h__ -#include -#include -#include -#include "yaffsfs.h" -#include "lib.h" - -int yaffs_test_open(arg_temp *args_struct); - -#endif diff --git a/direct/timothy_tests/mirror_tests/yaffs_test_truncate.c b/direct/timothy_tests/mirror_tests/yaffs_test_truncate.c deleted file mode 100644 index 9e99590..0000000 --- a/direct/timothy_tests/mirror_tests/yaffs_test_truncate.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * YAFFS: Yet another FFS. A NAND-flash specific file system. - * - * Copyright (C) 2002-2011 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. - */ - -#include "yaffs_test_truncate.h" - -int yaffs_test_truncate(arg_temp *args_struct) -{ - char path[200]; - char message[200]; - int output=0; - join_paths(yaffs_struct.root_path,args_struct->string1, path ); - sprintf(message,"file path: %s\n",path); - print_message(3,message); - - output=yaffs_truncate(path,args_struct->int1); - return output; -} diff --git a/direct/timothy_tests/mirror_tests/yaffs_test_truncate.h b/direct/timothy_tests/mirror_tests/yaffs_test_truncate.h deleted file mode 100644 index 02517cb..0000000 --- a/direct/timothy_tests/mirror_tests/yaffs_test_truncate.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * YAFFS: Yet another Flash File System . A NAND-flash specific file system. - * - * Copyright (C) 2002-2011 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_test_truncate_h__ -#define __yaffs_test_truncate_h__ -#include -#include -#include -#include "yaffsfs.h" -#include "lib.h" - -int yaffs_test_truncate(arg_temp *args_struct); - -#endif diff --git a/direct/timothy_tests/mirror_tests/yaffs_test_unlink.c b/direct/timothy_tests/mirror_tests/yaffs_test_unlink.c deleted file mode 100644 index 6982e77..0000000 --- a/direct/timothy_tests/mirror_tests/yaffs_test_unlink.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * YAFFS: Yet another FFS. A NAND-flash specific file system. - * - * Copyright (C) 2002-2011 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. - */ - -#include "yaffs_test_unlink.h" - -int yaffs_test_unlink(arg_temp *args_struct) -{ - char path[250]; - char message[150]; - int output; - join_paths(yaffs_struct.root_path,args_struct->string1, path ); - sprintf(message,"file path: %s\n",path); - print_message(3,message); - - output= yaffs_unlink(path); - - if (output<0) { - print_message(3,"failed to unlink file\n"); - return -1; - } else { - return 1; - } - -} diff --git a/direct/timothy_tests/mirror_tests/yaffs_test_unlink.h b/direct/timothy_tests/mirror_tests/yaffs_test_unlink.h deleted file mode 100644 index cb8fdf2..0000000 --- a/direct/timothy_tests/mirror_tests/yaffs_test_unlink.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * YAFFS: Yet another Flash File System . A NAND-flash specific file system. - * - * Copyright (C) 2002-2011 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_test_unlink_h__ -#define __yaffs_test_unlink_h__ -#include -#include -#include -#include "yaffsfs.h" -#include "lib.h" - -int yaffs_test_unlink(arg_temp *args_struct); - -#endif diff --git a/direct/timothy_tests/mirror_tests/yaffs_test_write.c b/direct/timothy_tests/mirror_tests/yaffs_test_write.c deleted file mode 100644 index 2820d68..0000000 --- a/direct/timothy_tests/mirror_tests/yaffs_test_write.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * YAFFS: Yet another FFS. A NAND-flash specific file system. - * - * Copyright (C) 2002-2011 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. - */ - -#include "yaffs_test_write.h" - -int yaffs_test_write(arg_temp *args_struct) -{ - char path[200]; - char message[200]; - int output=0,output2=0; - int handle; - struct yaffs_stat yaffs_stat_struct; - join_paths(yaffs_struct.root_path,args_struct->string1, path ); - sprintf(message,"trying to write to: %s\nwith mode set to %o \n",path,args_struct->char1); - print_message(3,message); - printf("mode S_IREAD %d S_IWRITE %d\n",(args_struct->char2 & S_IREAD),(args_struct->char2 & S_IWRITE)); - handle=yaffs_open(path,((args_struct->char1 &(O_TRUNC|O_EXCL|O_CREAT|O_APPEND))|O_RDWR),(args_struct->char2&(S_IREAD|S_IWRITE))); - printf("handle %d\n",handle); - if (handle<0){ - print_message(3,"failed to open a handle\n"); - return -1; //handle failed to open - } - -/* output=yaffs_fstat(handle,&yaffs_stat_struct); - if (output < 0){ - sprintf(message,"failed to stat the file\n"); - print_message(3,message); - get_error_yaffs(); - } else { - sprintf(message,"stated the file\n"); - print_message(3,message); - sprintf(message," yaffs file mode is %d\n",(yaffs_stat_struct.st_mode & (S_IREAD| S_IWRITE))); - print_message(3,message); - sprintf(message,"mode S_IREAD %d S_IWRITE %d\n",(yaffs_stat_struct.st_mode & S_IREAD),(yaffs_stat_struct.st_mode & S_IWRITE)); - print_message(3,message); - } - - sprintf(message,"trying to write: %d bytes into the file\n",strlen(args_struct->string2)); - print_message(3,message); -*/ - output=yaffs_write(handle,&args_struct->string2,strlen(args_struct->string2)); - -/* print_message(3,"\n wrote to the file\n"); - output2=yaffs_fstat(handle,&yaffs_stat_struct); - if (output2 < 0){ - sprintf(message,"failed to stat the file\n"); - print_message(3,message); - get_error_yaffs(); - } else { - sprintf(message,"stated the file\n"); - print_message(3,message); - sprintf(message," yaffs file mode is %d\n",(yaffs_stat_struct.st_mode & (S_IREAD| S_IWRITE))); - print_message(3,message); - sprintf(message,"mode S_IREAD %d S_IWRITE %d\n",(yaffs_stat_struct.st_mode & S_IREAD),(yaffs_stat_struct.st_mode & S_IWRITE)); - print_message(3,message); - } -*/ yaffs_close(handle); -/* print_message(3,"\n closing the file\n"); - output2=yaffs_stat(path,&yaffs_stat_struct); - if (output2 < 0){ - sprintf(message,"failed to stat the file\n"); - print_message(3,message); - get_error_yaffs(); - } else { - sprintf(message,"stated the file\n"); - print_message(3,message); - sprintf(message," yaffs file mode is %d\n",(yaffs_stat_struct.st_mode & (S_IREAD| S_IWRITE))); - print_message(3,message); - sprintf(message,"mode S_IREAD %d S_IWRITE %d\n",(yaffs_stat_struct.st_mode & S_IREAD),(yaffs_stat_struct.st_mode & S_IWRITE)); - print_message(3,message); - } -*/ - - return output; -} diff --git a/direct/timothy_tests/mirror_tests/yaffs_test_write.h b/direct/timothy_tests/mirror_tests/yaffs_test_write.h deleted file mode 100644 index 0332f6f..0000000 --- a/direct/timothy_tests/mirror_tests/yaffs_test_write.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * YAFFS: Yet another Flash File System . A NAND-flash specific file system. - * - * Copyright (C) 2002-2011 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_test_write_h__ -#define __yaffs_test_write_h__ -#include -#include -#include -#include -#include "yaffsfs.h" -#include "lib.h" - -int yaffs_test_write(arg_temp *args_struct); - -#endif diff --git a/direct/timothy_tests/quick_tests/Makefile b/direct/timothy_tests/quick_tests/Makefile index ef339c5..49ecd7a 100644 --- a/direct/timothy_tests/quick_tests/Makefile +++ b/direct/timothy_tests/quick_tests/Makefile @@ -42,8 +42,8 @@ COMMONTESTOBJS = yaffscfg2k.o yaffs_osglue.o yaffs_hweight.o \ yaffs_yaffs1.o \ yaffs_yaffs2.o \ yaffs_verify.o \ - yaffs_error.o - + yaffs_error.o \ + yaffs_summary.o # yaffs_checkptrwtest.o\ TESTFILES = quick_tests.o lib.o \ @@ -108,7 +108,8 @@ TESTFILES = quick_tests.o lib.o \ test_yaffs_lstat.o test_yaffs_lstat_ENOENT.o test_yaffs_lstat_ENOTDIR.o test_yaffs_lstat_ENAMETOOLONG.o \ test_yaffs_lstat_NULL.o \ test_yaffs_flush.o test_yaffs_flush_EBADF.o test_yaffs_flush_EROFS.o \ - test_yaffs_dup.o test_yaffs_dup_EBADF.o + test_yaffs_dup.o test_yaffs_dup_EBADF.o + @@ -127,7 +128,8 @@ YAFFSSYMLINKS = yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffs_tagscomp yaffs_yaffs1.c yaffs_yaffs1.h \ yaffs_yaffs2.c yaffs_yaffs2.h \ yaffs_bitmap.c yaffs_bitmap.h \ - yaffs_verify.c yaffs_verify.h + yaffs_verify.c yaffs_verify.h \ + yaffs_summary.c yaffs_summary.h YAFFSDIRECTSYMLINKS = yaffsfs.c yaffs_flashif.h yaffs_flashif2.h\ yaffsfs.h ydirectenv.h \ diff --git a/direct/timothy_tests/quick_tests/README.txt b/direct/timothy_tests/quick_tests/README.txt index 1744392..55b670e 100644 --- a/direct/timothy_tests/quick_tests/README.txt +++ b/direct/timothy_tests/quick_tests/README.txt @@ -1,6 +1,20 @@ - Made by Timothy Manning on 04/11/2010 +This test is designed to test the response and error handling of the yaffs functions. + +compile command: make +run command: ./quick_tests + +command line options: + -h prints the available command line options. + -c tests will continue even if a test fails, rather than exiting the test. + -v verbose mode. will print all messages. + -q quiet mode. will not print any messages. + -t [number] sets the yaffs_trace() function to the number. + -n [number] sets the number of randomly selected tests to run after the test has run through + after running all of listed tests. + +############################# development infomation #################################################################### Tests made diff --git a/direct/timothy_tests/quick_tests/current_bugs.txt b/direct/timothy_tests/quick_tests/current_bugs.txt deleted file mode 100644 index a8a88c4..0000000 --- a/direct/timothy_tests/quick_tests/current_bugs.txt +++ /dev/null @@ -1,28 +0,0 @@ - -Made by Timothy Manning on 08/11/2010 - - -Current BUGS - - -Current WARNINGS - - WARNING- If yaffs is unmounted then most of yaffs' functions return ENODIR. - But some function return EBADF instead. - Functions which return ENOTDIR: open, close, access, unlink, lseek, write, read - - Functions which return ENOENT: access, stat - - - - WARNING-the function yaffs_open does not check the mode passed to it. - This means that yaffs open does not return EINVAL if a bad mode is passed to it. - However this causes the error EEXIST to happen instead, because both O_CREAT and O_EXCL flags are set. - - WARNING- yaffs_open will work with either of the two mode set to 255. - However there are only 4 or 5 flags that can be set for each of the modes. - This means that the programmer may not be setting the flags properly. - - WARNING- When mounting a non-existing mount point the error ENODEV is returned. - The quick tests have been altered to accommodate this error code. - With standard access function in linux the error returned is ENOENT. diff --git a/direct/timothy_tests/stress_tester/Makefile b/direct/timothy_tests/stress_tester/Makefile new file mode 100644 index 0000000..b6d8cf8 --- /dev/null +++ b/direct/timothy_tests/stress_tester/Makefile @@ -0,0 +1,122 @@ +# 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_osglue.o yaffs_hweight.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_nand.o \ + yaffs_checkptrw.o yaffs_qsort.o\ + yaffs_nameval.o yaffs_attribs.o \ + yaffs_norif1.o ynorsim.o \ + yaffs_allocator.o \ + yaffs_bitmap.o \ + yaffs_yaffs1.o \ + yaffs_yaffs2.o \ + yaffs_verify.o \ + yaffs_summary.o + + +SSCOMMONTESTOBJS = 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_nand.o \ + yaffs_attribs.o yaffs_allocator.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 = yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffs_tagscompat.c yaffs_tagscompat.h \ + yaffs_packedtags1.c yaffs_packedtags1.h yaffs_packedtags2.c yaffs_packedtags2.h \ + yaffs_nand.c yaffs_nand.h yaffs_getblockinfo.h \ + yaffs_checkptrw.h yaffs_checkptrw.c \ + yaffs_nameval.c yaffs_nameval.h \ + yaffs_trace.h yaffs_attribs.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 \ + yaffs_summary.c yaffs_summary.h + +YAFFSDIRECTSYMLINKS = yaffsfs.c yaffs_flashif.h yaffs_flashif2.h\ + yaffsfs.h yaffs_osglue.h ydirectenv.h \ + yaffs_flashif.c yaffscfg.h yaffs_qsort.c \ + yaffs_nandemul2k.h yaffs_list.h \ + yaffs_attribs.c \ + yaffs_nandif.c yaffs_nandif.h yportenv.h \ + yaffs_hweight.c yaffs_hweight.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 yaffs_osglue.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/stress_tester/README.txt b/direct/timothy_tests/stress_tester/README.txt new file mode 100644 index 0000000..364d975 --- /dev/null +++ b/direct/timothy_tests/stress_tester/README.txt @@ -0,0 +1,8 @@ +The stress_tester program opens and closes files at random in an effort to break yaffs. + +compile command: make +run command: ./yaffs_tester + +command line options: + -seed [number] sets the random seed generator to the number. + diff --git a/direct/timothy_tests/stress_tester/error_handler.c b/direct/timothy_tests/stress_tester/error_handler.c new file mode 100644 index 0000000..a9152f3 --- /dev/null +++ b/direct/timothy_tests/stress_tester/error_handler.c @@ -0,0 +1,84 @@ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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,NPRINT); + yaffs_error=yaffs_get_error(); + append_int_to_buffer(message_buffer, yaffs_error,MESSAGE_LEVEL_ERROR,PRINT); + + 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); + quit_program(); + //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/stress_tester/error_handler.h b/direct/timothy_tests/stress_tester/error_handler.h new file mode 100644 index 0000000..979f020 --- /dev/null +++ b/direct/timothy_tests/stress_tester/error_handler.h @@ -0,0 +1,23 @@ +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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/stress_tester/message_buffer.c b/direct/timothy_tests/stress_tester/message_buffer.c new file mode 100644 index 0000000..adefbf8 --- /dev/null +++ b/direct/timothy_tests/stress_tester/message_buffer.c @@ -0,0 +1,112 @@ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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/stress_tester/message_buffer.h b/direct/timothy_tests/stress_tester/message_buffer.h new file mode 100644 index 0000000..55f9e10 --- /dev/null +++ b/direct/timothy_tests/stress_tester/message_buffer.h @@ -0,0 +1,49 @@ +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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/stress_tester/yaffs_tester.c b/direct/timothy_tests/stress_tester/yaffs_tester.c new file mode 100644 index 0000000..86dcf46 --- /dev/null +++ b/direct/timothy_tests/stress_tester/yaffs_tester.c @@ -0,0 +1,384 @@ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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 */ + +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*/ + + +int main(int argc, char *argv[]){ + + + 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;xnumber_of_open_handles,MESSAGE_LEVEL_BASIC_TASKS,PRINT); + if (P_open_handles_array->number_of_open_handleshandle[x]!=-3 && xhandle[x]=output; + P_open_handles_array->path[x][0]='\0'; + strcat(P_open_handles_array->path[x],path); + add_to_buffer(&message_buffer,"yaffs handle: ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); + append_int_to_buffer(&message_buffer,output,MESSAGE_LEVEL_BASIC_TASKS,PRINT); + add_to_buffer(&message_buffer,"stored handle: ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); + + //yaffs_open will return a null pointer if it cannot open a file. check for errors will not work. + yaffs_check_for_errors(output, &message_buffer,"failed to open file","opened file"); + + P_open_handles_array->number_of_open_handles++; + } + else close_random_file(P_open_handles_array); + +} + +void write_to_random_file(handle_regster *P_open_handles_array){ + int number_of_lines_of_text=0; + int length=100; + char text[length+1]; + text[0]='\0'; + int seek=0; + int x=0; + int output=0; + if (P_open_handles_array->number_of_open_handles>0){ + + while (P_open_handles_array->handle[x]==-3){ /*find a random open handle*/ + x=rand() % (MAX_NUMBER_OF_OPENED_HANDLES-1); + } + add_to_buffer(&message_buffer,"\n\ntrying to write to ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); + append_to_buffer(&message_buffer,P_open_handles_array->path[x],MESSAGE_LEVEL_BASIC_TASKS,PRINT); + + stat_file(P_open_handles_array->path[x]); + number_of_lines_of_text=rand() %1000; + add_to_buffer(&message_buffer,"writing ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); + append_int_to_buffer(&message_buffer,number_of_lines_of_text,MESSAGE_LEVEL_BASIC_TASKS,NPRINT); + append_to_buffer(&message_buffer," lines of text",MESSAGE_LEVEL_BASIC_TASKS,PRINT); + + + for (;number_of_lines_of_text>0;number_of_lines_of_text--) + { + generate_random_string(text,length); + seek=rand()%1000; + add_to_buffer(&message_buffer,"trying to seek to ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); + append_int_to_buffer(&message_buffer,seek,MESSAGE_LEVEL_BASIC_TASKS,PRINT); + output=yaffs_lseek(P_open_handles_array->handle[x],seek,SEEK_SET); + yaffs_check_for_errors(output, &message_buffer,"failed to seek","seeked file"); + add_to_buffer(&message_buffer,"trying to write to file",MESSAGE_LEVEL_BASIC_TASKS,PRINT); + output=yaffs_write(P_open_handles_array->handle[x], text, strlen(text)); + yaffs_check_for_errors(output, &message_buffer,"failed to write text","wrote text"); + + } + } +} + +void truncate_random_file(handle_regster *P_open_handles_array){ + int x=0; + int truncate_size=0; + int output=0; + + if (P_open_handles_array->number_of_open_handles>0){ + add_to_buffer(&message_buffer,"\n\ntruncate function ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); + while (P_open_handles_array->handle[x]==-3){ /*find a random open handle*/ + x=rand() % (MAX_NUMBER_OF_OPENED_HANDLES-1); + } + add_to_buffer(&message_buffer,"trying to truncate ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); + append_to_buffer(&message_buffer,P_open_handles_array->path[x],MESSAGE_LEVEL_BASIC_TASKS,PRINT); + + stat_file(P_open_handles_array->path[x]); + truncate_size=rand() %10000; + output=yaffs_ftruncate(P_open_handles_array->handle[x], truncate_size); + yaffs_check_for_errors(output, &message_buffer,"failed to truncate file","truncated file"); + } +} + +void close_random_file(handle_regster *P_open_handles_array){ + /*run out of space on the handle pointer array*/ + /*make space*/ + int x=0; + int output=0; + int start=0; + printf("trying to clear handle"); + if (P_open_handles_array->number_of_open_handles>0){ + start=rand() % (MAX_NUMBER_OF_OPENED_HANDLES-1); + + for (x=start;(x+1>start ||xMAX_NUMBER_OF_OPENED_HANDLES-1) x=0; + if (P_open_handles_array->handle[x] !=-3 ){ + //the handle is open, so try to close it. + break; + } + + } + if (P_open_handles_array->handle[x]!=-3) + { + add_to_buffer(&message_buffer,"\n\ntrying to close file: ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); + append_to_buffer(&message_buffer,P_open_handles_array->path[x],MESSAGE_LEVEL_BASIC_TASKS,PRINT); + add_to_buffer(&message_buffer,"file handle: ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); + append_int_to_buffer(&message_buffer,P_open_handles_array->handle[x],MESSAGE_LEVEL_BASIC_TASKS,PRINT); + + stat_file(P_open_handles_array->path[x]); + output=yaffs_close(P_open_handles_array->handle[x]); + + if (output==-1) yaffs_check_for_errors(output, &message_buffer,"failed to close file","closed file"); + else { + yaffs_check_for_errors(output, &message_buffer,"failed to close file","closed file"); + P_open_handles_array->handle[x]=-3; + P_open_handles_array->path[x][0]='\0'; + P_open_handles_array->number_of_open_handles--; + } + } + else { + add_to_buffer(&message_buffer,"\n\ntried to close file but could not find a open file ",MESSAGE_LEVEL_BASIC_TASKS,PRINT); + } + } +} + +void stat_file(char *path){ + int output=0; + struct yaffs_stat stat; + if (yaffs_access(path,0)==0){ + add_to_buffer(&message_buffer,"file exists, trying to stat: ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); + add_to_buffer(&message_buffer,path,MESSAGE_LEVEL_BASIC_TASKS,PRINT); + output=yaffs_lstat(path,&stat); + yaffs_check_for_errors(output, &message_buffer,"failed to stat file","statted file"); + //stat.st_ino,(int)stat.st_size,stat.st_mode + add_to_buffer(&message_buffer,"yaffs inode: ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); + append_int_to_buffer(&message_buffer,stat.st_ino,MESSAGE_LEVEL_BASIC_TASKS,NPRINT); + append_to_buffer(&message_buffer," file size: ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); + append_int_to_buffer(&message_buffer,(int)stat.st_size,MESSAGE_LEVEL_BASIC_TASKS,NPRINT); + append_to_buffer(&message_buffer," file mode: ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT); + append_int_to_buffer(&message_buffer,stat.st_mode,MESSAGE_LEVEL_BASIC_TASKS,PRINT); + } + else{ + add_to_buffer(&message_buffer,path,MESSAGE_LEVEL_BASIC_TASKS,NPRINT); + append_to_buffer(&message_buffer," does not exist,could not stat",MESSAGE_LEVEL_BASIC_TASKS,PRINT); + } +} + +void test(char*yaffs_test_dir){ + struct yaffs_stat stat; + int output=0; + //char name[MAX_FILE_NAME_SIZE+3 ]="apple\0"; + //char path[MAX_FILE_NAME_SIZE]; + handle_regster open_handles_array; + //int handle_pointers[MAX_NUMBER_OF_OPENED_HANDLES]; + //int number_of_opened_handles=0; + int x=0; + + + open_handles_array.number_of_open_handles=0; + 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/stress_tester/yaffs_tester.h b/direct/timothy_tests/stress_tester/yaffs_tester.h new file mode 100644 index 0000000..11a0815 --- /dev/null +++ b/direct/timothy_tests/stress_tester/yaffs_tester.h @@ -0,0 +1,48 @@ +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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_NUMBER_OF_OPENED_HANDLES 70 +#define MAX_FILE_NAME_SIZE 51 + +typedef struct handle_regster_template{ + int handle[MAX_NUMBER_OF_OPENED_HANDLES]; + char path[MAX_NUMBER_OF_OPENED_HANDLES][100]; + int number_of_open_handles; +}handle_regster; + + +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,int length_of_str); /*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); +void stat_file(char *path); +void write_to_random_file(handle_regster *P_open_handles_array); +void close_random_file(handle_regster *P_open_handles_array); +void quit_program(); +void truncate_random_file(handle_regster *P_open_handles_array); +#endif diff --git a/direct/timothy_tests/threading/Makefile b/direct/timothy_tests/threading/Makefile index e733471..cb3c1e4 100644 --- a/direct/timothy_tests/threading/Makefile +++ b/direct/timothy_tests/threading/Makefile @@ -42,7 +42,8 @@ COMMONTESTOBJS = yaffscfg2k.o yaffs_osglue.o yaffs_hweight.o \ yaffs_yaffs1.o \ yaffs_yaffs2.o \ yaffs_verify.o \ - yaffs_error.o + yaffs_error.o \ + yaffs_summary.o # yaffs_checkptrwtest.o\ @@ -65,7 +66,8 @@ YAFFSSYMLINKS = yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffs_tagscomp yaffs_yaffs1.c yaffs_yaffs1.h \ yaffs_yaffs2.c yaffs_yaffs2.h \ yaffs_bitmap.c yaffs_bitmap.h \ - yaffs_verify.c yaffs_verify.h + yaffs_verify.c yaffs_verify.h \ + yaffs_summary.c yaffs_summary.h YAFFSDIRECTSYMLINKS = yaffsfs.c yaffs_flashif.h yaffs_flashif2.h\ yaffsfs.h ydirectenv.h \ diff --git a/direct/timothy_tests/threading/README.txt b/direct/timothy_tests/threading/README.txt new file mode 100644 index 0000000..68c1a61 --- /dev/null +++ b/direct/timothy_tests/threading/README.txt @@ -0,0 +1,12 @@ +Created by Timothy Manning on 7/01/11 + +This test is designed to test the locking ability of yaffs functions. + +compile command: make +run command: ./threading + + +command line arguments are: + -h displays the help contents + -t sets the number of threads + diff --git a/direct/timothy_tests/yaffs_and_linux_mirror_tests/Makefile b/direct/timothy_tests/yaffs_and_linux_mirror_tests/Makefile new file mode 100644 index 0000000..0ba8539 --- /dev/null +++ b/direct/timothy_tests/yaffs_and_linux_mirror_tests/Makefile @@ -0,0 +1,119 @@ +# 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_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_osglue.o yaffs_hweight.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_nand.o \ + yaffs_checkptrw.o yaffs_qsort.o\ + yaffs_nameval.o yaffs_attribs.o \ + yaffs_norif1.o ynorsim.o \ + yaffs_allocator.o \ + yaffs_bitmap.o \ + yaffs_yaffs1.o \ + yaffs_yaffs2.o \ + yaffs_verify.o \ + yaffs_error.o \ + yaffs_summary.o + +# yaffs_checkptrwtest.o\ + +TESTFILES = mirror_tests.o lib.o\ + linux_test_open.o yaffs_test_open.o\ + linux_test_truncate.o yaffs_test_truncate.o \ + linux_test_unlink.o yaffs_test_unlink.o \ + linux_test_write.o yaffs_test_write.o + + + + +YAFFSTESTOBJS = $(COMMONTESTOBJS) $(TESTFILES) + + +ALLOBJS = $(sort $(YAFFSTESTOBJS)) $(PYTHONOBJS) + +YAFFSSYMLINKS = yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffs_tagscompat.c yaffs_tagscompat.h \ + yaffs_packedtags1.c yaffs_packedtags1.h yaffs_packedtags2.c yaffs_packedtags2.h \ + yaffs_nand.c yaffs_nand.h yaffs_getblockinfo.h \ + yaffs_checkptrw.h yaffs_checkptrw.c \ + yaffs_nameval.c yaffs_nameval.h \ + yaffs_trace.h yaffs_attribs.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 \ + yaffs_summary.c yaffs_summary.h + +YAFFSDIRECTSYMLINKS = yaffsfs.c yaffs_flashif.h yaffs_flashif2.h\ + yaffsfs.h ydirectenv.h \ + yaffs_flashif.c yaffscfg.h yaffs_qsort.c \ + yaffs_nandemul2k.h yaffs_list.h \ + yaffs_attribs.c yaffs_osglue.h \ + yaffs_nandif.c yaffs_nandif.h yportenv.h \ + yaffs_hweight.h yaffs_hweight.c \ + yaffs_error.c + + +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 yaffs_osglue.c + +SYMLINKS = $(YAFFSSYMLINKS) $(YAFFSDIRECTSYMLINKS) $(DIRECTEXTRASYMLINKS) $(PYTONOSYMLINKS) +#all: directtest2k boottest + +all: mirror_tests + +$(ALLOBJS): %.o: %.c + gcc -c $(CFLAGS) -o $@ $< + +$(PYTONOSYMLINKS): + ln -s ../../python/$@ $@ + +$(YAFFSSYMLINKS): + ln -s ../../../$@ $@ + +$(YAFFSDIRECTSYMLINKS): + ln -s ../../$@ $@ + +$(DIRECTEXTRASYMLINKS): + ln -s ../../basic-test/$@ $@ + + +mirror_tests: $(SYMLINKS) $(ALLOBJS) + gcc $(CFLLAG) -o $@ $(ALLOBJS) + + + +clean: + rm -f mirror_tests $(ALLOBJS) core $(SYMLINKS) diff --git a/direct/timothy_tests/yaffs_and_linux_mirror_tests/README.txt b/direct/timothy_tests/yaffs_and_linux_mirror_tests/README.txt new file mode 100644 index 0000000..2c03959 --- /dev/null +++ b/direct/timothy_tests/yaffs_and_linux_mirror_tests/README.txt @@ -0,0 +1,27 @@ +Made by Timothy Manning on 24/12/2010 + + + mirror_tests is designed to check that yaffs behaves the same way as linux. + This is done by applying the same command to both linux and yaffs and + then checking the output of the functions. + The default place for creating linux files is direct/timothy_tests/mirror_tests/tests/ + This directory is removed and is recreated at the beginning of each test, + However some of the files may be read only and cannot be deleted. + It is much better to remove this directory via the command line. + + rm test/*;rmdir test/;./mirror_tests -n 100 -v + +compile command: make +run command: mirror_tests + +Command line arguments + -yaffs_path [PATH] sets the path for yaffs. + -linux_path [PATH] sets the path for linux. + -p [NUMBER] sets the print level for mirror_tests. + -v verbose mode everything is printed + -q quiet mode nothing is printed. + -n [number] sets the number of random tests to run. + -s [number] seeds rand with the number + -t [number] sets yaffs_trace to the number + -clean removes emfile and test dir + diff --git a/direct/timothy_tests/yaffs_and_linux_mirror_tests/lib.c b/direct/timothy_tests/yaffs_and_linux_mirror_tests/lib.c new file mode 100644 index 0000000..079ed25 --- /dev/null +++ b/direct/timothy_tests/yaffs_and_linux_mirror_tests/lib.c @@ -0,0 +1,141 @@ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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. + */ + +#include "lib.h" + +static int EXIT_ON_ERROR = 1; +static int 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. +void set_print_level(int new_level) +{ + PRINT_LEVEL=new_level; +} +int get_print_level(void) +{ + return PRINT_LEVEL; +} + +void set_exit_on_error(int num) +{ + EXIT_ON_ERROR=num; +} + +int get_exit_on_error(void) +{ + return EXIT_ON_ERROR; +} + +void display_error(void) +{ + +} + +void get_error_yaffs(void) +{ + int error_code=0; + char message[30]; + message[0]='\0'; + + error_code=yaffs_get_error(); + sprintf(message,"yaffs_error code %d\n",error_code); + print_message(1,message); + sprintf(message,"error is : %s\n",yaffs_error_to_str(error_code)); + print_message(1,message); +} + +void get_error_linux(void) +{ + int error_code=0; + char message[30]; + message[0]='\0'; + + error_code=errno; + sprintf(message,"linux_error code %d\n",error_code); + print_message(1,message); + strcpy(message,"error code"); + sprintf(message,"error is : %s\n",yaffs_error_to_str(error_code)); + //perror(message); + print_message(1,message); +} +void generate_random_string(char *ptr,int length_of_str){ + unsigned int x; + unsigned int length=((rand() %(length_of_str-3))+3); /*creates a int with the number of charecters been between 1 and 51*/ + char letter='\0'; + strcpy(ptr,""); + //printf("generating string\n"); + //printf("string length is %d\n",length); + for (x=0; x <= (length-2) &&length>2 ; x++) + { + //printf("x=%d\n",x); + /* keep generating a charecter until the charecter is legal*/ + while((letter=='\0' )||(letter=='/')||(letter=='\\')){ + letter=(rand() % 125-59)+58; /*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*/ + +} + +void join_paths(char *path1,char *path2,char *new_path ) +{ + char message[100]; + print_message(3,"joining paths\n"); + sprintf(message,"path1: %s\n",path1); + print_message(3,message); + sprintf(message,"path2: %s\n",path2); + print_message(3,message); + strcpy(new_path,""); + //strcat(new_path,path1); /*since all functions have this then pull it out*/ + if ( (path1[(sizeof(path1)/sizeof(char))-2]=='/') && path2[0]!='/') { + /*paths are compatiable. concatanate them. note -2 is because of \0*/ + strcat(new_path,path1); + strcat(new_path,path2); + //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]=='/') { + /*paths are compatiable. concatanate them*/ + strcat(new_path,path1); + strcat(new_path,path2); + + } 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]=='/') { + /*need to remove a "/". */ + /*yaffs does not mind the extra slash. */ + strcat(new_path,path1); + strcat(new_path,path2); + + } else { + //error + //return -1; + } +} + +void print_message(char print_level,char *message) +{ + if (print_level <= PRINT_LEVEL){ + printf(message); + } +} + + + diff --git a/direct/timothy_tests/yaffs_and_linux_mirror_tests/lib.h b/direct/timothy_tests/yaffs_and_linux_mirror_tests/lib.h new file mode 100644 index 0000000..0b33479 --- /dev/null +++ b/direct/timothy_tests/yaffs_and_linux_mirror_tests/lib.h @@ -0,0 +1,53 @@ +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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 _lib_h__ +#define _lib_h__ + +#include +#include +#include "yaffsfs.h" +#include + +typedef struct arg_temp2{ + char char1; + char char2; + char string1[100]; + char string2[100]; + int int1; + int int2; +} arg_temp; + + +typedef struct test_dir_temp +{ + int type_of_test; //used to tell if it is LINUX of YAFFS + char root_path[200]; +} test_dir; +test_dir yaffs_struct,linux_struct; + + + +void generate_random_string(char *ptr,int length_of_str); +void join_paths(char *path1,char *path2,char *new_path ); +void print_message(char print_level, char *message); +void set_print_level(int new_level); +int get_print_level(void); +void set_exit_on_error(int num); +int get_exit_on_error(void); +void display_error(void); +void get_error_yaffs(void); +void get_error_linux(void); +#endif diff --git a/direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_open.c b/direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_open.c new file mode 100644 index 0000000..871dc56 --- /dev/null +++ b/direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_open.c @@ -0,0 +1,38 @@ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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. + */ + +#include "linux_test_open.h" + +int linux_test_open(arg_temp *args_struct) +{ + char path[250]; + char message[150]; + int output; + join_paths(linux_struct.root_path,args_struct->string1, path ); + sprintf(message,"file path: %s\n",path); + print_message(3,message); + + output= open(path,args_struct->char1 & (O_TRUNC|O_EXCL|O_CREAT|O_APPEND) ,args_struct->char2& (S_IREAD|S_IWRITE)); + if (output>=0){ + output=close(output); + if (output<0) { + print_message(3,"failed to close handle\n"); + return -1; + } else { + return 1; + } + } else { + print_message(3,"failed to open file\n"); + return -1; + } +} diff --git a/direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_open.h b/direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_open.h new file mode 100644 index 0000000..6274934 --- /dev/null +++ b/direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_open.h @@ -0,0 +1,24 @@ +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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 __linux_test_open_h__ +#define __linux_test_open_h__ +#include +#include +#include +#include "lib.h" + +int linux_test_open(arg_temp *args_struct); +#endif diff --git a/direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_truncate.c b/direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_truncate.c new file mode 100644 index 0000000..94e8959 --- /dev/null +++ b/direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_truncate.c @@ -0,0 +1,27 @@ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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. + */ + +#include "linux_test_truncate.h" + +int linux_test_truncate(arg_temp *args_struct) +{ + char path[200]; + char message[200]; + int output=0; + join_paths(linux_struct.root_path,args_struct->string1, path ); + sprintf(message,"file path: %s\n",path); + print_message(3,message); + + output=truncate(path,args_struct->int1); + return output; +} diff --git a/direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_truncate.h b/direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_truncate.h new file mode 100644 index 0000000..7ef91d0 --- /dev/null +++ b/direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_truncate.h @@ -0,0 +1,27 @@ +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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 __linux_test_truncate_h__ +#define __linux_test_truncate_h__ +#include +#include +#include +#include +#include "yaffsfs.h" +#include "lib.h" + +int linux_test_truncate(arg_temp *args_struct); + +#endif diff --git a/direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_unlink.c b/direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_unlink.c new file mode 100644 index 0000000..575e7ae --- /dev/null +++ b/direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_unlink.c @@ -0,0 +1,33 @@ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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. + */ + +#include "linux_test_unlink.h" + +int linux_test_unlink(arg_temp *args_struct) +{ + char path[250]; + char message[150]; + int output; + join_paths(linux_struct.root_path,args_struct->string1, path ); + sprintf(message,"file path: %s\n",path); + print_message(3,message); + + output= unlink(path); + + if (output<0) { + print_message(3,"failed to unlink file\n"); + return -1; + } else { + return 1; + } +} diff --git a/direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_unlink.h b/direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_unlink.h new file mode 100644 index 0000000..7572aa8 --- /dev/null +++ b/direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_unlink.h @@ -0,0 +1,26 @@ +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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 __linux_test_unlink_h__ +#define __linux_test_unlink_h__ +#include +#include +#include +#include "yaffsfs.h" +#include "lib.h" + +int linux_test_unlink(arg_temp *args_struct); + +#endif diff --git a/direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_write.c b/direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_write.c new file mode 100644 index 0000000..b46c211 --- /dev/null +++ b/direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_write.c @@ -0,0 +1,37 @@ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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. + */ + +#include "linux_test_write.h" + +int linux_test_write(arg_temp *args_struct) +{ + char path[200]; + char message[200]; + int output=0; + int handle=-1; + join_paths(linux_struct.root_path,args_struct->string1, path ); + sprintf(message,"trying to write to: %s\nwith mode set to %o \n",path,args_struct->char1 ); + print_message(3,message); + printf("mode S_IREAD %d S_IWRITE %d\n",(args_struct->char2 & S_IREAD),(args_struct->char2 & S_IWRITE)); + handle=open(path,((args_struct->char1 &(O_TRUNC|O_EXCL|O_CREAT|O_APPEND))|O_RDWR),(args_struct->char2&(S_IREAD|S_IWRITE))); + printf("handle %d\n",handle); + if (handle<0){ + print_message(3,"failed to open a handle\n"); + return -1; //handle failed to open + } + sprintf(message,"trying to write: %d bytes into the file\n",strlen(args_struct->string2)); + print_message(3,message); + output=write(handle,args_struct->string2,strlen(args_struct->string2)); + close(handle); + return output; +} diff --git a/direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_write.h b/direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_write.h new file mode 100644 index 0000000..611fe7d --- /dev/null +++ b/direct/timothy_tests/yaffs_and_linux_mirror_tests/linux_test_write.h @@ -0,0 +1,27 @@ +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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 __linux_test_write_h__ +#define __linux_test_write_h__ +#include +#include +#include +#include +#include "yaffsfs.h" +#include "lib.h" + +int linux_test_write(arg_temp *args_struct); + +#endif diff --git a/direct/timothy_tests/yaffs_and_linux_mirror_tests/mirror_tests.c b/direct/timothy_tests/yaffs_and_linux_mirror_tests/mirror_tests.c new file mode 100644 index 0000000..cd4e5f2 --- /dev/null +++ b/direct/timothy_tests/yaffs_and_linux_mirror_tests/mirror_tests.c @@ -0,0 +1,601 @@ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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. + */ + +#include "mirror_tests.h" + +int random_seed; +int simulate_power_failure = 0; + +int num_of_random_tests=1; + + + +typedef struct test_list_temp2{ + char *test_name; + int (*test_pointer)(arg_temp *args_struct); +}test_list_temp; + +typedef struct test_temp2 { + int num_of_tests; + test_list_temp test_list[]; +}test_temp; + +test_temp yaffs_tests={ + 4, + {{"yaffs_test_open",yaffs_test_open}, + {"yaffs_test_truncate",yaffs_test_truncate}, + {"yaffs_test_unlink",yaffs_test_unlink}, + {"yaffs_test_write",yaffs_test_write} + } +}; + +test_temp linux_tests={ + 4, + {{"linux_test_open",linux_test_open}, + {"linux_test_truncate",linux_test_truncate}, + {"linux_test_unlink",linux_test_unlink}, + {"linux_test_write",linux_test_write} + } +}; + +const struct option long_options[]={ + {"help", 0,NULL,'h'}, + {"yaffs_path", 1,NULL,'y'}, + {"linux_path", 1,NULL,'l'}, + {"print_level", 1,NULL,'p'}, + {"quiet", 0,NULL,'q'}, + {"number", 1,NULL,'n'}, + {"seed", 1,NULL,'s'}, + {"trace", 1,NULL,'t'}, + {"clean", 0,NULL,'c'}, + {"verbose", 0,NULL,'v'} +}; + +const char short_options[]="hy:l:p:qn:s:t:cv"; + + +int main(int argc, char *argv[]) +{ + char message[100]; + +// yaffs_tests.num_of_tests=(sizeof(yaffs_tests)/sizeof(test_temp)); +// linux_tests.num_of_tests=(sizeof(linux_tests)/sizeof(test_temp)); + + init(argc,argv); + print_message(1,"running mirror_tests\n"); + sprintf(message,"linux_root_path: %s\n",linux_struct.root_path); + print_message(3,message); + sprintf(message,"yaffs_root_path: %s\n",yaffs_struct.root_path); + print_message(3,message); + sprintf(message,"linux_num_of_tests: %d\n",linux_tests.num_of_tests); + print_message(3,message); + sprintf(message,"yaffs_num_of_tests: %d\n",yaffs_tests.num_of_tests); + print_message(3,message); + + run_random_test(num_of_random_tests); + //compare_linux_and_yaffs(); + yaffs_unmount("yaffs2"); + return 0; +} + +void init(int argc, char *argv[]) +{ + char dir[200]; + dir[0]='\0'; + int x=-1; + char message[100]; + int new_option; + + x=(unsigned)time(NULL); + sprintf(message,"seeding srand with: %d\n",x); + print_message(2,message); + srand(x); + yaffs_set_trace(0); + linux_struct.type_of_test =LINUX; + yaffs_struct.type_of_test =YAFFS; + + sprintf(message,"current absolute path is: %s\n",getcwd(dir,200)); + print_message(3,message); + strcpy(dir,getcwd(dir,200)); + + strcat(dir,"/test/"); + printf("dir: %s\n",dir); + strcpy(linux_struct.root_path,dir); + strcpy(yaffs_struct.root_path,"yaffs2/test/"); + + + do { + new_option=getopt_long(argc,argv,short_options,long_options,NULL); + if (new_option=='h'){ + printf("mirror_tests help\n"); + printf("arguments:\n"); + printf("\t-yaffs_path [PATH] //sets the path for yaffs.\n"); + printf("\t-linux_path [PATH] //sets the path for linux.\n"); + printf("\t-p [NUMBER] //sets the print level for mirror_tests.\n"); + printf("\t-v //verbose mode everything is printed\n"); + printf("\t-q //quiet mode nothing is printed.\n"); + printf("\t-n [number] //sets the number of random tests to run.\n"); + printf("\t-s [number] //seeds rand with the number\n"); + printf("\t-t [number] //sets yaffs_trace to the number\n"); + printf("\t-clean //removes emfile and test dir\n"); + exit(0); + } else if (new_option=='y'){ + strcpy(yaffs_struct.root_path, optarg); + } else if (new_option=='l'){ + strcpy(linux_struct.root_path, optarg); + } else if (new_option=='p'){ + set_print_level(atoi(optarg)); + } else if (new_option=='v'){ + set_print_level(5); + } else if (new_option=='q'){ + set_print_level(-1); + } else if (new_option=='n'){ + num_of_random_tests=atoi(optarg); + } else if (new_option=='s'){ + srand(atoi(argv[x+1])); + } else if (new_option=='t'){ + yaffs_set_trace(atoi(optarg)); + } else if (new_option=='c'){ + clean_dir(); + exit(0); + } else if (new_option==-1){ + + } else if (new_option=='?') { + printf("bad argument\n"); + exit(0); + } + + } while(new_option!=-1); + clean_dir(); + yaffs_start_up(); + print_message(2,"\nmounting yaffs\n"); + x=yaffs_mount("yaffs2"); + if (x<0) { + print_message(3,"failed to mount yaffs\n"); + get_error_yaffs(); + } else { + print_message(3,"mounted yaffs\n"); + } + + + print_message(3,"\nmaking linux test dir\n"); + x=mkdir(linux_struct.root_path,0777); + if (x<0) { + print_message(1,"failed to make dir\n"); + get_error_linux(); + } else { + print_message(3,"made dir\n"); + } + + print_message(3,"\nmaking yaffs test dir\n"); + x=yaffs_mkdir(yaffs_struct.root_path,0777); + if (x<0) { + print_message(1,"failed to make dir\n"); + get_error_yaffs(); + } else { + print_message(3,"made dir\n"); + } +} + +int run_random_test(int num_of_random_tests) +{ + int y=0; + int x=-1; + int id=0; + int test_id=-1; + int num_of_tests_before_check=1; + char message[200]; + arg_temp args_struct; + for (y=0;(y*num_of_tests_before_check)=4){ + get_error_yaffs(); + get_error_linux(); + } + + if ((abs(yaffs_get_error())!=abs(errno)) && + (abs(yaffs_get_error())!=EISDIR && abs(errno) != 0) && + (abs(yaffs_get_error())!=ENOENT && abs(errno) != EACCES)&& + (abs(yaffs_get_error())!=EINVAL && abs(errno) != EBADF) + ){ + print_message(2,"\ndifference in returned errors######################################\n"); + get_error_yaffs(); + get_error_linux(); + if (get_exit_on_error()){ + exit(0); + } + } + } + //check_mode(&args_struct); + compare_linux_and_yaffs(&args_struct); + //check_mode(&args_struct); + + } + compare_linux_and_yaffs(&args_struct); +} + +int select_test_id(int test_len) +{ + int id=0; + //printf("test_len = %d\n",test_len); + id=(rand() % test_len ); + //printf("id %d\n",id); + return id; + +} + +int check_mode(arg_temp *args_struct) +{ + char path[200]; + char message[200]; + int output=0; + + struct yaffs_stat yaffs_stat_struct; + join_paths(yaffs_struct.root_path,args_struct->string1, path ); + sprintf(message,"\ntrying to stat to: %s\n",path); + print_message(3,message); + output=yaffs_stat(path,&yaffs_stat_struct); + if (output < 0){ + sprintf(message,"failed to stat the file\n"); + print_message(3,message); + get_error_yaffs(); + } else { + sprintf(message,"stated the file\n"); + print_message(3,message); + sprintf(message," yaffs file mode is %d\n",(yaffs_stat_struct.st_mode & (S_IREAD| S_IWRITE))); + print_message(3,message); + sprintf(message,"mode S_IREAD %d S_IWRITE %d\n",(yaffs_stat_struct.st_mode & S_IREAD),(yaffs_stat_struct.st_mode & S_IWRITE)); + print_message(3,message); + } + return 1; +} + +int check_mode_file(char *path) +{ + char message[200]; + int output=0; + + struct yaffs_stat yaffs_stat_struct; + + sprintf(message,"\ntrying to stat to: %s\n",path); + print_message(3,message); + output=yaffs_stat(path,&yaffs_stat_struct); + if (output < 0){ + sprintf(message,"failed to stat the file\n"); + print_message(3,message); + get_error_yaffs(); + } else { + sprintf(message,"stated the file\n"); + print_message(3,message); + sprintf(message," yaffs file mode is %d\n",(yaffs_stat_struct.st_mode & (S_IREAD| S_IWRITE))); + print_message(3,message); + sprintf(message,"mode S_IREAD %d S_IWRITE %d\n\n",(yaffs_stat_struct.st_mode & S_IREAD),(yaffs_stat_struct.st_mode & S_IWRITE)); + print_message(3,message); + } + return 1; +} + +int compare_linux_and_yaffs(arg_temp *args_struct) +{ + int x=0,y=0; + char l_path[200]; + char y_path[200]; + char file_name[200]; + int exit_bool=0; + int number_of_files_in_yaffs=0; + int number_of_files_in_linux=0; + char message[200]; + char **yaffs_file_list=NULL; + char **linux_file_list=NULL; + + struct yaffs_stat yaffs_stat_struct; + struct stat linux_stat_struct; + yaffs_DIR *yaffs_open_dir; + yaffs_dirent *yaffs_current_file; + + DIR *linux_open_dir; + struct dirent *linux_current_file; + + l_path[0]='\0'; + y_path[0]='\0'; + file_name[0]='\0'; + message[0]='\0'; + print_message(2,"\n\n\n comparing folders\n"); +// check_mode_file("yaffs2/test/YY"); + //find out the number of files in the directory + yaffs_open_dir = yaffs_opendir(yaffs_struct.root_path); + if (yaffs_open_dir) { + for (x=0;yaffs_readdir(yaffs_open_dir);x++){} + number_of_files_in_yaffs=x; + sprintf(message,"number of files in yaffs dir= %d\n",number_of_files_in_yaffs); + print_message(2,message); + yaffs_rewinddir(yaffs_open_dir); + } else { + print_message(3,"failed to open yaffs test dir\n"); + } + //create array + yaffs_file_list= (char **)malloc(x*sizeof(char*)); + for (x=0;xd_name = %s\n",yaffs_current_file->d_name); + if (yaffs_current_file){ + strcpy(yaffs_file_list[x],yaffs_current_file->d_name); + + } + yaffs_current_file =yaffs_readdir(yaffs_open_dir); + } + yaffs_closedir(yaffs_open_dir); + } else { + print_message(3,"failed to populate yaffs test list\n"); + } + + + //find out the number of files in the directory + linux_open_dir = opendir(linux_struct.root_path); + if (linux_open_dir){ + for (x=0;readdir(linux_open_dir);x++){} + number_of_files_in_linux=(x-2); + sprintf(message,"number of files in linux dir= %d\n",(number_of_files_in_linux)); + print_message(2,message); + //the -2 is because linux shows 2 extra files which are automaticly created. + + rewinddir(linux_open_dir); + } else { + print_message(3,"failed to open linux test dir\n"); + } + + //create array + linux_file_list= (char **)malloc(number_of_files_in_linux*sizeof(char*)); + + for (x=0;xd_name); + print_message(7,"opened file: "); + print_message(7,message); + print_message(7,"\n"); + } + if (linux_current_file && + 0!=strcmp(message,".")&& + 0!=strcmp(message,"..")){ + strcpy(file_name,linux_current_file->d_name); + //sprintf("file opened: %s\n",linux_current_file->d_name); + //print_message(3,message); + print_message(7,"added file to list\n"); + strcpy(linux_file_list[y],file_name); + sprintf(message,"file added to list: %s\n",linux_file_list[y]); + print_message(7,message); + y++; + } + linux_current_file =readdir(linux_open_dir); + } + closedir(linux_open_dir); + } else { + print_message(3,"failed to populate linux test dir\n"); + } + + + //match the files in both folders + for (x=0;x=0&& + stat(l_path,&linux_stat_struct)>=0){ + sprintf(message," yaffs file mode is %d\n",(yaffs_stat_struct.st_mode & (S_IREAD| S_IWRITE))); + print_message(3,message); + sprintf(message,"mode S_IREAD %d S_IWRITE %d\n",(yaffs_stat_struct.st_mode & S_IREAD),(yaffs_stat_struct.st_mode & S_IWRITE)); + print_message(3,message); + sprintf(message," linux file mode is %d\n",(linux_stat_struct.st_mode & (S_IREAD|S_IWRITE))); + print_message(3,message); + sprintf(message,"mode S_IREAD %d S_IWRITE %d\n",(linux_stat_struct.st_mode & S_IREAD),(linux_stat_struct.st_mode & S_IWRITE)); + print_message(3,message); + if ((yaffs_stat_struct.st_mode & (S_IREAD| S_IWRITE))== + ( linux_stat_struct.st_mode & (S_IREAD|S_IWRITE))){ + print_message(2,"file modes match\n"); + } else { + print_message(2,"file modes do not match\n"); + exit_bool=1; + } + linux_file_list[y][0]=NULL; + yaffs_file_list[x][0]=NULL; + } else { + print_message(2,"failed to stat one of the files\n"); + get_error_yaffs(); + get_error_linux(); + } + + //read file contents + + + break; + } + } + } + + //print remaining files + for (x=0;xd_name); +// generate_array_of_objects_in_yaffs(); +// generate_array_of_objects_in_linux(); + //first do a check to see if both sides have the same objects on both sides. + //then stat all of the files and compare size and mode + //read the text of each file and compare them. + + //show the diffrences by printing them. + return 1; + +} + +void generate_random_numbers(arg_temp *args_struct) +{ + char string[51]; + args_struct->char1= (rand() % 255); + args_struct->char2= (rand() % 255); + args_struct->int1= (rand() % 100000); + args_struct->int2= (rand() % 100000); + generate_random_string(string,50); + strcpy(args_struct->string1, string); + generate_random_string(string,50); + strcpy(args_struct->string2, string); +} + +void run_yaffs_test(int id,arg_temp *args_struct) +{ + char message[200]; + int output =0; + print_message(3,"\n"); + //printf("id = %d\n",id); + sprintf(message,"running_test %s\n",yaffs_tests.test_list[id].test_name); + print_message(3,message); + output=yaffs_tests.test_list[id].test_pointer(args_struct); + if (output<0) { + sprintf(message,"test_failed %s\n",yaffs_tests.test_list[id].test_name); + print_message(3,message); + } else { + print_message(3,"test_passed\n"); + } +} + +void run_linux_test(int id,arg_temp *args_struct) +{ + char message[200]; + int output =0; + print_message(3,"\n"); + //printf("id = %d\n",id); + sprintf(message,"running_test %s\n",linux_tests.test_list[id].test_name); + print_message(3,message); + output=linux_tests.test_list[id].test_pointer(args_struct); + if (output<0) { + sprintf(message,"test_failed %s\n",linux_tests.test_list[id].test_name); + print_message(3,message); + } else { + print_message(3,"test_passed\n"); + } +} + + +void clean_dir(void) +{ + char string[200]; + char file[200]; + char message[200]; + DIR *linux_open_dir; + struct dirent *linux_current_file; + int x=0,output=0; + + getcwd(string,200); + strcat(string,"/emfile-2k-0"); + sprintf(message,"\n\nunlinking emfile at this path: %s\n",string); + print_message(3,message); + unlink(string); + + + linux_open_dir = opendir(linux_struct.root_path); + if (linux_open_dir){ + + do + { + + linux_current_file =readdir(linux_open_dir); + if (NULL!=linux_current_file){ + + strcpy(file,linux_struct.root_path); + strcat(file,linux_current_file->d_name); + sprintf(message,"unlinking file %s\n",file); + print_message(3,message); + print_message(3,"chmoding file\n"); + output=chmod(file,(S_IRUSR|S_IWUSR)); + if (output<0) { + get_error_linux(); + } + print_message(3,"unlinking file\n"); + output=unlink(file); + if (output<0) { + get_error_linux(); + } + } + } while(linux_current_file); + closedir(linux_open_dir); + rmdir(linux_struct.root_path); + } + +} diff --git a/direct/timothy_tests/yaffs_and_linux_mirror_tests/mirror_tests.h b/direct/timothy_tests/yaffs_and_linux_mirror_tests/mirror_tests.h new file mode 100644 index 0000000..9d30833 --- /dev/null +++ b/direct/timothy_tests/yaffs_and_linux_mirror_tests/mirror_tests.h @@ -0,0 +1,61 @@ +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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 __mirror_tests_h__ +#define __mirror_tests_h__ + +#include +#include +#include //used for getting the current directory. +#include +#include +#include "yaffsfs.h" +#include "lib.h" +#include +#include +#include + +#include "linux_test_open.h" +#include "yaffs_test_open.h" +#include "linux_test_truncate.h" +#include "yaffs_test_truncate.h" +#include "linux_test_unlink.h" +#include "yaffs_test_unlink.h" +#include "linux_test_write.h" +#include "yaffs_test_write.h" + +#define LINUX 1 +#define YAFFS 2 + + + + + +void init(int argc, char *argv[]); +int run_random_test(int num_of_random_tests); +int compare_linux_and_yaffs(arg_temp *args_struct); + +int select_test_id(int test_len); +void generate_random_numbers(arg_temp *args_struct); +void run_yaffs_test(int id,arg_temp *args_struct); +void run_linux_test(int id,arg_temp *args_struct); +void clean_dir(void); +int select_test_id(int test_len); +int check_mode(arg_temp *args_struct); +int check_mode_file(char *path); +//void generate_array_of_objects_in_yaffs(void); +//void generate_array_of_objects_in_linux(void); + +#endif diff --git a/direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_open.c b/direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_open.c new file mode 100644 index 0000000..daeb8a4 --- /dev/null +++ b/direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_open.c @@ -0,0 +1,38 @@ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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. + */ + +#include "yaffs_test_open.h" + +int yaffs_test_open(arg_temp *args_struct) +{ + char path[200]; + char message[100]; + int output=0; + join_paths(yaffs_struct.root_path,args_struct->string1, path ); + sprintf(message,"file path: %s\n",path); + print_message(3,message); + + output=yaffs_open(path,args_struct->char1 &(O_TRUNC|O_EXCL|O_CREAT|O_APPEND),args_struct->char2&(S_IREAD|S_IWRITE)); + if (output>=0){ + output= yaffs_close(output); + if (output<0) { + print_message(3,"failed to close handle\n"); + return -1; + } else { + return 1; + } + } else { + print_message(3,"failed to open file\n"); + return -1; + } +} diff --git a/direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_open.h b/direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_open.h new file mode 100644 index 0000000..d64bd29 --- /dev/null +++ b/direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_open.h @@ -0,0 +1,26 @@ +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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_test_open_h__ +#define __yaffs_test_open_h__ +#include +#include +#include +#include "yaffsfs.h" +#include "lib.h" + +int yaffs_test_open(arg_temp *args_struct); + +#endif diff --git a/direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_truncate.c b/direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_truncate.c new file mode 100644 index 0000000..9e99590 --- /dev/null +++ b/direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_truncate.c @@ -0,0 +1,27 @@ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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. + */ + +#include "yaffs_test_truncate.h" + +int yaffs_test_truncate(arg_temp *args_struct) +{ + char path[200]; + char message[200]; + int output=0; + join_paths(yaffs_struct.root_path,args_struct->string1, path ); + sprintf(message,"file path: %s\n",path); + print_message(3,message); + + output=yaffs_truncate(path,args_struct->int1); + return output; +} diff --git a/direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_truncate.h b/direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_truncate.h new file mode 100644 index 0000000..02517cb --- /dev/null +++ b/direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_truncate.h @@ -0,0 +1,26 @@ +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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_test_truncate_h__ +#define __yaffs_test_truncate_h__ +#include +#include +#include +#include "yaffsfs.h" +#include "lib.h" + +int yaffs_test_truncate(arg_temp *args_struct); + +#endif diff --git a/direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_unlink.c b/direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_unlink.c new file mode 100644 index 0000000..6982e77 --- /dev/null +++ b/direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_unlink.c @@ -0,0 +1,34 @@ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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. + */ + +#include "yaffs_test_unlink.h" + +int yaffs_test_unlink(arg_temp *args_struct) +{ + char path[250]; + char message[150]; + int output; + join_paths(yaffs_struct.root_path,args_struct->string1, path ); + sprintf(message,"file path: %s\n",path); + print_message(3,message); + + output= yaffs_unlink(path); + + if (output<0) { + print_message(3,"failed to unlink file\n"); + return -1; + } else { + return 1; + } + +} diff --git a/direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_unlink.h b/direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_unlink.h new file mode 100644 index 0000000..cb8fdf2 --- /dev/null +++ b/direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_unlink.h @@ -0,0 +1,26 @@ +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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_test_unlink_h__ +#define __yaffs_test_unlink_h__ +#include +#include +#include +#include "yaffsfs.h" +#include "lib.h" + +int yaffs_test_unlink(arg_temp *args_struct); + +#endif diff --git a/direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_write.c b/direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_write.c new file mode 100644 index 0000000..2820d68 --- /dev/null +++ b/direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_write.c @@ -0,0 +1,85 @@ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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. + */ + +#include "yaffs_test_write.h" + +int yaffs_test_write(arg_temp *args_struct) +{ + char path[200]; + char message[200]; + int output=0,output2=0; + int handle; + struct yaffs_stat yaffs_stat_struct; + join_paths(yaffs_struct.root_path,args_struct->string1, path ); + sprintf(message,"trying to write to: %s\nwith mode set to %o \n",path,args_struct->char1); + print_message(3,message); + printf("mode S_IREAD %d S_IWRITE %d\n",(args_struct->char2 & S_IREAD),(args_struct->char2 & S_IWRITE)); + handle=yaffs_open(path,((args_struct->char1 &(O_TRUNC|O_EXCL|O_CREAT|O_APPEND))|O_RDWR),(args_struct->char2&(S_IREAD|S_IWRITE))); + printf("handle %d\n",handle); + if (handle<0){ + print_message(3,"failed to open a handle\n"); + return -1; //handle failed to open + } + +/* output=yaffs_fstat(handle,&yaffs_stat_struct); + if (output < 0){ + sprintf(message,"failed to stat the file\n"); + print_message(3,message); + get_error_yaffs(); + } else { + sprintf(message,"stated the file\n"); + print_message(3,message); + sprintf(message," yaffs file mode is %d\n",(yaffs_stat_struct.st_mode & (S_IREAD| S_IWRITE))); + print_message(3,message); + sprintf(message,"mode S_IREAD %d S_IWRITE %d\n",(yaffs_stat_struct.st_mode & S_IREAD),(yaffs_stat_struct.st_mode & S_IWRITE)); + print_message(3,message); + } + + sprintf(message,"trying to write: %d bytes into the file\n",strlen(args_struct->string2)); + print_message(3,message); +*/ + output=yaffs_write(handle,&args_struct->string2,strlen(args_struct->string2)); + +/* print_message(3,"\n wrote to the file\n"); + output2=yaffs_fstat(handle,&yaffs_stat_struct); + if (output2 < 0){ + sprintf(message,"failed to stat the file\n"); + print_message(3,message); + get_error_yaffs(); + } else { + sprintf(message,"stated the file\n"); + print_message(3,message); + sprintf(message," yaffs file mode is %d\n",(yaffs_stat_struct.st_mode & (S_IREAD| S_IWRITE))); + print_message(3,message); + sprintf(message,"mode S_IREAD %d S_IWRITE %d\n",(yaffs_stat_struct.st_mode & S_IREAD),(yaffs_stat_struct.st_mode & S_IWRITE)); + print_message(3,message); + } +*/ yaffs_close(handle); +/* print_message(3,"\n closing the file\n"); + output2=yaffs_stat(path,&yaffs_stat_struct); + if (output2 < 0){ + sprintf(message,"failed to stat the file\n"); + print_message(3,message); + get_error_yaffs(); + } else { + sprintf(message,"stated the file\n"); + print_message(3,message); + sprintf(message," yaffs file mode is %d\n",(yaffs_stat_struct.st_mode & (S_IREAD| S_IWRITE))); + print_message(3,message); + sprintf(message,"mode S_IREAD %d S_IWRITE %d\n",(yaffs_stat_struct.st_mode & S_IREAD),(yaffs_stat_struct.st_mode & S_IWRITE)); + print_message(3,message); + } +*/ + + return output; +} diff --git a/direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_write.h b/direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_write.h new file mode 100644 index 0000000..0332f6f --- /dev/null +++ b/direct/timothy_tests/yaffs_and_linux_mirror_tests/yaffs_test_write.h @@ -0,0 +1,27 @@ +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2011 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_test_write_h__ +#define __yaffs_test_write_h__ +#include +#include +#include +#include +#include "yaffsfs.h" +#include "lib.h" + +int yaffs_test_write(arg_temp *args_struct); + +#endif -- cgit v1.2.3