bcp_rand.h
3.2 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
BCP RAND TETS BENCH Header file
:set tabstop = 4
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef _BCP_RAND_H
#define _BCP_RAND_H
#define MAX_PATH_LEN 256
#define MAX_TEST_NUM 128
#define MAX_MEM_SEG 512
#define MAX_DIFF_SIZE 5
#define MEM_USED 0x40000000
#define MAX_PORT_NUM 2000
#define RAND_PORT_BASE 12000
#define RAND_SERVER_IP "127.0.0.1"
#define INVALID_REQ 0xFFFFFFFF
#define BDOOR_REQ 0x80000000
/* Lock */
#define AI_LOCK 0x0001
#define VI_LOCK 0x0002
#define SP_LOCK 0x0004
#define DP_LOCK 0x0008
#define USB0_LOCK 0x0010
#define USB1_LOCK 0x0020
#define PI_LOCK 0x0040
#define MI_LOCK 0x0080
#define SI_LOCK 0x0100
#define RI_LOCK 0x0200
#define LOCK_MASK 0x03FF
typedef struct {
char test_name[MAX_PATH_LEN]; /* The Name of test */
char test_cmd[MAX_PATH_LEN]; /* Test program */
char test_check[MAX_PATH_LEN]; /* Test check program */
int ret_code; /* Success test code */
char test_log[MAX_PATH_LEN]; /* should in a+ mode */
int res_lock; /* Resource lock */
int memory_size; /* How much memory test needed */
int pri; /* Priority 1--5(more stress) */
int max_copies; /* Max number of copies */
int cur_copies;
int total_copies;
} BCP_RAND_TEST;
struct _BCP_RAND_PROCESS;
typedef struct _BCP_RAND_PROCESS {
BCP_RAND_TEST *ptest; /* Which Test */
int test_pid; /* Test process ID */
int port; /* Port Number */
int start_addr;
int end_addr;
struct _BCP_RAND_PROCESS *next;
/* socket connect with the test
conn_sock != 0 means persistent connection */
int listen_sock;
int conn_sock;
int persist_con;
IpcPkt req; /* Ipc Req packet */
} BCP_RAND_PROCESS;
/* Main */
static int usage(void);
static int init_rand_test_list(BCP_RAND_TEST *plist);
static int init_rand_test_process(BCP_RAND_PROCESS *);
int read_test_file(BCP_RAND_TEST *plist, char *test_file);
int display_msg(int fd, char *msg);
/* Resource */
int init_rand_res();
int alloc_mem(int size);
int find_mem(int size, int start);
int trace_resource(int lock, int pos, int alloc);
int alloc_res(int lock, int size, int *start, int *end);
int free_res(int lock, int start, int size);
/* Test part */
static int run_random_test(BCP_RAND_TEST *bcp_rand_list, int test_num,
int seconds, int ntest);
int close_fork_fdec(int sim_sock, BCP_RAND_PROCESS *p_test);
int open_simulator_sock();
int open_listen_socket(BCP_RAND_PROCESS *proc);
BCP_RAND_PROCESS *add_tests(BCP_RAND_PROCESS *proc,
BCP_RAND_TEST *list, int which);
BCP_RAND_PROCESS* merge_tests(int, BCP_RAND_PROCESS *, BCP_RAND_PROCESS *);
BCP_RAND_PROCESS* remove_done_tests(BCP_RAND_PROCESS *proc);
int recv_pkt_from_sock(int fd, char *buf, int len);
int send_pkt_to_sock(int fd, char *buf, int len);
int proceed_a_req(int sim_sock, BCP_RAND_PROCESS *proc);
int get_req_pkt(int sim_sock, BCP_RAND_PROCESS *proc);
int get_req_for_all(int sim_sock, BCP_RAND_PROCESS *proc);
int pick_and_run(int sim_sock, BCP_RAND_PROCESS *proc);
int post_process(int sim_sock, BCP_RAND_PROCESS *proc);
int proceed_tests(int sim_sock, BCP_RAND_PROCESS *proc);
int run_a_test(BCP_RAND_PROCESS *proc);
#endif