1 |
786 |
skrzyp |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// tests/nc_test_framework.h
|
4 |
|
|
//
|
5 |
|
|
// Network characterization tests framework
|
6 |
|
|
//
|
7 |
|
|
//==========================================================================
|
8 |
|
|
//####BSDCOPYRIGHTBEGIN####
|
9 |
|
|
//
|
10 |
|
|
// -------------------------------------------
|
11 |
|
|
//
|
12 |
|
|
// Portions of this software may have been derived from OpenBSD or other sources,
|
13 |
|
|
// and are covered by the appropriate copyright disclaimers included herein.
|
14 |
|
|
//
|
15 |
|
|
// -------------------------------------------
|
16 |
|
|
//
|
17 |
|
|
//####BSDCOPYRIGHTEND####
|
18 |
|
|
//==========================================================================
|
19 |
|
|
//#####DESCRIPTIONBEGIN####
|
20 |
|
|
//
|
21 |
|
|
// Author(s): gthomas
|
22 |
|
|
// Contributors: gthomas
|
23 |
|
|
// Date: 2000-01-10
|
24 |
|
|
// Purpose:
|
25 |
|
|
// Description:
|
26 |
|
|
//
|
27 |
|
|
//
|
28 |
|
|
//####DESCRIPTIONEND####
|
29 |
|
|
//
|
30 |
|
|
//==========================================================================
|
31 |
|
|
|
32 |
|
|
#ifndef _TESTS_NC_TEST_FRAMEWORK_H_
|
33 |
|
|
#define _TESTS_NC_TEST_FRAMEWORK_H_
|
34 |
|
|
|
35 |
|
|
#define test_printf diag_printf
|
36 |
|
|
typedef cyg_addrword_t test_param_t;
|
37 |
|
|
|
38 |
|
|
#ifndef true
|
39 |
|
|
#define false 0
|
40 |
|
|
#define true 1
|
41 |
|
|
#endif
|
42 |
|
|
|
43 |
|
|
#define NC_SLAVE_PORT 7777
|
44 |
|
|
#define NC_MASTER_PORT 7776
|
45 |
|
|
|
46 |
|
|
#define NC_TESTING_SLAVE_PORT 8770
|
47 |
|
|
#define NC_TESTING_MASTER_PORT 8771
|
48 |
|
|
|
49 |
|
|
#define __string(s) #s
|
50 |
|
|
#define _string(s) __string(s)
|
51 |
|
|
|
52 |
|
|
//
|
53 |
|
|
// The basic idea behind this test structure is that one end will run
|
54 |
|
|
// in "slave" mode and the other in "master" mode. Typically, the slave
|
55 |
|
|
// will run on a target platform with the master running on a host.
|
56 |
|
|
//
|
57 |
|
|
// The slave starts up by listening for a connection on the "SLAVE_PORT".
|
58 |
|
|
// In order for the testing to require the minimum stack support, this
|
59 |
|
|
// connection (and the protocol) will use UDP.
|
60 |
|
|
//
|
61 |
|
|
// The master will connect to the slave and send it a request over this
|
62 |
|
|
// connection. Once the slave accepts the request, then master and slave
|
63 |
|
|
// will execute the operation, typically a test. The control connection
|
64 |
|
|
// will remain active until the master sends a 'disconnect' request. The
|
65 |
|
|
// control connection will be broken after the reply to this request has
|
66 |
|
|
// been sent.
|
67 |
|
|
//
|
68 |
|
|
|
69 |
|
|
#define MAX_ERRORS 5 // Give up after this many errors
|
70 |
|
|
#define NC_REPLY_TIMEOUT 10 // The slave may be slow
|
71 |
|
|
#define NC_TEST_TIMEOUT 3 // More generous for tests
|
72 |
|
|
#define NC_RESULTS_TIMEOUT (MAX_ERRORS+2)*NC_TEST_TIMEOUT
|
73 |
|
|
|
74 |
|
|
struct nc_request {
|
75 |
|
|
int type; // Description of request
|
76 |
|
|
int seq; // Sequence number, used to build response
|
77 |
|
|
int nbufs; // Number of "buffers" to send
|
78 |
|
|
int buflen; // Length of each buffer
|
79 |
|
|
int slave_port; // Network ports to use
|
80 |
|
|
int master_port;
|
81 |
|
|
int timeout; // Max time to wait for any packet
|
82 |
|
|
};
|
83 |
|
|
|
84 |
|
|
#define NC_REQUEST_DISCONNECT 0x0001
|
85 |
|
|
#define NC_REQUEST_UDP_SEND 0x0010 // Slave to send UDP data
|
86 |
|
|
#define NC_REQUEST_UDP_RECV 0x0011 // Slave to receive UDP data
|
87 |
|
|
#define NC_REQUEST_UDP_ECHO 0x0012 // Master->slave->master
|
88 |
|
|
#define NC_REQUEST_TCP_SEND 0x0020 // Slave to send TCP data
|
89 |
|
|
#define NC_REQUEST_TCP_RECV 0x0021 // Slave to receive TCP data
|
90 |
|
|
#define NC_REQUEST_TCP_ECHO 0x0022 // Master->slave->master
|
91 |
|
|
#define NC_REQUEST_START_IDLE 0x0100 // Start some idle processing
|
92 |
|
|
#define NC_REQUEST_STOP_IDLE 0x0101 // Stop idle processing
|
93 |
|
|
#define NC_REQUEST_SET_LOAD 0x0200 // Set the background load level
|
94 |
|
|
|
95 |
|
|
struct nc_reply {
|
96 |
|
|
int response; // ACK or NAK
|
97 |
|
|
int seq; // Must match request
|
98 |
|
|
int reason; // If NAK, why request turned down
|
99 |
|
|
union { // Miscellaneous data, depending on request
|
100 |
|
|
struct {
|
101 |
|
|
long elapsed_time; // In 10ms "ticks"
|
102 |
|
|
long count[2]; // Result
|
103 |
|
|
} idle_results;
|
104 |
|
|
} misc;
|
105 |
|
|
};
|
106 |
|
|
|
107 |
|
|
#define NC_REPLY_ACK 0x0001 // Request accepted
|
108 |
|
|
#define NC_REPLY_NAK 0x0000 // Request denied
|
109 |
|
|
#define NC_REPLY_NAK_UNKNOWN_REQUEST 0x0001
|
110 |
|
|
#define NC_REPLY_NAK_BAD_REQUEST 0x0002 // Slave can't handle
|
111 |
|
|
#define NC_REPLY_NAK_NO_BACKGROUND 0x0003 // Slave can't do background/idle
|
112 |
|
|
|
113 |
|
|
// Test data 'packets' look like this
|
114 |
|
|
struct nc_test_data {
|
115 |
|
|
long key1;
|
116 |
|
|
int seq;
|
117 |
|
|
int len;
|
118 |
|
|
long key2;
|
119 |
|
|
char data[0]; // Actual data
|
120 |
|
|
};
|
121 |
|
|
|
122 |
|
|
#define NC_TEST_DATA_KEY1 0xC0DEADC0
|
123 |
|
|
#define NC_TEST_DATA_KEY2 0xC0DEADC1
|
124 |
|
|
|
125 |
|
|
struct nc_test_results {
|
126 |
|
|
long key1; // Identify uniquely as a response record
|
127 |
|
|
int seq; // Matches request
|
128 |
|
|
int nsent;
|
129 |
|
|
int nrecvd;
|
130 |
|
|
long key2; // Additional verification
|
131 |
|
|
};
|
132 |
|
|
|
133 |
|
|
#define NC_TEST_RESULT_KEY1 0xDEADC0DE
|
134 |
|
|
#define NC_TEST_RESULT_KEY2 0xDEADC1DE
|
135 |
|
|
|
136 |
|
|
#endif // _TESTS_NC_TEST_FRAMEWORK_H_
|