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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [language/] [c/] [libc/] [stdio/] [current/] [tests/] [stdiooutput.c] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//=================================================================
2
//
3
//        stdiooutput.c
4
//
5
//        Testcase for miscellaneous C library output functions
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
//=================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):       jlarmour
43
// Contributors:    
44
// Date:            2000-04-20
45
// Description:     Contains testcode for C library stdio output
46
//                  functions
47
//
48
//
49
//####DESCRIPTIONEND####
50
 
51
// CONFIGURATION
52
 
53
#include <pkgconf/libc_stdio.h>   // Configuration header
54
 
55
// INCLUDES
56
 
57
#include <stdio.h>                 // All the stdio functions
58
#include <errno.h>                 // errno
59
#include <cyg/infra/testcase.h>    // Testcase API
60
 
61
// FUNCTIONS
62
 
63
static void
64
test( CYG_ADDRWORD data )
65
{
66
    int i;
67
 
68
 
69
    // Check 1
70
    CYG_TEST_INFO("Expect: Hello printf world 42!");
71
    printf("Hello printf %s %d!\n", "world", 42);
72
 
73
    // Check 2
74
    CYG_TEST_INFO("Expect: This is fprintf 0x07f!");
75
    fprintf(stdout, "This is fprintf 0x%03x!\n", 0x7f);
76
 
77
    // Check 3
78
    CYG_TEST_INFO("Expect: char tests");
79
    fputc( 'c', stderr );
80
    putc( 'h', stdout );
81
    putchar( 'a' );
82
    fputc( 'r', stdout );
83
    putchar( ' ' );
84
    fflush(stdout);
85
    putc( 't', stderr );
86
    fputc( 'e', stdout );
87
    putchar( 's' );
88
    fflush( NULL );
89
    putc( 't', stderr );
90
    fputc( 's', stderr );
91
    putchar( '\n' );
92
 
93
    // Check 4
94
    CYG_TEST_INFO("Expect: puts test");
95
    puts("puts test");
96
 
97
    // Check 5
98
    CYG_TEST_INFO("Expect: fputs test");
99
    fputs( "fputs test\n", stdout );
100
 
101
    // Check 6
102
    CYG_TEST_INFO("Expect: fwrite test");
103
    fwrite( "fwrite test\n", 6, 2, stderr );
104
 
105
    // Check 7
106
    CYG_TEST_INFO("Expect: wibble: No error");
107
    errno = ENOERR;
108
    perror( "wibble" );
109
 
110
    // Check 8
111
    CYG_TEST_INFO("Expect: Long string test!\nSitting on the side of the "
112
                  "highway waiting to catch speeding drivers, a State "
113
                  "Police Officer sees a car puttering along at 22 MPH. "
114
                  "He thinks to himself, \"This driver is just as "
115
                  "dangerous as a speeder!\" So he turns on his lights "
116
                  "and pulls the driver over. Approaching the car, "
117
                  "he notices that there are five old ladies-two in "
118
                  "the front seat and three in the back-wide eyed and "
119
                  "white as ghosts. The driver, obviously confused, says "
120
                  "to him, \"Officer, I don't understand, I was doing "
121
                  "exactly the speed limit! What seems to be the "
122
                  "problem?\" \"Ma'am,\" the officer replies, \"you "
123
                  "weren't speeding, but you should know that driving "
124
                  "slower than the speed limit can also be a danger to "
125
                  "other drivers.\" \"Slower than the speed limit? No "
126
                  "sir, I was doing the speed limit exactly...Twenty-two "
127
                  "miles an hour!\" the old woman says a bit proudly. "
128
                  "The State Police officer, trying to contain a "
129
                  "chuckle explains to her that \"22\" was the route "
130
                  "number, not the speed limit. A bit embarrassed, the "
131
                  "woman grinned and thanked the officer for pointing "
132
                  "out her error. \"But before I let you go, Ma'am, I "
133
                  "have to ask... Is everyone in this car OK? These "
134
                  "women seem awfully shaken and they haven't muttered a "
135
                  "single peep this whole time,\" the officer asks. \"Oh, "
136
                  "they'll be all right in a minute officer. We just got "
137
                  "off Route 119\".");
138
 
139
    printf("Long string test!\nSitting on the side of the "
140
           "highway waiting to catch speeding drivers, a State "
141
           "Police Officer sees a car puttering along at %d MPH. "
142
           "He thinks to himself, \"This driver is just as "
143
           "dangerous as a speeder!\" So he turns on his lights "
144
           "and pulls the driver over. Approaching the car, "
145
           "he notices that there are five old ladies-two in "
146
           "the front seat and three in the back-wide eyed and "
147
           "white as ghosts. The driver, obviously confused, says "
148
           "to him, \"Officer, I don't understand, I was doing "
149
           "exactly the speed limit! What seems to be the "
150
           "problem?\" \"Ma'am,\" the officer replies, \"you "
151
           "weren't speeding, but you should know that driving "
152
           "slower than the speed limit can also be a danger to "
153
           "other drivers.\" \"Slower than the speed limit? No "
154
           "sir, I was doing the speed limit exactly...Twenty-two "
155
           "miles an hour!\" the old woman says a bit proudly. "
156
           "The State Police officer, trying to contain a "
157
           "chuckle explains to her that \"%d\" was the route "
158
           "number, not the speed limit. A bit embarrassed, the "
159
           "%coman grinned and thanked the officer for pointing "
160
           "out her error. \"But before I let you go, Ma'am, I "
161
           "have to ask... Is everyone in this car OK? These "
162
           "women seem awfully shaken and they haven't muttered a "
163
           "single peep this whole time,\" the officer asks. \"Oh, "
164
           "they'll be all right in a minute officer. We just got "
165
           "off Route %d\".\n", 22, 22, 'w', 119);
166
 
167
    // Check 9
168
    CYG_TEST_INFO("Expect: Another puts test, just for fun");
169
    puts("Another puts test, just for fun");
170
 
171
    // Check 10
172
    CYG_TEST_INFO("Expect: more fputs testing");
173
    fputs( "more fputs testing\n", stderr );
174
 
175
    // Check 11
176
    CYG_TEST_INFO("Expect all the numbers from 1 to 100 in 5 columns");
177
    for (i=1; i<101; ++i) {
178
 
179
        printf("%5d ", i);
180
        if (i%5 == 0)
181
            fputc( '\n', stdout);
182
 
183
    } // for
184
 
185
    CYG_TEST_PASS("Stdio output tests completed");
186
    CYG_TEST_FINISH("Finished tests from testcase " __FILE__
187
                    " for C library stdio output functions");
188
 
189
} // test()
190
 
191
int
192
main(int argc, char *argv[])
193
{
194
    CYG_TEST_INIT();
195
 
196
    CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C "
197
                  "library stdio output functions");
198
    CYG_TEST_INFO("The output of these tests needs to be manually "
199
                  "verified.");
200
 
201
    test(0);
202
 
203
    return 0;
204
 
205
} // main()
206
 
207
// EOF stdiooutput.c

powered by: WebSVN 2.1.0

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