yaffs Commiting yaffs_tester.c and coresponding files
authorTimothy Manning <tfhmanning@gmail.com>
Mon, 18 Oct 2010 03:54:46 +0000 (16:54 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Mon, 18 Oct 2010 03:54:46 +0000 (16:54 +1300)
This file is located in yaffs2/direct/timothy_tests
This file isnt working yet.
Signed-off-by: Timothy Manning <tfhmanning@gmail.com>
direct/timothy_tests/Makefile [new file with mode: 0644]
direct/timothy_tests/yaffs_tester.c [new file with mode: 0644]
direct/timothy_tests/yaffs_tester.h [new file with mode: 0644]

diff --git a/direct/timothy_tests/Makefile b/direct/timothy_tests/Makefile
new file mode 100644 (file)
index 0000000..13371b2
--- /dev/null
@@ -0,0 +1,103 @@
+# Makefile for YAFFS direct stress tests
+#
+#
+# YAFFS: Yet another Flash File System. A NAND-flash specific file system.
+#
+# Copyright (C) 2003-2010 Aleph One Ltd.
+#
+#
+# Created by Charles Manning <charles@aleph1.co.uk>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# NB Warning this Makefile does not include header dependencies.
+#
+# $Id: Makefile,v 1.7 2010-02-25 22:34:47 charles Exp $
+
+#EXTRA_COMPILE_FLAGS = -DYAFFS_IGNORE_TAGS_ECC
+
+CFLAGS =      -DCONFIG_YAFFS_DIRECT -DCONFIG_YAFFS_SHORT_NAMES_IN_RAM -DCONFIG_YAFFS_YAFFS2  
+CFLAGS +=     -DCONFIG_YAFFS_PROVIDE_DEFS -DCONFIG_YAFFSFS_PROVIDE_VALUES
+CFLAGS +=    -Wall -g $(EXTRA_COMPILE_FLAGS) -Wstrict-aliasing 
+#CFLAGS +=    -fno-strict-aliasing
+CFLAGS +=    -O0
+CFLAGS +=    -Wextra -Wpointer-arith
+#CFLAGS +=    -DCONFIG_YAFFS_VALGRIND_TEST
+
+#CFLAGS+=   -Wshadow -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Wmissing-declarations
+#CFLAGS+=   -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Winline
+
+
+COMMONTESTOBJS = yaffscfg2k.o yaffs_ecc.o yaffs_fileem.o yaffs_fileem2k.o yaffsfs.o yaffs_guts.o \
+                yaffs_packedtags1.o yaffs_ramdisk.o yaffs_ramem2k.o \
+                yaffs_tagscompat.o yaffs_packedtags2.o yaffs_tagsvalidity.o yaffs_nand.o \
+                yaffs_checkptrw.o  yaffs_qsort.o\
+                yaffs_nameval.o \
+                yaffs_norif1.o  ynorsim.o   \
+                yaffs_allocator.o \
+                yaffs_bitmap.o \
+                yaffs_yaffs1.o \
+                yaffs_yaffs2.o \
+                yaffs_verify.o
+
+#               yaffs_checkptrwtest.o\
+
+YAFFSTESTOBJS  = $(COMMONTESTOBJS) yaffs_tester.o
+
+
+ALLOBJS = $(sort $(YAFFSTESTOBJS))
+
+YAFFSSYMLINKS = devextras.h yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffsinterface.h yportenv.h yaffs_tagscompat.c yaffs_tagscompat.h \
+          yaffs_packedtags1.c yaffs_packedtags1.h yaffs_packedtags2.c yaffs_packedtags2.h  yaffs_nandemul2k.h \
+          yaffs_nand.c yaffs_nand.h yaffs_getblockinfo.h yaffs_list.h \
+          yaffs_tagsvalidity.c yaffs_tagsvalidity.h yaffs_checkptrw.h yaffs_checkptrw.c \
+          yaffs_nameval.c yaffs_nameval.h \
+          yaffs_qsort.c yaffs_qsort.h yaffs_trace.h \
+          yaffs_allocator.c yaffs_allocator.h \
+          yaffs_yaffs1.c yaffs_yaffs1.h \
+          yaffs_yaffs2.c yaffs_yaffs2.h \
+          yaffs_bitmap.c yaffs_bitmap.h \
+          yaffs_verify.c yaffs_verify.h
+
+YAFFSDIRECTSYMLINKS =  yaffsfs.c yaffs_flashif.h yaffs_flashif2.h\
+                      yaffsfs.h yaffs_malloc.h ydirectenv.h \
+                      yaffs_flashif.c yaffscfg.h \
+                      yaffs_nandif.c yaffs_nandif.h
+
+
+DIRECTEXTRASYMLINKS =  yaffscfg2k.c yaffs_fileem2k.c yaffs_fileem2k.h\
+                       yaffs_fileem.c yaffs_norif1.c yaffs_norif1.h \
+                       yaffs_ramdisk.c yaffs_ramdisk.h yaffs_ramem2k.c \
+                       ynorsim.h ynorsim.c
+
+SYMLINKS = $(YAFFSSYMLINKS) $(YAFFSDIRECTSYMLINKS) $(DIRECTEXTRASYMLINKS)
+#all: directtest2k boottest
+
+all: yaffs_tester 
+
+$(ALLOBJS): %.o: %.c
+       gcc -c $(CFLAGS) -o $@ $<
+
+
+$(YAFFSSYMLINKS):
+       ln -s ../../$@ $@
+
+$(YAFFSDIRECTSYMLINKS):
+       ln -s ../$@ $@
+
+$(DIRECTEXTRASYMLINKS):
+       ln -s ../basic-test/$@ $@
+
+
+yaffs_tester: $(SYMLINKS) $(YAFFSTESTOBJS)
+       gcc $(CFLLAG) -o $@ $(YAFFSTESTOBJS)
+
+
+
+
+
+
+clean:
+       rm -f yaffs_tester  $(ALLOBJS) core $(SYMLINKS)
diff --git a/direct/timothy_tests/yaffs_tester.c b/direct/timothy_tests/yaffs_tester.c
new file mode 100644 (file)
index 0000000..e615ec3
--- /dev/null
@@ -0,0 +1,102 @@
+/*yaffs_tester.c*/
+#include "yaffs_tester.h"
+
+
+int random_seed;
+int simulate_power_failure = 0;
+
+
+buffer message_buffer; /*create  message_buffer */
+
+
+
+int main()
+{      
+       char yaffs_test_dir[]="/yaffs2/test_dir";
+       char yaffs_mount_dir[]="/yaffs2/";
+       printf("welcome to the yaffs tester\n");
+       init(yaffs_test_dir,yaffs_mount_dir);
+       test(yaffs_test_dir);
+
+       yaffs_unmount(yaffs_mount_dir);
+       return 0;
+}
+
+void add_to_buffer(buffer *p_Buffer, char message[])
+{
+       if (p_Buffer->head+1==p_Buffer->tail)
+       {
+               p_Buffer->tail++;
+               if (p_Buffer->tail >BUFFER_SIZE-1) p_Buffer->tail -= BUFFER_SIZE-1;
+               
+       }
+       /*move the head up one. the head always points at the last witten data*/
+       p_Buffer->head++;
+       if (p_Buffer->head >BUFFER_SIZE) p_Buffer->head -= BUFFER_SIZE;
+
+       strcpy(p_Buffer->buffer[p_Buffer->head],message);
+
+}
+void print_buffer(buffer *p_Buffer)
+{
+       for (x=p_Buffer->head; x>=p_Buffer->tail; x--)
+       {
+               
+       }
+
+}
+
+
+void init(char yaffs_test_dir[],char yaffs_mount_dir[])
+{
+       yaffs_StartUp();
+       yaffs_mount(yaffs_mount_dir);
+       if (yaffs_access(yaffs_test_dir,0))
+       {
+               yaffs_mkdir(yaffs_test_dir,S_IREAD | S_IWRITE);
+       }
+}
+
+void yaffs_check_for_errors(char output)
+{
+       if (output==-1)
+       {
+               printf("error####");
+               print_buffer(message_buffer);
+       }
+}
+
+void test(char yaffs_test_dir[])
+{
+       char name[MAX_FILE_NAME_SIZE +3];
+       unsigned int x;
+       while(1)
+       {
+
+               generate_random_string(name);
+               printf("the length of the string is %d \n",strlen(name)); 
+               printf("generated string is:");
+               for (x=0; x <= (strlen(name)-1)&&x<=MAX_FILE_NAME_SIZE ; x++)
+               {
+//                     printf("x=%d\n",x);
+                       printf("%c ",name[x]);
+               }
+               printf("\n");
+       }
+}
+void  generate_random_string(char *ptr)
+{
+       unsigned int x;
+       unsigned int length=((rand() %MAX_FILE_NAME_SIZE)+1);   /*creates a int with the number of charecters been between 1 and 51*/           
+       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);     
+               ptr[x]=(rand() % 126-32)+32;    /*generate a number between 32 and 126 and uses it as a charecter (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/yaffs_tester.h b/direct/timothy_tests/yaffs_tester.h
new file mode 100644 (file)
index 0000000..4c55110
--- /dev/null
@@ -0,0 +1,25 @@
+/*yaffs_tester.h */
+#ifndef __YAFFS_TESTER_H__
+       #define __YAFFS_TESTER_H__
+
+       #include <stdio.h>
+       
+       #include "yaffsfs.h"    /* it is in "yaffs2/direct/" link it in the Makefile */
+       
+
+       #define MAX_FILE_NAME_SIZE 51
+       #define BUFFER_MESSAGE_LENGTH 50                /*number of char in message*/
+       #define BUFFER_SIZE 50                  /*number of messages in buffer*/
+       typedef struct buffer_template
+       {
+               char buffer[BUFFER_SIZE][BUFFER_MESSAGE_LENGTH];
+               char head;
+               char tail;
+       }buffer; 
+
+       void init(char yaffs_test_dir[],char yaffs_mount_dir[]);        /*sets up yaffs and mounts yaffs */
+       void test(char yaffs_test_dir[]);                               /*contains the test code*/
+       void generate_random_string(char *ptr);                         /*generates a random string of letters to be used for a name*/
+       void add_to_buffer(buffer *p_Buffer, char message[]);           /*code for buffer*/
+       void print_buffer(buffer *p_Buffer);                            /*print all of the messages in the buffer*/ 
+#endif