Skip to content

Commit be8ff56

Browse files
Add writev tests (#59)
* Add test setup for writev tests * Add more tests * Fix the tests and add macro * Add details about writev tests * Update readme and the formatting on transport interface test file * Make changes pointed out in the comments * Fix README according the review comments * Fix PR comments
1 parent 39dfbae commit be8ff56

File tree

2 files changed

+651
-56
lines changed

2 files changed

+651
-56
lines changed

src/transport_interface/README.md

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@ The test directly exercises the transport interface on the device under testing
2121
* A PC to run the provided echo server.
2222
* A test application which runs on the device under test with transport interface implemented.
2323

24+
_NOTE: The writev tests are optional and can be used to verify the implementation of writev method using the scatter-gather approach._
25+
2426
The test application is usually implemented by calling the provided transport interface test routine from the main function.
2527

2628

2729
## 2. Transport Interface Test Cases
2830

2931
The transport interface tests verify the implementation by running various test cases. The test cases are designed according to the guidelines in the transport interface header file.
3032

33+
###Mandatory Test Cases
34+
3135
|Test Case |Test Case Detail |Expected result |
3236
|--- |--- |--- |
3337
|TransportSend_NetworkContextNullPtr |Test transport interface send with NULL network context pointer handling |Negative value should be returned |
@@ -36,15 +40,29 @@ The transport interface tests verify the implementation by running various test
3640
|TransportRecv_NetworkContextNullPtr |Test transport interface recv with NULL network context pointer handling |Negative value should be returned |
3741
|TransportRecv_BufferNullPtr |Test transport interface recv with NULL buffer pointer handling |Negative value should be returned |
3842
|TransportRecv_ZeroByteToRecv |Test transport interface recv with zero byte to receive handling |Negative value should be returned |
39-
|Transport_SendOneByteRecvCompare |Test send receive behavior in the following order<br>Send : 1 byte<br>Send : ( TRANSPORT_TEST_BUFFER_WRITABLE_LENGTH - 1 ) bytes<br>Receive : TRANSPORT_TEST_BUFFER_WRITABLE_LENGTH bytes | Send/receive/compare should has no error |
40-
|Transport_SendRecvOneByteCompare |Test send receive behavior in the following order<br>Send : TRANSPORT_TEST_BUFFER_WRITABLE_LENGTH bytes<br>Receive : 1 byte<br>Receive : ( TRANSPORT_TEST_BUFFER_WRITABLE_LENGTH - 1 ) bytes |Send/receive/compare should has no error|
41-
|Transport_SendRecvCompare |Test transport interface with send, receive and compare on bulk of data.<br>The data size ranges from 1 byte to TRANSPORT_TEST_BUFFER_WRITABLE_LENGTH bytes |Send/receive/compare should has no error within timeout |
42-
|Transport_SendRecvCompareMultithreaded |Test transport interface with send, receive and compare on bulk of data in multiple threads.<br>Each thread will create a network connection.<br>The data size ranges from 1 byte to TRANSPORT_TEST_BUFFER_WRITABLE_LENGTH bytes |Send/receive/compare should has no error within timeout |
43+
|Transport_SendOneByteRecvCompare |Test send receive behavior in the following order<br>Send : 1 byte<br>Send : ( TRANSPORT_TEST_BUFFER_WRITABLE_LENGTH - 1 ) bytes<br>Receive : TRANSPORT_TEST_BUFFER_WRITABLE_LENGTH bytes | Send/receive/compare should have no errors |
44+
|Transport_SendRecvOneByteCompare |Test send receive behavior in the following order<br>Send : TRANSPORT_TEST_BUFFER_WRITABLE_LENGTH bytes<br>Receive : 1 byte<br>Receive : ( TRANSPORT_TEST_BUFFER_WRITABLE_LENGTH - 1 ) bytes |Send/receive/compare should have no errors |
45+
|Transport_SendRecvCompare |Test transport interface with send, receive and compare on bulk of data.<br>The data size ranges from 1 byte to TRANSPORT_TEST_BUFFER_WRITABLE_LENGTH bytes |Send/receive/compare should have no error within timeout |
46+
|Transport_SendRecvCompareMultithreaded |Test transport interface with send, receive and compare on bulk of data in multiple threads.<br>Each thread will create a network connection.<br>The data size ranges from 1 byte to TRANSPORT_TEST_BUFFER_WRITABLE_LENGTH bytes |Send/receive/compare should have no error within timeout |
4347
|TransportSend_RemoteDisconnect |Test transport interface send function return value when disconnected by remote server |Negative value should be returned |
4448
|TransportRecv_RemoteDisconnect |Test transport interface receive function return value when disconnected by remote server |Negative value should be returned |
4549
|TransportRecv_NoDataToReceive |Test transport interface receive function return value when no data to receive |0 should be returned |
4650
|TransportRecv_ReturnZeroRetry |Test transport interface receive function return zero due to no data to receive. Send data to echo server then retry the receive function. Transport receive function should be able to receive data from echo server and return positive value. |Postive value should be returned after retry transport receive |
4751

52+
###Optional Test Cases
53+
54+
|Test Case |Test Case Detail |Expected result |
55+
|--- |--- |--- |
56+
|TransportWritev_NetworkContextNullPtr |Test transport interface writev with NULL network context pointer handling |Negative value should be returned |
57+
|TransportWritev_BufferNullPtr |Test transport interface writev with NULL transport vector array pointer handling |Negative value should be returned |
58+
|TransportWritev_ZeroByteToSend |Test transport interface writev with zero vector array length to send handling |Negative value should be returned |
59+
|TransportWritev_OneVectorBufferNullPtr |Test transport interface writev with one data pointer in the array pointing to NULL. |Negative value should be returned |
60+
|TransportWritev_OneVectorLengthZero |Test transport interface writev with one vector length being 0 |Negative value should be returned |
61+
|Transport_WritevOneByteRecvCompare |Test writev receive behavior in the following order<br>Send : 1 byte<br>Send : ( TRANSPORT_TEST_BUFFER_WRITABLE_LENGTH - 1 ) bytes<br>Receive : TRANSPORT_TEST_BUFFER_WRITABLE_LENGTH bytes | Send/receive/compare should have no errors |
62+
|Transport_WritevRecvCompare |Test transport interface with writev, receive and compare on bulk of data.<br>The data size ranges from 1 byte to TRANSPORT_TEST_BUFFER_WRITABLE_LENGTH bytes |Send/receive/compare should have no error within timeout |
63+
|Transport_WritevRecvCompareMultithreaded |Test transport interface with writev, receive and compare on bulk of data in multiple threads.<br>Each thread will create a network connection.<br>The data size ranges from 1 byte to TRANSPORT_TEST_BUFFER_WRITABLE_LENGTH bytes |Send/receive/compare should have no error within timeout |
64+
|TransportWritev_RemoteDisconnect |Test transport interface writev function return value when disconnected by remote server |Negative value should be returned |
65+
4866
Assert may be used to check invalid parameters. In that case, you need to replace
4967
the assert macro to return negative value in your transport interface implementation
5068
to ensure invalid parameter error can be catched by assert.<br><br>
@@ -173,7 +191,13 @@ int FRTest_ThreadTimedJoin( FRTestThreadHandle_t threadHandle,
173191
#define TRANSPORT_INTERFACE_TEST_ENABLED ( 1 ) /* Set 1 to enable the transport interface test. */
174192
```
175193
176-
6. Implement the main function and call the **RunQualificationTest**.
194+
7. Optionally define **TRANSPORT_TEST_EXECUTE_WRITEV_TESTS**, in **test_param_config.h** to enable the execution of writev tests.
195+
196+
```C
197+
#define TRANSPORT_TEST_EXECUTE_WRITEV_TESTS
198+
```
199+
200+
8. Implement the main function and call the **RunQualificationTest**.
177201

178202
The following is an example test application.
179203

@@ -240,7 +264,7 @@ void yourMainFunction( void )
240264
241265
## 6. Run The Transport Interface Test
242266
243-
The go-based echo_server.go program can setup a TCP server to echo back data. This echo server is used in the transport interface test to verify the transport interface implementation.
267+
The go-based echo_server.go program located [here](../../tools/echo_server) can setup a TCP server to echo back data. This echo server is used in the transport interface test to verify the transport interface implementation.
244268
245269
The transport interface test starts with the following steps:
246270

0 commit comments

Comments
 (0)