]> git.kernelconcepts.de Git - karo-tx-redboot.git/blobdiff - packages/net/lwip_tcpip/v2_0/tests/nc_test_slave.c
unified MX27, MX25, MX37 trees
[karo-tx-redboot.git] / packages / net / lwip_tcpip / v2_0 / tests / nc_test_slave.c
index 61c45d50a577f740eddb38b4166666c03dbe27bb..f8320e23335bf2758a30a1695fd0a876721c898a 100644 (file)
 
 #include "nc_test_framework.h"
 
-#include <cyg/error/errno.h>
-#include <cyg/error/codes.h>
-#include <cyg/error/strerror.h>
 #include <cyg/infra/diag.h>
 
 #include <lwip/inet.h>
 #include <lwip/arch.h>
-#define LWIP_TIMEVAL_PRIVATE 
+#include <lwip/sys.h>
+#define LWIP_TIMEVAL_PRIVATE 1
 #include <lwip/sockets.h>
+#include <cyg/infra/testcase.h>
 
 #ifndef CYGPKG_LIBC_STDIO
+#include <cyg/error/errno.h>
 #define perror(s) diag_printf(#s ": %s\n", strerror(errno))
+#else
+#include <stdio.h>
 #endif
 #define STACK_SIZE               (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x1000)
 #define MAX_LOAD_THREAD_LEVEL    20
 #define MAIN_THREAD_PRIORITY     CYGPKG_NET_THREAD_PRIORITY-2
 #define DESIRED_BACKGROUND_LOAD  20
 #define CYGHWR_NET_DRIVERS 1
+
+#if SO_REUSE
+#ifdef CYGPKG_LWIP_TCP
+#ifdef CYGPKG_LWIP_UDP
+
+
+#if 0
 static char         main_thread_stack[CYGHWR_NET_DRIVERS][STACK_SIZE];
 static cyg_thread   main_thread_data[CYGHWR_NET_DRIVERS];
 static cyg_handle_t main_thread_handle[CYGHWR_NET_DRIVERS];
+#endif
+
+
 static char         idle_thread_stack[STACK_SIZE];
 static cyg_thread   idle_thread_data;
 static cyg_handle_t idle_thread_handle;
@@ -185,7 +197,7 @@ do_udp_test(int s1, struct nc_request *req, struct sockaddr_in *master)
                         seq_errors++;
                     }
                 } else {
-                    test_printf("Bad data packet - key: %x/%x, seq: %d\n",
+                    test_printf("Bad data packet - key: %lx/%lx, seq: %d\n",
                                 ntohl(tdp->key1), ntohl(tdp->key2),
                                 ntohl(tdp->seq));
                 }
@@ -358,7 +370,7 @@ do_tcp_test(int s1, struct nc_request *req, struct sockaddr_in *master)
                         seq_errors++;
                     }
                 } else {
-                    test_printf("Bad data packet - key: %x/%x, seq: %d\n",
+                    test_printf("Bad data packet - key: %lx/%lx, seq: %d\n",
                                 ntohl(tdp->key1), ntohl(tdp->key2),
                                 ntohl(tdp->seq));
                 }
@@ -514,8 +526,9 @@ nc_slave(test_param_t param)
 }
 
 void
-net_test(test_param_t param)
+net_test(void *arg)
 {
+    test_param_t param = (test_param_t)arg;
 //    int i;
     if (param == 0) {
         test_printf("Start Network Characterization - SLAVE\n");
@@ -571,7 +584,7 @@ calibrate_load(int desired_load)
         load_idle = idle_thread_count;
         start_load(0);                         // Shut down background load
         percent_load = 100 - ((load_idle * 100) / no_load_idle);
-        diag_printf("High Load[%d] = %d => %d%%\n", load_thread_level, 
+        diag_printf("High Load[%ld] = %d => %d%%\n", load_thread_level, 
                     (int)idle_thread_count, percent_load);
         if ( percent_load > desired_load )
             break; // HIGH level is indeed higher
@@ -590,7 +603,7 @@ calibrate_load(int desired_load)
         load_idle = idle_thread_count;
         start_load(0);                         // Shut down background load
         percent_load = 100 - ((load_idle * 100) / no_load_idle);
-        diag_printf("Load[%d] = %d => %d%%\n", load_thread_level, 
+        diag_printf("Load[%ld] = %d => %d%%\n", load_thread_level, 
                     (int)idle_thread_count, percent_load);
         if (((high-low) <= 1) || (abs(desired_load-percent_load) <= 2)) break;
         if (percent_load < desired_load) {
@@ -612,7 +625,7 @@ calibrate_load(int desired_load)
     load_idle = idle_thread_count;
     start_load(0);                         // Shut down background load
     percent_load = 100 - ((load_idle * 100) / no_load_idle);
-    diag_printf("Final load[%d] = %d => %d%%\n", load_thread_level, 
+    diag_printf("Final load[%ld] = %d => %d%%\n", load_thread_level, 
                 (int)idle_thread_count, percent_load);
 //    no_load_idle_count_1_second = no_load_idle;
 }
@@ -750,9 +763,11 @@ static cyg_thread thread_data;
 static cyg_handle_t thread_handle;
 
 void
-cyg_user_start(void)
+nc_slave_main(void)
 {
        int i;  
+       
+       CYG_TEST_INIT();
    // Create the idle thread environment
     cyg_semaphore_init(&idle_thread_sem, 0);
     cyg_thread_create(IDLE_THREAD_PRIORITY,     // Priority
@@ -790,4 +805,32 @@ cyg_user_start(void)
                       &thread_data       // Thread data structure
             );
     cyg_thread_resume(thread_handle);  // Start it
+    cyg_scheduler_start();
+    CYG_TEST_FAIL_FINISH("Not reached");
+}
+
+
+externC void
+cyg_start( void )
+{
+    nc_slave_main();
+}
+
+#else // def CYGPKG_LWIP_UDP
+#define N_A_MSG "UDP support disabled"
+#endif // def CYGPKG_LWIP_UDP
+#else // def CYGPKG_LWIP_TCP
+#define N_A_MSG "TCP support disabled"
+#endif // def CYGPKG_LWIP_TCP
+#else // SO_REUSE
+#define N_A_MSG "SO_REUSE currently unavailable"
+#endif // SO_REUSE
+
+#ifdef N_A_MSG
+externC void
+cyg_start( void )
+{
+    CYG_TEST_INIT();
+    CYG_TEST_NA(N_A_MSG);
 }
+#endif // N_A_MSG