summaryrefslogtreecommitdiff
path: root/direct/timothy_tests/threading/thread_function.c
blob: 52b78d0f664a6b22bf7c842bdb2b89326b49a265 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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 <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.
 */

#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;
}