touched up test scripts. switched to the tap style testing
This commit is contained in:
107
t/t-003.c
107
t/t-003.c
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user