+/*
+ Prep related tests. These mostly drive cases that aren't driven by "normal"
+ connect, send, receive tests (e.g. UDP branches).
+*/
+static int prep() {
+ int errors = 0;
+ void* thing; // the thing that should be returned
+
+ thing = SIlisten_prep( UDP_DEVICE, "localhost:1234", AF_INET );
+ errors += fail_if_nil( thing, "listen prep udp returned nil block" );
+ SItrash( TP_BLK, thing );
+
+ thing = SIlisten_prep( UDP_DEVICE, "localhost:1234", 84306 ); // this should fail
+ errors += fail_not_nil( thing, "listen prep udp returned valid block ptr for bogus family" );
+
+ thing = SIconn_prep( si_ctx, UDP_DEVICE, "localhost:1234", 84306 ); // again, expect to fail; bogus family
+ errors += fail_not_nil( thing, "conn prep udp returned valid block ptr for bogus family" );
+
+ return errors;
+}
+
+/*
+ Polling/waiting tests. These are difficult at best because of the blocking
+ nature of things, not to mention needing to have real ports open etc.
+*/
+static int poll() {
+ int errors = 0;
+ int status;
+ struct ginfo_blk* dummy;
+
+
+ dummy = SIinitialise( 0 ); // get one to fiddle to drive edge cases
+ dummy->flags |= GIF_SHUTDOWN; // shutdown edge condition
+ SIpoll( dummy, 1 );
+
+ free( dummy->tp_map );
+ free( dummy->rbuf );
+ free( dummy->cbtab );
+
+ memset( dummy, 0, sizeof( *dummy ) ); // force bad cookie check code to drive
+ SIpoll( dummy, 1 );
+
+ free (dummy );
+
+ status = SIpoll( si_ctx, 1 );
+ errors += fail_if_true( status != 0, "poll failed" );
+
+ return errors;
+}
+