2010-06-07 Joel Sherrill <joel.sherrill@oarcorp.com>

* termios01/init.c, termios01/termios01.scn, termios02/init.c,
	termios02/termios02.scn: Add tests for cfigetspeed(), cfogetspeed(),
	cfisetspeed(), cfosetspeed(), ctermid(), tcflow(), tcflush(),
	tcsendbreak(), tcsetpgrp(), and tcgetpgrp(). Some of these methods
	are minimal implementations so the tests will have to grow as the
	methods grow.
This commit is contained in:
Joel Sherrill
2010-06-07 18:33:09 +00:00
parent 7d01d244d7
commit 9f5f6f533c
5 changed files with 284 additions and 14 deletions

View File

@@ -1,3 +1,12 @@
2010-06-07 Joel Sherrill <joel.sherrill@oarcorp.com>
* termios01/init.c, termios01/termios01.scn, termios02/init.c,
termios02/termios02.scn: Add tests for cfigetspeed(), cfogetspeed(),
cfisetspeed(), cfosetspeed(), ctermid(), tcflow(), tcflush(),
tcsendbreak(), tcsetpgrp(), and tcgetpgrp(). Some of these methods
are minimal implementations so the tests will have to grow as the
methods grow.
2010-06-07 Sebastian Huber <sebastian.huber@embedded-brains.de>
* heapwalk/init.c, malloctest/init.c: Update for heap extend changes.

View File

