1# Before `make install' is performed this script should be runnable with 2# `make test'. After `make install' it should work as `perl test.pl' 3 4######################### We start with some black magic to print on failure. 5 6# Change 1..1 below to 1..last_test_to_print . 7# (It may become useful if the test is moved to ./t subdirectory.) 8 9BEGIN { $| = 1; print "1..3\n"; } 10END {print "not ok 1\n" unless $loaded;} 11use lib '..'; 12use Device::Modem; 13$loaded = 1; 14print "ok 1\n"; 15 16######################### End of black magic. 17 18$|++; 19 20my $port = $ENV{'DEV_MODEM_PORT'}; 21my $baud = $ENV{'DEV_MODEM_BAUD'}; 22 23unless( $port && $baud ) { 24 print "skip 1\nskip 2\nskip 3\n"; 25 exit; 26} 27 28my $modem = Device::Modem->new( port => $port ); 29 30if( $modem->connect( baudrate => $baud ) ) { 31 print "ok 2\n"; 32} else { 33 print "not ok 2\n"; 34 die "cannot connect to $port serial port!: $!"; 35} 36 37print 'testing S-registers functions...', "\n"; 38 39my $v1 = $modem->S_register(1); 40my $v2 = $modem->S_register(1, 72); 41my $v3 = $modem->S_register(1); 42my $v4 = $modem->S_register(1, $v1); 43my $v5 = $modem->S_register(1); 44 45if( $v1 eq $v5 && $v1 == $v5 && 46 $v2 == 72 && $v3 == 72 && 47 $v4 eq $v1 && $v4 == $v1 ) { 48 print "ok 3\n"; 49} else { 50 print "not ok 3\n"; 51} 52