From 8f8f11b514b019e5fda484221d756dd4d736b93b Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Tue, 6 Sep 2011 22:22:36 +0200 Subject: Add tests for POSIX::tc{drain,flow,flush,sendbreak}() We don't want to mess with the user's terminal (as we might mess it up), so attempt to call each function on a disk file, and verify that it fails with ENOTTY. --- ext/POSIX/t/termios.t | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'ext/POSIX') diff --git a/ext/POSIX/t/termios.t b/ext/POSIX/t/termios.t index bb0b5f1d50..380bee678b 100644 --- a/ext/POSIX/t/termios.t +++ b/ext/POSIX/t/termios.t @@ -158,4 +158,22 @@ if (defined $termios) { } +$! = 0; +is(tcdrain(fileno $not_a_tty), undef, 'tcdrain on a non tty should fail'); +cmp_ok($!, '==', POSIX::ENOTTY, 'and set errno to ENOTTY'); + +$! = 0; +is(tcflow(fileno $not_a_tty, TCOON), undef, 'tcflow on a non tty should fail'); +cmp_ok($!, '==', POSIX::ENOTTY, 'and set errno to ENOTTY'); + +$! = 0; +is(tcflush(fileno $not_a_tty, TCOFLUSH), undef, + 'tcflush on a non tty should fail'); +cmp_ok($!, '==', POSIX::ENOTTY, 'and set errno to ENOTTY'); + +$! = 0; +is(tcsendbreak(fileno $not_a_tty, 0), undef, + 'tcsendbreak on a non tty should fail'); +cmp_ok($!, '==', POSIX::ENOTTY, 'and set errno to ENOTTY'); + done_testing(); -- cgit v1.2.1