source: rtems/testsuites/psxtests/psxobj01/init.c @ 9a4eca5

5
Last change on this file since 9a4eca5 was f05eeb2, checked in by Sebastian Huber <sebastian.huber@…>, on 04/19/16 at 11:39:00

score: Simplify _Objects_Initialize_information()

Remove unused supports_global parameter. Convert
_Objects_Initialize_information() to a macro to avoid use of
RTEMS_MULTIPROCESSING define for each caller.

  • Property mode set to 100644
File size: 2.9 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
23const char rtems_test_name[] = "PSXOBJ 1";
24
25/* forward declarations to avoid warnings */
26rtems_task Init(rtems_task_argument ignored);
27
28rtems_task Init(
29  rtems_task_argument ignored
30)
31{
32  Objects_Get_by_name_error  error;
33  Objects_Information        TestClass;
34  Objects_Control           *the_object;
35  char                       name[64];
36  size_t                     name_len;
37  bool                       bc;
38
39  TEST_BEGIN();
40
41  /* very fake object class to test with */
42  _Objects_Initialize_information(
43    &TestClass,
44    1,           /* the_api */
45    4,           /* the_class */
46    0,           /* maximum */
47    4,           /* size */
48    true,        /* is_string */
49    10,          /* maximum_name_length */
50    NULL         /* Objects_Thread_queue_Extract_callout extract */
51  );
52
53
54  puts( "INIT - _Objects_Get_by_name - NULL name" );
55  _Objects_Allocator_lock();
56  the_object = _Objects_Get_by_name( &TestClass, NULL, NULL, &error );
57  _Objects_Allocator_unlock();
58  rtems_test_assert( the_object == NULL );
59  rtems_test_assert( error == OBJECTS_GET_BY_NAME_INVALID_NAME );
60
61  puts( "INIT - _Objects_Get_by_name - name too long" );
62  strcpy( name, "TOOOOOOOOOOOOOOOOOO LONG" );
63  _Objects_Allocator_lock();
64  the_object = _Objects_Get_by_name( &TestClass, name, NULL, &error );
65  _Objects_Allocator_unlock();
66  rtems_test_assert( the_object == NULL );
67  rtems_test_assert( error == OBJECTS_GET_BY_NAME_NAME_TOO_LONG );
68
69  puts( "INIT - _Objects_Get_by_name - name of non-existent object" );
70  strcpy( name, "NOT FOUND" );
71  name_len = 123;
72  _Objects_Allocator_lock();
73  the_object = _Objects_Get_by_name( &TestClass, name, &name_len, &error );
74  _Objects_Allocator_unlock();
75  rtems_test_assert( the_object == NULL );
76  rtems_test_assert( error == OBJECTS_GET_BY_NAME_NO_OBJECT );
77  rtems_test_assert( name_len == 9 );
78
79  /* out of memory error ONLY when POSIX is enabled */
80  puts( "INIT - _Objects_Set_name fails - out of memory" );
81  rtems_workspace_greedy_allocate( NULL, 0 );
82
83  bc = _Objects_Set_name( &TestClass, &_Thread_Get_executing()->Object, name );
84  rtems_test_assert( bc == false );
85
86  TEST_END();
87  rtems_test_exit(0);
88}
89
90/* configuration information */
91
92#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
93#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
94
95#define CONFIGURE_MAXIMUM_TASKS  1
96#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
97
98#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
99
100#define CONFIGURE_INIT
101#include <rtems/confdefs.h>
102
103/* global variables */
Note: See TracBrowser for help on using the repository browser.