|
26 | 26 | #include <stdio.h>
|
27 | 27 | #include <stdlib.h>
|
28 | 28 | #include <string.h>
|
| 29 | +#include <sys/random.h> |
29 | 30 |
|
30 | 31 | #ifndef ARRAY_SIZE
|
31 | 32 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
|
@@ -1070,6 +1071,64 @@ static void astlpc_test_negotiate_mtu_low_high(void)
|
1070 | 1071 | free(lpc_mem);
|
1071 | 1072 | }
|
1072 | 1073 |
|
| 1074 | +static void astlpc_test_send_large_packet(void) |
| 1075 | +{ |
| 1076 | + struct astlpc_endpoint *bmc, *host; |
| 1077 | + struct astlpc_test ctx; |
| 1078 | + uint8_t kcs[2] = { 0 }; |
| 1079 | + void *lpc_mem; |
| 1080 | + int rc; |
| 1081 | + |
| 1082 | + host = &ctx.host; |
| 1083 | + bmc = &ctx.bmc; |
| 1084 | + |
| 1085 | + /* Test harness initialisation */ |
| 1086 | + lpc_mem = calloc(1, 1 * 1024 * 1024); |
| 1087 | + assert(lpc_mem); |
| 1088 | + |
| 1089 | + /* BMC initialisation */ |
| 1090 | + rc = endpoint_init(bmc, 8, MCTP_BINDING_ASTLPC_MODE_BMC, 8192, &kcs, |
| 1091 | + lpc_mem); |
| 1092 | + assert(!rc); |
| 1093 | + |
| 1094 | + /* Host initialisation */ |
| 1095 | + rc = endpoint_init(host, 9, MCTP_BINDING_ASTLPC_MODE_HOST, 8192, &kcs, |
| 1096 | + lpc_mem); |
| 1097 | + assert(!rc); |
| 1098 | + |
| 1099 | + ctx.count = 0; |
| 1100 | + mctp_set_rx_all(bmc->mctp, rx_message, &ctx); |
| 1101 | + |
| 1102 | + rc = mctp_astlpc_poll(bmc->astlpc); |
| 1103 | + assert(rc == 0); |
| 1104 | + |
| 1105 | + rc = mctp_astlpc_poll(host->astlpc); |
| 1106 | + assert(rc == 0); |
| 1107 | + |
| 1108 | + ctx.msg = malloc(2 * MCTP_BODY_SIZE(8192)); |
| 1109 | + assert(ctx.msg); |
| 1110 | + |
| 1111 | + memset(ctx.msg, 0x5a, 2 * MCTP_BODY_SIZE(8192)); |
| 1112 | + |
| 1113 | + rc = mctp_message_tx(host->mctp, 8, ctx.msg, 2 * MCTP_BODY_SIZE(8192)); |
| 1114 | + assert(rc == 0); |
| 1115 | + rc = mctp_astlpc_poll(bmc->astlpc); |
| 1116 | + assert(rc == 0); |
| 1117 | + rc = mctp_astlpc_poll(host->astlpc); |
| 1118 | + assert(rc == 0); |
| 1119 | + rc = mctp_astlpc_poll(bmc->astlpc); |
| 1120 | + assert(rc == 0); |
| 1121 | + rc = mctp_astlpc_poll(host->astlpc); |
| 1122 | + assert(rc == 0); |
| 1123 | + |
| 1124 | + assert(ctx.count == 1); |
| 1125 | + |
| 1126 | + free(ctx.msg); |
| 1127 | + endpoint_destroy(host); |
| 1128 | + endpoint_destroy(bmc); |
| 1129 | + free(lpc_mem); |
| 1130 | +} |
| 1131 | + |
1073 | 1132 | /* clang-format off */
|
1074 | 1133 | #define TEST_CASE(test) { #test, test }
|
1075 | 1134 | static const struct {
|
@@ -1109,6 +1168,7 @@ static const struct {
|
1109 | 1168 | TEST_CASE(astlpc_test_buffers_bad_host_init),
|
1110 | 1169 | TEST_CASE(astlpc_test_negotiate_increased_mtu),
|
1111 | 1170 | TEST_CASE(astlpc_test_negotiate_mtu_low_high),
|
| 1171 | + TEST_CASE(astlpc_test_send_large_packet), |
1112 | 1172 | };
|
1113 | 1173 | /* clang-format on */
|
1114 | 1174 |
|
|
0 commit comments