Updated timothy_tests/stress_tester
authorTimothy Manning <codedraftsman@gmail.com>
Tue, 29 Jun 2021 02:56:45 +0000 (14:56 +1200)
committerTimothy Manning <codedraftsman@gmail.com>
Thu, 1 Jul 2021 02:36:33 +0000 (14:36 +1200)
Updated the mount point's path.
Broke out some commonly used shared functions and defines into a
shared file.

Signed-off-by: Timothy Manning <codedraftsman@gmail.com>
direct/test-framework/timothy_tests/stress_tester/Makefile
direct/test-framework/timothy_tests/stress_tester/error_handler.c
direct/test-framework/timothy_tests/stress_tester/shared.c [new file with mode: 0644]
direct/test-framework/timothy_tests/stress_tester/shared.h [new file with mode: 0644]
direct/test-framework/timothy_tests/stress_tester/yaffs_tester.c
direct/test-framework/timothy_tests/stress_tester/yaffs_tester.h

index b730b72c9a17968a4f904063c49a6be3ec958735..146c22301becd6e7473b2fe0516862a2d95f42bf 100644 (file)
@@ -19,7 +19,7 @@ YDI_DIR = ../../../
 YDI_FRAMEWORK_DIR = ../../
 CLEAN_OBJS = yaffs_tester emfile-2k-0
 
-TESTFILES =    yaffs_tester.o message_buffer.o error_handler.o 
+TESTFILES =    yaffs_tester.o message_buffer.o error_handler.o shared.o
 
 all: yaffs_tester
 
@@ -32,10 +32,10 @@ include $(YDI_FRAMEWORK_DIR)/FrameworkRules.mk
 
 
 yaffs_test: $(FRAMEWORK_SOURCES) $(YAFFS_TEST_OBJS)
-       gcc $(CFLAGS) -o $@ $(YAFFS_TEST_OBJS)
+       gcc $(CFLAGS) -o $@ $(YAFFS_TEST_OBJS) -lpthread
 
 
 
 yaffs_tester: $(FRAMEWORK_SOURCES) $(YAFFS_TEST_OBJS)
-       gcc $(CFLAGS) -o $@ $(YAFFS_TEST_OBJS)
+       gcc $(CFLAGS) -o $@ $(YAFFS_TEST_OBJS) -lpthread
 
index 9d9ac975d9af5c519cc0c7c4b0202af224a62726..ff22260c296fa591f188a9d0fac44503452fe08e 100644 (file)
@@ -14,7 +14,7 @@
  * error_handler.c contains code for checking yaffs function calls for errors.
  */
 #include "error_handler.h"
-
+#include "shared.h"
 
 typedef struct error_codes_template {
   int code;
@@ -42,9 +42,9 @@ const error_entry error_list[] = {
        { 0, NULL }
 };
 
-const char * error_to_str(int err)
+char * error_to_str(int err)
 {
-       error_entry *e = error_list;
+       error_entry const *e = error_list;
        if (err < 0) 
                err = -err;
        while(e->code && e->text){
@@ -56,10 +56,8 @@ const char * error_to_str(int err)
 }
 
 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);
diff --git a/direct/test-framework/timothy_tests/stress_tester/shared.c b/direct/test-framework/timothy_tests/stress_tester/shared.c
new file mode 100644 (file)
index 0000000..75855d4
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * YAFFS: Yet another FFS. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2018 Aleph One Ltd.
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/*
+ * error_handler.c contains code for checking yaffs function calls for errors.
+ */
+#include "shared.h"
+#include "yaffsfs.h"
+
+void quit_program(){
+       yaffs_unmount(YAFFS_MOUNT_DIR);
+       exit(1);
+}
diff --git a/direct/test-framework/timothy_tests/stress_tester/shared.h b/direct/test-framework/timothy_tests/stress_tester/shared.h
new file mode 100644 (file)
index 0000000..6bfd6d0
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * YAFFS: Yet another Flash File System . A NAND-flash specific file system. 
+ *
+ * Copyright (C) 2002-2018 Aleph One Ltd.
+ *
+ * Created by Timothy Manning <timothy@yaffs.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1 as
+ * published by the Free Software Foundation.
+ *
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
+ */
+
+#ifndef __shared_h__
+#define __shared_h__
+
+#define YAFFS_TEST_DIR "/yflash2/test_dir" /*the path to the directory where all of the testing will take place*/
+#define YAFFS_MOUNT_DIR "/yflash2/"            /*the path to the mount point which yaffs will mount*/
+
+void quit_program();
+#endif
index ff1504d2342d072ce584f58fb4c85b6ed7cc8f5b..aabe70916efa3022bb650bdd9f9333b83b0f6fb7 100644 (file)
@@ -16,6 +16,7 @@
 
 
 #include "yaffs_tester.h"
+#include "shared.h"
 
 
 
@@ -25,16 +26,13 @@ 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);
+       init(YAFFS_TEST_DIR, YAFFS_MOUNT_DIR, argc, argv);
+       test(YAFFS_TEST_DIR);
+       yaffs_unmount(YAFFS_MOUNT_DIR);
        return 0;
 }
 
@@ -88,10 +86,8 @@ void init(char *yaffs_test_dir,char *yaffs_mount_dir,int argc, char *argv[]){
        
 }
 
-void quit_program(){
-       yaffs_unmount(yaffs_mount_dir);
-       exit(1);
-}
+
+
 void join_paths(char *path1,char *path2,char *new_path ){
 
 /*     printf("strlen path1:%d\n",strlen(path1));
@@ -169,9 +165,9 @@ void open_random_file(char *yaffs_test_dir, handle_regster *P_open_handles_array
        if (P_open_handles_array->number_of_open_handles<MAX_NUMBER_OF_OPENED_HANDLES)
        {
                generate_random_string(name,MAX_FILE_NAME_SIZE);
-               printf("before %d %d %d\n",strlen(yaffs_test_dir),strlen(name),strlen(path));
+               //printf("before %d %d %d\n",strlen(yaffs_test_dir),strlen(name),strlen(path));
                join_paths(yaffs_test_dir,name,path);
-               printf("after %d %d %d\n",strlen(yaffs_test_dir),strlen(name),strlen(path));
+               //printf("after %d %d %d\n",strlen(yaffs_test_dir),strlen(name),strlen(path));
                add_to_buffer(&message_buffer,"trying to open file: ",MESSAGE_LEVEL_BASIC_TASKS,NPRINT);
                append_to_buffer(&message_buffer,path,MESSAGE_LEVEL_BASIC_TASKS,PRINT);
                if (yaffs_access(path,0)==0){
@@ -330,8 +326,7 @@ void stat_file(char *path){
 }
 
 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;
index 5ff30b2b96f6a42eadde0fc929f4094a6a2ed1d0..2597be5b5f372c49457cf263104c8a9696ea6744 100644 (file)
@@ -42,6 +42,6 @@ void copy_array(char *from,char *to, unsigned int from_offset,unsigned int to_of
 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