diff --git a/tests/unit/s2n_drbg_test.c b/tests/unit/s2n_drbg_test.c index 4595ff79b6f..4b4222cfbfc 100644 --- a/tests/unit/s2n_drbg_test.c +++ b/tests/unit/s2n_drbg_test.c @@ -451,6 +451,8 @@ int main(int argc, char **argv) EXPECT_SUCCESS(s2n_stuffer_free(&nist_aes256_reference_entropy)); EXPECT_SUCCESS(s2n_config_free(config)); + /* Clean up with previously set functions */ + POSIX_GUARD_RESULT(s2n_rand_cleanup()); END_TEST(); } diff --git a/tests/unit/s2n_fork_generation_number_test.c b/tests/unit/s2n_fork_generation_number_test.c index 6ccf9e9274f..5b99dc15577 100644 --- a/tests/unit/s2n_fork_generation_number_test.c +++ b/tests/unit/s2n_fork_generation_number_test.c @@ -30,6 +30,7 @@ #include "s2n_test.h" #include "utils/s2n_fork_detection.h" +#include "utils/s2n_random.h" #define NUMBER_OF_FGN_TEST_CASES 4 #define MAX_NUMBER_OF_TEST_THREADS 2 @@ -189,6 +190,9 @@ static int s2n_unit_test_clone_child_process(void *parent_process_fgn) /* Verify in threads */ EXPECT_EQUAL(s2n_unit_test_thread(return_fork_generation_number), S2N_SUCCESS); + /* Clean up urandom of the child process */ + POSIX_GUARD_RESULT(s2n_rand_cleanup()); + /* This translates to the exit code for this child process */ return EXIT_SUCCESS; } diff --git a/tests/unit/s2n_key_update_threads_test.c b/tests/unit/s2n_key_update_threads_test.c index 364e26edf67..cf11f54bde6 100644 --- a/tests/unit/s2n_key_update_threads_test.c +++ b/tests/unit/s2n_key_update_threads_test.c @@ -208,6 +208,7 @@ static S2N_RESULT s2n_run_self_talk_test(s2n_test_scenario scenario_fn) EXPECT_SUCCESS(s2n_connection_free(client)); EXPECT_SUCCESS(s2n_cert_chain_and_key_free(chain_and_key)); EXPECT_SUCCESS(s2n_config_free(config)); + EXPECT_SUCCESS(s2n_io_pair_close_one_end(&io_pair, S2N_CLIENT)); exit(EXIT_SUCCESS); } diff --git a/tests/unit/s2n_override_openssl_random_test.c b/tests/unit/s2n_override_openssl_random_test.c index 765d806b525..b82043abf89 100644 --- a/tests/unit/s2n_override_openssl_random_test.c +++ b/tests/unit/s2n_override_openssl_random_test.c @@ -131,6 +131,8 @@ int main(int argc, char **argv) EXPECT_SUCCESS(s2n_stuffer_free(&dhparams_in)); EXPECT_SUCCESS(s2n_stuffer_free(&test_entropy)); free(dhparams_pem); + /* Clean up with previously set functions */ + POSIX_GUARD_RESULT(s2n_rand_cleanup()); END_TEST(); } diff --git a/tests/unit/s2n_random_test.c b/tests/unit/s2n_random_test.c index b2b5ecdbd63..2132854cfb2 100644 --- a/tests/unit/s2n_random_test.c +++ b/tests/unit/s2n_random_test.c @@ -839,10 +839,9 @@ static int s2n_random_invalid_urandom_fd_cb(struct random_test_case *test_case) EXPECT_OK(s2n_rand_set_urandom_for_test()); EXPECT_TRUE(dev_urandom->fd > STDERR_FILENO); - if (test == 0) { - /* Close the file descriptor. */ - EXPECT_EQUAL(close(dev_urandom->fd), 0); - } else { + /* Close the file descriptor. */ + EXPECT_EQUAL(close(dev_urandom->fd), 0); + if (test != 0) { /* Make the file descriptor invalid by pointing it to STDERR. */ dev_urandom->fd = STDERR_FILENO; } diff --git a/tests/unit/s2n_self_talk_broken_pipe_test.c b/tests/unit/s2n_self_talk_broken_pipe_test.c index 2303b9230da..cdce1ba6d9e 100644 --- a/tests/unit/s2n_self_talk_broken_pipe_test.c +++ b/tests/unit/s2n_self_talk_broken_pipe_test.c @@ -82,6 +82,7 @@ void mock_client(struct s2n_test_io_pair *io_pair) sleep(1); s2n_io_pair_shutdown_one_end(io_pair, S2N_CLIENT, SHUT_WR); + s2n_io_pair_close_one_end(io_pair, S2N_CLIENT); exit(0); }