summaryrefslogtreecommitdiffstats
path: root/testsuite/include/rtems/bsd/test/default-init.h
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/include/rtems/bsd/test/default-init.h')
-rw-r--r--testsuite/include/rtems/bsd/test/default-init.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/testsuite/include/rtems/bsd/test/default-init.h b/testsuite/include/rtems/bsd/test/default-init.h
index f8ea3acd..ea502f94 100644
--- a/testsuite/include/rtems/bsd/test/default-init.h
+++ b/testsuite/include/rtems/bsd/test/default-init.h
@@ -9,11 +9,31 @@
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
+#include <unistd.h>
+
#include <rtems/printer.h>
#include <rtems/test-info.h>
#include <rtems/stackchk.h>
#include <rtems/bsd/bsd.h>
+static void default_wait_for_link_up( const char *name )
+{
+ size_t seconds = 0;
+ while ( true ) {
+ bool link_active = false;
+ assert(rtems_bsd_iface_link_state( name, &link_active ) == 0);
+ if (link_active) {
+ return;
+ }
+ sleep( 1 );
+ ++seconds;
+ if (seconds > 10) {
+ printf("error: %s: no active link\n", name);
+ assert(seconds < 10);
+ }
+ }
+}
+
static void default_set_self_prio( rtems_task_priority prio )
{
rtems_status_code sc;
@@ -68,6 +88,15 @@ rtems_task Init(
sc = rtems_task_wake_after( 2 );
assert(sc == RTEMS_SUCCESSFUL);
+#if defined(TEST_WAIT_FOR_LINK)
+ /*
+ * Per test option to wait for the network interface. If the address
+ * is static the PHY may take a while to connect and bring the
+ * interface online.
+ */
+ default_wait_for_link_up( TEST_WAIT_FOR_LINK );
+#endif
+
test_main();
/* should not return */