touched up test scripts. switched to the tap style testing

This commit is contained in:
hyung-hwan 2022-12-17 16:04:33 +00:00
parent ce3340d2fa
commit 4779344dd0
10 changed files with 166 additions and 153 deletions

View File

@ -164,9 +164,10 @@ am__DIST_COMMON = $(srcdir)/Dockerfile.in $(srcdir)/Makefile.in \
$(top_srcdir)/ac/ar-lib $(top_srcdir)/ac/compile \
$(top_srcdir)/ac/config.guess $(top_srcdir)/ac/config.sub \
$(top_srcdir)/ac/install-sh $(top_srcdir)/ac/ltmain.sh \
$(top_srcdir)/ac/missing $(top_srcdir)/pkgs/hio.spec.in \
ac/ar-lib ac/compile ac/config.guess ac/config.sub ac/depcomp \
ac/install-sh ac/ltmain.sh ac/missing
$(top_srcdir)/ac/missing $(top_srcdir)/ac/tap-driver.sh \
$(top_srcdir)/pkgs/hio.spec.in ac/ar-lib ac/compile \
ac/config.guess ac/config.sub ac/install-sh ac/ltmain.sh \
ac/missing
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)

2
configure vendored
View File

@ -4405,6 +4405,8 @@ unknown)
esac
# Check whether --enable-silent-rules was given.
if test "${enable_silent_rules+set}" = set; then :
enableval=$enable_silent_rules;

View File

@ -13,6 +13,8 @@ dnl initialize automake
AM_INIT_AUTOMAKE([-Wall -Werror subdir-objects foreign])
AM_PROG_AR
AC_REQUIRE_AUX_FILE([tap-driver.sh])
dnl enable silent rules if automake supports them.
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([no])])
dnl m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])

View File

@ -13,8 +13,7 @@ LDFLAGS_COMMON=-L$(abs_builddir)/../lib -L$(libdir)
## for more information.
LIBADD_COMMON = ../lib/libhio.la $(LIBM)
check_SCRIPTS =
##noinst_SCRIPTS = $(check_SCRIPTS)
check_SCRIPTS = s-001.sh
EXTRA_DIST = $(check_SCRIPTS)
check_PROGRAMS = t-001 t-002 t-003 t-004
@ -43,6 +42,11 @@ t_004_CFLAGS = $(CFLAGS_COMMON)
t_004_LDFLAGS = $(LDFLAGS_COMMON)
t_004_LDADD = $(LIBADD_COMMON)
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/ac/tap-driver.sh
TESTS = $(check_PROGRAMS) $(check_SCRIPTS)
TEST_EXTENSIONS = .sh
SH_LOG_DRIVER = $(LOG_DRIVER)
SH_LOG_COMPILER = /bin/sh
##SH_LOG_DRIVER_FLAGS =
##AM_SH_LOG_DRIVER_FLAGS =

View File

