source: rtems/testsuites/sptests/spprintk/init.c @ a54d10d

5
Last change on this file since a54d10d was af43554, checked in by Sebastian Huber <sebastian.huber@…>, on 10/26/17 at 11:59:11

tests: Remove TEST_INIT

The TEST_EXTERN is a used only by the system.h style tests and they use
CONFIGURE_INIT appropriately.

Update #3170.
Update #3199.

  • Property mode set to 100644
File size: 4.2 KB
Line 
1/*
2 *  Exercise putk, printk, and getchark
3 *
4 *  COPYRIGHT (c) 1989-2010.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.org/license/LICENSE.
10 */
11
12#ifdef HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <rtems/score/basedefs.h>
17
18/*
19 * Undefined the RTEMS_PRINTFLIKE and make it nothing. The test code
20 * contained in the file is suppose to be wrong.
21 */
22#undef RTEMS_PRINTFLIKE
23#define RTEMS_PRINTFLIKE(_a, _b)
24
25#include <rtems/bspIo.h>
26#include <tmacros.h>
27
28const char rtems_test_name[] = "SPPRINTK";
29
30/* forward declarations to avoid warnings */
31rtems_task Init(rtems_task_argument argument);
32int test_getchar(void);
33void do_getchark(void);
34void do_putk(void);
35void do_printk(void);
36
37int test_getchar(void)
38{
39  return 0x35;
40}
41
42void do_getchark(void)
43{
44  int                                sc;
45  BSP_polling_getchar_function_type  poll_char;
46
47  poll_char = BSP_poll_char;
48
49  BSP_poll_char = NULL;
50
51  putk( "getchark - NULL getchar method - return -1" );
52  sc = getchark();
53  rtems_test_assert( sc == -1 );
54
55  putk( "getchark - test getchar method - returns 0x35" );
56  BSP_poll_char = test_getchar;
57  sc = getchark();
58  rtems_test_assert( sc == 0x35 );
59
60  BSP_poll_char = poll_char;
61}
62
63void do_putk(void)
64{
65  putk( "This is a test of putk" );
66}
67
68void do_printk(void)
69{
70  long lm = 2147483647L;
71  unsigned long ulm = 4294967295UL;
72  long long llm = 9223372036854775807LL;
73  long long ullm = 18446744073709551615ULL;
74
75  printk( "bad format -- %%q in parentheses (%q)\n" );
76
77  printk( "bad format -- %%lq in parentheses (%lq)\n", 0x1234 );
78
79  printk( "%%O octal upper case 16 -- %O\n", 16 );
80  printk( "%%o octal lower case of 16 -- %O\n", 16 );
81  printk( "%%I of 16 -- %I\n", 16 );
82  printk( "%%i of 16 -- %i\n", 16 );
83  printk( "%%D of 16 -- %D\n", 16 );
84  printk( "%%d of 16 -- %d\n", 16 );
85  printk( "%%-3d of 16 -- %-3d\n", 16 );
86  printk( "%%U of 16 -- %U\n", 16 );
87  printk( "%%u of 16 -- %u\n", 16 );
88  printk( "%%X of 16 -- %X\n", 16 );
89  printk( "%%x of 16 -- %x\n", 16 );
90  printk( "%%p of 0x1234 -- %p\n", (void *)0x1234 );
91
92  /* long */
93  printk( "%%lo of 2147483647 -- %lo\n", lm );
94  printk( "%%li of 2147483647 -- %li\n", lm );
95  printk( "%%lu of 2147483647 -- %lu\n", lm );
96  printk( "%%lx of 2147483647 -- %lx\n", lm );
97  printk( "%%lo of -2147483648 -- %lo\n", -lm - 1L );
98  printk( "%%li of -2147483648 -- %li\n", -lm - 1L );
99  printk( "%%lx of -2147483648 -- %lx\n", -lm - 1L );
100  printk( "%%lo of 4294967295 -- %lo\n", ulm );
101  printk( "%%lu of 4294967295 -- %lu\n", ulm );
102  printk( "%%lx of 4294967295 -- %lx\n", ulm );
103
104  /* long long */
105  printk( "%%llo of 9223372036854775807 -- %llo\n", llm );
106  printk( "%%lli of 9223372036854775807 -- %lli\n", llm );
107  printk( "%%llu of 9223372036854775807 -- %llu\n", llm );
108  printk( "%%llx of 9223372036854775807 -- %llx\n", llm );
109  printk( "%%llo of -9223372036854775808 -- %llo\n", -llm - 1LL );
110  printk( "%%lli of -9223372036854775808 -- %lli\n", -llm - 1LL );
111  printk( "%%llx of -9223372036854775808 -- %llx\n", -llm - 1LL );
112  printk( "%%llo of 18446744073709551615 -- %llo\n", ullm );
113  printk( "%%llu of 18446744073709551615 -- %llu\n", ullm );
114  printk( "%%llx of 18446744073709551615 -- %llx\n", ullm );
115
116  /* negative numbers */
117  printk( "%%d of -16 -- %d\n", -16 );
118  printk( "%%d of -16 -- %-3d\n", -16 );
119  printk( "%%u of -16 -- %u\n", -16 );
120
121  /* string formats */
122  printk( "%%s of Mary Had a Little Lamb -- (%s)\n",
123          "Mary Had a Little Lamb" );
124  printk( "%%s of NULL -- (%s)\n", NULL );
125  printk( "%%12s of joel -- (%20s)\n", "joel" );
126  printk( "%%4s of joel -- (%4s)\n", "joel" );
127  printk( "%%-12s of joel -- (%-20s)\n", "joel" );
128  printk( "%%-4s of joel -- (%-4s)\n", "joel" );
129  printk( "%%c of X -- (%c)\n", 'X' );
130}
131
132rtems_task Init(
133  rtems_task_argument argument
134)
135{
136  TEST_BEGIN();
137
138  do_putk();
139  putk("");
140
141  do_printk();
142  putk("");
143
144  do_getchark();
145
146  TEST_END();
147  rtems_test_exit( 0 );
148}
149
150/* configuration information */
151
152#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
153
154#define CONFIGURE_MAXIMUM_TASKS           1
155
156#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
157
158#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
159
160#define CONFIGURE_INIT
161
162#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.