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

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

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