@ -89,7 +89,6 @@ build_triplet = @build@
host_triplet = @host@
check_PROGRAMS = t-001$(EXEEXT) t-002$(EXEEXT) t-003$(EXEEXT) \
t-004$(EXEEXT)
TESTS = $(check_PROGRAMS) $(am__EXEEXT_1)
subdir = t
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
@ -385,10 +384,7 @@ am__set_TESTS_bases = \
AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING)'
RECHECK_LOGS = $(TEST_LOGS)
AM_RECURSIVE_TARGETS = check recheck
am__EXEEXT_1 =
TEST_SUITE_LOG = test-suite.log
TEST_EXTENSIONS = @EXEEXT@ .test
LOG_DRIVER = $(SHELL) $(top_srcdir)/ac/test-driver
LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS)
am__set_b = \
case '$@' in \
@ -402,12 +398,9 @@ am__set_b = \
esac
am__test_logs1 = $(TESTS:=.log)
am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log)
TEST_LOGS = $(am__test_logs2:.test.log=.log)
TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/ac/test-driver
TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
$(TEST_LOG_FLAGS)
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/ac/depcomp \
$(top_srcdir)/ac/test-driver
TEST_LOGS = $(am__test_logs2:.sh.log=.log)
SH_LOG_COMPILE = $(SH_LOG_COMPILER) $(AM_SH_LOG_FLAGS) $(SH_LOG_FLAGS)
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/ac/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
ALL_STATIC_LIBS = @ALL_STATIC_LIBS@
@ -559,7 +552,7 @@ CPPFLAGS_COMMON = \
CFLAGS_COMMON =
LDFLAGS_COMMON = -L$(abs_builddir)/../lib -L$(libdir)
LIBADD_COMMON = ../lib/libhio.la $(LIBM)
check_SCRIPTS =
check_SCRIPTS = s-001.sh
EXTRA_DIST = $(check_SCRIPTS)
t_001_SOURCES = t-001.c t.h
t_001_CPPFLAGS = $(CPPFLAGS_COMMON)
@ -581,10 +574,15 @@ t_004_CPPFLAGS = $(CPPFLAGS_COMMON)
t_004_CFLAGS = $(CFLAGS_COMMON)
t_004_LDFLAGS = $(LDFLAGS_COMMON)
t_004_LDADD = $(LIBADD_COMMON)
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/ac/tap-driver.sh
TESTS = $(check_PROGRAMS) $(check_SCRIPTS)
TEST_EXTENSIONS = .sh
SH_LOG_DRIVER = $(LOG_DRIVER)
SH_LOG_COMPILER = /bin/sh
all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs
.SUFFIXES: .c .lo .log .o .obj .sh .sh$(EXEEXT) .trs
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
@ -964,19 +962,19 @@ t-004.log: t-004$(EXEEXT)
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
.test.log:
.sh.log:
@p='$<'; \
$(am__set_b); \
$(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
$(am__check_pre) $(SH_LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
$(am__common_driver_flags) $(AM_SH_LOG_DRIVER_FLAGS) $(SH_LOG_DRIVER_FLAGS) -- $(SH_LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
@am__EXEEXT_TRUE@.test$(EXEEXT).log:
@am__EXEEXT_TRUE@.sh$(EXEEXT).log:
@am__EXEEXT_TRUE@ @p='$<'; \
@am__EXEEXT_TRUE@ $(am__set_b); \
@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
@am__EXEEXT_TRUE@ $(am__check_pre) $(SH_LOG_DRIVER) --test-name "$$f" \
@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_SH_LOG_DRIVER_FLAGS) $(SH_LOG_DRIVER_FLAGS) -- $(SH_LOG_COMPILE) \
@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
distdir: $(BUILT_SOURCES)

View File

@ -2,10 +2,12 @@
#include <hio-utl.h>
#include <stdio.h>
#include "t.h"
#include "tap.h"
int main ()
{
no_plan ();
{
union {
hio_uint16_t u16;
@ -19,16 +21,16 @@ int main ()
printf("htole16(x.u16) = 0x%04x\n", hio_htole16(x.u16));
printf("htobe16(x.u16) = 0x%04x\n", hio_htobe16(x.u16));
T_ASSERT1 (x.u16 != hio_htole16(x.u16) || x.u16 != hio_htobe16(x.u16), "u16 endian conversion #0");
T_ASSERT1 (x.u16 == hio_le16toh(hio_htole16(x.u16)), "u16 endian conversion #1");
T_ASSERT1 (x.u16 == hio_be16toh(hio_htobe16(x.u16)), "u16 endian conversion #2");
T_ASSERT1 (x.u16 == hio_ntoh16(hio_hton16(x.u16)), "u16 endian conversion #3");
OK (x.u16 != hio_htole16(x.u16) || x.u16 != hio_htobe16(x.u16), "u16 endian conversion #0");
OK (x.u16 == hio_le16toh(hio_htole16(x.u16)), "u16 endian conversion #1");
OK (x.u16 == hio_be16toh(hio_htobe16(x.u16)), "u16 endian conversion #2");
OK (x.u16 == hio_ntoh16(hio_hton16(x.u16)), "u16 endian conversion #3");
#define X_CONST (0x1122)
T_ASSERT1 (X_CONST != HIO_CONST_HTOLE16(X_CONST) || X_CONST != HIO_CONST_HTOBE16(X_CONST), "u16 constant endian conversion #0");
T_ASSERT1 (X_CONST == HIO_CONST_LE16TOH(HIO_CONST_HTOLE16(X_CONST)), "u16 constant endian conversion #1");
T_ASSERT1 (X_CONST == HIO_CONST_BE16TOH(HIO_CONST_HTOBE16(X_CONST)), "u16 constant endian conversion #2");
T_ASSERT1 (X_CONST == HIO_CONST_NTOH16(HIO_CONST_HTON16(X_CONST)), "u16 constant endian conversion #3");
OK (X_CONST != HIO_CONST_HTOLE16(X_CONST) || X_CONST != HIO_CONST_HTOBE16(X_CONST), "u16 constant endian conversion #0");
OK (X_CONST == HIO_CONST_LE16TOH(HIO_CONST_HTOLE16(X_CONST)), "u16 constant endian conversion #1");
OK (X_CONST == HIO_CONST_BE16TOH(HIO_CONST_HTOBE16(X_CONST)), "u16 constant endian conversion #2");
OK (X_CONST == HIO_CONST_NTOH16(HIO_CONST_HTON16(X_CONST)), "u16 constant endian conversion #3");
#undef X_CONST
}
@ -48,16 +50,16 @@ int main ()
printf("htole32(x.u32) = 0x%08x\n", (unsigned int)hio_htole32(x.u32));
printf("htobe32(x.u32) = 0x%08x\n", (unsigned int)hio_htobe32(x.u32));
T_ASSERT1 (x.u32 != hio_htole32(x.u32) || x.u32 != hio_htobe32(x.u32), "u32 endian conversion #0");
T_ASSERT1 (x.u32 == hio_le32toh(hio_htole32(x.u32)), "u32 endian conversion #1");
T_ASSERT1 (x.u32 == hio_be32toh(hio_htobe32(x.u32)), "u32 endian conversion #2");
T_ASSERT1 (x.u32 == hio_ntoh32(hio_hton32(x.u32)), "u32 endian conversion #3");
OK (x.u32 != hio_htole32(x.u32) || x.u32 != hio_htobe32(x.u32), "u32 endian conversion #0");
OK (x.u32 == hio_le32toh(hio_htole32(x.u32)), "u32 endian conversion #1");
OK (x.u32 == hio_be32toh(hio_htobe32(x.u32)), "u32 endian conversion #2");
OK (x.u32 == hio_ntoh32(hio_hton32(x.u32)), "u32 endian conversion #3");
#define X_CONST (0x11223344)
T_ASSERT1 (X_CONST != HIO_CONST_HTOLE32(X_CONST) || X_CONST != HIO_CONST_HTOBE32(X_CONST), "u32 constant endian conversion #0");
T_ASSERT1 (X_CONST == HIO_CONST_LE32TOH(HIO_CONST_HTOLE32(X_CONST)), "u32 constant endian conversion #1");
T_ASSERT1 (X_CONST == HIO_CONST_BE32TOH(HIO_CONST_HTOBE32(X_CONST)), "u32 constant endian conversion #2");
T_ASSERT1 (X_CONST == HIO_CONST_NTOH32(HIO_CONST_HTON32(X_CONST)), "u32 constant endian conversion #3");
OK (X_CONST != HIO_CONST_HTOLE32(X_CONST) || X_CONST != HIO_CONST_HTOBE32(X_CONST), "u32 constant endian conversion #0");
OK (X_CONST == HIO_CONST_LE32TOH(HIO_CONST_HTOLE32(X_CONST)), "u32 constant endian conversion #1");
OK (X_CONST == HIO_CONST_BE32TOH(HIO_CONST_HTOBE32(X_CONST)), "u32 constant endian conversion #2");
OK (X_CONST == HIO_CONST_NTOH32(HIO_CONST_HTON32(X_CONST)), "u32 constant endian conversion #3");
#undef X_CONST
}
@ -81,16 +83,16 @@ int main ()
printf("htole64(x.u64) = 0x%016llx\n", (unsigned long long)hio_htole64(x.u64));
printf("htobe64(x.u64) = 0x%016llx\n", (unsigned long long)hio_htobe64(x.u64));
T_ASSERT1 (x.u64 != hio_htole64(x.u64) || x.u64 != hio_htobe64(x.u64), "u64 endian conversion #0");
T_ASSERT1 (x.u64 == hio_le64toh(hio_htole64(x.u64)), "u64 endian conversion #1");
T_ASSERT1 (x.u64 == hio_be64toh(hio_htobe64(x.u64)), "u64 endian conversion #2");
T_ASSERT1 (x.u64 == hio_ntoh64(hio_hton64(x.u64)), "u64 endian conversion #3");
OK (x.u64 != hio_htole64(x.u64) || x.u64 != hio_htobe64(x.u64), "u64 endian conversion #0");
OK (x.u64 == hio_le64toh(hio_htole64(x.u64)), "u64 endian conversion #1");
OK (x.u64 == hio_be64toh(hio_htobe64(x.u64)), "u64 endian conversion #2");
OK (x.u64 == hio_ntoh64(hio_hton64(x.u64)), "u64 endian conversion #3");
#define X_CONST (((hio_uint64_t)0x11223344 << 32) | (hio_uint64_t)0x55667788)
T_ASSERT1 (X_CONST != HIO_CONST_HTOLE64(X_CONST) || X_CONST != HIO_CONST_HTOBE64(X_CONST), "u64 constant endian conversion #0");
T_ASSERT1 (X_CONST == HIO_CONST_LE64TOH(HIO_CONST_HTOLE64(X_CONST)), "u64 constant endian conversion #1");
T_ASSERT1 (X_CONST == HIO_CONST_BE64TOH(HIO_CONST_HTOBE64(X_CONST)), "u64 constant endian conversion #2");
T_ASSERT1 (X_CONST == HIO_CONST_NTOH64(HIO_CONST_HTON64(X_CONST)), "u64 constant endian conversion #3");
OK (X_CONST != HIO_CONST_HTOLE64(X_CONST) || X_CONST != HIO_CONST_HTOBE64(X_CONST), "u64 constant endian conversion #0");
OK (X_CONST == HIO_CONST_LE64TOH(HIO_CONST_HTOLE64(X_CONST)), "u64 constant endian conversion #1");
OK (X_CONST == HIO_CONST_BE64TOH(HIO_CONST_HTOBE64(X_CONST)), "u64 constant endian conversion #2");
OK (X_CONST == HIO_CONST_NTOH64(HIO_CONST_HTON64(X_CONST)), "u64 constant endian conversion #3");
#undef X_CONST
}
#endif
@ -128,22 +130,19 @@ int main ()
tmp = hio_htobe128(x.u128);
printf("htobe128(tmp) = 0x%016llx%016llx\n", (unsigned long long)(hio_uint64_t)(tmp >> 64), (unsigned long long)(hio_uint64_t)(tmp >> 0));
T_ASSERT1 (x.u128 != hio_htole128(x.u128) || x.u128 != hio_htobe128(x.u128), "u128 endian conversion #0");
T_ASSERT1 (x.u128 == hio_le128toh(hio_htole128(x.u128)), "u128 endian conversion #1");
T_ASSERT1 (x.u128 == hio_be128toh(hio_htobe128(x.u128)), "u128 endian conversion #2");
T_ASSERT1 (x.u128 == hio_ntoh128(hio_hton128(x.u128)), "u128 endian conversion #3");
OK (x.u128 != hio_htole128(x.u128) || x.u128 != hio_htobe128(x.u128), "u128 endian conversion #0");
OK (x.u128 == hio_le128toh(hio_htole128(x.u128)), "u128 endian conversion #1");
OK (x.u128 == hio_be128toh(hio_htobe128(x.u128)), "u128 endian conversion #2");
OK (x.u128 == hio_ntoh128(hio_hton128(x.u128)), "u128 endian conversion #3");
#define X_CONST (((hio_uint128_t)0x11223344 << 96) | ((hio_uint128_t)0x55667788 << 64) | ((hio_uint128_t)0x99aabbcc << 32) | ((hio_uint128_t)0xddeefffa))
T_ASSERT1 (X_CONST != HIO_CONST_HTOLE128(X_CONST) || X_CONST != HIO_CONST_HTOBE128(X_CONST), "u128 constant endian conversion #0");
T_ASSERT1 (X_CONST == HIO_CONST_LE128TOH(HIO_CONST_HTOLE128(X_CONST)), "u128 constant endian conversion #1");
T_ASSERT1 (X_CONST == HIO_CONST_BE128TOH(HIO_CONST_HTOBE128(X_CONST)), "u128 constant endian conversion #2");
T_ASSERT1 (X_CONST == HIO_CONST_NTOH128(HIO_CONST_HTON128(X_CONST)), "u128 constant endian conversion #3");
OK (X_CONST != HIO_CONST_HTOLE128(X_CONST) || X_CONST != HIO_CONST_HTOBE128(X_CONST), "u128 constant endian conversion #0");
OK (X_CONST == HIO_CONST_LE128TOH(HIO_CONST_HTOLE128(X_CONST)), "u128 constant endian conversion #1");
OK (X_CONST == HIO_CONST_BE128TOH(HIO_CONST_HTOBE128(X_CONST)), "u128 constant endian conversion #2");
OK (X_CONST == HIO_CONST_NTOH128(HIO_CONST_HTON128(X_CONST)), "u128 constant endian conversion #3");
#undef X_CONST
}
#endif
return 0;
oops:
return -1;
return exit_status();
}

