summaryrefslogtreecommitdiff
path: root/src/libstrongswan/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstrongswan/tests')
-rw-r--r--src/libstrongswan/tests/Makefile.am2
-rw-r--r--src/libstrongswan/tests/Makefile.in31
-rw-r--r--src/libstrongswan/tests/suites/test_array.c2
-rw-r--r--src/libstrongswan/tests/suites/test_asn1.c6
-rw-r--r--src/libstrongswan/tests/suites/test_bio_reader.c20
-rw-r--r--src/libstrongswan/tests/suites/test_chunk.c38
-rw-r--r--src/libstrongswan/tests/suites/test_host.c6
-rw-r--r--src/libstrongswan/tests/suites/test_iv_gen.c32
-rw-r--r--src/libstrongswan/tests/suites/test_ntru.c8
-rw-r--r--src/libstrongswan/tests/suites/test_printf.c12
-rw-r--r--src/libstrongswan/tests/suites/test_traffic_selector.c40
-rw-r--r--src/libstrongswan/tests/suites/test_utils.c96
-rw-r--r--src/libstrongswan/tests/test_runner.c30
-rw-r--r--src/libstrongswan/tests/test_runner.h4
-rw-r--r--src/libstrongswan/tests/utils/test_rng.c2
15 files changed, 229 insertions, 100 deletions
diff --git a/src/libstrongswan/tests/Makefile.am b/src/libstrongswan/tests/Makefile.am
index b2d456035..caa9d3a6a 100644
--- a/src/libstrongswan/tests/Makefile.am
+++ b/src/libstrongswan/tests/Makefile.am
@@ -12,7 +12,7 @@ libtest_la_CFLAGS = \
libtest_la_LDFLAGS = @COVERAGE_LDFLAGS@
libtest_la_LIBADD = \
$(top_builddir)/src/libstrongswan/libstrongswan.la \
- $(PTHREADLIB)
+ $(PTHREADLIB) $(ATOMICLIB)
TESTS = tests
diff --git a/src/libstrongswan/tests/Makefile.in b/src/libstrongswan/tests/Makefile.in
index 0a0f5893d..4e5321755 100644
--- a/src/libstrongswan/tests/Makefile.in
+++ b/src/libstrongswan/tests/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -14,7 +14,17 @@
@SET_MAKE@
VPATH = @srcdir@
-am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
@@ -80,8 +90,6 @@ host_triplet = @host@
TESTS = tests$(EXEEXT)
check_PROGRAMS = $(am__EXEEXT_1)
subdir = src/libstrongswan/tests
-DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
- $(top_srcdir)/depcomp
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/config/libtool.m4 \
$(top_srcdir)/m4/config/ltoptions.m4 \
@@ -95,6 +103,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/config/libtool.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
@@ -102,7 +111,7 @@ CONFIG_CLEAN_VPATH_FILES =
am__DEPENDENCIES_1 =
libtest_la_DEPENDENCIES = \
$(top_builddir)/src/libstrongswan/libstrongswan.la \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am__dirstamp = $(am__leading_dot)dirstamp
am_libtest_la_OBJECTS = libtest_la-test_suite.lo \
libtest_la-test_runner.lo utils/libtest_la-test_rng.lo
@@ -240,12 +249,14 @@ am__tty_colors = { \
std=''; \
fi; \
}
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
ALLOCA = @ALLOCA@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
+ATOMICLIB = @ATOMICLIB@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
@@ -295,6 +306,7 @@ LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
@@ -329,6 +341,7 @@ PTHREADLIB = @PTHREADLIB@
PYTHON = @PYTHON@
PYTHONEGGINSTALLDIR = @PYTHONEGGINSTALLDIR@
PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PACKAGE_VERSION = @PYTHON_PACKAGE_VERSION@
PYTHON_PLATFORM = @PYTHON_PLATFORM@
PYTHON_PREFIX = @PYTHON_PREFIX@
PYTHON_VERSION = @PYTHON_VERSION@
@@ -440,6 +453,7 @@ random_device = @random_device@
resolv_conf = @resolv_conf@
routing_table = @routing_table@
routing_table_prio = @routing_table_prio@
+runstatedir = @runstatedir@
s_plugins = @s_plugins@
sbindir = @sbindir@
scepclient_plugins = @scepclient_plugins@
@@ -481,7 +495,7 @@ libtest_la_CFLAGS = \
libtest_la_LDFLAGS = @COVERAGE_LDFLAGS@
libtest_la_LIBADD = \
$(top_builddir)/src/libstrongswan/libstrongswan.la \
- $(PTHREADLIB)
+ $(PTHREADLIB) $(ATOMICLIB)
tests_SOURCES = tests.h tests.c \
suites/test_linked_list.c \
@@ -549,7 +563,6 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/libstrongswan/tests/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu src/libstrongswan/tests/Makefile
-.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
@@ -1603,6 +1616,8 @@ uninstall-am:
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am
+.PRECIOUS: Makefile
+
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/src/libstrongswan/tests/suites/test_array.c b/src/libstrongswan/tests/suites/test_array.c
index eda72e10a..eed8fba56 100644
--- a/src/libstrongswan/tests/suites/test_array.c
+++ b/src/libstrongswan/tests/suites/test_array.c
@@ -512,7 +512,7 @@ END_TEST
START_TEST(test_insert_create_value)
{
array_t *array = NULL;
- u_int16_t v;
+ uint16_t v;
v = 1;
array_insert_create_value(&array, sizeof(v), ARRAY_TAIL, &v);
diff --git a/src/libstrongswan/tests/suites/test_asn1.c b/src/libstrongswan/tests/suites/test_asn1.c
index ac7c5519e..fa02df9ca 100644
--- a/src/libstrongswan/tests/suites/test_asn1.c
+++ b/src/libstrongswan/tests/suites/test_asn1.c
@@ -462,7 +462,7 @@ START_TEST(test_asn1_to_time)
{
typedef struct {
time_t time;
- u_int8_t type;
+ uint8_t type;
char *string;
} testdata_t;
@@ -525,7 +525,7 @@ START_TEST(test_asn1_from_time)
{
typedef struct {
time_t time;
- u_int8_t type;
+ uint8_t type;
chunk_t chunk;
} testdata_t;
@@ -759,7 +759,7 @@ END_TEST
START_TEST(test_asn1_parse_integer_uint64)
{
typedef struct {
- u_int64_t n;
+ uint64_t n;
chunk_t chunk;
} testdata_t;
diff --git a/src/libstrongswan/tests/suites/test_bio_reader.c b/src/libstrongswan/tests/suites/test_bio_reader.c
index 6a9743d62..d3b4b4358 100644
--- a/src/libstrongswan/tests/suites/test_bio_reader.c
+++ b/src/libstrongswan/tests/suites/test_bio_reader.c
@@ -65,7 +65,7 @@
START_TEST(test_read_uint8)
{
chunk_t data = chunk_from_chars(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07);
- u_int8_t val;
+ uint8_t val;
assert_integer_read(data, 8, val);
assert_basic_read(8, val);
@@ -76,7 +76,7 @@ END_TEST
START_TEST(test_read_uint16)
{
chunk_t data = chunk_from_chars(0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03);
- u_int16_t val;
+ uint16_t val;
assert_integer_read(data, 16, val);
assert_basic_read(16, val);
@@ -87,7 +87,7 @@ END_TEST
START_TEST(test_read_uint24)
{
chunk_t data = chunk_from_chars(0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x03);
- u_int32_t val;
+ uint32_t val;
assert_integer_read(data, 24, val);
assert_basic_read(24, val);
@@ -99,7 +99,7 @@ START_TEST(test_read_uint32)
{
chunk_t data = chunk_from_chars(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03);
- u_int32_t val;
+ uint32_t val;
assert_integer_read(data, 32, val);
assert_basic_read(32, val);
@@ -113,7 +113,7 @@ START_TEST(test_read_uint64)
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03);
- u_int64_t val;
+ uint64_t val;
assert_integer_read(data, 64, val);
assert_basic_read(64, val);
@@ -170,7 +170,7 @@ END_TEST
START_TEST(test_read_uint8_end)
{
chunk_t data = chunk_from_chars(0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00);
- u_int8_t val;
+ uint8_t val;
assert_integer_read_end(data, 8, val);
assert_basic_read_end(8, val);
@@ -181,7 +181,7 @@ END_TEST
START_TEST(test_read_uint16_end)
{
chunk_t data = chunk_from_chars(0x00, 0x03, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00);
- u_int16_t val;
+ uint16_t val;
assert_integer_read_end(data, 16, val);
assert_basic_read_end(16, val);
@@ -192,7 +192,7 @@ END_TEST
START_TEST(test_read_uint24_end)
{
chunk_t data = chunk_from_chars(0x00, 0x00, 0x03, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00);
- u_int32_t val;
+ uint32_t val;
assert_integer_read_end(data, 24, val);
assert_basic_read_end(24, val);
@@ -204,7 +204,7 @@ START_TEST(test_read_uint32_end)
{
chunk_t data = chunk_from_chars(0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00);
- u_int32_t val;
+ uint32_t val;
assert_integer_read_end(data, 32, val);
assert_basic_read_end(32, val);
@@ -218,7 +218,7 @@ START_TEST(test_read_uint64_end)
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
- u_int64_t val;
+ uint64_t val;
assert_integer_read_end(data, 64, val);
assert_basic_read_end(64, val);
diff --git a/src/libstrongswan/tests/suites/test_chunk.c b/src/libstrongswan/tests/suites/test_chunk.c
index 6272ca795..b82b1436f 100644
--- a/src/libstrongswan/tests/suites/test_chunk.c
+++ b/src/libstrongswan/tests/suites/test_chunk.c
@@ -316,11 +316,11 @@ START_TEST(test_chunk_skip)
foobar = chunk_from_str("foobar");
a = foobar;
a = chunk_skip(a, 0);
- ck_assert(chunk_equals(a, foobar));
+ ck_assert_chunk_eq(a, foobar);
a = chunk_skip(a, 1);
- ck_assert(chunk_equals(a, chunk_from_str("oobar")));
+ ck_assert_chunk_eq(a, chunk_from_str("oobar"));
a = chunk_skip(a, 2);
- ck_assert(chunk_equals(a, chunk_from_str("bar")));
+ ck_assert_chunk_eq(a, chunk_from_str("bar"));
a = chunk_skip(a, 3);
assert_chunk_empty(a);
@@ -338,20 +338,24 @@ START_TEST(test_chunk_skip_zero)
{
chunk_t foobar, a;
- a = chunk_empty;
- a = chunk_skip_zero(a);
+ a = chunk_skip_zero(chunk_empty);
assert_chunk_empty(a);
foobar = chunk_from_str("foobar");
- a = foobar;
- a = chunk_skip_zero(a);
- ck_assert(chunk_equals(a, foobar));
+ a = chunk_skip_zero(foobar);
+ ck_assert_chunk_eq(a, foobar);
- a = chunk_from_chars(0x00, 0xaa, 0xbb, 0xcc);
- a = chunk_skip_zero(a);
- ck_assert(chunk_equals(a, chunk_from_chars(0xaa, 0xbb, 0xcc)));
+ foobar = chunk_from_chars(0x00);
+ a = chunk_skip_zero(foobar);
+ ck_assert_chunk_eq(a, foobar);
+
+ a = chunk_skip_zero(chunk_from_chars(0x00, 0xaa, 0xbb, 0xcc));
+ ck_assert_chunk_eq(a, chunk_from_chars(0xaa, 0xbb, 0xcc));
a = chunk_skip_zero(a);
- ck_assert(chunk_equals(a, chunk_from_chars(0xaa, 0xbb, 0xcc)));
+ ck_assert_chunk_eq(a, chunk_from_chars(0xaa, 0xbb, 0xcc));
+
+ a = chunk_skip_zero(chunk_from_chars(0x00, 0x00, 0xaa, 0xbb, 0xcc));
+ ck_assert_chunk_eq(a, chunk_from_chars(0xaa, 0xbb, 0xcc));
}
END_TEST
@@ -736,7 +740,7 @@ START_TEST(test_chunk_mac)
{
chunk_t in;
u_char key[16];
- u_int64_t out;
+ uint64_t out;
int i, count;
count = countof(sip_vectors);
@@ -765,7 +769,7 @@ END_TEST
START_TEST(test_chunk_hash)
{
chunk_t chunk;
- u_int32_t hash_a, hash_b, hash_c;
+ uint32_t hash_a, hash_b, hash_c;
chunk = chunk_from_str("asdf");
@@ -787,7 +791,7 @@ END_TEST
START_TEST(test_chunk_hash_static)
{
chunk_t in;
- u_int32_t out, hash_a, hash_b, hash_inc = 0x7b891a95;
+ uint32_t out, hash_a, hash_b, hash_inc = 0x7b891a95;
int i, count;
count = countof(sip_vectors);
@@ -813,7 +817,7 @@ END_TEST
* test for chunk_internet_checksum[_inc]()
*/
-static inline u_int16_t compensate_alignment(u_int16_t val)
+static inline uint16_t compensate_alignment(uint16_t val)
{
return ((val & 0xff) << 8) | (val >> 8);
}
@@ -821,7 +825,7 @@ static inline u_int16_t compensate_alignment(u_int16_t val)
START_TEST(test_chunk_internet_checksum)
{
chunk_t chunk;
- u_int16_t sum;
+ uint16_t sum;
chunk = chunk_from_chars(0x45,0x00,0x00,0x30,0x44,0x22,0x40,0x00,0x80,0x06,
0x00,0x00,0x8c,0x7c,0x19,0xac,0xae,0x24,0x1e,0x2b);
diff --git a/src/libstrongswan/tests/suites/test_host.c b/src/libstrongswan/tests/suites/test_host.c
index 5cb8013ff..5d054577a 100644
--- a/src/libstrongswan/tests/suites/test_host.c
+++ b/src/libstrongswan/tests/suites/test_host.c
@@ -46,7 +46,7 @@ static void verify_netmask(chunk_t addr, int mask)
* host_create_any
*/
-static void verify_any(host_t *host, int family, u_int16_t port)
+static void verify_any(host_t *host, int family, uint16_t port)
{
verify_netmask(host->get_address(host), 0);
ck_assert(host->is_anyaddr(host));
@@ -88,7 +88,7 @@ END_TEST
* host_create_from_string
*/
-static void verify_address(host_t *host, chunk_t addr, int family, u_int16_t port)
+static void verify_address(host_t *host, chunk_t addr, int family, uint16_t port)
{
ck_assert(chunk_equals(host->get_address(host), addr));
ck_assert(!host->is_anyaddr(host));
@@ -656,7 +656,7 @@ END_TEST
static struct {
char *addr;
- u_int16_t port;
+ uint16_t port;
/* results for %H, %+H, %#H (falls back to [0]) */
char *result[3];
} printf_data[] = {
diff --git a/src/libstrongswan/tests/suites/test_iv_gen.c b/src/libstrongswan/tests/suites/test_iv_gen.c
index 4e45c8538..8b0a14b79 100644
--- a/src/libstrongswan/tests/suites/test_iv_gen.c
+++ b/src/libstrongswan/tests/suites/test_iv_gen.c
@@ -21,17 +21,17 @@
START_TEST(test_iv_gen_seq)
{
iv_gen_t *iv_gen;
- u_int64_t iv0, iv1_1, iv1_2;
+ uint64_t iv0, iv1_1, iv1_2;
iv_gen = iv_gen_seq_create();
- ck_assert(iv_gen->get_iv(iv_gen, 0, 8, (u_int8_t*)&iv0));
- ck_assert(iv_gen->get_iv(iv_gen, 1, 8, (u_int8_t*)&iv1_1));
+ ck_assert(iv_gen->get_iv(iv_gen, 0, 8, (uint8_t*)&iv0));
+ ck_assert(iv_gen->get_iv(iv_gen, 1, 8, (uint8_t*)&iv1_1));
ck_assert(iv0 != iv1_1);
/* every sequence number may be used twice, but results in a different IV */
- ck_assert(iv_gen->get_iv(iv_gen, 1, 8, (u_int8_t*)&iv1_2));
+ ck_assert(iv_gen->get_iv(iv_gen, 1, 8, (uint8_t*)&iv1_2));
ck_assert(iv0 != iv1_2);
ck_assert(iv1_1 != iv1_2);
- ck_assert(!iv_gen->get_iv(iv_gen, 1, 8, (u_int8_t*)&iv1_2));
+ ck_assert(!iv_gen->get_iv(iv_gen, 1, 8, (uint8_t*)&iv1_2));
iv_gen->destroy(iv_gen);
}
END_TEST
@@ -39,19 +39,19 @@ END_TEST
START_TEST(test_iv_gen_seq_len)
{
iv_gen_t *iv_gen;
- u_int64_t iv;
- u_int8_t buf[9];
+ uint64_t iv;
+ uint8_t buf[9];
iv_gen = iv_gen_seq_create();
- ck_assert(!iv_gen->get_iv(iv_gen, 0, 0, (u_int8_t*)&iv));
- ck_assert(!iv_gen->get_iv(iv_gen, 0, 1, (u_int8_t*)&iv));
- ck_assert(!iv_gen->get_iv(iv_gen, 0, 2, (u_int8_t*)&iv));
- ck_assert(!iv_gen->get_iv(iv_gen, 0, 3, (u_int8_t*)&iv));
- ck_assert(!iv_gen->get_iv(iv_gen, 0, 4, (u_int8_t*)&iv));
- ck_assert(!iv_gen->get_iv(iv_gen, 0, 5, (u_int8_t*)&iv));
- ck_assert(!iv_gen->get_iv(iv_gen, 0, 6, (u_int8_t*)&iv));
- ck_assert(!iv_gen->get_iv(iv_gen, 0, 7, (u_int8_t*)&iv));
- ck_assert(iv_gen->get_iv(iv_gen, 0, 8, (u_int8_t*)&iv));
+ ck_assert(!iv_gen->get_iv(iv_gen, 0, 0, (uint8_t*)&iv));
+ ck_assert(!iv_gen->get_iv(iv_gen, 0, 1, (uint8_t*)&iv));
+ ck_assert(!iv_gen->get_iv(iv_gen, 0, 2, (uint8_t*)&iv));
+ ck_assert(!iv_gen->get_iv(iv_gen, 0, 3, (uint8_t*)&iv));
+ ck_assert(!iv_gen->get_iv(iv_gen, 0, 4, (uint8_t*)&iv));
+ ck_assert(!iv_gen->get_iv(iv_gen, 0, 5, (uint8_t*)&iv));
+ ck_assert(!iv_gen->get_iv(iv_gen, 0, 6, (uint8_t*)&iv));
+ ck_assert(!iv_gen->get_iv(iv_gen, 0, 7, (uint8_t*)&iv));
+ ck_assert(iv_gen->get_iv(iv_gen, 0, 8, (uint8_t*)&iv));
ck_assert(iv_gen->get_iv(iv_gen, 0, 9, buf));
iv_gen->destroy(iv_gen);
}
diff --git a/src/libstrongswan/tests/suites/test_ntru.c b/src/libstrongswan/tests/suites/test_ntru.c
index d209fa2bc..0a6d24d04 100644
--- a/src/libstrongswan/tests/suites/test_ntru.c
+++ b/src/libstrongswan/tests/suites/test_ntru.c
@@ -25,7 +25,7 @@
#include <plugins/ntru/ntru_private_key.h>
IMPORT_FUNCTION_FOR_TESTS(ntru, ntru_drbg_create, ntru_drbg_t*,
- u_int32_t strength, chunk_t pers_str, rng_t *entropy)
+ uint32_t strength, chunk_t pers_str, rng_t *entropy)
IMPORT_FUNCTION_FOR_TESTS(ntru, ntru_trits_create, ntru_trits_t*,
size_t len, hash_algorithm_t alg, chunk_t seed)
@@ -36,7 +36,7 @@ IMPORT_FUNCTION_FOR_TESTS(ntru, ntru_poly_create_from_seed, ntru_poly_t*,
uint32_t indices_len_m, bool is_product_form)
IMPORT_FUNCTION_FOR_TESTS(ntru, ntru_poly_create_from_data, ntru_poly_t*,
- u_int16_t *data, uint16_t N, uint16_t q,
+ uint16_t *data, uint16_t N, uint16_t q,
uint32_t indices_len_p, uint32_t indices_len_m,
bool is_product_form)
@@ -73,8 +73,8 @@ char *parameter_sets[] = {
};
typedef struct {
- u_int32_t requested;
- u_int32_t standard;
+ uint32_t requested;
+ uint32_t standard;
}strength_t;
strength_t strengths[] = {
diff --git a/src/libstrongswan/tests/suites/test_printf.c b/src/libstrongswan/tests/suites/test_printf.c
index 9e40d1fc0..377f2a767 100644
--- a/src/libstrongswan/tests/suites/test_printf.c
+++ b/src/libstrongswan/tests/suites/test_printf.c
@@ -75,7 +75,7 @@ END_TEST
START_TEST(test_printf_unsigned)
{
- verify("1 23 456", "%u %lu %llu", 1, (u_long)23, (u_int64_t)456);
+ verify("1 23 456", "%u %lu %llu", 1, (u_long)23, (uint64_t)456);
verify("65535 255", "%hu %hhu", 0x1ffff, 0x1ff);
verify("123456789", "%zu", (size_t)123456789);
verify(" 12", "%5u", 12);
@@ -99,7 +99,7 @@ END_TEST
START_TEST(test_printf_hex)
{
- verify("1 23 456", "%x %lx %llx", 1, (u_long)0x23, (u_int64_t)0x456);
+ verify("1 23 456", "%x %lx %llx", 1, (u_long)0x23, (uint64_t)0x456);
verify("12abcdef 12ABCDEF", "%x %X", 0x12ABCDEF, 0x12ABCDEF);
verify("ffff ff", "%hx %hhx", 0x1ffff, 0x1ff);
verify("23456789", "%zx", (size_t)0x23456789);
@@ -170,10 +170,10 @@ END_TEST
START_TEST(test_printf_pri)
{
- verify("255", "%" PRIu8, (u_int8_t)0xFF);
- verify("65535", "%" PRIu16, (u_int16_t)0xFFFF);
- verify("4294967295", "%" PRIu32, (u_int32_t)0x1FFFFFFFFll);
- verify("18446744073709551615", "%" PRIu64, (u_int64_t)0xFFFFFFFFFFFFFFFFll);
+ verify("255", "%" PRIu8, (uint8_t)0xFF);
+ verify("65535", "%" PRIu16, (uint16_t)0xFFFF);
+ verify("4294967295", "%" PRIu32, (uint32_t)0x1FFFFFFFFll);
+ verify("18446744073709551615", "%" PRIu64, (uint64_t)0xFFFFFFFFFFFFFFFFll);
verify("-1", "%" PRId8, (int8_t)-1);
verify("-1", "%" PRId16, (int16_t)-1);
diff --git a/src/libstrongswan/tests/suites/test_traffic_selector.c b/src/libstrongswan/tests/suites/test_traffic_selector.c
index 5c0fb754d..0d5d877ac 100644
--- a/src/libstrongswan/tests/suites/test_traffic_selector.c
+++ b/src/libstrongswan/tests/suites/test_traffic_selector.c
@@ -198,7 +198,7 @@ struct {
char *from;
char *to;
char *net;
- u_int8_t mask;
+ uint8_t mask;
bool exact;
} to_subnet_tests[] = {
{ TS_IPV4_ADDR_RANGE, "10.0.0.1", "10.0.0.1", "10.0.0.1", 32, TRUE },
@@ -218,7 +218,7 @@ START_TEST(test_to_subnet)
{
traffic_selector_t *ts;
host_t *net, *exp_net;
- u_int8_t mask;
+ uint8_t mask;
ts = traffic_selector_create_from_string(0, to_subnet_tests[_i].type,
to_subnet_tests[_i].from, 0, to_subnet_tests[_i].to, 0);
@@ -234,9 +234,9 @@ END_TEST
struct {
char *cidr;
- u_int16_t from_port;
- u_int16_t to_port;
- u_int16_t port;
+ uint16_t from_port;
+ uint16_t to_port;
+ uint16_t port;
} to_subnet_port_tests[] = {
{ "10.0.0.0/8", 0, 0, 0 },
{ "10.0.0.1/32", 80, 80, 80 },
@@ -252,7 +252,7 @@ START_TEST(test_to_subnet_port)
{
traffic_selector_t *ts;
host_t *net, *exp_net;
- u_int8_t mask;
+ uint8_t mask;
int exp_mask;
ts = traffic_selector_create_from_cidr(to_subnet_port_tests[_i].cidr, 0,
@@ -431,9 +431,9 @@ struct {
bool contained;
struct {
char *net;
- u_int8_t proto;
- u_int16_t from_port;
- u_int16_t to_port;
+ uint8_t proto;
+ uint16_t from_port;
+ uint16_t to_port;
} a, b;
} is_contained_in_tests[] = {
{ TRUE, { "10.0.0.0/16", 0, 0, 65535 }, { "10.0.0.0/16", 0, 0, 65535 }, },
@@ -555,9 +555,9 @@ struct {
int res;
struct {
char *net;
- u_int8_t proto;
- u_int16_t from_port;
- u_int16_t to_port;
+ uint8_t proto;
+ uint16_t from_port;
+ uint16_t to_port;
} a, b;
} cmp_tests[] = {
{ 0, { "10.0.0.0/8", 0, 0, 65535 }, { "10.0.0.0/8", 0, 0, 65535 }, },
@@ -706,13 +706,13 @@ START_TEST(test_hash)
END_TEST
struct {
- u_int8_t proto;
- u_int16_t from_port;
- u_int16_t to_port;
- u_int8_t from_type;
- u_int8_t from_code;
- u_int8_t to_type;
- u_int8_t to_code;
+ uint8_t proto;
+ uint16_t from_port;
+ uint16_t to_port;
+ uint8_t from_type;
+ uint8_t from_code;
+ uint8_t to_type;
+ uint8_t to_code;
char *str;
char *str_alt;
} icmp_tests[] = {
@@ -731,7 +731,7 @@ struct {
START_TEST(test_icmp)
{
traffic_selector_t *ts;
- u_int16_t from, to;
+ uint16_t from, to;
ts = traffic_selector_create_dynamic(icmp_tests[_i].proto,
icmp_tests[_i].from_port, icmp_tests[_i].to_port);
diff --git a/src/libstrongswan/tests/suites/test_utils.c b/src/libstrongswan/tests/suites/test_utils.c
index 104b0b2c0..1eb3c8bc3 100644
--- a/src/libstrongswan/tests/suites/test_utils.c
+++ b/src/libstrongswan/tests/suites/test_utils.c
@@ -121,9 +121,9 @@ END_TEST
START_TEST(test_htoun)
{
chunk_t net64, expected;
- u_int16_t host16 = 513;
- u_int32_t net16 = 0, host32 = 67305985;
- u_int64_t net32 = 0, host64 = 578437695752307201ULL;
+ uint16_t host16 = 513;
+ uint32_t net16 = 0, host32 = 67305985;
+ uint64_t net32 = 0, host64 = 578437695752307201ULL;
net64 = chunk_alloca(16);
memset(net64.ptr, 0, net64.len);
@@ -133,14 +133,14 @@ START_TEST(test_htoun)
ck_assert(chunk_equals(expected, chunk_from_thing(net16)));
expected = chunk_from_chars(0x00, 0x00, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00);
- htoun32((u_int16_t*)&net32 + 1, host32);
+ htoun32((uint16_t*)&net32 + 1, host32);
ck_assert(chunk_equals(expected, chunk_from_thing(net32)));
expected = chunk_from_chars(0x00, 0x00, 0x00, 0x00,
0x08, 0x07, 0x06, 0x05,
0x04, 0x03, 0x02, 0x01,
0x00, 0x00, 0x00, 0x00);
- htoun64((u_int32_t*)net64.ptr + 1, host64);
+ htoun64((uint32_t*)net64.ptr + 1, host64);
ck_assert(chunk_equals(expected, net64));
}
END_TEST
@@ -148,9 +148,9 @@ END_TEST
START_TEST(test_untoh)
{
chunk_t net;
- u_int16_t host16;
- u_int32_t host32;
- u_int64_t host64;
+ uint16_t host16;
+ uint32_t host32;
+ uint64_t host64;
net = chunk_from_chars(0x00, 0x02, 0x01, 0x00);
host16 = untoh16(net.ptr + 1);
@@ -197,6 +197,82 @@ START_TEST(test_round)
END_TEST
/*******************************************************************************
+ * streq
+ */
+
+static struct {
+ char *a;
+ char *b;
+ bool eq;
+ bool case_eq;
+} streq_data[] = {
+ {NULL, NULL, TRUE, TRUE},
+ {NULL, "", FALSE, FALSE},
+ {"", NULL, FALSE, FALSE},
+ {"abc", "", FALSE, FALSE},
+ {"abc", "abc", TRUE, TRUE},
+ {"abc", "ABC", FALSE, TRUE},
+};
+
+START_TEST(test_streq)
+{
+ bool eq;
+
+ ck_assert(streq(streq_data[_i].a, streq_data[_i].a));
+ ck_assert(streq(streq_data[_i].b, streq_data[_i].b));
+ eq = streq(streq_data[_i].a, streq_data[_i].b);
+ ck_assert(eq == streq_data[_i].eq);
+
+ ck_assert(strcaseeq(streq_data[_i].a, streq_data[_i].a));
+ ck_assert(strcaseeq(streq_data[_i].b, streq_data[_i].b));
+ eq = strcaseeq(streq_data[_i].a, streq_data[_i].b);
+ ck_assert(eq == streq_data[_i].case_eq);
+}
+END_TEST
+
+/*******************************************************************************
+ * strneq
+ */
+
+static struct {
+ char *a;
+ char *b;
+ size_t n;
+ bool eq;
+ bool case_eq;
+} strneq_data[] = {
+ {NULL, NULL, 0, TRUE, TRUE},
+ {NULL, NULL, 10, TRUE, TRUE},
+ {NULL, "", 0, FALSE, FALSE},
+ {"", NULL, 0, FALSE, FALSE},
+ {"abc", "", 0, TRUE, TRUE},
+ {"abc", "", 1, FALSE, FALSE},
+ {"abc", "ab", 1, TRUE, TRUE},
+ {"abc", "ab", 2, TRUE, TRUE},
+ {"abc", "ab", 3, FALSE, FALSE},
+ {"abc", "abc", 3, TRUE, TRUE},
+ {"abc", "abc", 4, TRUE, TRUE},
+ {"abc", "abC", 2, TRUE, TRUE},
+ {"abc", "abC", 3, FALSE, TRUE},
+};
+
+START_TEST(test_strneq)
+{
+ bool eq;
+
+ ck_assert(strneq(strneq_data[_i].a, strneq_data[_i].a, strneq_data[_i].n));
+ ck_assert(strneq(strneq_data[_i].b, strneq_data[_i].b, strneq_data[_i].n));
+ eq = strneq(strneq_data[_i].a, strneq_data[_i].b, strneq_data[_i].n);
+ ck_assert(eq == strneq_data[_i].eq);
+
+ ck_assert(strncaseeq(strneq_data[_i].a, strneq_data[_i].a, strneq_data[_i].n));
+ ck_assert(strncaseeq(strneq_data[_i].b, strneq_data[_i].b, strneq_data[_i].n));
+ eq = strncaseeq(strneq_data[_i].a, strneq_data[_i].b, strneq_data[_i].n);
+ ck_assert(eq == strneq_data[_i].case_eq);
+}
+END_TEST
+
+/*******************************************************************************
* strpfx
*/
@@ -308,7 +384,7 @@ END_TEST
START_TEST(test_memxor_aligned)
{
- u_int64_t a = 0, b = 0;
+ uint64_t a = 0, b = 0;
chunk_t ca, cb;
int i;
@@ -848,6 +924,8 @@ Suite *utils_suite_create()
suite_add_tcase(s, tc);
tc = tcase_create("string helper");
+ tcase_add_loop_test(tc, test_streq, 0, countof(streq_data));
+ tcase_add_loop_test(tc, test_strneq, 0, countof(strneq_data));
tcase_add_loop_test(tc, test_strpfx, 0, countof(strpfx_data));
suite_add_tcase(s, tc);
diff --git a/src/libstrongswan/tests/test_runner.c b/src/libstrongswan/tests/test_runner.c
index 66d0e612d..ed77b3c86 100644
--- a/src/libstrongswan/tests/test_runner.c
+++ b/src/libstrongswan/tests/test_runner.c
@@ -90,6 +90,28 @@ static void apply_filter(array_t *loaded, char *filter, bool exclude)
}
/**
+ * Check if the given string is contained in the filter string.
+ */
+static bool is_in_filter(const char *find, char *filter)
+{
+ enumerator_t *names;
+ bool found = FALSE;
+ char *name;
+
+ names = enumerator_create_token(filter, ",", " ");
+ while (names->enumerate(names, &name))
+ {
+ if (streq(name, find))
+ {
+ found = TRUE;
+ break;
+ }
+ }
+ names->destroy(names);
+ return found;
+}
+
+/**
* Removes and destroys test suites that are not selected or
* explicitly excluded.
*/
@@ -524,11 +546,17 @@ int test_runner_run(const char *name, test_configuration_t configs[],
enumerator_t *enumerator;
int passed = 0, result;
level_t level = LEVEL_SILENT;
- char *cfg, *verbosity;
+ char *cfg, *runners, *verbosity;
/* redirect all output to stderr (to redirect make's stdout to /dev/null) */
dup2(2, 1);
+ runners = getenv("TESTS_RUNNERS");
+ if (runners && !is_in_filter(name, runners))
+ {
+ return EXIT_SUCCESS;
+ }
+
cfg = getenv("TESTS_STRONGSWAN_CONF");
suites = load_suites(configs, init, cfg);
diff --git a/src/libstrongswan/tests/test_runner.h b/src/libstrongswan/tests/test_runner.h
index 5c3057096..e0fe767c5 100644
--- a/src/libstrongswan/tests/test_runner.h
+++ b/src/libstrongswan/tests/test_runner.h
@@ -70,6 +70,7 @@ struct test_configuration_t {
* - TESTS_VERBOSITY: Numerical loglevel for debug log
* - TESTS_STRONGSWAN_CONF: Specify a path to a custom strongswan.conf
* - TESTS_PLUGINS: Specify an explicit list of plugins to load
+ * - TESTS_RUNNERS: Run specific test runners only
* - TESTS_SUITES: Run specific test suites only
* - TESTS_SUITES_EXCLUDE: Don't run specific test suites
* - TESTS_REDUCED_KEYLENGTHS: Test minimal keylengths for public key tests only
@@ -77,6 +78,9 @@ struct test_configuration_t {
* Please note that TESTS_PLUGINS actually must be implemented by the init
* callback function, as plugin loading is delegated.
*
+ * EXIT_SUCCESS is returned right away if TESTS_RUNNERS is defined but the name
+ * passed to this function is not contained in it.
+ *
* @param name name of test runner
* @param config test suite constructors with dependencies
* @param init_cb init/deinit callback
diff --git a/src/libstrongswan/tests/utils/test_rng.c b/src/libstrongswan/tests/utils/test_rng.c
index 01569509b..2985a56e3 100644
--- a/src/libstrongswan/tests/utils/test_rng.c
+++ b/src/libstrongswan/tests/utils/test_rng.c
@@ -34,7 +34,7 @@ struct private_rng_t {
};
METHOD(rng_t, get_bytes, bool,
- private_rng_t *this, size_t bytes, u_int8_t *buffer)
+ private_rng_t *this, size_t bytes, uint8_t *buffer)
{
if (bytes > this->entropy.len)
{