summaryrefslogtreecommitdiffstats
path: root/c/src/tests/libtests
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1997-10-23 15:12:46 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1997-10-23 15:12:46 +0000
commit514cf30bb5bff7af44363b12182d844c15da3e67 (patch)
tree43e6934d99210d49a540bcf7f3b9338fbcd7293d /c/src/tests/libtests
parentAdded console_reserve_resources. (diff)
downloadrtems-514cf30bb5bff7af44363b12182d844c15da3e67.tar.bz2
Added new test for termios style consoles from Eric Norum.
Diffstat (limited to 'c/src/tests/libtests')
-rw-r--r--c/src/tests/libtests/Makefile.in3
-rw-r--r--c/src/tests/libtests/termios/Makefile.in62
-rw-r--r--c/src/tests/libtests/termios/init.c141
3 files changed, 205 insertions, 1 deletions
diff --git a/c/src/tests/libtests/Makefile.in b/c/src/tests/libtests/Makefile.in
index c2bb1d78d3..a4ea686b76 100644
--- a/c/src/tests/libtests/Makefile.in
+++ b/c/src/tests/libtests/Makefile.in
@@ -14,4 +14,5 @@ include $(PROJECT_ROOT)/make/directory.cfg
LIBRTEMSCPLUSPLUS_yes_V = rtems++
LIBRTEMSCPLUSPLUS = $(LIBRTEMSCPLUSPLUS_$(HAS_CPLUSPLUS)_V)
-SUB_DIRS=cpuuse rtmonuse malloctest stackchk monitor $(LIBRTEMSCPLUSPLUS)
+SUB_DIRS=cpuuse malloctest monitor rtmonuse stackchk \
+ termios $(LIBRTEMSCPLUSPLUS)
diff --git a/c/src/tests/libtests/termios/Makefile.in b/c/src/tests/libtests/termios/Makefile.in
new file mode 100644
index 0000000000..a01fb83ce2
--- /dev/null
+++ b/c/src/tests/libtests/termios/Makefile.in
@@ -0,0 +1,62 @@
+#
+# $Id$
+#
+
+@SET_MAKE@
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH=@srcdir@
+
+SAMPLE=termios
+PGM=${ARCH}/$(SAMPLE).exe
+
+MANAGERS=io
+
+# C source names, if any, go here -- minus the .c
+C_PIECES=init
+C_FILES=$(C_PIECES:%=%.c)
+C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
+
+H_FILES=
+
+DOCTYPES=
+DOCS=$(DOCTYPES:%=$(SAMPLE).%)
+
+SRCS=$(DOCS) $(C_FILES) $(H_FILES)
+OBJS=$(C_O_FILES)
+
+PRINT_SRCS=$(DOCS)
+
+PGM=${ARCH}/$(SAMPLE).exe
+
+include $(RTEMS_CUSTOM)
+include $(PROJECT_ROOT)/make/leaf.cfg
+
+#
+# (OPTIONAL) Add local stuff here using +=
+#
+
+DEFINES +=
+CPPFLAGS +=
+CFLAGS +=
+
+LD_PATHS +=
+LD_LIBS +=
+LDFLAGS +=
+
+#
+# Add your list of files to delete here. The config files
+# already know how to delete some stuff, so you may want
+# to just run 'make clean' first to see what gets missed.
+# 'make clobber' already includes 'make clean'
+#
+
+CLEAN_ADDITIONS +=
+CLOBBER_ADDITIONS +=
+
+all: ${ARCH} $(SRCS) $(PGM)
+ $(INSTALL_VARIANT) -m 555 ${PGM} ${PROJECT_RELEASE}/tests
+ $(INSTALL_VARIANT) -m 555 ${PGM} ${PROJECT_RELEASE}/samples
+
+${PGM}: $(OBJS) $(LINK_FILES)
+ $(make-exe)
diff --git a/c/src/tests/libtests/termios/init.c b/c/src/tests/libtests/termios/init.c
new file mode 100644
index 0000000000..cea9a04c2f
--- /dev/null
+++ b/c/src/tests/libtests/termios/init.c
@@ -0,0 +1,141 @@
+/*
+ * RTEMS configuration/initialization
+ *
+ * This program may be distributed and used for any purpose.
+ * I ask only that you:
+ * 1. Leave this author information intact.
+ * 2. Document any changes you make.
+ *
+ * W. Eric Norum
+ * Saskatchewan Accelerator Laboratory
+ * University of Saskatchewan
+ * Saskatoon, Saskatchewan, CANADA
+ * eric@skatter.usask.ca
+ */
+
+#include <bsp.h>
+
+#define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_MAXIMUM_SEMAPHORES 20
+#define CONFIGURE_MAXIMUM_TIMERS 5
+#define CONFIGURE_MAXIMUM_PERIODS 1
+
+#define CONFIGURE_MICROSECONDS_PER_TICK 1000
+
+#define CONFIGURE_INIT
+rtems_task Init (rtems_task_argument argument);
+
+#include <confdefs.h>
+
+#include <stdio.h>
+#include <unistd.h>
+#include <termios.h>
+#include <errno.h>
+#include <string.h>
+
+/*
+ * Test raw (ICANON=0) input
+ */
+static void
+testRawInput (int vmin, int vtime)
+{
+ int i;
+ struct termios old, new;
+ rtems_interval ticksPerSecond, then, now;
+ unsigned int msec;
+ unsigned long count;
+ int nread;
+ unsigned char cbuf[100];
+
+ printf ("*** Raw input VMIN=%d VTIME=%d ***\n", vmin, vtime);
+ rtems_clock_get (RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticksPerSecond);
+ i = tcgetattr (fileno (stdin), &old);
+ if (i < 0) {
+ printf ("tcgetattr failed: %s\n", strerror (errno));
+ return;
+ }
+ new = old;
+ new.c_lflag &= ~(ICANON|ECHO|ECHONL|ECHOK|ECHOE|ECHOPRT|ECHOCTL);
+ new.c_cc[VMIN] = vmin;
+ new.c_cc[VTIME] = vtime;
+ i = tcsetattr (fileno (stdin), TCSANOW, &new);
+ if (i < 0) {
+ printf ("tcsetattr failed: %s\n", strerror (errno));
+ return;
+ }
+ do {
+ rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &then);
+ count = 0;
+ for (;;) {
+ nread = read (fileno (stdin), cbuf, sizeof cbuf);
+ if (nread < 0) {
+ printf ("Read error: %s\n", strerror (errno));
+ goto out;
+ }
+ count++;
+ if (nread != 0)
+ break;
+ }
+ rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &now);
+ msec = (now - then) * 1000 / ticksPerSecond;
+ printf ("Count:%-10lu Interval:%3u.%3.3d Char:",
+ count, msec / 1000, msec % 1000);
+ for (i = 0 ; i < nread ; i++)
+ printf (" %2.2x", cbuf[i]);
+ printf ("\n");
+ } while (cbuf[0] != 'q');
+ out:
+ i = tcsetattr (fileno (stdin), TCSANOW, &old);
+ if (i < 0)
+ printf ("tcsetattr failed: %s\n", strerror (errno));
+ printf ("*** End of Raw input VMIN=%d VTIME=%d ***\n", vmin, vtime);
+}
+
+/*
+ * RTEMS Startup Task
+ */
+rtems_task
+Init (rtems_task_argument ignored)
+{
+ int i, j;
+
+ printf( "\n\n*** HELLO WORLD TEST ***\n" );
+ printf( "Hello World\n" );
+ printf( "*** END OF HELLO WORLD TEST ***\n" );
+
+ printf( "\n\ntype 'q' to exit raw input tests\n\n" );
+
+ for (;;) {
+ /*
+ * Test blocking, line-oriented input
+ */
+ do {
+ printf (">>> ");
+ fflush (stdout);
+ i = scanf (" %d", &j);
+ printf ("Return: %d Value: %d\n", i, j);
+ } while (i != 0);
+
+ /*
+ * Consume what scanf rejected
+ */
+ while ((i = getchar ()) != '\n')
+ if (i == EOF)
+ break;
+
+ /*
+ * Test character-oriented input
+ */
+ testRawInput (0, 0);
+ testRawInput (0, 20);
+ testRawInput (5, 0);
+ testRawInput (5, 20);
+ }
+ exit (1);
+}