View File

@ -1,53 +1,55 @@
#include <hio-utl.h>
#include <stdio.h>
#include "t.h"
#include "tap.h"
int main ()
{
no_plan ();
{
int is_sober;
const hio_bch_t* endptr;
hio_intmax_t v;
v = hio_bchars_to_intmax("10 ", 3, HIO_BCHARS_TO_INTMAX_MAKE_OPTION(0,0,0,10), &endptr, &is_sober);
T_ASSERT1 (v == 10 && *endptr == ' ' && is_sober == 1, "space after digits without rtrim");
OK (v == 10 && *endptr == ' ' && is_sober == 1, "space after digits without rtrim");
v = hio_bchars_to_intmax("10 ", 3, HIO_BCHARS_TO_INTMAX_MAKE_OPTION(0,0,1,10), &endptr, &is_sober);
T_ASSERT1 (v == 10 && *endptr == '\0' && is_sober == 1, "space after digits with rtrim");
OK (v == 10 && *endptr == '\0' && is_sober == 1, "space after digits with rtrim");
v = hio_bchars_to_intmax("10E", 3, HIO_BCHARS_TO_INTMAX_MAKE_OPTION(0,0,1,10), &endptr, &is_sober);
T_ASSERT1 (v == 10 && *endptr == 'E' && is_sober == 1, "number ending with E without the E option ");
OK (v == 10 && *endptr == 'E' && is_sober == 1, "number ending with E without the E option ");
v = hio_bchars_to_intmax("10E", 3, HIO_BCHARS_TO_INTMAX_MAKE_OPTION(1,0,1,10), &endptr, &is_sober);
T_ASSERT1 (v == 10 && *endptr == '\0' && is_sober == 1, "integer in E notation");
OK (v == 10 && *endptr == '\0' && is_sober == 1, "integer in E notation");
v = hio_bchars_to_intmax("10E+0", 5, HIO_BCHARS_TO_INTMAX_MAKE_OPTION(1,0,1,10), &endptr, &is_sober);
T_ASSERT1 (v == 10 && *endptr == '\0' && is_sober == 1, "integer in E notation");
OK (v == 10 && *endptr == '\0' && is_sober == 1, "integer in E notation");
v = hio_bchars_to_intmax("10E+1", 5, HIO_BCHARS_TO_INTMAX_MAKE_OPTION(1,0,1,10), &endptr, &is_sober);
T_ASSERT1 (v == 100 && *endptr == '\0' && is_sober == 1, "integer in E notation");
OK (v == 100 && *endptr == '\0' && is_sober == 1, "integer in E notation");
v = hio_bchars_to_intmax("10E+2", 5, HIO_BCHARS_TO_INTMAX_MAKE_OPTION(1,0,1,10), &endptr, &is_sober);
T_ASSERT1 (v == 1000 && *endptr == '\0' && is_sober == 1, "integer in E notation");
OK (v == 1000 && *endptr == '\0' && is_sober == 1, "integer in E notation");
v = hio_bchars_to_intmax("10E3", 4, HIO_BCHARS_TO_INTMAX_MAKE_OPTION(1,0,1,10), &endptr, &is_sober);
T_ASSERT1 (v == 10000 && *endptr == '\0' && is_sober == 1, "integer in E notation");
OK (v == 10000 && *endptr == '\0' && is_sober == 1, "integer in E notation");
v = hio_bchars_to_intmax("10E-", 4, HIO_BCHARS_TO_INTMAX_MAKE_OPTION(1,0,1,10), &endptr, &is_sober);
T_ASSERT1 (v == 10 && *endptr == '\0' && is_sober == 1, "integer in E notation");
OK (v == 10 && *endptr == '\0' && is_sober == 1, "integer in E notation");
v = hio_bchars_to_intmax("10E-0", 5, HIO_BCHARS_TO_INTMAX_MAKE_OPTION(1,0,1,10), &endptr, &is_sober);
T_ASSERT1 (v == 10 && *endptr == '\0' && is_sober == 1, "integer in E notation");
OK (v == 10 && *endptr == '\0' && is_sober == 1, "integer in E notation");
v = hio_bchars_to_intmax("10E-1", 5, HIO_BCHARS_TO_INTMAX_MAKE_OPTION(1,0,1,10), &endptr, &is_sober);
T_ASSERT1 (v == 1 && *endptr == '\0' && is_sober == 1, "integer in E notation");
OK (v == 1 && *endptr == '\0' && is_sober == 1, "integer in E notation");
v = hio_bchars_to_intmax("10E-2", 5, HIO_BCHARS_TO_INTMAX_MAKE_OPTION(1,0,1,10), &endptr, &is_sober);
T_ASSERT1 (v == 0 && *endptr == '\0' && is_sober == 1, "integer in E notation");
OK (v == 0 && *endptr == '\0' && is_sober == 1, "integer in E notation");
}
{
@ -56,21 +58,19 @@ int main ()
hio_uch_t uc;
x = hio_uc_to_utf8(0x2665, tmp, HIO_COUNTOF(tmp));
T_ASSERT1 (x == 3 && (hio_uint8_t)tmp[0] == 0xE2 && (hio_uint8_t)tmp[1] == 0x99 && (hio_uint8_t)tmp[2] == 0xA5, "unicode to utf8 conversion");
OK (x == 3 && (hio_uint8_t)tmp[0] == 0xE2 && (hio_uint8_t)tmp[1] == 0x99 && (hio_uint8_t)tmp[2] == 0xA5, "unicode to utf8 conversion");
x = hio_utf8_to_uc(tmp, x, &uc);
T_ASSERT1 (x == 3 && uc == 0x2665, "utf8 to unicode conversion");
OK (x == 3 && uc == 0x2665, "utf8 to unicode conversion");
#if (HIO_SIZEOF_UCH_T > 2)
x = hio_uc_to_utf8(0x1F3E9, tmp, HIO_COUNTOF(tmp));
T_ASSERT1 (x == 4 && (hio_uint8_t)tmp[0] == 0xF0 && (hio_uint8_t)tmp[1] == 0x9F && (hio_uint8_t)tmp[2] == 0x8F && (hio_uint8_t)tmp[3] == 0xA9, "unicode to utf8 conversion");
OK (x == 4 && (hio_uint8_t)tmp[0] == 0xF0 && (hio_uint8_t)tmp[1] == 0x9F && (hio_uint8_t)tmp[2] == 0x8F && (hio_uint8_t)tmp[3] == 0xA9, "unicode to utf8 conversion");
x = hio_utf8_to_uc(tmp, x, &uc);
T_ASSERT1 (x == 4 && uc == 0x1F3E9, "utf8 to unicode conversion");
OK (x == 4 && uc == 0x1F3E9, "utf8 to unicode conversion");
#endif
}
return 0;
oops:
return -1;
return exit_status();
}

