diff --git a/tests/testlib/s2n_self_talk_test_utils.c b/tests/testlib/s2n_self_talk_test_utils.c deleted file mode 100644 index 3c3ed0ec2f3..00000000000 --- a/tests/testlib/s2n_self_talk_test_utils.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). - * You may not use this file except in compliance with the License. - * A copy of the License is located at - * - * http://aws.amazon.com/apache2.0 - * - * or in the "license" file accompanying this file. This file is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. See the License for the specific language governing - * permissions and limitations under the License. - */ - -#include "testlib/s2n_testlib.h" - -S2N_RESULT s2n_noop_inet_socket_cb(struct s2n_connection *conn) -{ - return S2N_RESULT_OK; -} diff --git a/tests/testlib/s2n_testlib.h b/tests/testlib/s2n_testlib.h index 2ad592d33b9..1cb99b052a0 100644 --- a/tests/testlib/s2n_testlib.h +++ b/tests/testlib/s2n_testlib.h @@ -245,10 +245,3 @@ extern const s2n_parsed_extension EMPTY_PARSED_EXTENSIONS[S2N_PARSED_EXTENSIONS_ int s2n_kem_recv_public_key_fuzz_test(const uint8_t *buf, size_t len, struct s2n_kem_params *kem_params); int s2n_kem_recv_ciphertext_fuzz_test(const uint8_t *buf, size_t len, struct s2n_kem_params *kem_params); int s2n_kem_recv_ciphertext_fuzz_test_init(const char *kat_file_path, struct s2n_kem_params *kem_params); - -/* A collection of callbacks run during inet socket self talk tests */ -struct self_talk_inet_socket_callbacks { - S2N_RESULT (*server_post_handshake_cb)(struct s2n_connection *conn); - S2N_RESULT (*client_post_handshake_cb)(struct s2n_connection *conn); -}; -S2N_RESULT s2n_noop_inet_socket_cb(struct s2n_connection *conn); diff --git a/tests/unit/s2n_self_talk_inet_socket_test.c b/tests/unit/s2n_self_talk_inet_socket_test.c index de71a008f1f..ac3eeca6d27 100644 --- a/tests/unit/s2n_self_talk_inet_socket_test.c +++ b/tests/unit/s2n_self_talk_inet_socket_test.c @@ -28,6 +28,17 @@ const char CHAR_A = 'a'; const char CHAR_B = 'b'; +/* A collection of callbacks run during inet socket self talk tests */ +struct self_talk_inet_socket_callbacks { + S2N_RESULT (*server_post_handshake_cb)(struct s2n_connection *conn); + S2N_RESULT (*client_post_handshake_cb)(struct s2n_connection *conn); +}; + +S2N_RESULT s2n_noop_inet_socket_cb(struct s2n_connection *conn) +{ + return S2N_RESULT_OK; +} + static S2N_RESULT start_client(int fd, int read_pipe, const struct self_talk_inet_socket_callbacks *socket_cb) { /* Setup connections */ @@ -57,15 +68,13 @@ static S2N_RESULT start_client(int fd, int read_pipe, const struct self_talk_ine char sync = 0; char recv_buffer[1] = { 0 }; - { - RESULT_GUARD_POSIX(read(read_pipe, &sync, 1)); - RESULT_GUARD_POSIX(s2n_recv(client_conn, recv_buffer, 1, &blocked)); - RESULT_ENSURE_EQ(memcmp(&CHAR_A, &recv_buffer[0], 1), 0); + RESULT_GUARD_POSIX(read(read_pipe, &sync, 1)); + RESULT_GUARD_POSIX(s2n_recv(client_conn, recv_buffer, 1, &blocked)); + RESULT_ENSURE_EQ(memcmp(&CHAR_A, &recv_buffer[0], 1), 0); - RESULT_GUARD_POSIX(read(read_pipe, &sync, 1)); - RESULT_GUARD_POSIX(s2n_recv(client_conn, recv_buffer, 1, &blocked)); - RESULT_ENSURE_EQ(memcmp(&CHAR_B, &recv_buffer[0], 1), 0); - } + RESULT_GUARD_POSIX(read(read_pipe, &sync, 1)); + RESULT_GUARD_POSIX(s2n_recv(client_conn, recv_buffer, 1, &blocked)); + RESULT_ENSURE_EQ(memcmp(&CHAR_B, &recv_buffer[0], 1), 0); return S2N_RESULT_OK; } @@ -99,15 +108,14 @@ static S2N_RESULT start_server(int fd, int write_pipe, const struct self_talk_in char sync = 0; char send_buffer[1] = { 0 }; - { - send_buffer[0] = CHAR_A; - EXPECT_SUCCESS(s2n_send(server_conn, send_buffer, 1, &blocked)); - EXPECT_SUCCESS(write(write_pipe, &sync, 1)); - - send_buffer[0] = CHAR_B; - EXPECT_SUCCESS(s2n_send(server_conn, send_buffer, 1, &blocked)); - EXPECT_SUCCESS(write(write_pipe, &sync, 1)); - } + + send_buffer[0] = CHAR_A; + EXPECT_SUCCESS(s2n_send(server_conn, send_buffer, 1, &blocked)); + EXPECT_SUCCESS(write(write_pipe, &sync, 1)); + + send_buffer[0] = CHAR_B; + EXPECT_SUCCESS(s2n_send(server_conn, send_buffer, 1, &blocked)); + EXPECT_SUCCESS(write(write_pipe, &sync, 1)); return S2N_RESULT_OK; }