X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Fsi95_test.c;h=26b1b21a38d12cc2ec34918abefed32f6a9bfbd0;hb=c113b0836f3ebd58911c30de1636a707174efe55;hp=d5bcc3a9da1aba1f91e59180f2f31f7e27145b11;hpb=d961525e9eb23e3dee4a16960a1772782c3b8b36;p=ric-plt%2Flib%2Frmr.git diff --git a/test/si95_test.c b/test/si95_test.c index d5bcc3a..26b1b21 100644 --- a/test/si95_test.c +++ b/test/si95_test.c @@ -36,6 +36,12 @@ #include #include +#include // these four needed for si address tests +#include +#include +#include + + #include #include @@ -67,14 +73,14 @@ #include #include -//#include +#include //#include //#include //#include //#include //#include -//#include -//#include +#include +#include //#include //#include #include @@ -90,6 +96,11 @@ #include //#include +// --------------------------------------------------------------------- + +void* si_ctx = NULL; // a global context might be useful + +// --------------------------------------------------------------------- /* Memory allocation/free related tests @@ -124,7 +135,6 @@ static int memory( ) { return errors; } -void* si_ctx = NULL; // a global context might be useful /* Test initialisation related things @@ -141,6 +151,58 @@ static int init() { return errors; } +static int cleanup() { + int errors = 0; + + if( ! si_ctx ) { + return 0; + } + + SIconnect( si_ctx, "localhost:43086" ); // ensure context has a tp block to free on shutdown + SIshutdown( si_ctx ); + + return errors; +} + +/* + Address related tests. +*/ +static int addr() { + int errors = 0; + int l; + struct sockaddr* addr; + char buf1[4096]; + char buf2[4096]; + char* dest; + + addr = (struct sockaddr *) malloc( sizeof( struct sockaddr ) ); +/* + l = SIgenaddr( " [ff02::4]:4567", PF_INET6, IPPROTO_TCP, SOCK_STREAM, &addr ); + + SIgenaddr( " [ff02::4]:4567", PF_INET6, IPPROTO_TCP, SOCK_STREAM, &addr ); +*/ + + dest = NULL; + snprintf( buf1, sizeof( buf1 ), " [ff02::5:4001" ); // invalid address, drive leading space eater too + l = SIaddress( buf1, &dest, AC_TOADDR6 ); + errors += fail_if_true( l > 0, "to addr6 with bad addr convdersion returned valid len" ); + + snprintf( buf1, sizeof( buf1 ), "[ff02::5]:4002" ); // v6 might not be supported so failure is OK here + l=SIaddress( buf1, &dest, AC_TOADDR6 ); + errors += fail_if_true( l < 1, "to addr convdersion failed" ); + + snprintf( buf1, sizeof( buf1 ), "localhost:43086" ); + l = SIaddress( buf1, (void **) &dest, AC_TOADDR ); + errors += fail_if_true( l < 1, "to addr convdersion failed" ); + + snprintf( buf1, sizeof( buf1 ), "localhost:4004" ); + l = SIaddress( buf1, &dest, AC_TODOT ); + errors += fail_if_true( l < 1, "to dot convdersion failed" ); + + return errors; + +} + /* Drive tests... */ @@ -153,7 +215,11 @@ int main() { errors += init(); errors += memory(); + errors += addr(); +fprintf( stderr, ">>> cleaning\n" ); + errors += cleanup(); + fprintf( stderr, " testing finished\n" ); if( errors == 0 ) { fprintf( stderr, " all tests were OK\n\n" ); } else {