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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [net/] [ppp/] [current/] [tests/] [chat.c] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      tests/ppp_up.c
4
//
5
//      Simple test of PPP and networking support
6
//
7
//==========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
9
// -------------------------------------------                              
10
// This file is part of eCos, the Embedded Configurable Operating System.   
11
// Copyright (C) 2003 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):    gthomas
50
// Contributors: gthomas
51
// Date:         2000-01-10
52
// Purpose:      
53
// Description:  
54
//              
55
//
56
//####DESCRIPTIONEND####
57
//
58
//==========================================================================
59
 
60
// PPP test code
61
 
62
#if 0
63
#include <network.h>
64
 
65
#include <pkgconf/system.h>
66
#include <pkgconf/net.h>
67
#include <pkgconf/ppp.h>
68
 
69
#include <cyg/ppp/ppp.h>
70
 
71
#include <cyg/io/io.h>
72
#include <cyg/io/serialio.h>
73
 
74
#include <cyg/infra/testcase.h>
75
#endif
76
 
77
#include "ppp_test_support.inl"
78
 
79
 
80
 
81
//==========================================================================
82
 
83
 
84
#define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x1000)
85
static char stack[STACK_SIZE];
86
static cyg_thread thread_data;
87
static cyg_handle_t thread_handle;
88
 
89
//==========================================================================
90
 
91
static const char *script1[] =
92
{
93
    "ABORT"             ,       "BUSY"          ,
94
    "ABORT"             ,       "NO CARRIER"    ,
95
    ""                  ,       "Chat Test"     ,
96
    "CONNECT"           ,       "\\c"           ,
97
    "TIMEOUT"           ,       "10"            ,
98
    "ogin:--ogin:"      ,       "ppp"           ,
99
    "TIMEOUT"           ,       "5"             ,
100
    "assword:"          ,       "hithere"       ,
101
 
102
};
103
 
104
//==========================================================================
105
 
106
static struct test_info
107
{
108
    char        *name;
109
    const char  **script;
110
    cyg_int32   result;
111
} tests[] =
112
{
113
    { "CHAT_TEST_1"     , script1       , 1 },          // Simple test to completion
114
    { "CHAT_TEST_2"     , script1       , 0 },          // Expects an ABORT
115
    { "CHAT_TEST_3"     , script1       , 0 },          // Expects a timeout
116
    { NULL              , NULL          , 0 }
117
};
118
 
119
//==========================================================================
120
 
121
void
122
chat_test(cyg_addrword_t p)
123
{
124
    cyg_serial_baud_rate_t old;
125
    cyg_int32 failures = 0;
126
    cyg_int32 result;
127
    struct test_info *test;
128
 
129
    CYG_TEST_INIT();
130
 
131
    CYG_TEST_INFO("Start CHAT test");
132
 
133
    old = ppp_test_set_baud( CYGNUM_SERIAL_BAUD_115200 );
134
 
135
    for( test = &tests[0]; test->name != NULL; test++ )
136
    {
137
        CYG_TEST_INFO( test->name );
138
        ppp_test_announce( test->name );
139
 
140
        result = cyg_ppp_chat( CYGPKG_PPP_TEST_DEVICE, test->script );
141
 
142
        diag_printf("chat result %d expected %d\n",result,test->result );
143
 
144
        if( result != test->result )
145
        {
146
            CYG_TEST_FAIL( test->name );
147
            failures++;
148
        }
149
        else
150
            CYG_TEST_PASS( test->name );
151
 
152
        cyg_thread_delay( 300 );
153
    }
154
 
155
    ppp_test_set_baud( old );
156
 
157
    ppp_test_finish();
158
 
159
//    ppp_test_announce( "CHAT_TEST_1" );
160
 
161
//    success = cyg_ppp_chat( CYGPKG_PPP_TEST_DEVICE, script );
162
 
163
//    if( !success )
164
//        CYG_TEST_INFO("Chat script failed");
165
 
166
    CYG_TEST_FINISH("CHAT test done");
167
}
168
 
169
//==========================================================================
170
 
171
void
172
cyg_start(void)
173
{
174
    // Create a main thread, so we can run the scheduler and have time 'pass'
175
    cyg_thread_create(10,                // Priority - just a number
176
                      chat_test,          // entry
177
                      0,                 // entry parameter
178
                      "CHAT test",        // Name
179
                      &stack[0],         // Stack
180
                      STACK_SIZE,        // Size
181
                      &thread_handle,    // Handle
182
                      &thread_data       // Thread data structure
183
            );
184
    cyg_thread_resume(thread_handle);  // Start it
185
    cyg_scheduler_start();
186
}
187
 
188
//==========================================================================

powered by: WebSVN 2.1.0

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