107
t/t-003.c
View File

@ -1,7 +1,7 @@
#include <hio-rad.h>
#include <stdio.h>
#include "t.h"
#include "tap.h"
#include <sys/socket.h>
@ -10,6 +10,8 @@
int main ()
{
no_plan ();
{
hio_uint8_t buf[10240];
hio_rad_hdr_t* hdr = (hio_rad_hdr_t*)buf;
@ -53,10 +55,10 @@ int main ()
};
hio_rad_initialize (hdr, HIO_RAD_ACCESS_REQUEST, 255);
T_ASSERT1 (hdr->code == HIO_RAD_ACCESS_REQUEST, "hdr->code not ok");
T_ASSERT1 (hdr->id == 255, "hdr->id not ok");
OK (hdr->code == HIO_RAD_ACCESS_REQUEST, "hdr->code not ok");
OK (hdr->id == 255, "hdr->id not ok");
exptotlen = HIO_SIZEOF(*hdr);
T_ASSERT1 (hdr->length == HIO_CONST_HTON16(HIO_SIZEOF(*hdr)), "hdr->length not ok");
OK (hdr->length == HIO_CONST_HTON16(HIO_SIZEOF(*hdr)), "hdr->length not ok");
for (i = 0; i < HIO_COUNTOF(data); i++)
@ -68,25 +70,25 @@ int main ()
hio_rad_lxvsattr_hdr_t* lxvsattr;
vsattr = hio_rad_insert_vsattr(hdr, HIO_SIZEOF(buf), data[i].vendor, data[i].attrcode, data[i].ptr, data[i].len);
T_ASSERT1 (vsattr != HIO_NULL, "attribute insertion failure");
T_ASSERT1 (hio_ntoh16(hdr->length) == exptotlen + vsattr->length, "hdr->length not ok after attribute insertion");
OK (vsattr != HIO_NULL, "attribute insertion failure");
OK (hio_ntoh16(hdr->length) == exptotlen + vsattr->length, "hdr->length not ok after attribute insertion");
if (HIO_RAD_ATTR_IS_LONG_EXTENDED(vsattr->type))
{
exptotlen += HIO_SIZEOF(*lxvsattr);
lxvsattr = (hio_rad_lxvsattr_hdr_t*)vsattr;
T_ASSERT1 (lxvsattr->length == HIO_SIZEOF(*lxvsattr) + data[i].len, "wrong attribute length");
OK (lxvsattr->length == HIO_SIZEOF(*lxvsattr) + data[i].len, "wrong attribute length");
}
else if (HIO_RAD_ATTR_IS_SHORT_EXTENDED(vsattr->type))
{
exptotlen += HIO_SIZEOF(*xvsattr);
xvsattr = (hio_rad_xvsattr_hdr_t*)vsattr;
T_ASSERT1 (xvsattr->length == HIO_SIZEOF(*xvsattr) + data[i].len, "wrong attribute length");
OK (xvsattr->length == HIO_SIZEOF(*xvsattr) + data[i].len, "wrong attribute length");
}
else
{
exptotlen += HIO_SIZEOF(*vsattr);
T_ASSERT1 (vsattr->length == HIO_SIZEOF(*vsattr) + data[i].len, "wrong attribute length");
OK (vsattr->length == HIO_SIZEOF(*vsattr) + data[i].len, "wrong attribute length");
}
}
else
@ -96,30 +98,30 @@ int main ()
hio_rad_lxattr_hdr_t* lxattr;
attr = hio_rad_insert_attr(hdr, HIO_SIZEOF(buf), data[i].attrcode, data[i].ptr, data[i].len);
T_ASSERT1 (attr != HIO_NULL, "attribute insertion failure");
T_ASSERT1 (hio_ntoh16(hdr->length) == exptotlen + attr->length, "hdr->length not ok after attribute insertion");
OK (attr != HIO_NULL, "attribute insertion failure");
OK (hio_ntoh16(hdr->length) == exptotlen + attr->length, "hdr->length not ok after attribute insertion");
if (HIO_RAD_ATTR_IS_LONG_EXTENDED(attr->type))
{
exptotlen += HIO_SIZEOF(*lxattr);
lxattr = (hio_rad_lxattr_hdr_t*)attr;
T_ASSERT1 (lxattr->length == HIO_SIZEOF(*lxattr) + data[i].len, "wrong attribute length");
OK (lxattr->length == HIO_SIZEOF(*lxattr) + data[i].len, "wrong attribute length");
}
else if (HIO_RAD_ATTR_IS_SHORT_EXTENDED(attr->type))
{
exptotlen += HIO_SIZEOF(*xattr);
xattr = (hio_rad_xattr_hdr_t*)attr;
T_ASSERT1 (xattr->length == HIO_SIZEOF(*xattr) + data[i].len, "wrong attribute length");
OK (xattr->length == HIO_SIZEOF(*xattr) + data[i].len, "wrong attribute length");
}
else
{
exptotlen += HIO_SIZEOF(*attr);
T_ASSERT1 (attr->length == HIO_SIZEOF(*attr) + data[i].len, "wrong attribute length");
OK (attr->length == HIO_SIZEOF(*attr) + data[i].len, "wrong attribute length");
}
}
T_ASSERT1 (hio_comp_bchars((hio_uint8_t*)hdr + hio_ntoh16(hdr->length) - data[i].len, data[i].len, data[i].ptr, data[i].len, 0) == 0, "wrong attribute value");
OK (hio_comp_bchars((hio_uint8_t*)hdr + hio_ntoh16(hdr->length) - data[i].len, data[i].len, data[i].ptr, data[i].len, 0) == 0, "wrong attribute value");
exptotlen += data[i].len;
T_ASSERT1 (hio_ntoh16(hdr->length) == exptotlen, "hdr->length not ok after attribute insertion");
OK (hio_ntoh16(hdr->length) == exptotlen, "hdr->length not ok after attribute insertion");
for (j = 0; j < HIO_COUNTOF(data); j++)
{
@ -133,46 +135,46 @@ int main ()
void* val_ptr;
int val_len;
T_ASSERT1 (vsattr != HIO_NULL, "find failure");
OK (vsattr != HIO_NULL, "find failure");
if (HIO_RAD_ATTR_IS_SHORT_EXTENDED(vsattr->type))
{
hio_rad_xvsattr_hdr_t* xvsattr = (hio_rad_xvsattr_hdr_t*)vsattr;
T_ASSERT1 (hio_ntoh32(xvsattr->vendor) == data[j].vendor, "wrong vendor code");
T_ASSERT1 (xvsattr->type == HIO_RAD_ATTR_CODE_HI(data[j].attrcode), "wrong attribute base");
T_ASSERT1 (xvsattr->length == HIO_SIZEOF(*xvsattr) + data[j].len, "wrong attribute length");
T_ASSERT1 (xvsattr->xvs.type == HIO_RAD_ATTR_CODE_LO(data[j].attrcode), "wrong vendor-specific attribute type");
T_ASSERT1 (xvsattr->xvs.length == HIO_SIZEOF(xvsattr->xvs) + data[j].len, "wrong attribute length");
OK (hio_ntoh32(xvsattr->vendor) == data[j].vendor, "wrong vendor code");
OK (xvsattr->type == HIO_RAD_ATTR_CODE_HI(data[j].attrcode), "wrong attribute base");
OK (xvsattr->length == HIO_SIZEOF(*xvsattr) + data[j].len, "wrong attribute length");
OK (xvsattr->xvs.type == HIO_RAD_ATTR_CODE_LO(data[j].attrcode), "wrong vendor-specific attribute type");
OK (xvsattr->xvs.length == HIO_SIZEOF(xvsattr->xvs) + data[j].len, "wrong attribute length");
val_ptr = xvsattr + 1;
val_len = xvsattr->xvs.length - HIO_SIZEOF(xvsattr->xvs);
}
else if (HIO_RAD_ATTR_IS_LONG_EXTENDED(vsattr->type))
{
hio_rad_lxvsattr_hdr_t* lxvsattr = (hio_rad_lxvsattr_hdr_t*)vsattr;
T_ASSERT1 (hio_ntoh32(lxvsattr->vendor) == data[j].vendor, "wrong vendor code");
T_ASSERT1 (lxvsattr->type == HIO_RAD_ATTR_CODE_HI(data[j].attrcode), "wrong attribute base");
T_ASSERT1 (lxvsattr->length == HIO_SIZEOF(*lxvsattr) + data[j].len, "wrong attribute length");
T_ASSERT1 (lxvsattr->lxvs.type == HIO_RAD_ATTR_CODE_LO(data[j].attrcode), "wrong vendor-specific attribute type");
T_ASSERT1 (lxvsattr->lxvs.length == HIO_SIZEOF(lxvsattr->lxvs) + data[j].len, "wrong attribute length");
OK (hio_ntoh32(lxvsattr->vendor) == data[j].vendor, "wrong vendor code");
OK (lxvsattr->type == HIO_RAD_ATTR_CODE_HI(data[j].attrcode), "wrong attribute base");
OK (lxvsattr->length == HIO_SIZEOF(*lxvsattr) + data[j].len, "wrong attribute length");
OK (lxvsattr->lxvs.type == HIO_RAD_ATTR_CODE_LO(data[j].attrcode), "wrong vendor-specific attribute type");
OK (lxvsattr->lxvs.length == HIO_SIZEOF(lxvsattr->lxvs) + data[j].len, "wrong attribute length");
val_ptr = lxvsattr + 1;
val_len = lxvsattr->lxvs.length - HIO_SIZEOF(lxvsattr->lxvs);
}
else
{
T_ASSERT1 (hio_ntoh32(vsattr->vendor) == data[j].vendor, "wrong vendor code");
T_ASSERT1 (vsattr->type == HIO_RAD_ATTR_VENDOR_SPECIFIC, "wrong attribute type");
T_ASSERT1 (vsattr->length == HIO_SIZEOF(*vsattr) + data[j].len, "wrong attribute length");
T_ASSERT1 (vsattr->vs.type == data[j].attrcode, "wrong vendor-specific attribute type");
T_ASSERT1 (vsattr->vs.length == HIO_SIZEOF(vsattr->vs) + data[j].len, "wrong attribute length");
OK (hio_ntoh32(vsattr->vendor) == data[j].vendor, "wrong vendor code");
OK (vsattr->type == HIO_RAD_ATTR_VENDOR_SPECIFIC, "wrong attribute type");
OK (vsattr->length == HIO_SIZEOF(*vsattr) + data[j].len, "wrong attribute length");
OK (vsattr->vs.type == data[j].attrcode, "wrong vendor-specific attribute type");
OK (vsattr->vs.length == HIO_SIZEOF(vsattr->vs) + data[j].len, "wrong attribute length");
val_ptr = vsattr + 1;
val_len = vsattr->vs.length - HIO_SIZEOF(vsattr->vs);
}
T_ASSERT1 (hio_comp_bchars(val_ptr, val_len, data[j].ptr, data[j].len, 0) == 0, "wrong attribute value");
OK (hio_comp_bchars(val_ptr, val_len, data[j].ptr, data[j].len, 0) == 0, "wrong attribute value");
}
else
{
T_ASSERT1 (vsattr == HIO_NULL, "find failure");
OK (vsattr == HIO_NULL, "find failure");
}
}
else
@ -184,39 +186,39 @@ int main ()
{
void* val_ptr;
int val_len;
T_ASSERT1 (attr != HIO_NULL, "find failure");
OK (attr != HIO_NULL, "find failure");
if (HIO_RAD_ATTR_IS_SHORT_EXTENDED(attr->type))
{
hio_rad_xattr_hdr_t* xattr = (hio_rad_xattr_hdr_t*)attr;
T_ASSERT1 (HIO_RAD_ATTR_CODE_HI(data[j].attrcode) == xattr->type, "wrong extended attribute base");
T_ASSERT1 (HIO_RAD_ATTR_CODE_LO(data[j].attrcode) == xattr->xtype, "wrong extended attribute type");
T_ASSERT1 (xattr->length == HIO_SIZEOF(*xattr) + data[j].len, "wrong attribute length");
OK (HIO_RAD_ATTR_CODE_HI(data[j].attrcode) == xattr->type, "wrong extended attribute base");
OK (HIO_RAD_ATTR_CODE_LO(data[j].attrcode) == xattr->xtype, "wrong extended attribute type");
OK (xattr->length == HIO_SIZEOF(*xattr) + data[j].len, "wrong attribute length");
val_ptr = xattr + 1;
val_len = xattr->length - HIO_SIZEOF(*xattr);
}
else if (HIO_RAD_ATTR_IS_LONG_EXTENDED(attr->type))
{
hio_rad_lxattr_hdr_t* lxattr = (hio_rad_lxattr_hdr_t*)attr;
T_ASSERT1 (HIO_RAD_ATTR_CODE_HI(data[j].attrcode) == lxattr->type, "wrong long extended attribute base");
T_ASSERT1 (HIO_RAD_ATTR_CODE_LO(data[j].attrcode) == lxattr->xtype, "wrong long extended attribute type");
T_ASSERT1 (lxattr->length == HIO_SIZEOF(*lxattr) + data[j].len, "wrong attribute length");
OK (HIO_RAD_ATTR_CODE_HI(data[j].attrcode) == lxattr->type, "wrong long extended attribute base");
OK (HIO_RAD_ATTR_CODE_LO(data[j].attrcode) == lxattr->xtype, "wrong long extended attribute type");
OK (lxattr->length == HIO_SIZEOF(*lxattr) + data[j].len, "wrong attribute length");
val_ptr = lxattr + 1;
val_len = lxattr->length - HIO_SIZEOF(*lxattr);
}
else
{
T_ASSERT1 (attr->type == data[j].attrcode, "wrong attribute type");
T_ASSERT1 (attr->length == HIO_SIZEOF(*attr) + data[j].len, "wrong attribute length");
OK (attr->type == data[j].attrcode, "wrong attribute type");
OK (attr->length == HIO_SIZEOF(*attr) + data[j].len, "wrong attribute length");
val_ptr = attr + 1;
val_len = attr->length - HIO_SIZEOF(*attr);
}
T_ASSERT1 (hio_comp_bchars(val_ptr, val_len, data[j].ptr, data[j].len, 0) == 0, "wrong attribute value");
OK (hio_comp_bchars(val_ptr, val_len, data[j].ptr, data[j].len, 0) == 0, "wrong attribute value");
}
else
{
T_ASSERT1 (attr == HIO_NULL, "find failure");
OK (attr == HIO_NULL, "find failure");
}
}
}
@ -227,7 +229,7 @@ int main ()
exptotlen -= HIO_SIZEOF(hio_rad_attr_hdr_t) + 8; /* the first User-Password in the data table */
exptotlen -= HIO_SIZEOF(hio_rad_attr_hdr_t) + 8; /* the second User-Password in the data table */
exptotlen += HIO_SIZEOF(hio_rad_attr_hdr_t) + HIO_RAD_USER_PASSWORD_TOTSIZE(18);
T_ASSERT1 (hio_ntoh16(hdr->length) == exptotlen, "hdr->length not ok");
OK (hio_ntoh16(hdr->length) == exptotlen, "hdr->length not ok");
{
char tmp[1024];
@ -238,12 +240,12 @@ int main ()
/* the following call must insert 5 attributes. it returns the pointer to the first attribute. */
attr = hio_rad_insert_attr (hdr, HIO_SIZEOF(buf), HIO_RAD_ATTR_CODE_EXTENDED_6(10), tmp, 1024);
T_ASSERT1 (attr != HIO_NULL, "long extended attribue insertion failure");
T_ASSERT1 (attr->type == HIO_RAD_ATTR_EXTENDED_6, "wrong extended attribute base");
OK (attr != HIO_NULL, "long extended attribue insertion failure");
OK (attr->type == HIO_RAD_ATTR_EXTENDED_6, "wrong extended attribute base");
lxattr = (hio_rad_lxattr_hdr_t*)attr;
T_ASSERT1 (lxattr->xtype == 10, "wrong extended attribute type");
T_ASSERT1 (lxattr->xflags == (1 << 7), "wrong long extended attribute flags");
OK (lxattr->xtype == 10, "wrong extended attribute type");
OK (lxattr->xflags == (1 << 7), "wrong long extended attribute flags");
/* TODO: inspect 4 continuing attributes */
}
@ -261,8 +263,5 @@ int main ()
#endif
}
return 0;
oops:
return -1;
return exit_status();
}

