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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [language/] [c/] [libc/] [stdio/] [v2_0/] [tests/] [stdiooutput.c] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
//=================================================================
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 Red Hat, 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 version.
16
//
17
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
20
// for more details.
21
//
22
// You should have received a copy of the GNU General Public License along
23
// with eCos; if not, write to the Free Software Foundation, Inc.,
24
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25
//
26
// As a special exception, if other files instantiate templates or use macros
27
// or inline functions from this file, or you compile this file and link it
28
// with other works to produce a work based on this file, this file does not
29
// by itself cause the resulting work to be covered by the GNU General Public
30
// License. However the source code for this file must still be made available
31
// in accordance with section (3) of the GNU General Public License.
32
//
33
// This exception does not invalidate any other reasons why a work based on
34
// this file might be covered by the GNU General Public License.
35
//
36
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37
// at http://sources.redhat.com/ecos/ecos-license/
38
// -------------------------------------------
39
//####ECOSGPLCOPYRIGHTEND####
40
//=================================================================
41
//#####DESCRIPTIONBEGIN####
42
//
43
// Author(s):       jlarmour
44
// Contributors:    
45
// Date:            2000-04-20
46
// Description:     Contains testcode for C library stdio output
47
//                  functions
48
//
49
//
50
//####DESCRIPTIONEND####
51
 
52
// CONFIGURATION
53
 
54
#include <pkgconf/libc_stdio.h>   // Configuration header
55
 
56
// INCLUDES
57
 
58
#include <stdio.h>                 // All the stdio functions
59
#include <errno.h>                 // errno
60
#include <cyg/infra/testcase.h>    // Testcase API
61
 
62
// FUNCTIONS
63
 
