source: rtems/testsuites/psxtests/psxobj01/init.c @ c0d5778

4.11
Last change on this file since c0d5778 was c0d5778, checked in by Joel Sherrill <joel.sherrill@…>, on Jul 27, 2010 at 8:16:23 PM

2010-07-27 Joel Sherrill <joel.sherrill@…>

  • psxobj01/Makefile.am, psxobj01/init.c, psxobj01/psxobj01.scn: Add test for runnign out of workspace when setting object name as string.
  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*  Odd Object Name/Id Error Cases
2 *
3 *  COPYRIGHT (c) 1989-2009.
4 *  On-Line Applications Research Corporation (OAR).
5 *
6 *  The license and distribution terms for this file may be
7 *  found in the file LICENSE in this distribution or at
8 *  http://www.rtems.com/license/LICENSE.
9 *
10 *  $Id$
11 */
12
13#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
14#include <tmacros.h>
15#include "test_support.h"
16
17rtems_task Init(
18  rtems_task_argument ignored
19)
20{
21  Objects_Name_or_id_lookup_errors namerc;
22  Objects_Information              TestClass;
23  Objects_Id                       id;
24  char                             name[64];
25  bool                             bc;
26
27  puts( "\n\n*** POSIX OBJECT TEST 1 ***" );
28
29  /* very fake object class to test with */
30  _Objects_Initialize_information(
31    &TestClass,
32    1,           /* the_api */
33    4,           /* the_class */
34    0,           /* maximum */
35    4,           /* size */
36    true,        /* is_string */
37    10           /* maximum_name_length */
38    #if defined(RTEMS_MULTIPROCESSING)
39      ,
40      false,       /* supports_global */
41      NULL         /* Objects_Thread_queue_Extract_callout extract */
42    #endif
43  );
44
45  puts( "INIT - _Objects_Name_to_id_string - NULL name" );
46  namerc = _Objects_Name_to_id_string( &TestClass, NULL, &id );
47  if ( namerc != OBJECTS_INVALID_NAME ) {
48    printf( "ERROR - Status = %d\n", namerc );
49    rtems_test_exit(0);
50  }
51
52  puts( "INIT - _Objects_Name_to_id_string - NULL ID" );
53  namerc = _Objects_Name_to_id_string( &TestClass, name, NULL );
54  if ( namerc != OBJECTS_INVALID_ADDRESS ) {
55    printf( "ERROR - Status = %d\n", namerc );
56    rtems_test_exit(0);
57  }
58
59  puts( "INIT - _Objects_Name_to_id_string - name of non-existent object" );
60  strcpy( name, "NOT FOUND" );
61  namerc = _Objects_Name_to_id_string( &TestClass, name, &id );
62  if ( namerc != OBJECTS_INVALID_NAME ) {
63    printf( "ERROR - Status = %d\n", namerc );
64    rtems_test_exit(0);
65  }
66
67  /* out of memory error ONLY when POSIX is enabled */
68  puts( "INIT - _Objects_Set_name fails - out of memory" );
69  Allocate_majority_of_workspace( 1 );
70
71  bc = _Objects_Set_name( &TestClass, &_Thread_Executing->Object, name );
72  rtems_test_assert( bc == false );
73
74  puts( "*** END OF POSIX OBJECT TEST 1 ***" );
75  rtems_test_exit(0);
76}
77
78/* configuration information */
79
80#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
81#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
82
83#define CONFIGURE_MAXIMUM_TASKS  1
84#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
85
86#define CONFIGURE_INIT
87#include <rtems/confdefs.h>
88
89/* global variables */
Note: See TracBrowser for help on using the repository browser.