1#!perl -T 2 3BEGIN { 4 use Config; 5 use Test::More; 6 plan skip_all => "POSIX is unavailable" 7 if $Config{'extensions'} !~ m!\bPOSIX\b!; 8} 9use strict; 10use POSIX; 11BEGIN { 12 plan skip_all => "POSIX::Termios not implemented" 13 if !eval "POSIX::Termios->new;1" 14 and $@=~/not implemented/; 15} 16 17 18my @getters = qw(getcflag getiflag getispeed getlflag getoflag getospeed); 19 20plan tests => 3 + 2 * (3 + NCCS() + @getters); 21 22my $r; 23 24# create a new object 25my $termios = eval { POSIX::Termios->new }; 26is( $@, '', "calling POSIX::Termios->new" ); 27ok( defined $termios, "\tchecking if the object is defined" ); 28isa_ok( $termios, "POSIX::Termios", "\tchecking the type of the object" ); 29 30# testing getattr() 31 32SKIP: { 33 -t STDIN or skip("STDIN not a tty", 2); 34 $r = eval { $termios->getattr(0) }; 35 is( $@, '', "calling getattr(0)" ); 36 ok( defined $r, "\tchecking if the returned value is defined: $r" ); 37} 38 39SKIP: { 40 -t STDOUT or skip("STDOUT not a tty", 2); 41 $r = eval { $termios->getattr(1) }; 42 is( $@, '', "calling getattr(1)" ); 43 ok( defined $r, "\tchecking if the returned value is defined: $r" ); 44} 45 46SKIP: { 47 -t STDERR or skip("STDERR not a tty", 2); 48 $r = eval { $termios->getattr(2) }; 49 is( $@, '', "calling getattr(2)" ); 50 ok( defined $r, "\tchecking if the returned value is defined: $r" ); 51} 52 53# testing getcc() 54for my $i (0..NCCS()-1) { 55 $r = eval { $termios->getcc($i) }; 56 is( $@, '', "calling getcc($i)" ); 57 ok( defined $r, "\tchecking if the returned value is defined: $r" ); 58} 59 60# testing getcflag() 61for my $method (@getters) { 62 $r = eval { $termios->$method() }; 63 is( $@, '', "calling $method()" ); 64 ok( defined $r, "\tchecking if the returned value is defined: $r" ); 65} 66 67