@@ -135,14 +135,17 @@ void test_termios_baud2index(void)
rtems_test_assert( i == -1 );
if ( i != -1 )
for (i=0 ; baud_table[i].constant != -1 ; i++ ) {
printf( "termios_baud_to_index(B%" PRIdrtems_termios_baud_t ") - OK\n", baud_table[i].baud );
index = rtems_termios_baud_to_index( baud_table[i].constant );
if ( index != i ) {
printf( "ERROR - returned %d should be %d\n", index, i );
rtems_test_exit(0);
for (i=0 ; baud_table[i].constant != -1 ; i++ ) {
printf(
"termios_baud_to_index(B%" PRIdrtems_termios_baud_t ") - OK\n",
baud_table[i].baud
);
index = rtems_termios_baud_to_index( baud_table[i].constant );
if ( index != i ) {
printf( "ERROR - returned %d should be %d\n", index, i );
rtems_test_exit(0);
}
}
}
}
/*
@@ -377,6 +380,71 @@ void test_termios_set_stop_bits(
}
}
void test_termios_cfoutspeed(void)
{
int i;
int sc;
speed_t speed;
struct termios term;
tcflag_t bad;
bad = CBAUD << 1;
memset( &term, '\0', sizeof(term) );
puts( "cfsetospeed(BAD BAUD) - EINVAL" );
sc = cfsetospeed( &term, bad );
rtems_test_assert( sc == -1 );
rtems_test_assert( errno == EINVAL );
for (i=0 ; baud_table[i].constant != -1 ; i++ ) {
memset( &term, '\0', sizeof(term) );
printf(
"cfsetospeed(B%" PRIdrtems_termios_baud_t ") - OK\n",
baud_table[i].baud
);
sc = cfsetospeed( &term, baud_table[i].constant );
rtems_test_assert( !sc );
printf(
"cfgetospeed(B%" PRIdrtems_termios_baud_t ") - OK\n",
baud_table[i].baud
);
speed = cfgetospeed( &term );
rtems_test_assert( speed == baud_table[i].constant );
}
}
void test_termios_cfinspeed(void)
{
int i;
int sc;
speed_t speed;
struct termios term;
tcflag_t bad;
bad = CBAUD << 1;
memset( &term, '\0', sizeof(term) );
puts( "cfsetispeed(BAD BAUD) - EINVAL" );
sc = cfsetispeed( &term, bad );
rtems_test_assert( sc == -1 );
rtems_test_assert( errno == EINVAL );
for (i=0 ; baud_table[i].constant != -1 ; i++ ) {
memset( &term, '\0', sizeof(term) );
printf(
"cfsetispeed(B%" PRIdrtems_termios_baud_t ") - OK\n",
baud_table[i].baud
);
sc = cfsetispeed( &term, baud_table[i].constant );
rtems_test_assert( !sc );
printf(
"cfgetispeed(B%" PRIdrtems_termios_baud_t ") - OK\n",
baud_table[i].baud
);
speed = cfgetispeed( &term );
rtems_test_assert( speed == baud_table[i].constant );
}
}
rtems_task Init(
rtems_task_argument ignored
)
@@ -481,6 +549,10 @@ rtems_task Init(
test_termios_set_stop_bits(test);
test_termios_cfoutspeed();
test_termios_cfinspeed();
puts( "Init - close - " TERMIOS_TEST_DRIVER_DEVICE_NAME " - OK" );
rc = close( test );
if ( rc != 0 ) {

View File

@@ -196,5 +196,87 @@ tcsetattr(TCSANOW, 2 bits) - OK
set_attributes - B38400 8-NONE-2
tcsetattr(TCSADRAIN, 2 bits) - OK
set_attributes - B38400 8-NONE-2
cfsetospeed(BAD BAUD) - EINVAL
cfsetospeed(B0) - OK
cfgetospeed(B0) - OK
cfsetospeed(B50) - OK
cfgetospeed(B50) - OK
cfsetospeed(B75) - OK
cfgetospeed(B75) - OK
cfsetospeed(B110) - OK
cfgetospeed(B110) - OK
cfsetospeed(B134) - OK
cfgetospeed(B134) - OK
cfsetospeed(B150) - OK
cfgetospeed(B150) - OK
cfsetospeed(B200) - OK
cfgetospeed(B200) - OK
cfsetospeed(B300) - OK
cfgetospeed(B300) - OK
cfsetospeed(B600) - OK
cfgetospeed(B600) - OK
cfsetospeed(B1200) - OK
cfgetospeed(B1200) - OK
cfsetospeed(B1800) - OK
cfgetospeed(B1800) - OK
cfsetospeed(B2400) - OK
cfgetospeed(B2400) - OK
cfsetospeed(B4800) - OK
cfgetospeed(B4800) - OK
cfsetospeed(B9600) - OK
cfgetospeed(B9600) - OK
cfsetospeed(B19200) - OK
cfgetospeed(B19200) - OK
cfsetospeed(B38400) - OK
cfgetospeed(B38400) - OK
cfsetospeed(B57600) - OK
cfgetospeed(B57600) - OK
cfsetospeed(B115200) - OK
cfgetospeed(B115200) - OK
cfsetospeed(B230400) - OK
cfgetospeed(B230400) - OK
cfsetospeed(B460800) - OK
cfgetospeed(B460800) - OK
cfsetispeed(BAD BAUD) - EINVAL
cfsetispeed(B0) - OK
cfgetispeed(B0) - OK
cfsetispeed(B50) - OK
cfgetispeed(B50) - OK
cfsetispeed(B75) - OK
cfgetispeed(B75) - OK
cfsetispeed(B110) - OK
cfgetispeed(B110) - OK
cfsetispeed(B134) - OK
cfgetispeed(B134) - OK
cfsetispeed(B150) - OK
cfgetispeed(B150) - OK
cfsetispeed(B200) - OK
cfgetispeed(B200) - OK
cfsetispeed(B300) - OK
cfgetispeed(B300) - OK
cfsetispeed(B600) - OK
cfgetispeed(B600) - OK
cfsetispeed(B1200) - OK
cfgetispeed(B1200) - OK
cfsetispeed(B1800) - OK
cfgetispeed(B1800) - OK
cfsetispeed(B2400) - OK
cfgetispeed(B2400) - OK
cfsetispeed(B4800) - OK
cfgetispeed(B4800) - OK
cfsetispeed(B9600) - OK
cfgetispeed(B9600) - OK
cfsetispeed(B19200) - OK
cfgetispeed(B19200) - OK
cfsetispeed(B38400) - OK
cfgetispeed(B38400) - OK
cfsetispeed(B57600) - OK
cfgetispeed(B57600) - OK
cfsetispeed(B115200) - OK
cfgetispeed(B115200) - OK
cfsetispeed(B230400) - OK
cfgetispeed(B230400) - OK
cfsetispeed(B460800) - OK
cfgetispeed(B460800) - OK
Init - close - /dev/test - OK
*** END OF TEST TERMIOS 01 ***

View File

@@ -1,5 +1,5 @@
/*
* COPYRIGHT (c) 1989-2009.
* COPYRIGHT (c) 1989-2010.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -12,33 +12,119 @@
#include "tmacros.h"
#include <termios.h>
#include <errno.h>
#include <unistd.h>
rtems_task Init(
rtems_task_argument ignored
)
{
int sc;
pid_t pid;
char *term_name_p;
char term_name[32];
printf( "\n\n*** TERMIOS 02 TEST ***\n" );
puts( "\n\n*** TERMIOS 02 TEST ***" );
printf( "tcdrain(12) - EBADF\n" );
puts( "tcdrain(12) - EBADF" );
sc = tcdrain(12);
rtems_test_assert( sc == -1 );
rtems_test_assert( errno == EBADF );
printf( "tcdrain(stdin) - OK\n" );
puts( "tcdrain(stdin) - OK" );
sc = tcdrain(0);
rtems_test_assert( !sc );
printf( "tcdrain(stdout) - OK\n" );
puts( "tcdrain(stdout) - OK" );
tcdrain(1);
rtems_test_assert( !sc );
printf( "tcdrain(stderr) - OK\n" );
puts( "tcdrain(stderr) - OK" );
tcdrain(2);
rtems_test_assert( !sc );
printf( "*** END OF TERMIOS 02 TEST ***\n" );
puts( "" );
/***** TEST TCFLOW *****/
puts( "tcflow(stdin, TCOOFF) - ENOTSUP" );
sc = tcflow( 0, TCOOFF );
rtems_test_assert( sc == -1 );
rtems_test_assert( errno = ENOTSUP );
puts( "tcflow(stdin, TCOON) - ENOTSUP" );
sc = tcflow( 0, TCOON );
rtems_test_assert( sc == -1 );
rtems_test_assert( errno = ENOTSUP );
puts( "tcflow(stdin, TCIOFF) - ENOTSUP" );
sc = tcflow( 0, TCIOFF );
rtems_test_assert( sc == -1 );
rtems_test_assert( errno = ENOTSUP );
puts( "tcflow(stdin, TCION) - ENOTSUP" );
sc = tcflow( 0, TCION );
rtems_test_assert( sc == -1 );
rtems_test_assert( errno = ENOTSUP );
puts( "tcflow(stdin, 22) - EINVAL" );
sc = tcflow( 0, 22 );
rtems_test_assert( sc == -1 );
rtems_test_assert( errno = EINVAL );
puts( "" );
/***** TEST TCFLUSH *****/
puts( "tcflush(stdin, TCIFLUSH) - ENOTSUP" );
sc = tcflush( 0, TCIFLUSH );
rtems_test_assert( sc == -1 );
rtems_test_assert( errno = ENOTSUP );
puts( "tcflush(stdin, TCOFLUSH) - ENOTSUP" );
sc = tcflush( 0, TCOFLUSH );
rtems_test_assert( sc == -1 );
rtems_test_assert( errno = ENOTSUP );
puts( "tcflush(stdin, TCIOFLUSH) - ENOTSUP" );
sc = tcflush( 0, TCIOFLUSH );
rtems_test_assert( sc == -1 );
rtems_test_assert( errno = ENOTSUP );
puts( "tcflush(stdin, 22) - EINVAL" );
sc = tcflush( 0, 22 );
rtems_test_assert( sc == -1 );
rtems_test_assert( errno = EINVAL );
puts( "" );
/***** TEST TCGETPGRP *****/
puts( "tcgetpgrp( 1 ) - OK" );
pid = tcgetpgrp(1);
rtems_test_assert( pid == getpid() );
puts( "tcsetpgrp( 1, 3 ) - OK" );
sc = tcsetpgrp( 1, 3 );
rtems_test_assert( !sc );
puts( "" );
/***** TEST TCSENDBREAK *****/
puts( "tcsendbreak( 1, 0 ) - OK" );
sc = tcsendbreak( 1, 0 );
rtems_test_assert( !sc );
puts( "" );
/***** TEST CTERMID *****/
puts( "ctermid( NULL ) - OK" );
term_name_p = ctermid( NULL );
rtems_test_assert( term_name_p );
printf( "ctermid ==> %s\n", term_name_p );
puts( "ctermid( term_name ) - OK" );
term_name_p = ctermid( term_name );
rtems_test_assert( term_name_p == term_name );
printf( "ctermid ==> %s\n", term_name_p );
puts( "*** END OF TERMIOS 02 TEST ***" );
exit( 0 );
}

View File

@@ -3,4 +3,25 @@ tcdrain(12) - EBADF
tcdrain(stdin) - OK
tcdrain(stdout) - OK
tcdrain(stderr) - OK
tcflow(stdin, TCOOFF) - ENOTSUP
tcflow(stdin, TCOON) - ENOTSUP
tcflow(stdin, TCIOFF) - ENOTSUP
tcflow(stdin, TCION) - ENOTSUP
tcflow(stdin, 22) - EINVAL
tcflush(stdin, TCIFLUSH) - ENOTSUP
tcflush(stdin, TCOFLUSH) - ENOTSUP
tcflush(stdin, TCIOFLUSH) - ENOTSUP
tcflush(stdin, 22) - EINVAL
tcgetpgrp( 1 ) - OK
tcsetpgrp( 1, 3 ) - OK
tcsendbreak( 1, 0 ) - OK
ctermid( NULL ) - OK
ctermid ==> /dev/console
ctermid( term_name ) - OK
ctermid ==> /dev/console
*** END OF TERMIOS 02 TEST ***