Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
lrstewart committed Sep 8, 2023
1 parent ef89981 commit ae50685
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/testlib/s2n_ktls_test_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ ssize_t s2n_test_ktls_sendmsg_io_stuffer(void *io_context, const struct msghdr *
size_t len = msg->msg_iov[count].iov_len;

if (s2n_stuffer_write_bytes(data_buffer, buf, len) != S2N_SUCCESS) {
fprintf(stderr, "Stuffer write of %li failed with %s / %s\n", len,
s2n_strerror(s2n_errno, NULL), s2n_strerror_debug(s2n_errno, NULL));
size_t partial_len = MIN(len, s2n_stuffer_space_remaining(data_buffer));
POSIX_GUARD(s2n_stuffer_write_bytes(data_buffer, buf, partial_len));
total_len += partial_len;
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/s2n_ktls_io_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#define S2N_TEST_TO_SEND 10
#define S2N_TEST_MSG_IOVLEN 5

extern s2n_ktls_sendmsg_fn s2n_sendmsg_fn;

S2N_RESULT s2n_ktls_set_control_data(struct msghdr *msg, char *buf, size_t buf_size,
int cmsg_type, uint8_t record_type);
S2N_RESULT s2n_ktls_get_control_data(struct msghdr *msg, int cmsg_type, uint8_t *record_type);
Expand Down Expand Up @@ -825,6 +827,17 @@ int main(int argc, char **argv)
s2n_blocked_status blocked = S2N_NOT_BLOCKED;
ssize_t result = s2n_ktls_sendv_with_offset(conn,
test_iovecs.iovecs, test_iovecs.iovecs_count, offset, &blocked);
fprintf(stderr, "%li result = %li\n", offset, result);
fprintf(stderr, "%li sendmsg_fn=%li conn.io_context=%li out=%li\n", offset,
(uintptr_t) s2n_sendmsg_fn, (uintptr_t) conn->send_io_context, (uintptr_t) &out);
fprintf(stderr, "%li control.growable=%i data.growable=%i "
"data.allocated=%i data.write_cursor=%i "
"data.read_cursor=%i\n", offset,
out.ancillary_buffer.growable,
out.data_buffer.growable,
out.data_buffer.blob.allocated,
out.data_buffer.write_cursor,
out.data_buffer.read_cursor);
EXPECT_EQUAL(result, expected_sent);

EXPECT_EQUAL(out.sendmsg_invoked_count, 1);
Expand Down

0 comments on commit ae50685

Please sign in to comment.