mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-20 19:09:47 +08:00
@@ -219,7 +219,7 @@ lib_screens += complex/complex.scn
|
||||
complex_SOURCES = complex/init.c complex/docomplex.c \
|
||||
complex/docomplexf.c complex/docomplexl.c
|
||||
complex_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_complex) \
|
||||
$(support_includes) -DNO_LONG_DOUBLE
|
||||
$(support_includes)
|
||||
complex_LDADD = -lm $(LDADD)
|
||||
endif
|
||||
|
||||
@@ -483,7 +483,7 @@ dl06-pre-tar.o: dl06-pre-tar.c dl06-pre-tar.h
|
||||
$(AM_V_CC)$(COMPILE) -c -o $@ $<
|
||||
dl06-pre-init.o: dl06-pre-tar.o
|
||||
$(AM_V_CC)$(COMPILE) $(dl06_CPPFLAGS) $(CPU_CFLAGS) $(AM_CFLAGS) \
|
||||
-DDL06_PRE -c -o $@ $(srcdir)/dl06/init.c
|
||||
-c -o $@ $(srcdir)/dl06/pre-init.c
|
||||
dl06.pre: dl06-pre-init.o dl06/dl06-dl-load.o dl06-pre-tar.o
|
||||
@rm -f $@ dl06-sym.o
|
||||
$(AM_V_CCLD)$(LINK.c) $(CPU_CFLAGS) $(AM_CFLAGS) $(AM_LDFLAGS) -o $@ $+ $(LDADD)
|
||||
@@ -985,8 +985,7 @@ lib_tests += mathl
|
||||
lib_screens += mathl/mathl.scn
|
||||
mathl_SOURCES = mathl/init.c mathl/domathl.c
|
||||
mathl_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_mathl) \
|
||||
$(support_includes) -I$(top_srcdir)/math \
|
||||
-DNO_LONG_DOUBLE
|
||||
$(support_includes) -I$(top_srcdir)/math
|
||||
mathl_LDADD = -lm $(LDADD)
|
||||
endif
|
||||
|
||||
@@ -1044,7 +1043,7 @@ lib_docs += mouse01/mouse01.doc
|
||||
mouse01_SOURCES = mouse01/init.c mouse01/serial_mouse_config.c \
|
||||
mouse01/msmouse.c termios04/termios_testdriver_intr.c
|
||||
mouse01_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_mouse01) \
|
||||
$(support_includes) -I$(top_srcdir)/termios04
|
||||
$(support_includes)
|
||||
endif
|
||||
|
||||
if TEST_nanosleep
|
||||
@@ -1448,9 +1447,9 @@ lib_tests += termios05
|
||||
lib_screens += termios05/termios05.scn
|
||||
lib_docs += termios05/termios05.doc
|
||||
termios05_SOURCES = termios05/init.c \
|
||||
termios04/termios_testdriver_intr.c
|
||||
termios05/termios_testdriver_task.c
|
||||
termios05_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_termios05) \
|
||||
$(support_includes) -I$(top_srcdir)/termios04 -DTASK_DRIVEN
|
||||
$(support_includes)
|
||||
endif
|
||||
|
||||
if TEST_termios06
|
||||
@@ -1460,7 +1459,7 @@ lib_docs += termios06/termios06.doc
|
||||
termios06_SOURCES = termios06/init.c \
|
||||
termios03/termios_testdriver_polled.c termios06/test_pppd.c
|
||||
termios06_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_termios06) \
|
||||
$(support_includes) -I$(top_srcdir)/termios03
|
||||
$(support_includes)
|
||||
endif
|
||||
|
||||
if TEST_termios07
|
||||
@@ -1470,7 +1469,7 @@ lib_docs += termios07/termios07.doc
|
||||
termios07_SOURCES = termios07/init.c \
|
||||
termios04/termios_testdriver_intr.c
|
||||
termios07_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_termios07) \
|
||||
$(support_includes) -I$(top_srcdir)/termios04
|
||||
$(support_includes)
|
||||
endif
|
||||
|
||||
if TEST_termios08
|
||||
@@ -1480,7 +1479,7 @@ lib_docs += termios08/termios08.doc
|
||||
termios08_SOURCES = termios08/init.c \
|
||||
termios03/termios_testdriver_polled.c
|
||||
termios08_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_termios08) \
|
||||
$(support_includes) -I$(top_srcdir)/termios03
|
||||
$(support_includes)
|
||||
endif
|
||||
|
||||
if TEST_termios09
|
||||
@@ -1499,17 +1498,17 @@ lib_docs += termios10/termios10.doc
|
||||
termios10_SOURCES = termios10/init.c
|
||||
termios10_SOURCES += termios03/termios_testdriver_polled.c
|
||||
termios10_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_termios10) \
|
||||
$(support_includes) -I$(top_srcdir)/termios03
|
||||
$(support_includes)
|
||||
endif
|
||||
|
||||
if TEST_termios11
|
||||
lib_tests += termios11
|
||||
lib_screens += termios11/termios11.scn
|
||||
lib_docs += termios11/termios11.doc
|
||||
termios11_SOURCES = termios10/init.c
|
||||
termios11_SOURCES = termios11/init.c
|
||||
termios11_SOURCES += termios04/termios_testdriver_intr.c
|
||||
termios11_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_termios11) \
|
||||
$(support_includes) -I$(top_srcdir)/termios04 -DINTERRUPT_DRIVEN
|
||||
$(support_includes)
|
||||
endif
|
||||
|
||||
if TEST_top
|
||||
@@ -1560,7 +1559,7 @@ lib_docs += uid01/uid01.doc
|
||||
uid01_SOURCES = uid01/init.c uid01/serial_mouse_config.c \
|
||||
uid01/msmouse.c termios04/termios_testdriver_intr.c
|
||||
uid01_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_uid01) \
|
||||
$(support_includes) -I$(top_srcdir)/termios04
|
||||
$(support_includes)
|
||||
endif
|
||||
|
||||
if TEST_unlink
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
/* FIXME: Why is this defined? */
|
||||
#define NO_LONG_DOUBLE
|
||||
|
||||
#ifdef NO_LONG_DOUBLE
|
||||
#define PROVIDE_EMPTY_FUNC
|
||||
#endif
|
||||
|
||||
@@ -1,88 +1 @@
|
||||
/*
|
||||
* Copyright (c) 2014 Chris Johns <chrisj@rtems.org>. All rights reserved.
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "tmacros.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <rtems/rtl/rtl.h>
|
||||
#include <rtems/untar.h>
|
||||
|
||||
#include "dl-load.h"
|
||||
|
||||
const char rtems_test_name[] = "libdl (RTL) 6";
|
||||
|
||||
/* forward declarations to avoid warnings */
|
||||
static rtems_task Init(rtems_task_argument argument);
|
||||
|
||||
#if DL06_PRE
|
||||
#include "dl06-pre-tar.h"
|
||||
#else
|
||||
#include "dl06-tar.h"
|
||||
#endif
|
||||
|
||||
#define TARFILE_START dl06_tar
|
||||
#define TARFILE_SIZE dl06_tar_size
|
||||
|
||||
static int test(void)
|
||||
{
|
||||
int ret;
|
||||
ret = dl_load_test();
|
||||
if (ret)
|
||||
rtems_test_exit(ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
{
|
||||
int te;
|
||||
|
||||
TEST_BEGIN();
|
||||
|
||||
te = Untar_FromMemory((void *)TARFILE_START, (size_t)TARFILE_SIZE);
|
||||
if (te != 0)
|
||||
{
|
||||
printf("untar failed: %d\n", te);
|
||||
rtems_test_exit(1);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
test();
|
||||
|
||||
TEST_END();
|
||||
|
||||
rtems_test_exit(0);
|
||||
}
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
|
||||
|
||||
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS 1
|
||||
|
||||
#define CONFIGURE_MAXIMUM_SEMAPHORES 1
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
|
||||
#define CONFIGURE_INIT_TASK_STACK_SIZE (8U * 1024U)
|
||||
|
||||
#define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT)
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
#include <rtems/confdefs.h>
|
||||
#include "initimpl.h"
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (c) 2014 Chris Johns <chrisj@rtems.org>. All rights reserved.
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "tmacros.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <rtems/rtl/rtl.h>
|
||||
#include <rtems/untar.h>
|
||||
|
||||
#include "dl-load.h"
|
||||
|
||||
const char rtems_test_name[] = "libdl (RTL) 6";
|
||||
|
||||
/* forward declarations to avoid warnings */
|
||||
static rtems_task Init(rtems_task_argument argument);
|
||||
|
||||
#if DL06_PRE
|
||||
#include "dl06-pre-tar.h"
|
||||
#else
|
||||
#include "dl06-tar.h"
|
||||
#endif
|
||||
|
||||
#define TARFILE_START dl06_tar
|
||||
#define TARFILE_SIZE dl06_tar_size
|
||||
|
||||
static int test(void)
|
||||
{
|
||||
int ret;
|
||||
ret = dl_load_test();
|
||||
if (ret)
|
||||
rtems_test_exit(ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
{
|
||||
int te;
|
||||
|
||||
TEST_BEGIN();
|
||||
|
||||
te = Untar_FromMemory((void *)TARFILE_START, (size_t)TARFILE_SIZE);
|
||||
if (te != 0)
|
||||
{
|
||||
printf("untar failed: %d\n", te);
|
||||
rtems_test_exit(1);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
test();
|
||||
|
||||
TEST_END();
|
||||
|
||||
rtems_test_exit(0);
|
||||
}
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
|
||||
|
||||
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS 1
|
||||
|
||||
#define CONFIGURE_MAXIMUM_SEMAPHORES 1
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
|
||||
#define CONFIGURE_INIT_TASK_STACK_SIZE (8U * 1024U)
|
||||
|
||||
#define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT)
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
#include <rtems/confdefs.h>
|
||||
@@ -0,0 +1,2 @@
|
||||
#define DL06_PRE 1
|
||||
#include "initimpl.h"
|
||||
@@ -14,6 +14,9 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
/* FIXME: Why is this defined? */
|
||||
#define NO_LONG_DOUBLE
|
||||
|
||||
#ifdef NO_LONG_DOUBLE
|
||||
#define PROVIDE_EMPTY_FUNC
|
||||
#endif
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <rtems/mw_uid.h>
|
||||
#include "termios_testdriver_intr.h"
|
||||
#include "../termios04/termios_testdriver_intr.h"
|
||||
#include "tmacros.h"
|
||||
|
||||
const char rtems_test_name[] = "MOUSE 1";
|
||||
@@ -151,7 +151,6 @@ rtems_task Init(
|
||||
/* 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
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#include "tmacros.h"
|
||||
#include <rtems/serial_mouse.h>
|
||||
#include "termios_testdriver_intr.h"
|
||||
#include "../termios04/termios_testdriver_intr.h"
|
||||
|
||||
extern const char *Mouse_Type_Short;
|
||||
|
||||
|
||||
@@ -0,0 +1,306 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* This file contains a test fixture termios device driver
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-2012.
|
||||
* 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.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "tmacros.h"
|
||||
#include <rtems/libio.h>
|
||||
#include <stdlib.h>
|
||||
#include <termios.h>
|
||||
#include <rtems/termiostypes.h>
|
||||
#include <rtems/dumpbuf.h>
|
||||
#include "termios_testdriver_intr.h"
|
||||
|
||||
/* forward declarations to avoid warnings */
|
||||
void termios_test_driver_wait_for_tx_to_complete(void);
|
||||
rtems_timer_service_routine Rx_ISR(
|
||||
rtems_id ignored_id,
|
||||
void *ignored_address
|
||||
);
|
||||
rtems_timer_service_routine Tx_ISR(
|
||||
rtems_id ignored_id,
|
||||
void *ignored_address
|
||||
);
|
||||
ssize_t termios_test_driver_write_helper(
|
||||
int port,
|
||||
const char *buf,
|
||||
size_t len
|
||||
);
|
||||
int termios_test_driver_set_attributes(
|
||||
int minor,
|
||||
const struct termios *t
|
||||
);
|
||||
#if defined(TASK_DRIVEN)
|
||||
int termios_test_driver_inbyte_nonblocking(int port);
|
||||
#endif
|
||||
|
||||
/* global variables */
|
||||
rtems_id Rx_Timer;
|
||||
rtems_id Tx_Timer;
|
||||
|
||||
#define TX_MAX 1024
|
||||
uint8_t Tx_Buffer[TX_MAX];
|
||||
int Tx_Index = 0;
|
||||
struct rtems_termios_tty *Ttyp;
|
||||
|
||||
void termios_test_driver_wait_for_tx_to_complete(void)
|
||||
{
|
||||
rtems_task_wake_after( 2 * rtems_clock_get_ticks_per_second() );
|
||||
}
|
||||
|
||||
void termios_test_driver_dump_tx(const char *c)
|
||||
{
|
||||
termios_test_driver_wait_for_tx_to_complete();
|
||||
|
||||
printf( "%s %d characters\n", c, Tx_Index );
|
||||
rtems_print_buffer( Tx_Buffer, Tx_Index );
|
||||
Tx_Index = 0;
|
||||
}
|
||||
|
||||
const uint8_t *Rx_Buffer;
|
||||
int Rx_Index = 0;
|
||||
int Rx_Length = 0;
|
||||
bool Rx_FirstTime = true;
|
||||
bool Rx_EnqueueNow = false;
|
||||
|
||||
#if defined(TASK_DRIVEN)
|
||||
int termios_test_driver_inbyte_nonblocking( int port )
|
||||
{
|
||||
if ( Rx_FirstTime == true ) {
|
||||
Rx_FirstTime = false;
|
||||
return -1;
|
||||
}
|
||||
if ( Rx_Index >= Rx_Length )
|
||||
return -1;
|
||||
return Rx_Buffer[ Rx_Index++ ];
|
||||
}
|
||||
#endif
|
||||
|
||||
rtems_timer_service_routine Rx_ISR(
|
||||
rtems_id ignored_id,
|
||||
void *ignored_address
|
||||
)
|
||||
{
|
||||
uint8_t ch;
|
||||
|
||||
if ( Rx_Index >= Rx_Length )
|
||||
return;
|
||||
|
||||
ch = Rx_Buffer[ Rx_Index++ ];
|
||||
rtems_termios_enqueue_raw_characters (Ttyp, (char *)&ch, 1);
|
||||
#if defined(TASK_DRIVEN)
|
||||
rtems_termios_rxirq_occured(Ttyp);
|
||||
#endif
|
||||
|
||||
(void) rtems_timer_fire_after( Rx_Timer, 10, Rx_ISR, NULL );
|
||||
}
|
||||
|
||||
rtems_timer_service_routine Tx_ISR(
|
||||
rtems_id ignored_id,
|
||||
void *ignored_address
|
||||
)
|
||||
{
|
||||
rtems_termios_dequeue_characters (Ttyp, 1);
|
||||
|
||||
(void) rtems_timer_fire_after( Tx_Timer, 10, Tx_ISR, NULL );
|
||||
}
|
||||
|
||||
void termios_test_driver_set_rx_enqueue_now(
|
||||
bool value
|
||||
)
|
||||
{
|
||||
Rx_EnqueueNow = value;
|
||||
}
|
||||
|
||||
void termios_test_driver_set_rx(
|
||||
const void *p,
|
||||
size_t len
|
||||
)
|
||||
{
|
||||
Rx_Buffer = p;
|
||||
Rx_Length = len;
|
||||
Rx_Index = 0;
|
||||
|
||||
if ( Rx_EnqueueNow == false) {
|
||||
(void) rtems_timer_fire_after( Rx_Timer, 10, Rx_ISR, NULL );
|
||||
return;
|
||||
}
|
||||
|
||||
do {
|
||||
uint8_t ch;
|
||||
ch = Rx_Buffer[ Rx_Index++ ];
|
||||
rtems_termios_enqueue_raw_characters (Ttyp, (char *)&ch, 1);
|
||||
} while (Rx_Index < Rx_Length );
|
||||
}
|
||||
|
||||
ssize_t termios_test_driver_write_helper(
|
||||
int port,
|
||||
const char *buf,
|
||||
size_t len
|
||||
)
|
||||
{
|
||||
if (len > 0) {
|
||||
Tx_Buffer[Tx_Index++] = buf[0];
|
||||
(void) rtems_timer_fire_after( Tx_Timer, 10, Tx_ISR, NULL );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set Attributes Handler
|
||||
*/
|
||||
int termios_test_driver_set_attributes(
|
||||
int minor,
|
||||
const struct termios *t
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Test Device Driver Entry Points
|
||||
*/
|
||||
rtems_device_driver termios_test_driver_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg
|
||||
)
|
||||
{
|
||||
rtems_termios_initialize();
|
||||
|
||||
/*
|
||||
* Register Device Names
|
||||
*/
|
||||
(void) rtems_io_register_name( TERMIOS_TEST_DRIVER_DEVICE_NAME, major, 0 );
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
static int first_open(int major, int minor, void *arg)
|
||||
{
|
||||
rtems_status_code status;
|
||||
|
||||
status = rtems_timer_create(rtems_build_name('T', 'M', 'R', 'X'), &Rx_Timer);
|
||||
if ( status != RTEMS_SUCCESSFUL )
|
||||
rtems_fatal_error_occurred(1);
|
||||
|
||||
status = rtems_timer_create(rtems_build_name('T', 'M', 'T', 'X'), &Tx_Timer);
|
||||
if ( status != RTEMS_SUCCESSFUL )
|
||||
rtems_fatal_error_occurred(1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int last_close(int major, int minor, void *arg)
|
||||
{
|
||||
rtems_status_code status;
|
||||
|
||||
status = rtems_timer_cancel(Rx_Timer);
|
||||
if ( status != RTEMS_SUCCESSFUL )
|
||||
rtems_fatal_error_occurred(1);
|
||||
|
||||
status = rtems_timer_cancel(Tx_Timer);
|
||||
if ( status != RTEMS_SUCCESSFUL )
|
||||
rtems_fatal_error_occurred(1);
|
||||
|
||||
status = rtems_timer_delete(Rx_Timer);
|
||||
if ( status != RTEMS_SUCCESSFUL )
|
||||
rtems_fatal_error_occurred(1);
|
||||
|
||||
status = rtems_timer_delete(Tx_Timer);
|
||||
if ( status != RTEMS_SUCCESSFUL )
|
||||
rtems_fatal_error_occurred(1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
rtems_device_driver termios_test_driver_open(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg
|
||||
)
|
||||
{
|
||||
rtems_status_code sc;
|
||||
rtems_libio_open_close_args_t *args = arg;
|
||||
static const rtems_termios_callbacks Callbacks = {
|
||||
first_open, /* firstOpen */
|
||||
last_close, /* lastClose */
|
||||
#if defined(TASK_DRIVEN)
|
||||
termios_test_driver_inbyte_nonblocking,/* pollRead */
|
||||
#else
|
||||
NULL, /* pollRead */
|
||||
#endif
|
||||
termios_test_driver_write_helper, /* write */
|
||||
termios_test_driver_set_attributes, /* setAttributes */
|
||||
NULL, /* stopRemoteTx */
|
||||
NULL, /* startRemoteTx */
|
||||
#if defined(TASK_DRIVEN)
|
||||
TERMIOS_TASK_DRIVEN /* outputUsesInterrupts */
|
||||
#else
|
||||
0 /* outputUsesInterrupts */
|
||||
#endif
|
||||
};
|
||||
|
||||
if ( minor > 2 ) {
|
||||
puts( "ERROR - Termios_testdriver - only 1 minor supported" );
|
||||
rtems_test_exit(0);
|
||||
}
|
||||
|
||||
sc = rtems_termios_open (major, minor, arg, &Callbacks);
|
||||
directive_failed( sc, "termios open" );
|
||||
|
||||
Ttyp = args->iop->data1; /* Keep cookie returned by termios_open */
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
rtems_device_driver termios_test_driver_close(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg
|
||||
)
|
||||
{
|
||||
return rtems_termios_close (arg);
|
||||
}
|
||||
|
||||
rtems_device_driver termios_test_driver_read(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg
|
||||
)
|
||||
{
|
||||
return rtems_termios_read (arg);
|
||||
}
|
||||
|
||||
rtems_device_driver termios_test_driver_write(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg
|
||||
)
|
||||
{
|
||||
return rtems_termios_write (arg);
|
||||
}
|
||||
|
||||
rtems_device_driver termios_test_driver_control(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg
|
||||
)
|
||||
{
|
||||
return rtems_termios_ioctl (arg);
|
||||
}
|
||||
@@ -1,306 +1 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* This file contains a test fixture termios device driver
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-2012.
|
||||
* 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.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "tmacros.h"
|
||||
#include <rtems/libio.h>
|
||||
#include <stdlib.h>
|
||||
#include <termios.h>
|
||||
#include <rtems/termiostypes.h>
|
||||
#include <rtems/dumpbuf.h>
|
||||
#include "termios_testdriver_intr.h"
|
||||
|
||||
/* forward declarations to avoid warnings */
|
||||
void termios_test_driver_wait_for_tx_to_complete(void);
|
||||
rtems_timer_service_routine Rx_ISR(
|
||||
rtems_id ignored_id,
|
||||
void *ignored_address
|
||||
);
|
||||
rtems_timer_service_routine Tx_ISR(
|
||||
rtems_id ignored_id,
|
||||
void *ignored_address
|
||||
);
|
||||
ssize_t termios_test_driver_write_helper(
|
||||
int port,
|
||||
const char *buf,
|
||||
size_t len
|
||||
);
|
||||
int termios_test_driver_set_attributes(
|
||||
int minor,
|
||||
const struct termios *t
|
||||
);
|
||||
#if defined(TASK_DRIVEN)
|
||||
int termios_test_driver_inbyte_nonblocking(int port);
|
||||
#endif
|
||||
|
||||
/* global variables */
|
||||
rtems_id Rx_Timer;
|
||||
rtems_id Tx_Timer;
|
||||
|
||||
#define TX_MAX 1024
|
||||
uint8_t Tx_Buffer[TX_MAX];
|
||||
int Tx_Index = 0;
|
||||
struct rtems_termios_tty *Ttyp;
|
||||
|
||||
void termios_test_driver_wait_for_tx_to_complete(void)
|
||||
{
|
||||
rtems_task_wake_after( 2 * rtems_clock_get_ticks_per_second() );
|
||||
}
|
||||
|
||||
void termios_test_driver_dump_tx(const char *c)
|
||||
{
|
||||
termios_test_driver_wait_for_tx_to_complete();
|
||||
|
||||
printf( "%s %d characters\n", c, Tx_Index );
|
||||
rtems_print_buffer( Tx_Buffer, Tx_Index );
|
||||
Tx_Index = 0;
|
||||
}
|
||||
|
||||
const uint8_t *Rx_Buffer;
|
||||
int Rx_Index = 0;
|
||||
int Rx_Length = 0;
|
||||
bool Rx_FirstTime = true;
|
||||
bool Rx_EnqueueNow = false;
|
||||
|
||||
#if defined(TASK_DRIVEN)
|
||||
int termios_test_driver_inbyte_nonblocking( int port )
|
||||
{
|
||||
if ( Rx_FirstTime == true ) {
|
||||
Rx_FirstTime = false;
|
||||
return -1;
|
||||
}
|
||||
if ( Rx_Index >= Rx_Length )
|
||||
return -1;
|
||||
return Rx_Buffer[ Rx_Index++ ];
|
||||
}
|
||||
#endif
|
||||
|
||||
rtems_timer_service_routine Rx_ISR(
|
||||
rtems_id ignored_id,
|
||||
void *ignored_address
|
||||
)
|
||||
{
|
||||
uint8_t ch;
|
||||
|
||||
if ( Rx_Index >= Rx_Length )
|
||||
return;
|
||||
|
||||
ch = Rx_Buffer[ Rx_Index++ ];
|
||||
rtems_termios_enqueue_raw_characters (Ttyp, (char *)&ch, 1);
|
||||
#if defined(TASK_DRIVEN)
|
||||
rtems_termios_rxirq_occured(Ttyp);
|
||||
#endif
|
||||
|
||||
(void) rtems_timer_fire_after( Rx_Timer, 10, Rx_ISR, NULL );
|
||||
}
|
||||
|
||||
rtems_timer_service_routine Tx_ISR(
|
||||
rtems_id ignored_id,
|
||||
void *ignored_address
|
||||
)
|
||||
{
|
||||
rtems_termios_dequeue_characters (Ttyp, 1);
|
||||
|
||||
(void) rtems_timer_fire_after( Tx_Timer, 10, Tx_ISR, NULL );
|
||||
}
|
||||
|
||||
void termios_test_driver_set_rx_enqueue_now(
|
||||
bool value
|
||||
)
|
||||
{
|
||||
Rx_EnqueueNow = value;
|
||||
}
|
||||
|
||||
void termios_test_driver_set_rx(
|
||||
const void *p,
|
||||
size_t len
|
||||
)
|
||||
{
|
||||
Rx_Buffer = p;
|
||||
Rx_Length = len;
|
||||
Rx_Index = 0;
|
||||
|
||||
if ( Rx_EnqueueNow == false) {
|
||||
(void) rtems_timer_fire_after( Rx_Timer, 10, Rx_ISR, NULL );
|
||||
return;
|
||||
}
|
||||
|
||||
do {
|
||||
uint8_t ch;
|
||||
ch = Rx_Buffer[ Rx_Index++ ];
|
||||
rtems_termios_enqueue_raw_characters (Ttyp, (char *)&ch, 1);
|
||||
} while (Rx_Index < Rx_Length );
|
||||
}
|
||||
|
||||
ssize_t termios_test_driver_write_helper(
|
||||
int port,
|
||||
const char *buf,
|
||||
size_t len
|
||||
)
|
||||
{
|
||||
if (len > 0) {
|
||||
Tx_Buffer[Tx_Index++] = buf[0];
|
||||
(void) rtems_timer_fire_after( Tx_Timer, 10, Tx_ISR, NULL );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set Attributes Handler
|
||||
*/
|
||||
int termios_test_driver_set_attributes(
|
||||
int minor,
|
||||
const struct termios *t
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Test Device Driver Entry Points
|
||||
*/
|
||||
rtems_device_driver termios_test_driver_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *arg
|
||||
)
|
||||
{
|
||||
rtems_termios_initialize();
|
||||
|
||||
/*
|
||||
* Register Device Names
|
||||
*/
|
||||
(void) rtems_io_register_name( TERMIOS_TEST_DRIVER_DEVICE_NAME, major, 0 );
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
static int first_open(int major, int minor, void *arg)
|
||||
{
|
||||
rtems_status_code status;
|
||||
|
||||
status = rtems_timer_create(rtems_build_name('T', 'M', 'R', 'X'), &Rx_Timer);
|
||||
if ( status != RTEMS_SUCCESSFUL )
|
||||
rtems_fatal_error_occurred(1);
|
||||
|
||||
status = rtems_timer_create(rtems_build_name('T', 'M', 'T', 'X'), &Tx_Timer);
|
||||
if ( status != RTEMS_SUCCESSFUL )
|
||||
rtems_fatal_error_occurred(1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int last_close(int major, int minor, void *arg)
|
||||
{
|
||||
rtems_status_code status;
|
||||
|
||||
status = rtems_timer_cancel(Rx_Timer);
|
||||
if ( status != RTEMS_SUCCESSFUL )
|
||||
rtems_fatal_error_occurred(1);
|
||||
|
||||
status = rtems_timer_cancel(Tx_Timer);
|
||||
if ( status != RTEMS_SUCCESSFUL )
|
||||
rtems_fatal_error_occurred(1);
|
||||
|
||||
status = rtems_timer_delete(Rx_Timer);
|
||||
if ( status != RTEMS_SUCCESSFUL )
|
||||
rtems_fatal_error_occurred(1);
|
||||
|
||||
status = rtems_timer_delete(Tx_Timer);
|
||||
if ( status != RTEMS_SUCCESSFUL )
|
||||
rtems_fatal_error_occurred(1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
rtems_device_driver termios_test_driver_open(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg
|
||||
)
|
||||
{
|
||||
rtems_status_code sc;
|
||||
rtems_libio_open_close_args_t *args = arg;
|
||||
static const rtems_termios_callbacks Callbacks = {
|
||||
first_open, /* firstOpen */
|
||||
last_close, /* lastClose */
|
||||
#if defined(TASK_DRIVEN)
|
||||
termios_test_driver_inbyte_nonblocking,/* pollRead */
|
||||
#else
|
||||
NULL, /* pollRead */
|
||||
#endif
|
||||
termios_test_driver_write_helper, /* write */
|
||||
termios_test_driver_set_attributes, /* setAttributes */
|
||||
NULL, /* stopRemoteTx */
|
||||
NULL, /* startRemoteTx */
|
||||
#if defined(TASK_DRIVEN)
|
||||
TERMIOS_TASK_DRIVEN /* outputUsesInterrupts */
|
||||
#else
|
||||
0 /* outputUsesInterrupts */
|
||||
#endif
|
||||
};
|
||||
|
||||
if ( minor > 2 ) {
|
||||
puts( "ERROR - Termios_testdriver - only 1 minor supported" );
|
||||
rtems_test_exit(0);
|
||||
}
|
||||
|
||||
sc = rtems_termios_open (major, minor, arg, &Callbacks);
|
||||
directive_failed( sc, "termios open" );
|
||||
|
||||
Ttyp = args->iop->data1; /* Keep cookie returned by termios_open */
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
rtems_device_driver termios_test_driver_close(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg
|
||||
)
|
||||
{
|
||||
return rtems_termios_close (arg);
|
||||
}
|
||||
|
||||
rtems_device_driver termios_test_driver_read(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg
|
||||
)
|
||||
{
|
||||
return rtems_termios_read (arg);
|
||||
}
|
||||
|
||||
rtems_device_driver termios_test_driver_write(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg
|
||||
)
|
||||
{
|
||||
return rtems_termios_write (arg);
|
||||
}
|
||||
|
||||
rtems_device_driver termios_test_driver_control(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void * arg
|
||||
)
|
||||
{
|
||||
return rtems_termios_ioctl (arg);
|
||||
}
|
||||
#include "termios_testdriver_impl.h"
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include <tmacros.h>
|
||||
#include "test_support.h"
|
||||
#include "termios_testdriver_intr.h"
|
||||
#include "../termios04/termios_testdriver_intr.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
#define TASK_DRIVEN
|
||||
#include "../termios04/termios_testdriver_impl.h"
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include <tmacros.h>
|
||||
#include "test_support.h"
|
||||
#include "termios_testdriver_polled.h"
|
||||
#include "../termios03/termios_testdriver_polled.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include <tmacros.h>
|
||||
#include "test_support.h"
|
||||
#include "termios_testdriver_intr.h"
|
||||
#include "../termios04/termios_testdriver_intr.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include <tmacros.h>
|
||||
#include "test_support.h"
|
||||
#include "termios_testdriver_polled.h"
|
||||
#include "../termios03/termios_testdriver_polled.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@@ -1,191 +1 @@
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-2012,2019.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <tmacros.h>
|
||||
#include "test_support.h"
|
||||
|
||||
#ifdef INTERRUPT_DRIVEN
|
||||
#include "termios_testdriver_intr.h"
|
||||
const char rtems_test_name[] = "TERMIOS 11 -- Interrupt driven";
|
||||
#else
|
||||
#include "termios_testdriver_polled.h"
|
||||
const char rtems_test_name[] = "TERMIOS 10 -- Polled";
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <termios.h>
|
||||
#include <rtems/dumpbuf.h>
|
||||
#include <rtems/libio.h>
|
||||
|
||||
int Test_fd;
|
||||
|
||||
static void open_it(void)
|
||||
{
|
||||
Test_fd = open( TERMIOS_TEST_DRIVER_DEVICE_NAME, O_RDWR );
|
||||
rtems_test_assert( Test_fd != -1 );
|
||||
}
|
||||
|
||||
static void change_lflag( const char *desc, int mask, int new )
|
||||
{
|
||||
int rc;
|
||||
struct termios attr;
|
||||
|
||||
if (desc) {
|
||||
printf( "Changing c_lflag to: %s\n", desc );
|
||||
}
|
||||
|
||||
rc = tcgetattr( Test_fd, &attr );
|
||||
rtems_test_assert( rc == 0 );
|
||||
|
||||
attr.c_lflag &= ~mask;
|
||||
attr.c_lflag |= new;
|
||||
|
||||
rc = tcsetattr( Test_fd, TCSANOW, &attr );
|
||||
rtems_test_assert( rc == 0 );
|
||||
}
|
||||
|
||||
|
||||
static void read_it(ssize_t expected, int expected_intr)
|
||||
{
|
||||
ssize_t rc;
|
||||
char buf[32];
|
||||
|
||||
rtems_test_assert( expected <= sizeof(buf) );
|
||||
|
||||
rc = read( Test_fd, buf, expected );
|
||||
if (expected_intr) {
|
||||
rtems_test_assert( rc == -1 );
|
||||
rtems_test_assert( errno == EINTR );
|
||||
} else {
|
||||
if ( expected != rc )
|
||||
printf( "ERROR - expected=%zd rc=%zd\n", expected, rc );
|
||||
rtems_test_assert( expected == rc );
|
||||
}
|
||||
}
|
||||
|
||||
static void close_it(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = close( Test_fd );
|
||||
rtems_test_assert( rc == 0 );
|
||||
}
|
||||
|
||||
volatile int sigint_occurred = 0;
|
||||
volatile int sigquit_occurred = 0;
|
||||
|
||||
static void sigint_handler(int signo)
|
||||
{
|
||||
rtems_test_assert(signo == SIGINT);
|
||||
sigint_occurred = 1;
|
||||
}
|
||||
|
||||
static void sigquit_handler(int signo)
|
||||
{
|
||||
rtems_test_assert(signo == SIGQUIT);
|
||||
sigquit_occurred = 1;
|
||||
}
|
||||
|
||||
static void test_read_for_signal(
|
||||
const char *description,
|
||||
int isig_value,
|
||||
char c,
|
||||
int sigint_expected,
|
||||
int sigquit_expected
|
||||
)
|
||||
{
|
||||
char expected[3];
|
||||
|
||||
printf("Test read for %s\n", description);
|
||||
|
||||
expected[0] = c;
|
||||
expected[1] = '\n'; /* in canonical mode, so need \n for read to return */
|
||||
expected[2] = '\0';
|
||||
|
||||
sigint_occurred = 0;
|
||||
sigquit_occurred = 0;
|
||||
|
||||
open_it();
|
||||
|
||||
change_lflag(NULL, ISIG, isig_value);
|
||||
|
||||
termios_test_driver_set_rx( expected, 2 );
|
||||
|
||||
read_it(1, (sigint_expected || sigquit_expected));
|
||||
|
||||
rtems_test_assert(sigint_occurred == sigint_expected);
|
||||
rtems_test_assert(sigquit_occurred == sigquit_expected);
|
||||
close_it();
|
||||
}
|
||||
|
||||
/*
|
||||
* Use a POSIX init thread so signals are enabled.
|
||||
*/
|
||||
static void *POSIX_Init(void *argument)
|
||||
{
|
||||
int rc;
|
||||
|
||||
TEST_BEGIN();
|
||||
|
||||
signal(SIGINT, sigint_handler);
|
||||
signal(SIGQUIT, sigquit_handler);
|
||||
|
||||
puts( "Exercise default ISIG handler with ISIG enabled");
|
||||
test_read_for_signal("VKILL - no signals", ISIG, '\003', 0, 0);
|
||||
test_read_for_signal("VQUIT - no signals", ISIG, '\034', 0, 0);
|
||||
|
||||
puts( "Exercise POSIX ISIG handler with ISIG enabled");
|
||||
rc = rtems_termios_register_isig_handler(rtems_termios_posix_isig_handler);
|
||||
rtems_test_assert( rc == 0 );
|
||||
test_read_for_signal("VKILL - signal caught", ISIG, '\003', 1, 0);
|
||||
test_read_for_signal("VQUIT - signal caught", ISIG, '\034', 0, 1);
|
||||
|
||||
puts( "Exercise default ISIG handler with ISIG enabled");
|
||||
rc = rtems_termios_register_isig_handler(rtems_termios_default_isig_handler);
|
||||
rtems_test_assert( rc == 0 );
|
||||
test_read_for_signal("VKILL - signal caught", ISIG, '\003', 0, 0);
|
||||
test_read_for_signal("VQUIT - signal caught", ISIG, '\034', 0, 0);
|
||||
|
||||
puts( "Exercise POSIX ISIG handler with ISIG disabled");
|
||||
rc = rtems_termios_register_isig_handler(rtems_termios_posix_isig_handler);
|
||||
rtems_test_assert( rc == 0 );
|
||||
test_read_for_signal("VKILL - signal caught", 0, '\003', 0, 0);
|
||||
test_read_for_signal("VQUIT - signal caught", 0, '\034', 0, 0);
|
||||
|
||||
TEST_END();
|
||||
|
||||
rtems_test_exit(0);
|
||||
}
|
||||
|
||||
/* configuration information */
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
#define CONFIGURE_APPLICATION_EXTRA_DRIVERS \
|
||||
TERMIOS_TEST_DRIVER_TABLE_ENTRY
|
||||
|
||||
/* we need to be able to open the test device */
|
||||
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
|
||||
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
|
||||
#define CONFIGURE_MAXIMUM_TIMERS 2
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
#include <rtems/confdefs.h>
|
||||
/* end of file */
|
||||
#include "termios10impl.h"
|
||||
|
||||
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
* COPYRIGHT (c) 1989-2012,2019.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <tmacros.h>
|
||||
#include "test_support.h"
|
||||
|
||||
#ifdef INTERRUPT_DRIVEN
|
||||
#include "../termios04/termios_testdriver_intr.h"
|
||||
const char rtems_test_name[] = "TERMIOS 11 -- Interrupt driven";
|
||||
#else
|
||||
#include "../termios03/termios_testdriver_polled.h"
|
||||
const char rtems_test_name[] = "TERMIOS 10 -- Polled";
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <termios.h>
|
||||
#include <rtems/dumpbuf.h>
|
||||
#include <rtems/libio.h>
|
||||
|
||||
int Test_fd;
|
||||
|
||||
static void open_it(void)
|
||||
{
|
||||
Test_fd = open( TERMIOS_TEST_DRIVER_DEVICE_NAME, O_RDWR );
|
||||
rtems_test_assert( Test_fd != -1 );
|
||||
}
|
||||
|
||||
static void change_lflag( const char *desc, int mask, int new )
|
||||
{
|
||||
int rc;
|
||||
struct termios attr;
|
||||
|
||||
if (desc) {
|
||||
printf( "Changing c_lflag to: %s\n", desc );
|
||||
}
|
||||
|
||||
rc = tcgetattr( Test_fd, &attr );
|
||||
rtems_test_assert( rc == 0 );
|
||||
|
||||
attr.c_lflag &= ~mask;
|
||||
attr.c_lflag |= new;
|
||||
|
||||
rc = tcsetattr( Test_fd, TCSANOW, &attr );
|
||||
rtems_test_assert( rc == 0 );
|
||||
}
|
||||
|
||||
|
||||
static void read_it(ssize_t expected, int expected_intr)
|
||||
{
|
||||
ssize_t rc;
|
||||
char buf[32];
|
||||
|
||||
rtems_test_assert( expected <= sizeof(buf) );
|
||||
|
||||
rc = read( Test_fd, buf, expected );
|
||||
if (expected_intr) {
|
||||
rtems_test_assert( rc == -1 );
|
||||
rtems_test_assert( errno == EINTR );
|
||||
} else {
|
||||
if ( expected != rc )
|
||||
printf( "ERROR - expected=%zd rc=%zd\n", expected, rc );
|
||||
rtems_test_assert( expected == rc );
|
||||
}
|
||||
}
|
||||
|
||||
static void close_it(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = close( Test_fd );
|
||||
rtems_test_assert( rc == 0 );
|
||||
}
|
||||
|
||||
volatile int sigint_occurred = 0;
|
||||
volatile int sigquit_occurred = 0;
|
||||
|
||||
static void sigint_handler(int signo)
|
||||
{
|
||||
rtems_test_assert(signo == SIGINT);
|
||||
sigint_occurred = 1;
|
||||
}
|
||||
|
||||
static void sigquit_handler(int signo)
|
||||
{
|
||||
rtems_test_assert(signo == SIGQUIT);
|
||||
sigquit_occurred = 1;
|
||||
}
|
||||
|
||||
static void test_read_for_signal(
|
||||
const char *description,
|
||||
int isig_value,
|
||||
char c,
|
||||
int sigint_expected,
|
||||
int sigquit_expected
|
||||
)
|
||||
{
|
||||
char expected[3];
|
||||
|
||||
printf("Test read for %s\n", description);
|
||||
|
||||
expected[0] = c;
|
||||
expected[1] = '\n'; /* in canonical mode, so need \n for read to return */
|
||||
expected[2] = '\0';
|
||||
|
||||
sigint_occurred = 0;
|
||||
sigquit_occurred = 0;
|
||||
|
||||
open_it();
|
||||
|
||||
change_lflag(NULL, ISIG, isig_value);
|
||||
|
||||
termios_test_driver_set_rx( expected, 2 );
|
||||
|
||||
read_it(1, (sigint_expected || sigquit_expected));
|
||||
|
||||
rtems_test_assert(sigint_occurred == sigint_expected);
|
||||
rtems_test_assert(sigquit_occurred == sigquit_expected);
|
||||
close_it();
|
||||
}
|
||||
|
||||
/*
|
||||
* Use a POSIX init thread so signals are enabled.
|
||||
*/
|
||||
static void *POSIX_Init(void *argument)
|
||||
{
|
||||
int rc;
|
||||
|
||||
TEST_BEGIN();
|
||||
|
||||
signal(SIGINT, sigint_handler);
|
||||
signal(SIGQUIT, sigquit_handler);
|
||||
|
||||
puts( "Exercise default ISIG handler with ISIG enabled");
|
||||
test_read_for_signal("VKILL - no signals", ISIG, '\003', 0, 0);
|
||||
test_read_for_signal("VQUIT - no signals", ISIG, '\034', 0, 0);
|
||||
|
||||
puts( "Exercise POSIX ISIG handler with ISIG enabled");
|
||||
rc = rtems_termios_register_isig_handler(rtems_termios_posix_isig_handler);
|
||||
rtems_test_assert( rc == 0 );
|
||||
test_read_for_signal("VKILL - signal caught", ISIG, '\003', 1, 0);
|
||||
test_read_for_signal("VQUIT - signal caught", ISIG, '\034', 0, 1);
|
||||
|
||||
puts( "Exercise default ISIG handler with ISIG enabled");
|
||||
rc = rtems_termios_register_isig_handler(rtems_termios_default_isig_handler);
|
||||
rtems_test_assert( rc == 0 );
|
||||
test_read_for_signal("VKILL - signal caught", ISIG, '\003', 0, 0);
|
||||
test_read_for_signal("VQUIT - signal caught", ISIG, '\034', 0, 0);
|
||||
|
||||
puts( "Exercise POSIX ISIG handler with ISIG disabled");
|
||||
rc = rtems_termios_register_isig_handler(rtems_termios_posix_isig_handler);
|
||||
rtems_test_assert( rc == 0 );
|
||||
test_read_for_signal("VKILL - signal caught", 0, '\003', 0, 0);
|
||||
test_read_for_signal("VQUIT - signal caught", 0, '\034', 0, 0);
|
||||
|
||||
TEST_END();
|
||||
|
||||
rtems_test_exit(0);
|
||||
}
|
||||
|
||||
/* configuration information */
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
|
||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||
#define CONFIGURE_APPLICATION_EXTRA_DRIVERS \
|
||||
TERMIOS_TEST_DRIVER_TABLE_ENTRY
|
||||
|
||||
/* we need to be able to open the test device */
|
||||
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
|
||||
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
|
||||
#define CONFIGURE_MAXIMUM_TIMERS 2
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
#include <rtems/confdefs.h>
|
||||
/* end of file */
|
||||
@@ -0,0 +1,2 @@
|
||||
#define INTERRUPT_DRIVEN
|
||||
#include "../termios10/termios10impl.h"
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <rtems/mw_uid.h>
|
||||
#include "termios_testdriver_intr.h"
|
||||
#include "../termios04/termios_testdriver_intr.h"
|
||||
#include "tmacros.h"
|
||||
|
||||
const char rtems_test_name[] = "UID 1";
|
||||
@@ -123,7 +123,6 @@ rtems_task Init(
|
||||
/* 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
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#include "tmacros.h"
|
||||
#include <rtems/serial_mouse.h>
|
||||
#include "termios_testdriver_intr.h"
|
||||
#include "../termios04/termios_testdriver_intr.h"
|
||||
|
||||
extern const char *Mouse_Type_Short;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user