64
static void
65
test( CYG_ADDRWORD data )
66
{
67
    int i;
68
 
69
 
70
    // Check 1
71
    CYG_TEST_INFO("Expect: Hello printf world 42!");
72
    printf("Hello printf %s %d!\n", "world", 42);
73
 
74
    // Check 2
75
    CYG_TEST_INFO("Expect: This is fprintf 0x07f!");
76
    fprintf(stdout, "This is fprintf 0x%03x!\n", 0x7f);
77
 
78
    // Check 3
79
    CYG_TEST_INFO("Expect: char tests");
80
    fputc( 'c', stderr );
81
    putc( 'h', stdout );
82
    putchar( 'a' );
83
    fputc( 'r', stdout );
84
    putchar( ' ' );
85
    fflush(stdout);
86
    putc( 't', stderr );
87
    fputc( 'e', stdout );
88
    putchar( 's' );
89
    fflush( NULL );
90
    putc( 't', stderr );
91
    fputc( 's', stderr );
92
    putchar( '\n' );
93
 
94
    // Check 4
95
    CYG_TEST_INFO("Expect: puts test");
96
    puts("puts test");
97
 
98
    // Check 5
99
    CYG_TEST_INFO("Expect: fputs test");
100
    fputs( "fputs test\n", stdout );
101
 
102
    // Check 6
103
    CYG_TEST_INFO("Expect: fwrite test");
104
    fwrite( "fwrite test\n", 6, 2, stderr );
105
 
106
    // Check 7
107
    CYG_TEST_INFO("Expect: wibble: No error");
108
    errno = ENOERR;
109
    perror( "wibble" );
110
 
111
    // Check 8
112
    CYG_TEST_INFO("Expect: Long string test!\nSitting on the side of the "
113
                  "highway waiting to catch speeding drivers, a State "
114
                  "Police Officer sees a car puttering along at 22 MPH. "
115
                  "He thinks to himself, \"This driver is just as "
116
                  "dangerous as a speeder!\" So he turns on his lights "
117
                  "and pulls the driver over. Approaching the car, "
118
                  "he notices that there are five old ladies-two in "
119
                  "the front seat and three in the back-wide eyed and "
120
                  "white as ghosts. The driver, obviously confused, says "
121
                  "to him, \"Officer, I don't understand, I was doing "
122
                  "exactly the speed limit! What seems to be the "
123
                  "problem?\" \"Ma'am,\" the officer replies, \"you "
124
                  "weren't speeding, but you should know that driving "
125
                  "slower than the speed limit can also be a danger to "
126
                  "other drivers.\" \"Slower than the speed limit? No "
127
                  "sir, I was doing the speed limit exactly...Twenty-two "
128
                  "miles an hour!\" the old woman says a bit proudly. "
129
                  "The State Police officer, trying to contain a "
130
                  "chuckle explains to her that \"22\" was the route "
131
                  "number, not the speed limit. A bit embarrassed, the "
132
                  "woman grinned and thanked the officer for pointing "
133
                  "out her error. \"But before I let you go, Ma'am, I "
134
                  "have to ask... Is everyone in this car OK? These "
135
                  "women seem awfully shaken and they haven't muttered a "
136
                  "single peep this whole time,\" the officer asks. \"Oh, "
137
                  "they'll be all right in a minute officer. We just got "
138
                  "off Route 119\".");
139
 
140
    printf("Long string test!\nSitting on the side of the "
141
           "highway waiting to catch speeding drivers, a State "
142
           "Police Officer sees a car puttering along at %d MPH. "
143
           "He thinks to himself, \"This driver is just as "
144
           "dangerous as a speeder!\" So he turns on his lights "
145
           "and pulls the driver over. Approaching the car, "
146
           "he notices that there are five old ladies-two in "
147
           "the front seat and three in the back-wide eyed and "
148
           "white as ghosts. The driver, obviously confused, says "
149
           "to him, \"Officer, I don't understand, I was doing "
150
           "exactly the speed limit! What seems to be the "
151
           "problem?\" \"Ma'am,\" the officer replies, \"you "
152
           "weren't speeding, but you should know that driving "
153
           "slower than the speed limit can also be a danger to "
154
           "other drivers.\" \"Slower than the speed limit? No "
155
           "sir, I was doing the speed limit exactly...Twenty-two "
156
           "miles an hour!\" the old woman says a bit proudly. "
157
           "The State Police officer, trying to contain a "
158
           "chuckle explains to her that \"%d\" was the route "
159
           "number, not the speed limit. A bit embarrassed, the "
160
           "%coman grinned and thanked the officer for pointing "
161
           "out her error. \"But before I let you go, Ma'am, I "
162
           "have to ask... Is everyone in this car OK? These "
163
           "women seem awfully shaken and they haven't muttered a "
164
           "single peep this whole time,\" the officer asks. \"Oh, "
165
           "they'll be all right in a minute officer. We just got "
166
           "off Route %d\".\n", 22, 22, 'w', 119);
167
 
168
    // Check 9
169
    CYG_TEST_INFO("Expect: Another puts test, just for fun");
170
    puts("Another puts test, just for fun");
171
 
172
    // Check 10
173
    CYG_TEST_INFO("Expect: more fputs testing");
174
    fputs( "more fputs testing\n", stderr );
175
 
176
    // Check 11
177
    CYG_TEST_INFO("Expect all the numbers from 1 to 100 in 5 columns");
178
    for (i=1; i<101; ++i) {
179
 
180
        printf("%5d ", i);
181
        if (i%5 == 0)
182
            fputc( '\n', stdout);
183
 
184
    } // for
185
 
186
    CYG_TEST_PASS("Stdio output tests completed");
187
    CYG_TEST_FINISH("Finished tests from testcase " __FILE__
188
                    " for C library stdio output functions");
189
 
190
} // test()
191
 
192
int
193
main(int argc, char *argv[])
194
{
195
    CYG_TEST_INIT();
196
 
197
    CYG_TEST_INFO("Starting tests from testcase " __FILE__ " for C "
198
                  "library stdio output functions");
199
    CYG_TEST_INFO("The output of these tests needs to be manually "
200
                  "verified.");
201
 
202
    test(0);
203
 
204
    return 0;
205
 
206
} // main()
207
 
208
// EOF stdiooutput.c

powered by: WebSVN 2.1.0

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