diff options
author | Yuyang Huang <yuyanghuang@google.com> | 2024-02-16 12:36:09 +0900 |
---|---|---|
committer | Yuyang Huang <yuyanghuang@google.com> | 2024-02-20 19:46:22 +0900 |
commit | 82e41db69beaa95862b0edf280cfcc6a7521d706 (patch) | |
tree | 8d9e0f08c8c3d92657faa18e02c2116a302b5ecf | |
parent | 8d01d94d856e70200948a48cacc10b617c2f2638 (diff) | |
download | apf-82e41db69beaa95862b0edf280cfcc6a7521d706.tar.gz |
v5: trigger transmit failure in the test_buf_allocator
In test_buf_allocator, if the transmit buffer length is less than
ETH_HLEN, returns transmit failure. This will enable testing of the
interpreter's error handling logic within the unit test.
Test: TH
Change-Id: Ib05297c986dcb732a99e2f25c3e8acbd14d00ebc
-rw-r--r-- | v5/test_buf_allocator.c | 1 | ||||
-rw-r--r-- | v5/test_buf_allocator.h | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/v5/test_buf_allocator.c b/v5/test_buf_allocator.c index 3fec1f5..e30815e 100644 --- a/v5/test_buf_allocator.c +++ b/v5/test_buf_allocator.c @@ -42,6 +42,7 @@ uint8_t* apf_allocate_buffer(__attribute__ ((unused)) void* ctx, uint32_t size) */ int apf_transmit_buffer(__attribute__((unused)) void* ctx, uint8_t* ptr, uint32_t len, uint8_t dscp) { + if (len && len < ETH_HLEN) return -1; if (ptr != apf_test_buffer) return -1; apf_test_tx_packet_len = len; apf_test_tx_dscp = dscp; diff --git a/v5/test_buf_allocator.h b/v5/test_buf_allocator.h index a03a2cc..c5fa5c4 100644 --- a/v5/test_buf_allocator.h +++ b/v5/test_buf_allocator.h @@ -18,6 +18,7 @@ #define TEST_BUF_ALLOCATOR #include <stdint.h> +#include <linux/if_ether.h> extern uint8_t apf_test_buffer[1514]; extern uint32_t apf_test_tx_packet_len; |