source: rtems/testsuites/libtests/bspcmdline01/init.c @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 4.7 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2009.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <tmacros.h>
15#include <rtems/bspcmdline.h>
16
17extern const char *bsp_boot_cmdline;
18
19void test_errors(void)
20{
21  const char *p;
22  char        result[32];
23
24  bsp_boot_cmdline = NULL;
25
26  puts( "rtems_bsp_cmdline_get_param - name=NULL - returns NULL" );
27  p = rtems_bsp_cmdline_get_param( NULL, result, 32 );
28  rtems_test_assert( p == NULL );
29
30  puts( "rtems_bsp_cmdline_get_param - result=NULL - returns NULL" );
31  p = rtems_bsp_cmdline_get_param( "name", NULL, 32 );
32  rtems_test_assert( p == NULL );
33
34  puts( "rtems_bsp_cmdline_get_param - length=0 - returns NULL" );
35  p = rtems_bsp_cmdline_get_param( "name", result, 0 );
36  rtems_test_assert( p == NULL );
37
38  puts( "rtems_bsp_cmdline_get_param_raw - name=NULL - returns NULL" );
39  p = rtems_bsp_cmdline_get_param_raw( NULL );
40  rtems_test_assert( p == NULL );
41
42  bsp_boot_cmdline = NULL;
43
44  puts( "rtems_bsp_cmdline_get_param - bsp_boot_cmdline=NULL - returns NULL" );
45  p = rtems_bsp_cmdline_get_param( "name", result, 5 );
46  rtems_test_assert( p == NULL );
47
48  puts(
49    "rtems_bsp_cmdline_get_param_raw - bsp_boot_cmdline=NULL - returns NULL" );
50  p = rtems_bsp_cmdline_get_param_raw( "name" );
51  rtems_test_assert( p == NULL );
52 
53  bsp_boot_cmdline = "edit";
54  puts (
55    "rtems_bsp_cmdline_get_param - bsp_boot_cmdline = edit name = "
56      "edit -no error" );
57  p = rtems_bsp_cmdline_get_param("edit", result, 5);
58  rtems_test_assert( p != NULL );
59
60  bsp_boot_cmdline = "joel=123456789";
61  puts( "rtems_bsp_cmdline_get_param - too short buffer" );
62  p = rtems_bsp_cmdline_get_param("joel", result, 5);
63  rtems_test_assert( p != NULL );
64
65  bsp_boot_cmdline = "--arg1=X`";
66  puts( "rtems_bsp_cmdline_get_param_rhs - short match" );
67  p = rtems_bsp_cmdline_get_param_rhs("arg", result, 10);
68  rtems_test_assert( p == NULL );
69}
70
71void test_search(
72  bool        null_expected,
73  const char *cmdline,
74  const char *param
75)
76{
77  const char *p;
78  char        value[80];
79  size_t      length;
80
81  bsp_boot_cmdline = cmdline;
82
83  printf(
84    "\n"
85    "Testing for param=(%s)%s\n"
86    "  Command Line : (%s)\n",
87    param,
88    ((null_expected) ? " - Expect NULL" : ""),
89    cmdline
90  );
91
92  printf( "rtems_bsp_cmdline_get_param_raw(%s)\n", param );
93  p = rtems_bsp_cmdline_get_param_raw( param );
94  if ( null_expected ) {
95    if ( p )
96      puts( "ERROR - rtems_bsp_cmdline_get_param_raw did not return NULL" );
97    else
98      printf( "rtems_bsp_cmdline_get_param_raw(%s) returned NULL\n", param );
99    rtems_test_assert( !p );
100  } else {
101    if ( p )
102      printf( "rtems_bsp_cmdline_get_param_raw(%s) returned (%s)\n", param, p );
103    else
104      printf( "rtems_bsp_cmdline_get_param_raw(%s) returned NULL\n", param );
105
106    rtems_test_assert( p );
107  }
108
109  printf( "rtems_bsp_cmdline_get_param_rhs(%s)\n", param );
110  length = sizeof(value);
111  p = rtems_bsp_cmdline_get_param_rhs( param, value, length );
112  if ( null_expected ) {
113    if ( p )
114      puts( "ERROR - rtems_bsp_cmdline_get_param_rhs did not return NULL" );
115    else
116      printf( "rtems_bsp_cmdline_get_param_rhs(%s) returned NULL\n", param );
117    rtems_test_assert( !p );
118  } else {
119    if ( !p )
120      puts( "ERROR - rtems_bsp_cmdline_get_param_rhs returned NULL" );
121    rtems_test_assert( p );
122    printf(
123      "rtems_bsp_cmdline_get_param_rhs(%s) returned (%s) value=(%s)\n",
124      param,
125      ((*p == '\0') ? "ZERO_LENGTH_STRING" : p ),
126      ((*value == '\0') ? "ZERO_LENGTH_STRING" : value )
127    );
128  }
129
130}
131
132rtems_task Init(
133  rtems_task_argument ignored
134)
135{
136  const char *bspcmdline;
137
138  puts( "\n\n*** TEST OF PARSING BOOT COMMAND STRING ***" );
139
140  bspcmdline = rtems_bsp_cmdline_get();
141  if ( bspcmdline ) {
142    printf(
143      "BSP has a boot command line:\n"
144      "%s\n",
145      bspcmdline
146    );
147  } else {
148    puts( "BSP does not have a boot command line" );
149  }
150
151  puts( "\nTest Parameter Error Conditions" );
152  test_errors();
153
154  test_search( false, "--arg=", "--arg" );
155  test_search( true, "--arg=", "-g" );
156  test_search( false, "--ip=192.168.1.151 --name=fred", "-name" );
157  test_search( false, "--ip=192.168.1.151 --name=fred", "-ip" );
158  test_search(
159    false,
160    "--ip=192.168.1.151 --name=\"joel and michele\" --cpu=fast",
161    "-name"
162    );
163
164  puts( "*** END OF OF PARSING BOOT COMMAND STRING ***" );
165  rtems_test_exit(0);
166}
167
168/* configuration information */
169
170#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
171#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
172
173#define CONFIGURE_MAXIMUM_TASKS         1
174#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
175
176#define CONFIGURE_INIT
177#include <rtems/confdefs.h>
178
179/* global variables */
Note: See TracBrowser for help on using the repository browser.