From 5f61aa469fb4b46a5a1f4aacbe459323b5d13edd Mon Sep 17 00:00:00 2001 From: Timothy Manning Date: Fri, 7 Jan 2011 11:43:00 +1300 Subject: [PATCH] yaffs Added another test to direct/timothy_tests/threading Signed-off-by: Timothy Manning --- direct/timothy_tests/linux_tests/mkdir_link | Bin 0 -> 7262 bytes direct/timothy_tests/linux_tests/mkdir_link.c | 18 +++ direct/timothy_tests/linux_tests/mkdir_link.h | 0 direct/timothy_tests/linux_tests/rename | Bin 0 -> 7220 bytes direct/timothy_tests/linux_tests/rename.c | 17 +++ direct/timothy_tests/linux_tests/rename.h | 0 direct/timothy_tests/threading/Makefile | 115 ++++++++++++++++++ direct/timothy_tests/threading/lib.c | 42 +++++++ direct/timothy_tests/threading/lib.h | 38 ++++++ direct/timothy_tests/threading/test_a.c | 99 +++++++++++++++ direct/timothy_tests/threading/test_a.h | 22 ++++ direct/timothy_tests/threading/test_b.c | 39 ++++++ direct/timothy_tests/threading/test_b.h | 21 ++++ .../timothy_tests/threading/thread_function.c | 70 +++++++++++ .../timothy_tests/threading/thread_function.h | 28 +++++ direct/timothy_tests/threading/threading.c | 81 ++++++++++++ direct/timothy_tests/threading/threading.h | 24 ++++ 17 files changed, 614 insertions(+) create mode 100755 direct/timothy_tests/linux_tests/mkdir_link create mode 100644 direct/timothy_tests/linux_tests/mkdir_link.c create mode 100644 direct/timothy_tests/linux_tests/mkdir_link.h create mode 100755 direct/timothy_tests/linux_tests/rename create mode 100644 direct/timothy_tests/linux_tests/rename.c create mode 100644 direct/timothy_tests/linux_tests/rename.h create mode 100644 direct/timothy_tests/threading/Makefile create mode 100644 direct/timothy_tests/threading/lib.c create mode 100644 direct/timothy_tests/threading/lib.h create mode 100644 direct/timothy_tests/threading/test_a.c create mode 100644 direct/timothy_tests/threading/test_a.h create mode 100644 direct/timothy_tests/threading/test_b.c create mode 100644 direct/timothy_tests/threading/test_b.h create mode 100644 direct/timothy_tests/threading/thread_function.c create mode 100644 direct/timothy_tests/threading/thread_function.h create mode 100644 direct/timothy_tests/threading/threading.c create mode 100644 direct/timothy_tests/threading/threading.h diff --git a/direct/timothy_tests/linux_tests/mkdir_link b/direct/timothy_tests/linux_tests/mkdir_link new file mode 100755 index 0000000000000000000000000000000000000000..7f92f37fb4c170312e3435476ed88bf1b8d2a41c GIT binary patch literal 7262 zcmeHMVQd^n6`r#%?KPyW39?rD+j{h={oO zgt$-KhAQe>#=wEd257Vnbzw*~b-*p-&_gx>Q>deDicD+^c?Je4Y%gk*zV2=z>b@6_ zP-@Vi9>RX9uR<1wJ`Nq_JTQfN_Ca|B{729?r309vb&p^1(}1@m-M$z4VE>C?QrMop zH)b;fjoI|pY$jhANqA1;ex-wJQonoO0hE-Vv0`|+N?%(5IzpAUdqlsB)!J*zP7>SUnsga*jjzI7FD zT!rrgUYrO=7>A9#D$^XwIeF9bldf-?0%1up9Ie9a>OpNflQ#>Vl@__9>5MCe-Avve z6y9hKfjf%Emh0vnGwY<1e#XfQ&v#MdxX{p2#cVE_$&20HT|3*&`x8y*xk~HgJOiRqDDPkdTpdS)BMCnctbcAR)dVtQ&bI9JDjkuRs_ zw+>JKsd#zmvA$lr3HQ!!!{6im_K9c0kbU!Pf#D%U#pxfo1}!WT}(k)JhiCF9qk z_<#M~s^YcK_BXvxPXC0R6lX&(ky5Ukpjy(mzv-6VSVse);(Ykvp}A@Q(_;E(pCKRi zi;MNAV&G29`n6|Rhr%7_!ZFsBFI||MA?NZ^anU%}5kstnK+a$Yke1+n>D`;<@+5S? zTfPqbqY6H=2WYA<7M<*ig(t(Y(x0Iyeg#HG+e*h!o)TzQf2Lp2>NV{wRHc5UN2@GK zuUX)L9G9Yo+J6+`e=5w!? zt0u~Rtofa(&Kg*aOm%Lc@u|)T+$^7Xm8{|$q3t)_KNjbs2M?Qv=BA>txf#ZSWA7B7 zgT)(Vf74l(24{-b!sSa-)u<|5S3zFpmKZ9G(nRiS^A?R(U^Zg9BK-%3Q}BlizR{3gFXTKnQcl{Eu#?l;NLyaY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{b!TA%!H-L4#Lx?v&LFjlISPg9mILx~hUxl}?!h3;vzR8hV3;zxQ^EnJCaXP>^ zQ0J|}&jNEiF@8MTeh!$=XF#;SOPmPs>CY>`!L#sLVC{bm{QvbT{sOR387~{F?iFtl zSK`01s#g3Hm`Ag`kMw_iV2-oDD6l+|MY#s?jstJ0*dyM$O5Xzfg7&`(;{}*!zTc_X z=UKI$f3(uoI}TDJ)*%uITO=m8;@U1qwF%Z=)OI`?(RZg%zV*xPAp#BOx?{a)m9 zP4*(cDafNqdc3>4XXlP?vuD??{hfVg-;SN#o%Eb5Kr`vO$x+kFr&m_UuNK1Wcyiy4 zy)+3t$ZCFY~Y%wB6K<6&9c zo=tk5ebgE<7mmnFyh<#U~6K?^3CCt>Dz_;(Zs-rkY8++t$zbkW53b> literal 0 HcmV?d00001 diff --git a/direct/timothy_tests/linux_tests/mkdir_link.c b/direct/timothy_tests/linux_tests/mkdir_link.c new file mode 100644 index 0000000..d466958 --- /dev/null +++ b/direct/timothy_tests/linux_tests/mkdir_link.c @@ -0,0 +1,18 @@ +#include +#include + + +int main() +{ + int output=0; + int error_code =0 ; + output =symlink("timothy/home/tests/new_dir" "timothy/home/test/new_dir_link"); + output=mkdir("timothy/home/test/new_dir_link" ); + printf("output %d\n",output); + if (output <0 ) { + error_code = errno; + printf("error code %d\n",error_code); + printf("Error description is : %s\n",strerror(errno)); + } + return 0; +} diff --git a/direct/timothy_tests/linux_tests/mkdir_link.h b/direct/timothy_tests/linux_tests/mkdir_link.h new file mode 100644 index 0000000..e69de29 diff --git a/direct/timothy_tests/linux_tests/rename b/direct/timothy_tests/linux_tests/rename new file mode 100755 index 0000000000000000000000000000000000000000..a16897849dcd075b9c4f3d03080a78a66432a54d GIT binary patch literal 7220 zcmeHMZEPGz8J;^|(rZYH?YfOyOj(IDII44Yik&tQA9idfapJ~};{@8MS)K3J-b?Rp zPrG}?u88!&I|dF!7C@mjNDD!#mS%pbo-%nID8|LVgqSC~p8$n9n*WyTRX$x+&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8^$N_t|6cHS|JSNJ*=Yg$vg_zZrajeFL?jf0Gb>IYQ9?? z&g0La6%FTDXoj#4C@RNtrM<-mgy^U!sO^FJvA}hPiRw02ttSdA16(&0RyA;aP?)u= zbwFXx9yQ+;<{MS>T4An4YW^xL&B%GGFlVItZ&O%ZCve^=%#{c0Vi|L$s{3c^D#3qR z^6!SmBRez#+WE$d9x+c_^1*Ol;1mXNW52M4|(fD9Kfi-y-vA(0o=?s0qgb! z@K1riR&k}|pCJ6P7g*lLK?g*=c#3?~&o@VGLwDdl5DMdL1JdpU*3Un$`ilC;fwlj5 z!}>$u%KCo>oW(i>CGGu&ky4<&R}k0!35ff}C1Bk@&Wd-I;YDEW?*RP$5wP~Bft^se zqQQJyk!AQXVzh@Nvljj1T|d`dK#BV+_y*FBEW<7^*H!w9_u6B?T#o@!{vPps1)uf* zXc_)BaOJ)D?}2sutI_^H0ymV#Lrrj__$x4PTxq{1SSzjq^V*j0jqP6q)`9h{#T3=! zsT%&R1#T+YBi^_y{~_R`y8Xcoq8*s`!7soT?QaLx^R1Tu^l{hs{M_(xG>$9yuEG8R zv#r!Ga-#yfp=`?Xtwi+E)~)S=8D=suO7y6Z z+blDYOQ*+lJw5xnWi>koIv?*bHDWb7ey0|>J(IPl?*?q`uD<>qoqcBi&YcH(2F=0F z9eq7)HFtYv%yna9rjWc$tOTSNablmy;pubU6rj>pxzzlivUU literal 0 HcmV?d00001 diff --git a/direct/timothy_tests/linux_tests/rename.c b/direct/timothy_tests/linux_tests/rename.c new file mode 100644 index 0000000..9c40c2f --- /dev/null +++ b/direct/timothy_tests/linux_tests/rename.c @@ -0,0 +1,17 @@ +#include +#include + + +int main() +{ + int output=0; + int error_code =0 ; + output=rename( "/home/timothy/test/cat/","/home/timothy/test/dog/"); + printf("output %d\n",output); + if (output <0 ) { + error_code = errno; + printf("error code %d\n",error_code); + printf("Error description is : %s\n",strerror(errno)); + } + return 0; +} diff --git a/direct/timothy_tests/linux_tests/rename.h b/direct/timothy_tests/linux_tests/rename.h new file mode 100644 index 0000000..e69de29 diff --git a/direct/timothy_tests/threading/Makefile b/direct/timothy_tests/threading/Makefile new file mode 100644 index 0000000..8006b79 --- /dev/null +++ b/direct/timothy_tests/threading/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_tagsvalidity.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 = threading.o thread_function.o \ + test_a.o test_b.o lib.o + + + +YAFFSTESTOBJS = $(COMMONTESTOBJS) $(TESTFILES) + +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_tagsvalidity.c yaffs_tagsvalidity.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: threading + +$(ALLOBJS): %.o: %.c + gcc -c $(CFLAGS) -o $@ $< + +$(PYTONOSYMLINKS): + ln -s ../../python/$@ $@ + +$(YAFFSSYMLINKS): + ln -s ../../../$@ $@ + +$(YAFFSDIRECTSYMLINKS): + ln -s ../../$@ $@ + +$(DIRECTEXTRASYMLINKS): + ln -s ../../basic-test/$@ $@ + + +threading: $(SYMLINKS) $(ALLOBJS) + gcc $(CFLLAG) -o $@ $(ALLOBJS) -lpthread + + + + + + +clean: + rm -f threading $(ALLOBJS) core $(SYMLINKS) diff --git a/direct/timothy_tests/threading/lib.c b/direct/timothy_tests/threading/lib.c new file mode 100644 index 0000000..6456958 --- /dev/null +++ b/direct/timothy_tests/threading/lib.c @@ -0,0 +1,42 @@ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2010 Aleph One Ltd. + * for Toby Churchill Ltd and Brightstar Engineering + * + * Created by Timothy Manning + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include "lib.h" +static unsigned int *p_counter; +static unsigned int numberOfThreads=5; + +unsigned int get_num_of_threads(void) +{ + return numberOfThreads; +} + +void number_of_threads(unsigned int num) +{ + numberOfThreads=num; +} + +int get_counter(int x) +{ + return p_counter[x]; +} + +void set_counter(int x, unsigned int value) +{ + p_counter[x]=value; +} + +void init_counter(unsigned int size_of_counter) +{ + p_counter=malloc(size_of_counter*sizeof(int)); +} + diff --git a/direct/timothy_tests/threading/lib.h b/direct/timothy_tests/threading/lib.h new file mode 100644 index 0000000..f635294 --- /dev/null +++ b/direct/timothy_tests/threading/lib.h @@ -0,0 +1,38 @@ +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2010 Aleph One Ltd. + * for Toby Churchill Ltd and Brightstar Engineering + * + * Created by Timothy Manning + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1 as + * published by the Free Software Foundation. + * + * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL. + */ + +#ifndef __lib_h__ +#define __lib_h__ + +#define BOVVER_HANDLES 10 +#include "yaffsfs.h" +struct bovver_context { + int bovverType; + int threadId; + char baseDir[200]; + int h[BOVVER_HANDLES]; + yaffs_DIR *dirH; + int opMax; + int op; + int cycle; +}; + +int get_counter(int x); +void set_counter(int x, unsigned int value); +void init_counter(unsigned int size_of_counter); +void number_of_threads(unsigned int num); +unsigned int get_num_of_threads(void); + +#endif diff --git a/direct/timothy_tests/threading/test_a.c b/direct/timothy_tests/threading/test_a.c new file mode 100644 index 0000000..391530c --- /dev/null +++ b/direct/timothy_tests/threading/test_a.c @@ -0,0 +1,99 @@ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2010 Aleph One Ltd. + * for Toby Churchill Ltd and Brightstar Engineering + * + * Created by Timothy Manning + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include "test_a.h" + + + + + +void test_a(void *x) +{ + struct bovver_context *bc = (struct bovver_context *)x; + + int i; + int op; + int pos; + int n; + int n1; + + char name[200]; + char name1[200]; + + int start_op; + + + i = rand() % BOVVER_HANDLES; + op = rand() % bc->opMax; + pos = rand() & 20000000; + n = rand() % 100; + n1 = rand() % 100; + + start_op = op; + + sprintf(name, "%s/xx%d",bc->baseDir,n); + sprintf(name1,"%s/xx%d",bc->baseDir,n1); + + bc->op = op; + bc->cycle++; + + op-=1; + if(op < 0){ + if(bc->h[i]>= 0){ + yaffs_close(bc->h[i]); + bc->h[i] = -1; + } + return; + } + + op-=1; + if(op < 0){ + if(bc->h[i] < 0) + bc->h[i] = yaffs_open(name,O_CREAT| O_RDWR, 0666); + return; + } + + op-=5; + if(op< 0){ + yaffs_lseek(bc->h[i],pos,SEEK_SET); + yaffs_write(bc->h[i],name,n); + return; + } + + op-=1; + if(op < 0){ + yaffs_unlink(name); + return; + } + op-=1; + if(op < 0){ + yaffs_rename(name,name1); + return; + } + op-=1; + if(op < 0){ + yaffs_mkdir(name,0666); + return; + } + op-=1; + if(op < 0){ + yaffs_rmdir(name); + return; + } + + bc->opMax = (start_op - op -1); + + return; + +} + diff --git a/direct/timothy_tests/threading/test_a.h b/direct/timothy_tests/threading/test_a.h new file mode 100644 index 0000000..87cb3df --- /dev/null +++ b/direct/timothy_tests/threading/test_a.h @@ -0,0 +1,22 @@ +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2010 Aleph One Ltd. + * for Toby Churchill Ltd and Brightstar Engineering + * + * Created by Timothy Manning + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1 as + * published by the Free Software Foundation. + * + * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL. + */ + +#ifndef __test_a_h__ +#define __test_a_h__ + +#include "yaffsfs.h" +#include "lib.h" +void test_a(void *x); +#endif diff --git a/direct/timothy_tests/threading/test_b.c b/direct/timothy_tests/threading/test_b.c new file mode 100644 index 0000000..0476113 --- /dev/null +++ b/direct/timothy_tests/threading/test_b.c @@ -0,0 +1,39 @@ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2010 Aleph One Ltd. + * for Toby Churchill Ltd and Brightstar Engineering + * + * Created by Timothy Manning + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include "test_b.h" + +void test_b(void *x) +{ + struct bovver_context *bc = (struct bovver_context *)x; + int n = rand() % 20; + + bc->cycle++; + + if(!bc->dirH) + bc->dirH = yaffs_opendir(bc->baseDir); + + if(!bc->dirH) + return; + + if(n == 0){ + yaffs_closedir(bc->dirH); + bc->dirH = NULL; + } else { + while(n > 1){ + n--; + yaffs_readdir(bc->dirH); + } + } +} + diff --git a/direct/timothy_tests/threading/test_b.h b/direct/timothy_tests/threading/test_b.h new file mode 100644 index 0000000..c242a93 --- /dev/null +++ b/direct/timothy_tests/threading/test_b.h @@ -0,0 +1,21 @@ +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2010 Aleph One Ltd. + * for Toby Churchill Ltd and Brightstar Engineering + * + * Created by Timothy Manning + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1 as + * published by the Free Software Foundation. + * + * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL. + */ + +#ifndef __test_b_h__ +#define __test_b_h__ +#include "yaffsfs.h" +#include "lib.h" +void test_b(void *x); +#endif diff --git a/direct/timothy_tests/threading/thread_function.c b/direct/timothy_tests/threading/thread_function.c new file mode 100644 index 0000000..52b78d0 --- /dev/null +++ b/direct/timothy_tests/threading/thread_function.c @@ -0,0 +1,70 @@ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2010 Aleph One Ltd. + * for Toby Churchill Ltd and Brightstar Engineering + * + * Created by Timothy Manning + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include "thread_function.h" + + + +int number_of_tests=2; + + +void * init(int threadId, const char *baseDir, int bovver_type) +{ + struct bovver_context *bc = malloc(sizeof(struct bovver_context)); + + if(bc){ + memset(bc,0,sizeof(*bc)); + bc->threadId = threadId; + strncpy(bc->baseDir,baseDir,200); + bc->bovverType = bovver_type; + bc->opMax = 99; + printf("bovver_init %d \"%s\"\n",threadId,baseDir); + } + return (void *)bc; +} + + +typedef struct test { + void (*p_function)(void *); /*pointer to test function*/ + /*char pass_message[50]; will not need a pass message*/ + char *name_of_test; /*pointer to fail message, needs to include name of test*/ +}test_template; + + +test_template test_list[]={ + //{dummy_test,dummy_test_clean,"dummy_test"}, + {test_a, "test_a"}, + {test_b, "test_b"} +}; + +int thread_function(void *thread_id_ptr) +{ + int thread_id = (int) thread_id_ptr; + int test_id=0; + unsigned int y=0; + printf("Starting thread %d, id %d\n", pthread_self(),thread_id); + void *x=init(thread_id,"/yaffs2/",0); + while(1){ + y++; + //set_counter(thread_id,y); + test_id=(rand()%(number_of_tests-1)); + test_list[test_id].p_function(x); + //printf("thread: %d. ran test: %d\n",thread_id,y); + //printf("counter before %d\n",get_counter(thread_id)); + set_counter(thread_id,y); + //printf("counter after setting %d\n",get_counter(thread_id)); + } + //select random file name from a list. + //run a random function on the file. + return 1; +} diff --git a/direct/timothy_tests/threading/thread_function.h b/direct/timothy_tests/threading/thread_function.h new file mode 100644 index 0000000..106793f --- /dev/null +++ b/direct/timothy_tests/threading/thread_function.h @@ -0,0 +1,28 @@ +/* + * YAFFS: Yet another Flash File System . A NAND-flash specific file system. + * + * Copyright (C) 2002-2010 Aleph One Ltd. + * for Toby Churchill Ltd and Brightstar Engineering + * + * Created by Timothy Manning + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1 as + * published by the Free Software Foundation. + * + * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL. + */ + +#ifndef __thread_function_h__ +#define __thread_function_h__ + + +#include +#include + +#include "test_a.h" +#include "test_b.h" +#include "lib.h" +int thread_function(void * thread_id); +void * init(int threadId, const char *baseDir, int bovver_type); +#endif diff --git a/direct/timothy_tests/threading/threading.c b/direct/timothy_tests/threading/threading.c new file mode 100644 index 0000000..a9ed1bb --- /dev/null +++ b/direct/timothy_tests/threading/threading.c @@ -0,0 +1,81 @@ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2010 Aleph One Ltd. + * for Toby Churchill Ltd and Brightstar Engineering + * + * Created by Timothy Manning + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include "threading.h" + +int random_seed; +int simulate_power_failure = 0; + +const struct option long_options[]={ + {"help", 0,NULL,'h'}, + {"threads", 1,NULL,'t'} +}; + +const char short_options[]="hqn:t:cv"; + + + + +void main_init(int argc, char *argv[]) +{ + int new_option; + int x=0; + int new_num_of_threads=5; + do{ + new_option=getopt_long(argc,argv,short_options,long_options,NULL); + if (0==strcmp(argv[x],"-h")){ + printf("help\n"); + printf("-h will print the commands available\n"); + printf("-c will continue after a test failes else the program will exit\n"); + printf("-v will print all messages\n"); + printf("-q quiet mode only the number of tests passed and failed will be printed\n"); + printf("-t [number] set yaffs_trace to number\n"); + printf("-n [number] sets the number of random loops to run after the the test has run\n"); + exit(0); + } else if (new_option=='t') { + new_num_of_threads=atoi(optarg); + } + }while (new_option!=-1); + number_of_threads(new_num_of_threads); + init_counter(new_num_of_threads); + +} + +int main(int argc, char *argv[]) +{ + main_init(argc,argv); + pthread_t threads[get_num_of_threads()]; + unsigned int x=0; + int output=0; + int y=0; + + for (x=0;x0){ + printf("failed to create thread %d. Error is %d\n",x,output); + } + + } + while (1){ + y=0; + printf("thread counter: %d ",get_counter(y)); + for (y=1;y + * + * 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 __threading_h__ +#define __threading_h__ + +#include +#include +#include "thread_function.h" +#include "lib.h" +#include +#endif -- 2.30.2