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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [net/] [autotest/] [current/] [tests/] [snmppings.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/snmppings.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 CYGPKG_SNMPAGENT // Do we support SNMP at all?
67
 
68
#ifdef CYGBLD_DEVS_ETH_DEVICE_H    // Get the device config if it exists
69
#include CYGBLD_DEVS_ETH_DEVICE_H  // May provide CYGTST_DEVS_ETH_TEST_NET_REALTIME
70
#endif
71
 
72
#ifdef CYGPKG_NET_TESTS_USE_RT_TEST_HARNESS // do we use the rt test?
73
# ifdef CYGTST_DEVS_ETH_TEST_NET_REALTIME // Get the test ancilla if it exists
74
#  include CYGTST_DEVS_ETH_TEST_NET_REALTIME
75
# endif
76
#endif
77
 
78
 
79
// Fill in the blanks if necessary
80
#ifndef TNR_OFF
81
# define TNR_OFF()
82
#endif
83
#ifndef TNR_ON
84
# define TNR_ON()
85
#endif
86
#ifndef TNR_INIT
87
# define TNR_INIT()
88
#endif
89
#ifndef TNR_PRINT_ACTIVITY
90
# define TNR_PRINT_ACTIVITY()
91
#endif
92
 
93
// ------------------------------------------------------------------------
94
 
95
#include <errno.h>
96
#include <network.h>
97
 
98
#include "autohost.inl"
99
 
100
#define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x10000)
101
static char stack[STACK_SIZE];
102
static cyg_thread thread_data;
103
static cyg_handle_t thread_handle;
104
 
105
static void
106
do_ping_tests(struct bootp *bp, int N, int testtime, int filesize)
107
{
108
    int i;
109
    char order[256];
110
    diag_printf( "INFO: telling %s to run %d pings for %d seconds, %d bytes and up\n",
111
          inet_ntoa(bp->bp_siaddr), N, testtime, filesize );
112
 
113
    // For 2nd and subsequent orders, we vary the ping data size:
114
    for ( i = 0; i < N; i++ ) {
115
        sprintf( order, "%s %s %d %d", "SLOW_PING",
116
                 inet_ntoa(bp->bp_yiaddr),
117
                 testtime,
118
                 filesize + 50 * i );
119
        autohost_tell( bp, order );
120
    }
121
}
122
 
123
static void
124
do_snmp_tests(struct bootp *bp, int N, int testtime)
125
{
126
    int i;
127
    char order[256];
128
    diag_printf( "INFO: telling %s to run %d snmpwalks for %d seconds\n",
129
          inet_ntoa(bp->bp_siaddr), N, testtime );
130
 
131
#ifdef XFAIL
132
    // reduce the time to run so that we get a result
133
    testtime *= 3;
134
    testtime /= 4;
135
#endif
136
    for ( i = 0; i < N; i++ ) {
137
        sprintf( order, "%s %s %d", "SNMP_WALK",
138
                 inet_ntoa(bp->bp_yiaddr),
139
                 testtime );
140
        autohost_tell( bp, order );
141
    }
142
}
143
 
144
static void
145
do_flood_tests(struct bootp *bp, int testtime, int on, int off)
146
{
147
    char order[256];
148
    diag_printf( "INFO: telling %s to run 1 flood ping for %d seconds, %d/%d flood/sleep\n",
149
          inet_ntoa(bp->bp_siaddr), testtime, on, off );
150
 
151
    sprintf( order, "%s %s %d %d %d %d", "FLOOD_PING",
152
             inet_ntoa(bp->bp_yiaddr),
153
             testtime,
154
             56, // constant size
155
             on, off );
156
    autohost_tell( bp, order );
157
}
158
 
159
 
160
#define TESTTIME (5 * 60) // Seconds
161
 
162
#define NUM_SESSIONS 10 // why not?
163
 
164
void
165
net_test(cyg_addrword_t param)
166
{
167
    extern void cyg_net_snmp_init(void);
168
 
169
    CYG_TEST_INIT();
170
    CYG_TEST_INFO("Start multiple SNMP server test");
171
    init_all_network_interfaces();
172
 
173
    autohost_init();
174
 
175
    cyg_net_snmp_init();
176
 
177
    TNR_INIT();
178
 
179
    // Now command the host to do ping to us...
180
#ifdef CYGHWR_NET_DRIVER_ETH0
181
    if (eth0_up) {
182
        // Two SNMP walk tests
183
        do_snmp_tests(&eth0_bootp_data, 2, TESTTIME);
184
        // ...and flood ping for one second in 10
185
        do_flood_tests(&eth0_bootp_data, TESTTIME, 1, 9 );
186
        // ...and ping a couple of times too, 56 bytes and 2000 bytes.
187
        do_ping_tests(&eth0_bootp_data, 1, TESTTIME, 56 );
188
        do_ping_tests(&eth0_bootp_data, 1, TESTTIME, 2000 );
189
        // which makes 5 tests in all.
190
    }
191
#endif
192
#ifdef CYGHWR_NET_DRIVER_ETH1
193
    if (eth1_up) {
194
        // Two SNMP walk tests
195
        do_snmp_tests(&eth1_bootp_data, 2, TESTTIME);
196
        // ...and flood ping for two seconds in 13
197
        do_flood_tests(&eth1_bootp_data, TESTTIME, 2, 11 );
198
        // ...and ping a couple of times too, 500 bytes and 1600 bytes.
199
        do_ping_tests(&eth1_bootp_data, 1, TESTTIME, 500 );
200
        do_ping_tests(&eth1_bootp_data, 1, TESTTIME, 1600 );
201
        // which makes 5 tests in all.
202
    }
203
#endif
204
    // Let the server run for 5 minutes
205
    cyg_thread_delay(2*100); // let the stuff start up first
206
    TNR_ON();
207
    cyg_thread_delay(TESTTIME*100); // FIXME - assume cS clock.
208
    // Additional delay 'cos host may be slower than us - and it has to
209
    // complete a transfer anyway:
210
    cyg_thread_delay(  30    *100); // FIXME - assume cS clock.
211
    TNR_OFF();
212
 
213
    autohost_end( 5 * (0
214
#ifdef CYGHWR_NET_DRIVER_ETH0
215
                  + eth0_up
216
#endif
217
#ifdef CYGHWR_NET_DRIVER_ETH1
218
                  + eth1_up
219
#endif
220
        ) ); // check for N pass messages from hosts
221
 
222
    TNR_PRINT_ACTIVITY();
223
    CYG_TEST_EXIT("Done");
224
}
225
 
226
#endif // CYGPKG_SNMPAGENT - Do we support SNMP at all?
227
 
228
void
229
cyg_start(void)
230
{
231
#ifdef CYGPKG_SNMPAGENT // Do we support SNMP at all?
232
    // Create a main thread, so we can run the scheduler and have time 'pass'
233
    cyg_thread_create(10,                // Priority - just a number
234
                      net_test,          // entry
235
                      0,                 // entry parameter
236
                      "Network test",    // Name
237
                      &stack[0],         // Stack
238
                      STACK_SIZE,        // Size
239
                      &thread_handle,    // Handle
240
                      &thread_data       // Thread data structure
241
            );
242
    cyg_thread_resume(thread_handle);  // Start it
243
    cyg_scheduler_start();
244
#else
245
    CYG_TEST_NA( "No SNMP agent in this configuration" );
246
#endif // CYGPKG_SNMPAGENT - Do we support SNMP at all?
247
}
248
 
249
// EOF snmppings.c

powered by: WebSVN 2.1.0

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