From 87c2fd4310e5b345102d7a4915dc5e3a65052305 Mon Sep 17 00:00:00 2001 From: Bernhard Schmidt Date: Sun, 14 Oct 2018 22:51:08 +0200 Subject: Revert "Merge branch 'stretch' of ssh://git.debian.org/git/collab-maint/openvpn into stretch" This reverts commit 3804bc2606a92e2f2f4b3a2b043af0d77d92b386, reversing changes made to 678cfd249add7ca758e4c41933c7b730132c99f4. --- tests/unit_tests/openvpn/Makefile.am | 13 +-- tests/unit_tests/openvpn/mock_msg.c | 15 ++- tests/unit_tests/openvpn/test_packet_id.c | 175 ------------------------------ 3 files changed, 10 insertions(+), 193 deletions(-) delete mode 100644 tests/unit_tests/openvpn/test_packet_id.c (limited to 'tests') diff --git a/tests/unit_tests/openvpn/Makefile.am b/tests/unit_tests/openvpn/Makefile.am index b0813a0..fafe6b2 100644 --- a/tests/unit_tests/openvpn/Makefile.am +++ b/tests/unit_tests/openvpn/Makefile.am @@ -1,6 +1,6 @@ AUTOMAKE_OPTIONS = foreign -check_PROGRAMS = argv_testdriver buffer_testdriver packet_id_testdriver +check_PROGRAMS = argv_testdriver buffer_testdriver if ENABLE_CRYPTO check_PROGRAMS += tls_crypt_testdriver @@ -27,17 +27,6 @@ buffer_testdriver_SOURCES = test_buffer.c mock_msg.c \ $(openvpn_srcdir)/buffer.c \ $(openvpn_srcdir)/platform.c -packet_id_testdriver_CFLAGS = @TEST_CFLAGS@ \ - -I$(openvpn_includedir) -I$(compat_srcdir) -I$(openvpn_srcdir) \ - $(OPTIONAL_CRYPTO_CFLAGS) -packet_id_testdriver_LDFLAGS = @TEST_LDFLAGS@ \ - $(OPTIONAL_CRYPTO_LIBS) -packet_id_testdriver_SOURCES = test_packet_id.c mock_msg.c \ - $(openvpn_srcdir)/buffer.c \ - $(openvpn_srcdir)/otime.c \ - $(openvpn_srcdir)/packet_id.c \ - $(openvpn_srcdir)/platform.c - tls_crypt_testdriver_CFLAGS = @TEST_CFLAGS@ \ -I$(openvpn_includedir) -I$(compat_srcdir) -I$(openvpn_srcdir) \ $(OPTIONAL_CRYPTO_CFLAGS) diff --git a/tests/unit_tests/openvpn/mock_msg.c b/tests/unit_tests/openvpn/mock_msg.c index 060588f..eb0d5e9 100644 --- a/tests/unit_tests/openvpn/mock_msg.c +++ b/tests/unit_tests/openvpn/mock_msg.c @@ -29,12 +29,9 @@ #endif #include -#include +#include #include #include -#include -#include - #include "errlevel.h" #include "error.h" @@ -73,8 +70,14 @@ x_msg(const unsigned int flags, const char *format, ...) void assert_failed(const char *filename, int line, const char *condition) { - mock_assert(false, condition ? condition : "", filename, line); - /* Keep compiler happy. Should not happen, mock_assert() does not return */ + if (condition) + { + printf("Assertion failed at %s:%d (%s)", filename, line, condition); + } + else + { + printf("Assertion failed at %s:%d", filename, line); + } exit(1); } diff --git a/tests/unit_tests/openvpn/test_packet_id.c b/tests/unit_tests/openvpn/test_packet_id.c deleted file mode 100644 index 0a785ad..0000000 --- a/tests/unit_tests/openvpn/test_packet_id.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * OpenVPN -- An application to securely tunnel IP networks - * over a single UDP port, with support for SSL/TLS-based - * session authentication and key exchange, - * packet encryption, packet authentication, and - * packet compression. - * - * Copyright (C) 2016 Fox Crypto B.V. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program (see the file COPYING included with this - * distribution); if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#elif defined(_MSC_VER) -#include "config-msvc.h" -#endif - -#include "syshead.h" - -#include -#include -#include -#include - -#include "packet_id.h" - -#include "mock_msg.h" - -struct test_packet_id_write_data { - struct { - uint32_t buf_id; - uint32_t buf_time; - } test_buf_data; - struct buffer test_buf; - struct packet_id_send pis; -}; - -static int -test_packet_id_write_setup(void **state) { - struct test_packet_id_write_data *data = - calloc(1, sizeof(struct test_packet_id_write_data)); - - if (!data) - { - return -1; - } - - data->test_buf.data = (void *) &data->test_buf_data; - data->test_buf.capacity = sizeof(data->test_buf_data); - - *state = data; - return 0; -} - -static int -test_packet_id_write_teardown(void **state) { - free(*state); - return 0; -} - -static void -test_packet_id_write_short(void **state) -{ - struct test_packet_id_write_data *data = *state; - - now = 5010; - assert_true(packet_id_write(&data->pis, &data->test_buf, false, false)); - assert_true(data->pis.id == 1); - assert_true(data->test_buf_data.buf_id == htonl(1)); - assert_true(data->test_buf_data.buf_time == 0); -} - -static void -test_packet_id_write_long(void **state) -{ - struct test_packet_id_write_data *data = *state; - - now = 5010; - assert_true(packet_id_write(&data->pis, &data->test_buf, true, false)); - assert(data->pis.id == 1); - assert(data->pis.time == now); - assert_true(data->test_buf_data.buf_id == htonl(1)); - assert_true(data->test_buf_data.buf_time == htonl(now)); -} - -static void -test_packet_id_write_short_prepend(void **state) -{ - struct test_packet_id_write_data *data = *state; - - data->test_buf.offset = sizeof(packet_id_type); - now = 5010; - assert_true(packet_id_write(&data->pis, &data->test_buf, false, true)); - assert_true(data->pis.id == 1); - assert_true(data->test_buf_data.buf_id == htonl(1)); - assert_true(data->test_buf_data.buf_time == 0); -} - -static void -test_packet_id_write_long_prepend(void **state) -{ - struct test_packet_id_write_data *data = *state; - - data->test_buf.offset = sizeof(data->test_buf_data); - now = 5010; - assert_true(packet_id_write(&data->pis, &data->test_buf, true, true)); - assert(data->pis.id == 1); - assert(data->pis.time == now); - assert_true(data->test_buf_data.buf_id == htonl(1)); - assert_true(data->test_buf_data.buf_time == htonl(now)); -} - -static void -test_packet_id_write_short_wrap(void **state) -{ - struct test_packet_id_write_data *data = *state; - - data->pis.id = ~0; - assert_false(packet_id_write(&data->pis, &data->test_buf, false, false)); -} - -static void -test_packet_id_write_long_wrap(void **state) -{ - struct test_packet_id_write_data *data = *state; - - data->pis.id = ~0; - data->pis.time = 5006; - - /* Write fails if time did not change */ - now = 5006; - assert_false(packet_id_write(&data->pis, &data->test_buf, true, false)); - - /* Write succeeds if time moved forward */ - now = 5010; - assert_true(packet_id_write(&data->pis, &data->test_buf, true, false)); - - assert(data->pis.id == 1); - assert(data->pis.time == now); - assert_true(data->test_buf_data.buf_id == htonl(1)); - assert_true(data->test_buf_data.buf_time == htonl(now)); -} - -int -main(void) { - const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(test_packet_id_write_short, - test_packet_id_write_setup, test_packet_id_write_teardown), - cmocka_unit_test_setup_teardown(test_packet_id_write_long, - test_packet_id_write_setup, test_packet_id_write_teardown), - cmocka_unit_test_setup_teardown(test_packet_id_write_short_prepend, - test_packet_id_write_setup, test_packet_id_write_teardown), - cmocka_unit_test_setup_teardown(test_packet_id_write_long_prepend, - test_packet_id_write_setup, test_packet_id_write_teardown), - cmocka_unit_test_setup_teardown(test_packet_id_write_short_wrap, - test_packet_id_write_setup, test_packet_id_write_teardown), - cmocka_unit_test_setup_teardown(test_packet_id_write_long_wrap, - test_packet_id_write_setup, test_packet_id_write_teardown), - }; - - return cmocka_run_group_tests_name("packet_id tests", tests, NULL, NULL); -} -- cgit v1.2.3