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

Last change on this file since 9c9c6a9 was 9c9c6a9, checked in by Sebastian Huber <sebastian.huber@…>, on Nov 21, 2018 at 4:30:52 PM

score: Remove Objects_Information::is_string

Use Objects_Information::name_length to store this information.

Update #3621.

  • Property mode set to 100644
File size: 2.8 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    10,          /* maximum_name_length */
49    NULL         /* Objects_Thread_queue_Extract_callout extract */
50  );
51
52
53  puts( "INIT - _Objects_Get_by_name - NULL name" );
54  _Objects_Allocator_lock();
55  the_object = _Objects_Get_by_name( &TestClass, NULL, NULL, &error );
56  _Objects_Allocator_unlock();
57  rtems_test_assert( the_object == NULL );
58  rtems_test_assert( error == OBJECTS_GET_BY_NAME_INVALID_NAME );
59
60  puts( "INIT - _Objects_Get_by_name - name too long" );
61  strcpy( name, "TOOOOOOOOOOOOOOOOOO LONG" );
62  _Objects_Allocator_lock();
63  the_object = _Objects_Get_by_name( &TestClass, name, NULL, &error );
64  _Objects_Allocator_unlock();
65  rtems_test_assert( the_object == NULL );
66  rtems_test_assert( error == OBJECTS_GET_BY_NAME_NAME_TOO_LONG );
67
68  puts( "INIT - _Objects_Get_by_name - name of non-existent object" );
69  strcpy( name, "NOT FOUND" );
70  name_len = 123;
71  _Objects_Allocator_lock();
72  the_object = _Objects_Get_by_name( &TestClass, name, &name_len, &error );
73  _Objects_Allocator_unlock();
74  rtems_test_assert( the_object == NULL );
75  rtems_test_assert( error == OBJECTS_GET_BY_NAME_NO_OBJECT );
76  rtems_test_assert( name_len == 9 );
77
78  /* out of memory error ONLY when POSIX is enabled */
79  puts( "INIT - _Objects_Set_name fails - out of memory" );
80  rtems_workspace_greedy_allocate( NULL, 0 );
81
82  bc = _Objects_Set_name( &TestClass, &_Thread_Get_executing()->Object, name );
83  rtems_test_assert( bc == false );
84
85  TEST_END();
86  rtems_test_exit(0);
87}
88
89/* configuration information */
90
91#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
92#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
93
94#define CONFIGURE_MAXIMUM_TASKS  1
95#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
96
97#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
98
99#define CONFIGURE_INIT
100#include <rtems/confdefs.h>
101
102/* global variables */
Note: See TracBrowser for help on using the repository browser.