OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [net/] [autotest/] [current/] [tests/] [slowping.c] - Blame information for rev 825

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      autotest/current/tests/slowping.c
4
//
5
//      Simple pinging test, the server pings me and little else.
6
//
7
//==========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
9
// -------------------------------------------                              
10
// This file is part of eCos, the Embedded Configurable Operating System.   
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under    
14
// the terms of the GNU General Public License as published by the Free     
15
// Software Foundation; either version 2 or (at your option) any later      
16
// version.                                                                 
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT      
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
21
// for more details.                                                        
22
//
23
// You should have received a copy of the GNU General Public License        
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
26
//
27
// As a special exception, if other files instantiate templates or use      
28
// macros or inline functions from this file, or you compile this file      
29
// and link it with other works to produce a work based on this file,       
30
// this file does not by itself cause the resulting work to be covered by   
31
// the GNU General Public License. However the source code for this file    
32
// must still be made available in accordance with section (3) of the GNU   
33
// General Public License v2.                                               
34
//
35
// This exception does not invalidate any other reasons why a work based    
36
// on this file might be covered by the GNU General Public License.         
37
// -------------------------------------------                              
38
// ####ECOSGPLCOPYRIGHTEND####                                              
39
// ####BSDALTCOPYRIGHTBEGIN####                                             
40
// -------------------------------------------                              
41
// Portions of this software may have been derived from FreeBSD, OpenBSD,   
42
// or other sources, and if so are covered by the appropriate copyright     
43
// and license included herein.                                             
44
// -------------------------------------------                              
45
// ####BSDALTCOPYRIGHTEND####                                               
46
//==========================================================================
47
//#####DESCRIPTIONBEGIN####
48
//
49
// Author(s):    hmt,gthomas
50
// Contributors: hmt,gthomas
51
// Date:         2000-10-23
52
// Purpose:      
53
// Description:  
54
//              
55
//
56
//####DESCRIPTIONEND####
57
//
58
//==========================================================================
59
 
60
#include <pkgconf/system.h>
61
 
62
#include <cyg/infra/testcase.h>         // testing infrastructure
63
 
64
#include <pkgconf/net.h>
65
 
66
#ifdef CYGBLD_DEVS_ETH_DEVICE_H    // Get the device config if it exists
67
#include CYGBLD_DEVS_ETH_DEVICE_H  // May provide CYGTST_DEVS_ETH_TEST_NET_REALTIME
68
#endif
69
 
70
#ifdef CYGPKG_NET_TESTS_USE_RT_TEST_HARNESS // do we use the rt test?
71
# ifdef CYGTST_DEVS_ETH_TEST_NET_REALTIME // Get the test ancilla if it exists
72
#  include CYGTST_DEVS_ETH_TEST_NET_REALTIME
73
# endif
74
#endif
75
 
76
 
77
// Fill in the blanks if necessary
78
#ifndef TNR_OFF
79
# define TNR_OFF()
80
#endif
81
#ifndef TNR_ON
82
# define TNR_ON()
83
#endif
84
#ifndef TNR_INIT
85
# define TNR_INIT()
86
#endif
87
#ifndef TNR_PRINT_ACTIVITY
88
# define TNR_PRINT_ACTIVITY()
89
#endif
90
 
91
// ------------------------------------------------------------------------
92
 
93
#include <errno.h>
94
#include <network.h>
95
 
96
#include "autohost.inl"
97
 
98
#define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x10000)
99
static char stack[STACK_SIZE];
100
static cyg_thread thread_data;
101
static cyg_handle_t thread_handle;
102
 
103
static void
104
do_ping_tests(struct bootp *bp, int N, int testtime, int filesize)
105
{
106
    int i;
107
    char order[256];
108
    diag_printf( "INFO: telling %s to run %d pings for %d seconds, %d bytes and up\n",
109
          inet_ntoa(bp->bp_siaddr), N, testtime, filesize );
110
 
111
    // For 2nd and subsequent orders, we vary the ping data size:
112
    for ( i = 0; i < N; i++ ) {
113
        sprintf( order, "%s %s %d %d", "SLOW_PING",
114
                 inet_ntoa(bp->bp_yiaddr),
115
                 testtime,
116
                 filesize + 50 * i );
117
        autohost_tell( bp, order );
118
    }
119
}
120
 
121
#define TESTTIME (5 * 60) // Seconds
122
 
123
#define NUM_SESSIONS 10 // why not?
124
 
125
void
126
net_test(cyg_addrword_t param)
127
{
128
    int i;
129
    int numtests;
130
    CYG_TEST_INIT();
131
    CYG_TEST_INFO("Start PING server test");
132
    init_all_network_interfaces();
133
 
134
    autohost_init();
135
 
136
    TNR_INIT();
137
 
138
    numtests = NUM_SESSIONS; // The number of pingers started OK
139
    i = numtests;
140
    // Now command the host to do ping to us...
141
#ifdef CYGHWR_NET_DRIVER_ETH0
142
    if (eth0_up) {
143
        // 2 small tests by default and a couple of larger ones
144
        do_ping_tests(&eth0_bootp_data, 2, TESTTIME, 64);
145
        do_ping_tests(&eth0_bootp_data, 2, TESTTIME, 1000);
146
        do_ping_tests(&eth0_bootp_data, 2, TESTTIME, 10000);
147
        i -= 6;
148
    }
149
#endif
150
#ifdef CYGHWR_NET_DRIVER_ETH1
151
    if (eth1_up && i > 0) {
152
        // rest of the tests depending...
153
        do_ping_tests(&eth1_bootp_data, 1, TESTTIME, 64);
154
        i--;
155
        if ( i > 0 ) {
156
            do_ping_tests(&eth1_bootp_data, 1, TESTTIME, 4000);
157
            i--;
158
        }
159
        if ( i > 0 ) {
160
            do_ping_tests(&eth1_bootp_data, i, TESTTIME, 1200);
161
            i = 0;
162
        }
163
    }
164
#endif
165
    numtests -= i; // Adjust to how many we *actually* requested
166
 
167
    // Let the server run for 5 minutes
168
    cyg_thread_delay(2*100); // let the stuff start up first
169
    TNR_ON();
170
    cyg_thread_delay(TESTTIME*100); // FIXME - assume cS clock.
171
    // Additional delay 'cos host may be slower than us - and it has to
172
    // complete a transfer anyway:
173
    cyg_thread_delay(  30    *100); // FIXME - assume cS clock.
174
    TNR_OFF();
175
 
176
    autohost_end( numtests ); // check for N pass messages from hosts
177
 
178
    TNR_PRINT_ACTIVITY();
179
    CYG_TEST_EXIT("Done");
180
}
181
 
182
void
183
cyg_start(void)
184
{
185
    // Create a main thread, so we can run the scheduler and have time 'pass'
186
    cyg_thread_create(10,                // Priority - just a number
187
                      net_test,          // entry
188
                      0,                 // entry parameter
189
                      "Network test",    // Name
190
                      &stack[0],         // Stack
191
                      STACK_SIZE,        // Size
192
                      &thread_handle,    // Handle
193
                      &thread_data       // Thread data structure
194
            );
195
    cyg_thread_resume(thread_handle);  // Start it
196
    cyg_scheduler_start();
197
}
198
 
199
// EOF slowping.c

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.