moved all files to the top-level
This commit is contained in:
48
t/Makefile.am
Normal file
48
t/Makefile.am
Normal file
@ -0,0 +1,48 @@
|
||||
AUTOMAKE_OPTIONS = nostdinc
|
||||
|
||||
CPPFLAGS_COMMON = \
|
||||
-I$(abs_builddir) \
|
||||
-I$(abs_builddir)/../lib \
|
||||
-I$(abs_srcdir) \
|
||||
-I$(abs_srcdir)/../lib \
|
||||
-I$(includedir)
|
||||
CFLAGS_COMMON =
|
||||
LDFLAGS_COMMON=-L$(abs_builddir)/../lib -L$(libdir)
|
||||
## place $(LIBM) here as all programs below are C only programs linked
|
||||
## against the C/C++ hybrid library. Read comments in ../bin/Makefile.am
|
||||
## for more information.
|
||||
LIBADD_COMMON = ../lib/libhio.la $(LIBM)
|
||||
|
||||
check_SCRIPTS =
|
||||
##noinst_SCRIPTS = $(check_SCRIPTS)
|
||||
EXTRA_DIST = $(check_SCRIPTS)
|
||||
|
||||
check_PROGRAMS = t-001 t-002 t-003 t-004
|
||||
|
||||
t_001_SOURCES = t-001.c t.h
|
||||
t_001_CPPFLAGS = $(CPPFLAGS_COMMON)
|
||||
t_001_CFLAGS = $(CFLAGS_COMMON)
|
||||
t_001_LDFLAGS = $(LDFLAGS_COMMON)
|
||||
t_001_LDADD = $(LIBADD_COMMON)
|
||||
|
||||
t_002_SOURCES = t-002.c t.h
|
||||
t_002_CPPFLAGS = $(CPPFLAGS_COMMON)
|
||||
t_002_CFLAGS = $(CFLAGS_COMMON)
|
||||
t_002_LDFLAGS = $(LDFLAGS_COMMON)
|
||||
t_002_LDADD = $(LIBADD_COMMON)
|
||||
|
||||
t_003_SOURCES = t-003.c t.h
|
||||
t_003_CPPFLAGS = $(CPPFLAGS_COMMON)
|
||||
t_003_CFLAGS = $(CFLAGS_COMMON)
|
||||
t_003_LDFLAGS = $(LDFLAGS_COMMON)
|
||||
t_003_LDADD = $(LIBADD_COMMON)
|
||||
|
||||
t_004_SOURCES = t-004.c t.h
|
||||
t_004_CPPFLAGS = $(CPPFLAGS_COMMON)
|
||||
t_004_CFLAGS = $(CFLAGS_COMMON)
|
||||
t_004_LDFLAGS = $(LDFLAGS_COMMON)
|
||||
t_004_LDADD = $(LIBADD_COMMON)
|
||||
|
||||
|
||||
TESTS = $(check_PROGRAMS) $(check_SCRIPTS)
|
||||
|
1151
t/Makefile.in
Normal file
1151
t/Makefile.in
Normal file
File diff suppressed because it is too large
Load Diff
11
t/b.sh
Executable file
11
t/b.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "Content-Type: text/plain"
|
||||
echo "Custom-Attribute: abcdef"
|
||||
echo
|
||||
|
||||
printenv
|
||||
exec cat /home/hyung-hwan/projects/hawk/lib/run.c
|
||||
##exec cat /home/hyung-hwan/projects/hawk/lib/uch-prop.h
|
||||
##exec cat /tmp/qq
|
||||
|
12
t/c.sh
Executable file
12
t/c.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
file=/home/hyung-hwan/projects/hawk/lib/run.c
|
||||
|
||||
echo "Content-Type: text/plain"
|
||||
echo "Custom-Attribute: abcdef"
|
||||
#echo "Content-Length: " `stat -c %s "${file}"`
|
||||
echo "Content-Length: iurtoitre"
|
||||
echo
|
||||
|
||||
echo "abc"
|
||||
exec cat "${file}"
|
12
t/d.sh
Executable file
12
t/d.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
## curl -v --http1.0 --data-binary @/etc/group --http1.1 http://127.0.0.1:9988/home/hyung-hwan/projects/hio/t/d.sh
|
||||
|
||||
echo "Content-Type: text/plain"
|
||||
echo
|
||||
|
||||
while IFS= read -r x
|
||||
do
|
||||
echo "$x"
|
||||
done
|
||||
echo "<<EOF>>"
|
22
t/e.sh
Executable file
22
t/e.sh
Executable file
@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
|
||||
## curl -v --http1.0 --data-binary @/etc/group --http1.1 http://127.0.0.1:9988/home/hyung-hwan/projects/hio/t/d.sh
|
||||
|
||||
echo "Content-Type: text/plain"
|
||||
echo
|
||||
|
||||
if IFS= read -r x
|
||||
then
|
||||
q="${x}"
|
||||
while IFS= read -r x
|
||||
do
|
||||
q="${q}
|
||||
${x}"
|
||||
done
|
||||
else
|
||||
q = ""
|
||||
fi
|
||||
|
||||
sleep 3
|
||||
printf "%s" "$q"
|
||||
##echo "<<EOF>>"
|
19
t/http1.hawk
Normal file
19
t/http1.hawk
Normal file
@ -0,0 +1,19 @@
|
||||
BEGIN {
|
||||
|
||||
|
||||
x = sys::socket (sys::AF_INET, sys::SOCK_STREAM, 0);
|
||||
sys::connect (x, "127.0.0.1:9988");
|
||||
|
||||
msg = b"GET /home/hyung-hwan/projects/hio/t/b.sh HTTP/1.1\r\n\
|
||||
Host: www.google.com\r\n\
|
||||
Connection: close\r\n\r\n";
|
||||
|
||||
#msg = b"GET /home/hyung-hwan/projects/hio/t/b.sh HTTP/1.1\r\n\
|
||||
#Host: www.google.com\r\n\
|
||||
#Connection: Keep-Alive\r\n\r\n";
|
||||
|
||||
|
||||
sys::write (x, msg);
|
||||
while (sys::read (x, buf) > 0) { printf ("%s", buf); }
|
||||
sys::close (x);
|
||||
}
|
149
t/t-001.c
Normal file
149
t/t-001.c
Normal file
@ -0,0 +1,149 @@
|
||||
/* test endian conversion macros */
|
||||
|
||||
#include <hio-utl.h>
|
||||
#include <stdio.h>
|
||||
#include "t.h"
|
||||
|
||||
int main ()
|
||||
{
|
||||
{
|
||||
union {
|
||||
hio_uint16_t u16;
|
||||
hio_uint8_t arr[2];
|
||||
} x;
|
||||
|
||||
x.arr[0] = 0x11;
|
||||
x.arr[1] = 0x22;
|
||||
|
||||
printf("x.u16 = 0x%04x\n", x.u16);
|
||||
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");
|
||||
|
||||
#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");
|
||||
#undef X_CONST
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
union {
|
||||
hio_uint32_t u32;
|
||||
hio_uint8_t arr[4];
|
||||
} x;
|
||||
|
||||
x.arr[0] = 0x11;
|
||||
x.arr[1] = 0x22;
|
||||
x.arr[2] = 0x33;
|
||||
x.arr[3] = 0x44;
|
||||
|
||||
printf("x.u32 = 0x%08x\n", (unsigned int)x.u32);
|
||||
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");
|
||||
|
||||
#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");
|
||||
#undef X_CONST
|
||||
}
|
||||
|
||||
#if defined(HIO_HAVE_UINT64_T)
|
||||
{
|
||||
union {
|
||||
hio_uint64_t u64;
|
||||
hio_uint8_t arr[8];
|
||||
} x;
|
||||
|
||||
x.arr[0] = 0x11;
|
||||
x.arr[1] = 0x22;
|
||||
x.arr[2] = 0x33;
|
||||
x.arr[3] = 0x44;
|
||||
x.arr[4] = 0x55;
|
||||
x.arr[5] = 0x66;
|
||||
x.arr[6] = 0x77;
|
||||
x.arr[7] = 0x88;
|
||||
|
||||
printf("x.u64 = 0x%016llx\n", (unsigned long long)x.u64);
|
||||
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");
|
||||
|
||||
#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");
|
||||
#undef X_CONST
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HIO_HAVE_UINT128_T)
|
||||
{
|
||||
union {
|
||||
hio_uint128_t u128;
|
||||
hio_uint8_t arr[16];
|
||||
} x;
|
||||
hio_uint128_t tmp;
|
||||
|
||||
x.arr[0] = 0x11;
|
||||
x.arr[1] = 0x22;
|
||||
x.arr[2] = 0x33;
|
||||
x.arr[3] = 0x44;
|
||||
x.arr[4] = 0x55;
|
||||
x.arr[5] = 0x66;
|
||||
x.arr[6] = 0x77;
|
||||
x.arr[7] = 0x88;
|
||||
x.arr[8] = 0x99;
|
||||
x.arr[9] = 0xaa;
|
||||
x.arr[10] = 0xbb;
|
||||
x.arr[11] = 0xcc;
|
||||
x.arr[12] = 0xdd;
|
||||
x.arr[13] = 0xee;
|
||||
x.arr[14] = 0xff;
|
||||
x.arr[15] = 0xfa;
|
||||
|
||||
printf("x.u128 = 0x%016llx%016llx\n", (unsigned long long)(hio_uint64_t)(x.u128 >> 64), (unsigned long long)(hio_uint64_t)(x.u128 >> 0));
|
||||
|
||||
tmp = hio_htole128(x.u128);
|
||||
printf("htole128(tmp) = 0x%016llx%016llx\n", (unsigned long long)(hio_uint64_t)(tmp >> 64), (unsigned long long)(hio_uint64_t)(tmp >> 0));
|
||||
|
||||
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");
|
||||
|
||||
#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");
|
||||
#undef X_CONST
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
oops:
|
||||
return -1;
|
||||
}
|
76
t/t-002.c
Normal file
76
t/t-002.c
Normal file
@ -0,0 +1,76 @@
|
||||
|
||||
#include <hio-utl.h>
|
||||
#include <stdio.h>
|
||||
#include "t.h"
|
||||
|
||||
int main ()
|
||||
{
|
||||
{
|
||||
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");
|
||||
|
||||
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");
|
||||
|
||||
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 ");
|
||||
|
||||
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");
|
||||
|
||||
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");
|
||||
|
||||
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");
|
||||
|
||||
|
||||
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");
|
||||
|
||||
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");
|
||||
|
||||
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");
|
||||
|
||||
|
||||
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");
|
||||
|
||||
|
||||
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");
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
{
|
||||
hio_bch_t tmp[10];
|
||||
hio_oow_t x;
|
||||
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");
|
||||
|
||||
x = hio_utf8_to_uc(tmp, x, &uc);
|
||||
T_ASSERT1 (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");
|
||||
|
||||
x = hio_utf8_to_uc(tmp, x, &uc);
|
||||
T_ASSERT1 (x == 4 && uc == 0x1F3E9, "utf8 to unicode conversion");
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
|
||||
oops:
|
||||
return -1;
|
||||
}
|
268
t/t-003.c
Normal file
268
t/t-003.c
Normal file
@ -0,0 +1,268 @@
|
||||
|
||||
#include <hio-rad.h>
|
||||
#include <stdio.h>
|
||||
#include "t.h"
|
||||
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
int main ()
|
||||
{
|
||||
{
|
||||
hio_uint8_t buf[10240];
|
||||
hio_rad_hdr_t* hdr = (hio_rad_hdr_t*)buf;
|
||||
int i, j, n, exptotlen;
|
||||
|
||||
struct
|
||||
{
|
||||
int index; /* index among same attributes */
|
||||
int vendor;
|
||||
int attrcode;
|
||||
void* ptr;
|
||||
int len;
|
||||
} data[] = {
|
||||
{ 0, 0, HIO_RAD_ATTR_REPLY_MESSAGE, "reply message", 13 },
|
||||
{ 1, 0, HIO_RAD_ATTR_REPLY_MESSAGE, "reply message 2", 15 },
|
||||
{ 0, 10415, 1, "470010171566423", 15 },
|
||||
{ 0, 10415, 8, "imsi-mcc-mnc", 12 },
|
||||
{ 0, 4329, 5, "ssid", 4 },
|
||||
{ 0, 0, HIO_RAD_ATTR_NAS_IDENTIFIER, "nas identifier", 14 },
|
||||
{ 0, 0, HIO_RAD_ATTR_USER_PASSWORD, "password", 8 },
|
||||
{ 1, 0, HIO_RAD_ATTR_USER_PASSWORD, "password", 8 },
|
||||
{ 0, 0, HIO_RAD_ATTR_USER_NAME, "username", 8 },
|
||||
{ 1, 10415, 8, "imsi-mcc-mnc-2", 14 },
|
||||
|
||||
/* Frag-Status 241.1 integer. */
|
||||
{ 0, 0, HIO_RAD_ATTR_CODE_EXTENDED_1(1), "\x02", 1 },
|
||||
{ 1, 0, HIO_RAD_ATTR_CODE_EXTENDED_1(1), "\x01", 1 },
|
||||
{ 2, 0, HIO_RAD_ATTR_CODE_EXTENDED_1(1), "\x00", 1 },
|
||||
/* Proxy-State-Length 241.2 integer. */
|
||||
{ 0, 0, HIO_RAD_ATTR_CODE_EXTENDED_1(2), "\xFF", 1 },
|
||||
|
||||
{ 3, 0, HIO_RAD_ATTR_CODE_EXTENDED_1(1), "\x03", 1 },
|
||||
{ 1, 0, HIO_RAD_ATTR_CODE_EXTENDED_1(2), "\xDD", 1 },
|
||||
|
||||
|
||||
{ 0, 6527, HIO_RAD_ATTR_CODE_EXTENDED_1(2), "evs attribute", 13 },
|
||||
{ 1, 6527, HIO_RAD_ATTR_CODE_EXTENDED_1(2), "evs attribute 2", 15 },
|
||||
{ 0, 8888, HIO_RAD_ATTR_CODE_EXTENDED_4(444), "evs attribute", 13 },
|
||||
|
||||
{ 2, 0, HIO_RAD_ATTR_REPLY_MESSAGE, "reply message 3", 15 },
|
||||
};
|
||||
|
||||
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");
|
||||
exptotlen = HIO_SIZEOF(*hdr);
|
||||
T_ASSERT1 (hdr->length == HIO_CONST_HTON16(HIO_SIZEOF(*hdr)), "hdr->length not ok");
|
||||
|
||||
|
||||
for (i = 0; i < HIO_COUNTOF(data); i++)
|
||||
{
|
||||
if (data[i].vendor)
|
||||
{
|
||||
hio_rad_vsattr_hdr_t* vsattr;
|
||||
hio_rad_xvsattr_hdr_t* xvsattr;
|
||||
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");
|
||||
|
||||
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");
|
||||
}
|
||||
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");
|
||||
}
|
||||
else
|
||||
{
|
||||
exptotlen += HIO_SIZEOF(*vsattr);
|
||||
T_ASSERT1 (vsattr->length == HIO_SIZEOF(*vsattr) + data[i].len, "wrong attribute length");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hio_rad_attr_hdr_t* attr;
|
||||
hio_rad_xattr_hdr_t* xattr;
|
||||
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");
|
||||
|
||||
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");
|
||||
}
|
||||
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");
|
||||
}
|
||||
else
|
||||
{
|
||||
exptotlen += HIO_SIZEOF(*attr);
|
||||
T_ASSERT1 (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");
|
||||
exptotlen += data[i].len;
|
||||
T_ASSERT1 (hio_ntoh16(hdr->length) == exptotlen, "hdr->length not ok after attribute insertion");
|
||||
|
||||
for (j = 0; j < HIO_COUNTOF(data); j++)
|
||||
{
|
||||
if (data[j].vendor)
|
||||
{
|
||||
hio_rad_vsattr_hdr_t* vsattr;
|
||||
|
||||
vsattr = hio_rad_find_vsattr(hdr, data[j].vendor, data[j].attrcode, data[j].index);
|
||||
if (j <= i)
|
||||
{
|
||||
void* val_ptr;
|
||||
int val_len;
|
||||
|
||||
T_ASSERT1 (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");
|
||||
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");
|
||||
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");
|
||||
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");
|
||||
}
|
||||
else
|
||||
{
|
||||
T_ASSERT1 (vsattr == HIO_NULL, "find failure");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hio_rad_attr_hdr_t* attr;
|
||||
|
||||
attr = hio_rad_find_attr(hdr, data[j].attrcode, data[j].index);
|
||||
if (j <= i)
|
||||
{
|
||||
void* val_ptr;
|
||||
int val_len;
|
||||
T_ASSERT1 (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");
|
||||
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");
|
||||
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");
|
||||
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");
|
||||
}
|
||||
else
|
||||
{
|
||||
T_ASSERT1 (attr == HIO_NULL, "find failure");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hio_rad_fill_authenticator (hdr);
|
||||
hio_rad_set_user_password (hdr, HIO_SIZEOF(buf), "real_real_password", "testing123");
|
||||
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");
|
||||
|
||||
{
|
||||
char tmp[1024];
|
||||
hio_rad_attr_hdr_t* attr;
|
||||
hio_rad_lxattr_hdr_t* lxattr;
|
||||
|
||||
for (i = 0; i < HIO_COUNTOF(tmp); i++) tmp[i] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i % 26];
|
||||
|
||||
/* 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");
|
||||
|
||||
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");
|
||||
|
||||
/* TODO: inspect 4 continuing attributes */
|
||||
}
|
||||
|
||||
#if 1
|
||||
{
|
||||
int s = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
struct sockaddr_in sin;
|
||||
memset (&sin, 0, sizeof(sin));
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_addr.s_addr = inet_addr("192.168.1.1");
|
||||
sin.sin_port = HIO_CONST_HTON16(1812);
|
||||
sendto (s, hdr, hio_ntoh16(hdr->length), 0, &sin, sizeof(sin));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
oops:
|
||||
return -1;
|
||||
}
|
101
t/t-004.c
Normal file
101
t/t-004.c
Normal file
@ -0,0 +1,101 @@
|
||||
#include <hio-utl.h>
|
||||
#include <string.h>
|
||||
#include "t.h"
|
||||
|
||||
/* https://131002.net/siphash/siphash24.c */
|
||||
|
||||
static hio_uint8_t vectors[64][8] =
|
||||
{
|
||||
{ 0x31, 0x0e, 0x0e, 0xdd, 0x47, 0xdb, 0x6f, 0x72, },
|
||||
{ 0xfd, 0x67, 0xdc, 0x93, 0xc5, 0x39, 0xf8, 0x74, },
|
||||
{ 0x5a, 0x4f, 0xa9, 0xd9, 0x09, 0x80, 0x6c, 0x0d, },
|
||||
{ 0x2d, 0x7e, 0xfb, 0xd7, 0x96, 0x66, 0x67, 0x85, },
|
||||
{ 0xb7, 0x87, 0x71, 0x27, 0xe0, 0x94, 0x27, 0xcf, },
|
||||
{ 0x8d, 0xa6, 0x99, 0xcd, 0x64, 0x55, 0x76, 0x18, },
|
||||
{ 0xce, 0xe3, 0xfe, 0x58, 0x6e, 0x46, 0xc9, 0xcb, },
|
||||
{ 0x37, 0xd1, 0x01, 0x8b, 0xf5, 0x00, 0x02, 0xab, },
|
||||
{ 0x62, 0x24, 0x93, 0x9a, 0x79, 0xf5, 0xf5, 0x93, },
|
||||
{ 0xb0, 0xe4, 0xa9, 0x0b, 0xdf, 0x82, 0x00, 0x9e, },
|
||||
{ 0xf3, 0xb9, 0xdd, 0x94, 0xc5, 0xbb, 0x5d, 0x7a, },
|
||||
{ 0xa7, 0xad, 0x6b, 0x22, 0x46, 0x2f, 0xb3, 0xf4, },
|
||||
{ 0xfb, 0xe5, 0x0e, 0x86, 0xbc, 0x8f, 0x1e, 0x75, },
|
||||
{ 0x90, 0x3d, 0x84, 0xc0, 0x27, 0x56, 0xea, 0x14, },
|
||||
{ 0xee, 0xf2, 0x7a, 0x8e, 0x90, 0xca, 0x23, 0xf7, },
|
||||
{ 0xe5, 0x45, 0xbe, 0x49, 0x61, 0xca, 0x29, 0xa1, },
|
||||
{ 0xdb, 0x9b, 0xc2, 0x57, 0x7f, 0xcc, 0x2a, 0x3f, },
|
||||
{ 0x94, 0x47, 0xbe, 0x2c, 0xf5, 0xe9, 0x9a, 0x69, },
|
||||
{ 0x9c, 0xd3, 0x8d, 0x96, 0xf0, 0xb3, 0xc1, 0x4b, },
|
||||
{ 0xbd, 0x61, 0x79, 0xa7, 0x1d, 0xc9, 0x6d, 0xbb, },
|
||||
{ 0x98, 0xee, 0xa2, 0x1a, 0xf2, 0x5c, 0xd6, 0xbe, },
|
||||
{ 0xc7, 0x67, 0x3b, 0x2e, 0xb0, 0xcb, 0xf2, 0xd0, },
|
||||
{ 0x88, 0x3e, 0xa3, 0xe3, 0x95, 0x67, 0x53, 0x93, },
|
||||
{ 0xc8, 0xce, 0x5c, 0xcd, 0x8c, 0x03, 0x0c, 0xa8, },
|
||||
{ 0x94, 0xaf, 0x49, 0xf6, 0xc6, 0x50, 0xad, 0xb8, },
|
||||
{ 0xea, 0xb8, 0x85, 0x8a, 0xde, 0x92, 0xe1, 0xbc, },
|
||||
{ 0xf3, 0x15, 0xbb, 0x5b, 0xb8, 0x35, 0xd8, 0x17, },
|
||||
{ 0xad, 0xcf, 0x6b, 0x07, 0x63, 0x61, 0x2e, 0x2f, },
|
||||
{ 0xa5, 0xc9, 0x1d, 0xa7, 0xac, 0xaa, 0x4d, 0xde, },
|
||||
{ 0x71, 0x65, 0x95, 0x87, 0x66, 0x50, 0xa2, 0xa6, },
|
||||
{ 0x28, 0xef, 0x49, 0x5c, 0x53, 0xa3, 0x87, 0xad, },
|
||||
{ 0x42, 0xc3, 0x41, 0xd8, 0xfa, 0x92, 0xd8, 0x32, },
|
||||
{ 0xce, 0x7c, 0xf2, 0x72, 0x2f, 0x51, 0x27, 0x71, },
|
||||
{ 0xe3, 0x78, 0x59, 0xf9, 0x46, 0x23, 0xf3, 0xa7, },
|
||||
{ 0x38, 0x12, 0x05, 0xbb, 0x1a, 0xb0, 0xe0, 0x12, },
|
||||
{ 0xae, 0x97, 0xa1, 0x0f, 0xd4, 0x34, 0xe0, 0x15, },
|
||||
{ 0xb4, 0xa3, 0x15, 0x08, 0xbe, 0xff, 0x4d, 0x31, },
|
||||
{ 0x81, 0x39, 0x62, 0x29, 0xf0, 0x90, 0x79, 0x02, },
|
||||
{ 0x4d, 0x0c, 0xf4, 0x9e, 0xe5, 0xd4, 0xdc, 0xca, },
|
||||
{ 0x5c, 0x73, 0x33, 0x6a, 0x76, 0xd8, 0xbf, 0x9a, },
|
||||
{ 0xd0, 0xa7, 0x04, 0x53, 0x6b, 0xa9, 0x3e, 0x0e, },
|
||||
{ 0x92, 0x59, 0x58, 0xfc, 0xd6, 0x42, 0x0c, 0xad, },
|
||||
{ 0xa9, 0x15, 0xc2, 0x9b, 0xc8, 0x06, 0x73, 0x18, },
|
||||
{ 0x95, 0x2b, 0x79, 0xf3, 0xbc, 0x0a, 0xa6, 0xd4, },
|
||||
{ 0xf2, 0x1d, 0xf2, 0xe4, 0x1d, 0x45, 0x35, 0xf9, },
|
||||
{ 0x87, 0x57, 0x75, 0x19, 0x04, 0x8f, 0x53, 0xa9, },
|
||||
{ 0x10, 0xa5, 0x6c, 0xf5, 0xdf, 0xcd, 0x9a, 0xdb, },
|
||||
{ 0xeb, 0x75, 0x09, 0x5c, 0xcd, 0x98, 0x6c, 0xd0, },
|
||||
{ 0x51, 0xa9, 0xcb, 0x9e, 0xcb, 0xa3, 0x12, 0xe6, },
|
||||
{ 0x96, 0xaf, 0xad, 0xfc, 0x2c, 0xe6, 0x66, 0xc7, },
|
||||
{ 0x72, 0xfe, 0x52, 0x97, 0x5a, 0x43, 0x64, 0xee, },
|
||||
{ 0x5a, 0x16, 0x45, 0xb2, 0x76, 0xd5, 0x92, 0xa1, },
|
||||
{ 0xb2, 0x74, 0xcb, 0x8e, 0xbf, 0x87, 0x87, 0x0a, },
|
||||
{ 0x6f, 0x9b, 0xb4, 0x20, 0x3d, 0xe7, 0xb3, 0x81, },
|
||||
{ 0xea, 0xec, 0xb2, 0xa3, 0x0b, 0x22, 0xa8, 0x7f, },
|
||||
{ 0x99, 0x24, 0xa4, 0x3c, 0xc1, 0x31, 0x57, 0x24, },
|
||||
{ 0xbd, 0x83, 0x8d, 0x3a, 0xaf, 0xbf, 0x8d, 0xb7, },
|
||||
{ 0x0b, 0x1a, 0x2a, 0x32, 0x65, 0xd5, 0x1a, 0xea, },
|
||||
{ 0x13, 0x50, 0x79, 0xa3, 0x23, 0x1c, 0xe6, 0x60, },
|
||||
{ 0x93, 0x2b, 0x28, 0x46, 0xe4, 0xd7, 0x06, 0x66, },
|
||||
{ 0xe1, 0x91, 0x5f, 0x5c, 0xb1, 0xec, 0xa4, 0x6c, },
|
||||
{ 0xf3, 0x25, 0x96, 0x5c, 0xa1, 0x6d, 0x62, 0x9f, },
|
||||
{ 0x57, 0x5f, 0xf2, 0x8e, 0x60, 0x38, 0x1b, 0xe5, },
|
||||
{ 0x72, 0x45, 0x06, 0xeb, 0x4c, 0x32, 0x8a, 0x95, }
|
||||
};
|
||||
|
||||
static int test_sip_vectors()
|
||||
{
|
||||
#define MAXLEN 64
|
||||
|
||||
hio_uint8_t in[MAXLEN], out[8], k[16];
|
||||
int i;
|
||||
|
||||
for( i = 0; i < 16; ++i ) k[i] = i;
|
||||
|
||||
for( i = 0; i < MAXLEN; ++i )
|
||||
{
|
||||
in[i] = i;
|
||||
hio_sip_hash_24(k, in, i, out);
|
||||
T_ASSERT1 (memcmp(out, vectors[i], 8) == 0, "test vector failure");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
oops:
|
||||
return -1;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
if (test_sip_vectors() <= -1) return -1;
|
||||
return 0;
|
||||
}
|
21
t/t.h
Normal file
21
t/t.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef _HAWK_T_T_H_
|
||||
#define _HAWK_T_T_H_
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(__STDC_VERSION__) && (__STDC_VERSION__>=199901L)
|
||||
# define T_ASSERT_FAIL0() printf("FAILURE in %s:%s[%d]\n", __FILE__, __func__, (int)__LINE__)
|
||||
# define T_ASSERT_FAIL1(msg1) printf("FAILURE in %s:%s[%d] - %s\n", __FILE__, __func__, (int)__LINE__, msg1)
|
||||
# define T_ASSERT_FAIL2(msg1,msg2) printf("FAILURE in %s:%s[%d] - %s - %s\n", __FILE__, __func__, (int)__LINE__, msg1, msg2)
|
||||
#else
|
||||
# define T_ASSERT_FAIL0() printf("FAILURE in %s[%d]\n", __FILE__, (int)__LINE__)
|
||||
# define T_ASSERT_FAIL1(msg1) printf("FAILURE in %s[%d] - %s\n", __FILE__, (int)__LINE__, msg1)
|
||||
# define T_ASSERT_FAIL2(msg1,msg2) printf("FAILURE in %s[%d] - %s - %s\n", __FILE__, (int)__LINE__, msg1, msg2)
|
||||
#endif
|
||||
|
||||
#define T_ASSERT0(test) do { if (!(test)) { T_ASSERT_FAIL0(); goto oops; } } while(0)
|
||||
#define T_ASSERT1(test,msg1) do { if (!(test)) { T_ASSERT_FAIL1(msg1); goto oops; } } while(0)
|
||||
#define T_ASSERT2(test,msg1,msg2) do { if (!(test)) { T_ASSERT_FAIL2(msg1,msg2); goto oops; } } while(0)
|
||||
|
||||
|
||||
#endif
|
13
t/t1.txt
Normal file
13
t/t1.txt
Normal file
@ -0,0 +1,13 @@
|
||||
POST /home/hyung-hwan/projects/hio/t/b.sh HTTP/1.1
|
||||
Host: abc.txt
|
||||
Content-Type: text/plain
|
||||
Transfer-Encoding: chunked
|
||||
|
||||
7
|
||||
Mozilla
|
||||
9
|
||||
Developer
|
||||
7
|
||||
Network
|
||||
0
|
||||
|
15
t/t2.txt
Normal file
15
t/t2.txt
Normal file
@ -0,0 +1,15 @@
|
||||
GET /home/hyung-hwan/projects/hio/t/b.sh HTTP/1.1
|
||||
Host: abc.txt
|
||||
Transfer-Encoding: chunked
|
||||
Connection: close
|
||||
Trailer: Content-Type
|
||||
|
||||
7
|
||||
Mozilla
|
||||
9
|
||||
Developer
|
||||
7
|
||||
Network
|
||||
0
|
||||
Content-Type: text/plain
|
||||
|
13
t/t3.txt
Normal file
13
t/t3.txt
Normal file
@ -0,0 +1,13 @@
|
||||
POST /home/hyung-hwan/projects/hio/t/b.sh HTTP/1.0
|
||||
Host: abc.txt
|
||||
Content-Type: text/plain
|
||||
Transfer-Encoding: chunked
|
||||
|
||||
7
|
||||
Mozilla
|
||||
9
|
||||
Developer
|
||||
7
|
||||
Network
|
||||
0
|
||||
|
26
t/t4.txt
Normal file
26
t/t4.txt
Normal file
@ -0,0 +1,26 @@
|
||||
POST /home/hyung-hwan/projects/hio/t/b.sh HTTP/1.1
|
||||
Host: abc.txt
|
||||
Content-Type: text/plain
|
||||
Transfer-Encoding: chunked
|
||||
|
||||
7
|
||||
Mozilla
|
||||
9
|
||||
Developer
|
||||
7
|
||||
Network
|
||||
0
|
||||
|
||||
POST /home/hyung-hwan/projects/hio/t/c.sh HTTP/1.1
|
||||
Host: abc.txt
|
||||
Content-Type: text/plain
|
||||
Transfer-Encoding: chunked
|
||||
|
||||
7
|
||||
Mozilla
|
||||
9
|
||||
Developer
|
||||
7
|
||||
Network
|
||||
0
|
||||
|
Reference in New Issue
Block a user