source: rtems/testsuites/libtests/uid01/init.c @ 3cec2df

5
Last change on this file since 3cec2df was 3cec2df, checked in by Sebastian Huber <sebastian.huber@…>, on 12/17/19 at 08:17:43

config: CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS

Rename CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS into
CONFIGURE_MAXIMUM_FILE_DESCRIPTORS.

Update #3753.

  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*
2 * Copyright (c) 2013 Daniel Ramirez <javamonn@gmail.com>
3 *
4 * The license and distribution terms for this file may be
5 * found in the file LICENSE in this distribution or at
6 * http://www.rtems.org/license/LICENSE.
7 */
8
9#ifdef HAVE_CONFIG_H
10#include "config.h"
11#endif
12
13#include <bsp.h>
14
15#include <stdlib.h>
16#include <stdio.h>
17
18#include <sys/types.h>
19#include <sys/stat.h>
20#include <fcntl.h>
21#include <sys/ioctl.h>
22#include <unistd.h>
23#include <rtems/mw_uid.h>
24#include "../termios04/termios_testdriver_intr.h"
25#include "tmacros.h"
26
27const char rtems_test_name[] = "UID 1";
28
29#define UID_MESSAGE_COUNT 10
30
31/* forward declarations to avoid warnings */
32rtems_task Init(rtems_task_argument argument);
33void open_it(void);
34void register_it(void);
35void printf_uid_message(struct MW_UID_MESSAGE *uid);
36void receive_uid_message(void);
37void close_it(void);
38
39extern const char *Mouse_Type_Long;
40extern const char *Mouse_Type_Short;
41extern const unsigned char Mouse_Actions[];
42extern const size_t Mouse_Actions_Size;
43extern const size_t Mouse_Actions_Per_Iteration;
44
45int Mouse_Index = 0;
46
47int Test_fd;
48
49void open_it(void)
50{
51  /* open the file */
52  Test_fd = open( "/dev/mouse", O_RDONLY );
53  rtems_test_assert( Test_fd != -1 );
54}
55
56void register_it(void)
57{
58  int                rc;
59  char               name[5] = "mous";
60
61  rc = uid_open_queue( name, 0, UID_MESSAGE_COUNT );
62  rtems_test_assert( rc == 0 );
63
64  rc = uid_register_device( Test_fd, name );
65  rtems_test_assert( rc == 0 );
66}
67
68void printf_uid_message(
69  struct MW_UID_MESSAGE *uid
70)
71{
72  uid_print_message_with_plugin(
73    &rtems_test_printer,
74    uid
75  );
76}
77
78void receive_uid_message(void)
79{
80  int                    rc;
81  struct MW_UID_MESSAGE  uid;
82
83  rc = uid_read_message( &uid, 0.5L );
84  if ( rc != sizeof(struct MW_UID_MESSAGE) )
85    return;
86  printf_uid_message( &uid );
87}
88
89void close_it(void)
90{
91  int rc;
92
93  rc = uid_unregister_device( Test_fd );
94  rtems_test_assert( rc == 0 );
95
96  rc = close( Test_fd );
97  rtems_test_assert( rc == 0 );
98}
99
100rtems_task Init(
101  rtems_task_argument ignored
102)
103{
104
105  TEST_BEGIN();
106
107  open_it();
108  register_it();
109
110  /* No message should ever be recieved. With a timeout val of 0, this
111   * call will never return. We use this to check if patch was correct
112   * by passing a number of ticks greater than 0 and less than 1. If
113   * patch was correct, this call will timeout instead of waiting
114   * indefinitely.
115   */
116  receive_uid_message();
117
118  close_it();
119  TEST_END();
120  rtems_test_exit( 0 );
121}
122
123/* configuration information */
124
125#include <rtems/serial_mouse.h>
126
127/* NOTICE: the clock driver is explicitly disabled */
128#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
129#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
130#define CONFIGURE_APPLICATION_EXTRA_DRIVERS \
131    TERMIOS_TEST_DRIVER_TABLE_ENTRY, \
132    SERIAL_MOUSE_DRIVER_TABLE_ENTRY
133
134/* we need to be able to open the test device and mouse */
135#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 5
136#define CONFIGURE_MAXIMUM_TASKS  1
137#define CONFIGURE_MAXIMUM_TIMERS 2
138#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1
139
140#define CONFIGURE_MESSAGE_BUFFER_MEMORY \
141  CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE( \
142    UID_MESSAGE_COUNT, \
143    sizeof(struct MW_UID_MESSAGE) \
144  )
145
146#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
147
148#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
149
150#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
151
152#define CONFIGURE_INIT
153
154#include <rtems/confdefs.h>
155
156/* end of file */
Note: See TracBrowser for help on using the repository browser.