summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2021-08-15 10:49:23 +1000
committerChris Johns <chrisj@rtems.org>2021-08-15 10:49:23 +1000
commit179cc5ac80df291cfb16d3af9093864a4a93feb9 (patch)
treef6383233fb7e89b08f8ffa522e5e5e51cfe92050
parent9f3500f9b9e24df9293cc297d75099d1e7899d2a (diff)
testsuite: Wait for the link to be UPnfs-v5-bus-space-1
- Wait for a slow PHY to bring the link UP. If the IP address is static the test can start before the link is up and the test fails. - Make 2 tests wait. Others will need to be added.
-rw-r--r--testsuite/include/rtems/bsd/test/default-init.h29
-rw-r--r--testsuite/include/rtems/bsd/test/default-network-init.h28
-rw-r--r--testsuite/nfs01/test_main.c1
-rw-r--r--testsuite/ping01/test_main.c1
4 files changed, 59 insertions, 0 deletions
diff --git a/testsuite/include/rtems/bsd/test/default-init.h b/testsuite/include/rtems/bsd/test/default-init.h
index fd96805b..58bbbb30 100644
--- a/testsuite/include/rtems/bsd/test/default-init.h
+++ b/testsuite/include/rtems/bsd/test/default-init.h
@@ -9,6 +9,8 @@
#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>
@@ -21,6 +23,24 @@
*/
int ioctl(int fd, unsigned long request, ...);
+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;
@@ -75,6 +95,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 */
diff --git a/testsuite/include/rtems/bsd/test/default-network-init.h b/testsuite/include/rtems/bsd/test/default-network-init.h
index fffb739c..3d8f4eab 100644
--- a/testsuite/include/rtems/bsd/test/default-network-init.h
+++ b/testsuite/include/rtems/bsd/test/default-network-init.h
@@ -40,6 +40,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <sysexits.h>
+#include <unistd.h>
#include <machine/rtems-bsd-commands.h>
@@ -176,6 +177,25 @@ default_network_on_exit(int exit_code, void *arg)
}
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
Init(rtems_task_argument arg)
{
rtems_status_code sc;
@@ -238,6 +258,14 @@ Init(rtems_task_argument arg)
#endif
default_network_dhcpcd();
+#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();
assert(0);
diff --git a/testsuite/nfs01/test_main.c b/testsuite/nfs01/test_main.c
index e97c07cd..a78fefeb 100644
--- a/testsuite/nfs01/test_main.c
+++ b/testsuite/nfs01/test_main.c
@@ -46,6 +46,7 @@
#include <rtems/bsd/test/network-config.h>
#define TEST_NAME "LIBBSD NFS 1"
+#define TEST_WAIT_FOR_LINK NET_CFG_INTERFACE_0
#define TEST_STATE_USER_INPUT 1
static void
diff --git a/testsuite/ping01/test_main.c b/testsuite/ping01/test_main.c
index 5702cee2..8b9a42ce 100644
--- a/testsuite/ping01/test_main.c
+++ b/testsuite/ping01/test_main.c
@@ -46,6 +46,7 @@
#include <rtems/bsd/test/network-config.h>
#define TEST_NAME "LIBBSD PING 1"
+#define TEST_WAIT_FOR_LINK NET_CFG_INTERFACE_0
static void
test_ping(void)