forked from Imagelibrary/rtems
libtests: added test to confirm patch fixes bug
This commit is contained in:
committed by
Gedare Bloom
parent
66bf2cc909
commit
7cf81ba4aa
@@ -24,7 +24,7 @@ SUBDIRS += bspcmdline01 cpuuse devfs01 devfs02 devfs03 devfs04 \
|
||||
block08 block09 block10 block11 block12 stringto01 \
|
||||
tar01 tar02 tar03 \
|
||||
math mathf mathl complex \
|
||||
mouse01
|
||||
mouse01 uid01
|
||||
|
||||
if NETTESTS
|
||||
if HAS_POSIX
|
||||
|
||||
@@ -89,6 +89,7 @@ malloc05/Makefile
|
||||
monitor/Makefile
|
||||
monitor02/Makefile
|
||||
mouse01/Makefile
|
||||
uid01/Makefile
|
||||
putenvtest/Makefile
|
||||
rtems++/Makefile
|
||||
rtmonuse/Makefile
|
||||
|
||||
22
testsuites/libtests/uid01/Makefile.am
Normal file
22
testsuites/libtests/uid01/Makefile.am
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
rtems_tests_PROGRAMS = uid01
|
||||
uid01_SOURCES = init.c serial_mouse_config.c msmouse.c\
|
||||
../termios04/termios_testdriver_intr.c
|
||||
|
||||
dist_rtems_tests_DATA = uid01.doc
|
||||
|
||||
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
|
||||
include $(top_srcdir)/../automake/compile.am
|
||||
include $(top_srcdir)/../automake/leaf.am
|
||||
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/../support/include
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/termios04
|
||||
|
||||
LINK_OBJS = $(uid01_OBJECTS)
|
||||
LINK_LIBS = $(uid01_LDLIBS)
|
||||
|
||||
uid01$(EXEEXT): $(uid01_OBJECTS) $(uid01_DEPENDENCIES)
|
||||
@rm -f uid01$(EXEEXT)
|
||||
$(make-exe)
|
||||
|
||||
include $(top_srcdir)/../automake/local.am
|
||||
155
testsuites/libtests/uid01/init.c
Normal file
155
testsuites/libtests/uid01/init.c
Normal file
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* COPYRIGHT (c) 2013.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.com/license/LICENSE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <bsp.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <rtems/mw_uid.h>
|
||||
#include "termios_testdriver_intr.h"
|
||||
#include "tmacros.h"
|
||||
|
||||
#define UID_MESSAGE_COUNT 10
|
||||
|
||||
/* forward declarations to avoid warnings */
|
||||
rtems_task Init(rtems_task_argument argument);
|
||||
void open_it(void);
|
||||
void register_it(void);
|
||||
void printf_uid_message(struct MW_UID_MESSAGE *uid);
|
||||
void receive_uid_message(void);
|
||||
void close_it(void);
|
||||
|
||||
extern const char *Mouse_Type_Long;
|
||||
extern const char *Mouse_Type_Short;
|
||||
extern const unsigned char Mouse_Actions[];
|
||||
extern const size_t Mouse_Actions_Size;
|
||||
extern const size_t Mouse_Actions_Per_Iteration;
|
||||
|
||||
int Mouse_Index = 0;
|
||||
|
||||
int Test_fd;
|
||||
|
||||
void open_it(void)
|
||||
{
|
||||
/* open the file */
|
||||
Test_fd = open( "/dev/mouse", O_RDONLY );
|
||||
rtems_test_assert( Test_fd != -1 );
|
||||
}
|
||||
|
||||
void register_it(void)
|
||||
{
|
||||
int rc;
|
||||
char name[5] = "mous";
|
||||
|
||||
rc = uid_open_queue( name, 0, UID_MESSAGE_COUNT );
|
||||
rtems_test_assert( rc == 0 );
|
||||
|
||||
rc = uid_register_device( Test_fd, name );
|
||||
rtems_test_assert( rc == 0 );
|
||||
}
|
||||
|
||||
void printf_uid_message(
|
||||
struct MW_UID_MESSAGE *uid
|
||||
)
|
||||
{
|
||||
uid_print_message_with_plugin(
|
||||
stdout,
|
||||
(rtems_printk_plugin_t)fprintf,
|
||||
uid
|
||||
);
|
||||
}
|
||||
|
||||
void receive_uid_message(void)
|
||||
{
|
||||
int rc;
|
||||
struct MW_UID_MESSAGE uid;
|
||||
|
||||
rc = uid_read_message( &uid, 0.5L );
|
||||
if ( rc != sizeof(struct MW_UID_MESSAGE) )
|
||||
return;
|
||||
printf_uid_message( &uid );
|
||||
}
|
||||
|
||||
void close_it(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = uid_unregister_device( Test_fd );
|
||||
rtems_test_assert( rc == 0 );
|
||||
|
||||
rc = close( Test_fd );
|
||||
rtems_test_assert( rc == 0 );
|
||||
}
|
||||
|
||||
rtems_task Init(
|
||||
rtems_task_argument ignored
|
||||
)
|
||||
{
|
||||
|
||||
printf( "\n\n*** UID01 TEST ***\n" );
|
||||
|
||||
open_it();
|
||||
register_it();
|
||||
|
||||
/* No message should ever be recieved. With a timeout val of 0, this
|
||||
* call will never return. We use this to check if patch was correct
|
||||
* by passing a number of ticks greater than 0 and less than 1. If
|
||||
* patch was correct, this call will timeout instead of waiting
|
||||
* indefinitely.
|
||||
*/
|
||||
receive_uid_message();
|
||||
|
||||
close_it();
|
||||
printf( "*** END OF UID01 TEST ***\n" );
|
||||
rtems_test_exit( 0 );
|
||||
}
|
||||
|
||||
/* configuration information */
|
||||
|
||||
#include <rtems/serial_mouse.h>
|
||||
#include "termios_testdriver_intr.h"
|
||||
|
||||
/* NOTICE: the clock driver is explicitly disabled */
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
||||
#define CONFIGURE_APPLICATION_EXTRA_DRIVERS \
|
||||
TERMIOS_TEST_DRIVER_TABLE_ENTRY, \
|
||||
SERIAL_MOUSE_DRIVER_TABLE_ENTRY
|
||||
|
||||
/* one for the console and one for the test port */
|
||||
#define CONFIGURE_NUMBER_OF_TERMIOS_PORTS 2
|
||||
|
||||
/* we need to be able to open the test device and mouse */
|
||||
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 5
|
||||
#define CONFIGURE_MAXIMUM_TASKS 1
|
||||
#define CONFIGURE_MAXIMUM_TIMERS 2
|
||||
#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1
|
||||
|
||||
#define CONFIGURE_MESSAGE_BUFFER_MEMORY \
|
||||
CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE( \
|
||||
UID_MESSAGE_COUNT, \
|
||||
sizeof(struct MW_UID_MESSAGE) \
|
||||
)
|
||||
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
#include <rtems/confdefs.h>
|
||||
|
||||
/* end of file */
|
||||
37
testsuites/libtests/uid01/msmouse.c
Normal file
37
testsuites/libtests/uid01/msmouse.c
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-2011.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.com/license/LICENSE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
const char *Mouse_Type_Long = "Microsoft Mouse";
|
||||
const char *Mouse_Type_Short = "ms";
|
||||
|
||||
#define PRESSED 1
|
||||
#define NOT_PRESSED 0
|
||||
|
||||
#define MS_MOUSE_BYTES( _lb, _rb, _x, _y ) \
|
||||
(0x40 | ((_lb) ? 0x20 : 0x00) | ((_rb) ? 0x10 : 0x00) | \
|
||||
((_y & 0xC) >> 4) | (_x >> 6)), \
|
||||
(_x & 0x3F), \
|
||||
(_y & 0x3F)
|
||||
|
||||
const unsigned char Mouse_Actions[] = {
|
||||
MS_MOUSE_BYTES( PRESSED, NOT_PRESSED, 1, 2),
|
||||
MS_MOUSE_BYTES( NOT_PRESSED, PRESSED, 1, 2),
|
||||
MS_MOUSE_BYTES( NOT_PRESSED, NOT_PRESSED, 0xff, 2),
|
||||
MS_MOUSE_BYTES( NOT_PRESSED, NOT_PRESSED, 1, 0xff)
|
||||
};
|
||||
|
||||
const size_t Mouse_Actions_Size = sizeof(Mouse_Actions);
|
||||
const size_t Mouse_Actions_Per_Iteration = 3;
|
||||
|
||||
33
testsuites/libtests/uid01/serial_mouse_config.c
Normal file
33
testsuites/libtests/uid01/serial_mouse_config.c
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
*
|
||||
* MODULE DESCRIPTION:
|
||||
* This module implements the RTEMS drivers for the PC serial ports
|
||||
* as /dev/ttyS1 for COM1 and /dev/ttyS2 as COM2. If one of the ports
|
||||
* is used as the console, this driver would fail to initialize.
|
||||
*
|
||||
* This code was based on the console driver. It is based on the
|
||||
* current termios framework. This is just a shell around the
|
||||
* termios support.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "tmacros.h"
|
||||
#include <rtems/serial_mouse.h>
|
||||
#include "termios_testdriver_intr.h"
|
||||
|
||||
extern const char *Mouse_Type_Short;
|
||||
|
||||
bool bsp_get_serial_mouse_device(
|
||||
const char **name,
|
||||
const char **type
|
||||
)
|
||||
{
|
||||
*name = TERMIOS_TEST_DRIVER_DEVICE_NAME;
|
||||
*type = Mouse_Type_Short;
|
||||
|
||||
return true;
|
||||
}
|
||||
19
testsuites/libtests/uid01/uid01.doc
Normal file
19
testsuites/libtests/uid01/uid01.doc
Normal file
@@ -0,0 +1,19 @@
|
||||
# COPYRIGHT (c) 2013.
|
||||
# On-Line Applications Research Corporation (OAR).
|
||||
#
|
||||
# The license and distribution terms for this file may be
|
||||
# found in the file LICENSE in this distribution or at
|
||||
# http://www.rtems.com/license/LICENSE.
|
||||
#
|
||||
|
||||
This file describes the directives and concepts tested by this test set.
|
||||
|
||||
test set name: uid01
|
||||
|
||||
directives:
|
||||
+ uid_read_message
|
||||
|
||||
concepts:
|
||||
+ Tests that uid_read_message when called with a timeout greater than 0
|
||||
ticks but less than 1 tick will correctly round this up to a 1 tick
|
||||
timeout.
|
||||
Reference in New Issue
Block a user