|
@@ -142,51 +142,66 @@ static uint16_t rfc_tcpip_chksum ( const void *data, size_t len ) {
|
142
|
142
|
* Report TCP/IP fixed-data test result
|
143
|
143
|
*
|
144
|
144
|
* @v test TCP/IP test
|
|
145
|
+ * @v file Test code file
|
|
146
|
+ * @v line Test code line
|
145
|
147
|
*/
|
146
|
|
-#define tcpip_ok( test ) do { \
|
147
|
|
- uint16_t expected; \
|
148
|
|
- uint16_t generic_sum; \
|
149
|
|
- uint16_t sum; \
|
150
|
|
- expected = rfc_tcpip_chksum ( (test)->data, (test)->len ); \
|
151
|
|
- generic_sum = generic_tcpip_continue_chksum ( TCPIP_EMPTY_CSUM, \
|
152
|
|
- (test)->data, \
|
153
|
|
- (test)->len ); \
|
154
|
|
- ok ( generic_sum == expected ); \
|
155
|
|
- sum = tcpip_continue_chksum ( TCPIP_EMPTY_CSUM, (test)->data, \
|
156
|
|
- (test)->len ); \
|
157
|
|
- ok ( sum == expected ); \
|
158
|
|
- } while ( 0 )
|
|
148
|
+static void tcpip_okx ( struct tcpip_test *test, const char *file,
|
|
149
|
+ unsigned int line ) {
|
|
150
|
+ uint16_t expected;
|
|
151
|
+ uint16_t generic_sum;
|
|
152
|
+ uint16_t sum;
|
|
153
|
+
|
|
154
|
+ /* Verify generic_tcpip_continue_chksum() result */
|
|
155
|
+ expected = rfc_tcpip_chksum ( test->data, test->len );
|
|
156
|
+ generic_sum = generic_tcpip_continue_chksum ( TCPIP_EMPTY_CSUM,
|
|
157
|
+ test->data, test->len );
|
|
158
|
+ okx ( generic_sum == expected, file, line );
|
|
159
|
+
|
|
160
|
+ /* Verify optimised tcpip_continue_chksum() result */
|
|
161
|
+ sum = tcpip_continue_chksum ( TCPIP_EMPTY_CSUM, test->data, test->len );
|
|
162
|
+ okx ( sum == expected, file, line );
|
|
163
|
+}
|
|
164
|
+#define tcpip_ok( test ) tcpip_okx ( test, __FILE__, __LINE__ )
|
159
|
165
|
|
160
|
166
|
/**
|
161
|
167
|
* Report TCP/IP pseudorandom-data test result
|
162
|
168
|
*
|
163
|
169
|
* @v test TCP/IP test
|
|
170
|
+ * @v file Test code file
|
|
171
|
+ * @v line Test code line
|
164
|
172
|
*/
|
165
|
|
-#define tcpip_random_ok( test ) do { \
|
166
|
|
- uint8_t *data = ( tcpip_data + (test)->offset ); \
|
167
|
|
- uint16_t expected; \
|
168
|
|
- uint16_t generic_sum; \
|
169
|
|
- uint16_t sum; \
|
170
|
|
- unsigned long elapsed; \
|
171
|
|
- unsigned int i; \
|
172
|
|
- assert ( ( (test)->len + (test)->offset ) <= \
|
173
|
|
- sizeof ( tcpip_data ) ); \
|
174
|
|
- srandom ( (test)->seed ); \
|
175
|
|
- for ( i = 0 ; i < (test)->len ; i++ ) \
|
176
|
|
- data[i] = random(); \
|
177
|
|
- expected = rfc_tcpip_chksum ( data, (test)->len ); \
|
178
|
|
- generic_sum = generic_tcpip_continue_chksum ( TCPIP_EMPTY_CSUM, \
|
179
|
|
- data, \
|
180
|
|
- (test)->len ); \
|
181
|
|
- ok ( generic_sum == expected ); \
|
182
|
|
- simple_profile(); \
|
183
|
|
- sum = tcpip_continue_chksum ( TCPIP_EMPTY_CSUM, data, \
|
184
|
|
- (test)->len ); \
|
185
|
|
- elapsed = simple_profile(); \
|
186
|
|
- ok ( sum == expected ); \
|
187
|
|
- DBG ( "TCPIP checksummed %zd bytes (+%zd) in %ld ticks\n", \
|
188
|
|
- (test)->len, (test)->offset, elapsed ); \
|
189
|
|
- } while ( 0 )
|
|
173
|
+static void tcpip_random_okx ( struct tcpip_random_test *test,
|
|
174
|
+ const char *file, unsigned int line ) {
|
|
175
|
+ uint8_t *data = ( tcpip_data + test->offset );
|
|
176
|
+ uint16_t expected;
|
|
177
|
+ uint16_t generic_sum;
|
|
178
|
+ uint16_t sum;
|
|
179
|
+ unsigned long elapsed;
|
|
180
|
+ unsigned int i;
|
|
181
|
+
|
|
182
|
+ /* Sanity check */
|
|
183
|
+ assert ( ( test->len + test->offset ) <= sizeof ( tcpip_data ) );
|
|
184
|
+
|
|
185
|
+ /* Generate random data */
|
|
186
|
+ srandom ( test->seed );
|
|
187
|
+ for ( i = 0 ; i < test->len ; i++ )
|
|
188
|
+ data[i] = random();
|
|
189
|
+
|
|
190
|
+ /* Verify generic_tcpip_continue_chksum() result */
|
|
191
|
+ expected = rfc_tcpip_chksum ( data, test->len );
|
|
192
|
+ generic_sum = generic_tcpip_continue_chksum ( TCPIP_EMPTY_CSUM,
|
|
193
|
+ data, test->len );
|
|
194
|
+ okx ( generic_sum == expected, file, line );
|
|
195
|
+
|
|
196
|
+ /* Verify optimised tcpip_continue_chksum() result */
|
|
197
|
+ simple_profile();
|
|
198
|
+ sum = tcpip_continue_chksum ( TCPIP_EMPTY_CSUM, data, test->len );
|
|
199
|
+ elapsed = simple_profile();
|
|
200
|
+ okx ( sum == expected, file, line );
|
|
201
|
+ DBG ( "TCPIP checksummed %zd bytes (+%zd) in %ld ticks\n",
|
|
202
|
+ test->len, test->offset, elapsed );
|
|
203
|
+}
|
|
204
|
+#define tcpip_random_ok( test ) tcpip_random_okx ( test, __FILE__, __LINE__ )
|
190
|
205
|
|
191
|
206
|
/**
|
192
|
207
|
* Perform TCP/IP self-tests
|