View File

@ -1,6 +1,6 @@
#include <hio-utl.h>
#include <string.h>
#include "t.h"
#include "tap.h"
/* https://131002.net/siphash/siphash24.c */
@ -78,6 +78,7 @@ static int test_sip_vectors()
hio_uint8_t in[MAXLEN], out[8], k[16];
int i;
char tmp[64];
for( i = 0; i < 16; ++i ) k[i] = i;
@ -85,7 +86,8 @@ static int test_sip_vectors()
{
in[i] = i;
hio_sip_hash_24(k, in, i, out);
T_ASSERT1 (memcmp(out, vectors[i], 8) == 0, "test vector failure");
sprintf (tmp, "test vector %d", i);
OK (memcmp(out, vectors[i], 8) == 0, tmp);
}
return 0;
@ -96,6 +98,7 @@ oops:
int main()
{
no_plan ();
if (test_sip_vectors() <= -1) return -1;
return 0;
return exit_status();
}

View File

@ -1,31 +1,36 @@
tap_total=0
function tap_end()
tap_end()
{
printf "1..%d\n" tap_total
printf "1..%d\n" $tap_total
}
function tap_ok(msg)
tap_ok()
{
tap_total++;
printf "ok %d - %s\n" tap_total msg
local msg="$@"
tap_total=$((tap_total + 1))
printf "ok %d - %s\n" $tap_total "$msg"
}
function tap_fail(msg)
tap_fail()
{
tap_total++;
printf "not ok %d - %s\n" tap_total msg
local msg="$@"
tap_total=$((tap_total + 1))
printf "not ok %d - %s\n" $tap_total "$msg"
}
function tap_skip(msg)
tap_skip()
{
tap_total++;
printf "ok %d - # skip%s%s\n" tap_total (length(msg) > 0? " ": "") msg
local msg="$@"
tap_total=$((tap_total + 1))
[ -n "$msg" ] && msg=" $msg"
printf "ok %d - # skip%s\n" $tap_total "$msg"
}
function tap_ensure(a, b, desc, line)
tap_ensure()
{
id = sprintf("%s[%d]", desc, line);
if (a != b) tap_fail (id);
else tap_ok (id);
local a="$1"
local b="$2"
local desc="$3"
[ "x$a" = "x$b" ] && tap_ok "$desc" || tap_fail "$desc"
}