mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-01-04 01:37:34 -08:00
- EAPI6 - Enable tests - Patch out interactive steps in tests - Add network-test plans Upstream: - Fix handling of warnings leading to crash - Override Net::Telnet::fhopen to do the right thing - Fix autopage handling in constructor - Fix bad splitting and useless modifier in split - Remove hard requirement of Term::ReadKey Package-Manager: Portage-2.3.18, Repoman-2.3.6
126 lines
3.5 KiB
Diff
126 lines
3.5 KiB
Diff
From 60d93af35887e53677be5a0f95591489c2683c73 Mon Sep 17 00:00:00 2001
|
|
From: Kent Fredric <kentnl@gentoo.org>
|
|
Date: Wed, 13 Dec 2017 18:42:56 +1300
|
|
Subject: Remove test interactivity
|
|
|
|
Pass configuration by enviroment variables and don't prompt.
|
|
---
|
|
test.pl | 82 ++++++++++++++++-------------------------------------------------
|
|
1 file changed, 20 insertions(+), 62 deletions(-)
|
|
|
|
diff --git a/test.pl b/test.pl
|
|
index 369bc30..e9f7ae2 100644
|
|
--- a/test.pl
|
|
+++ b/test.pl
|
|
@@ -5,14 +5,8 @@
|
|
|
|
use Test::More tests => 32;
|
|
#use Test::More qw/no_plan/;
|
|
-use ExtUtils::MakeMaker qw/prompt/;
|
|
use Carp;
|
|
use Cwd;
|
|
-my $HAVE_Term_ReadKey = 0;
|
|
-eval "use Term::ReadKey";
|
|
-if(!$@) {
|
|
- $HAVE_Term_ReadKey = 1
|
|
-}
|
|
|
|
use vars qw/$ROUTER $PASSWD $LOGIN $S $EN_PASS $PASSCODE/;
|
|
|
|
@@ -161,18 +155,9 @@ END { cleanup() };
|
|
|
|
sub cleanup {
|
|
return unless -f "input.log" || -f "dump.log";
|
|
-
|
|
- print <<EOB;
|
|
-
|
|
-Would you like to delete the test logs? They will contain
|
|
-security info like your login and passwords. If you ran
|
|
-into problems and wish to investigate, you can save them
|
|
-and manually delete them later.
|
|
-EOB
|
|
-
|
|
my $dir = cwd();
|
|
|
|
- my $ans = prompt("Delete logs", "y");
|
|
+ my $ans = "y";
|
|
if ($ans eq "y") {
|
|
print "Deleting logs in $dir...";
|
|
unlink "input.log" or warn "Can't delete input.log! $!";
|
|
@@ -183,53 +168,26 @@ EOB
|
|
}
|
|
}
|
|
|
|
-sub get_login {
|
|
- print <<EOB;
|
|
-
|
|
-Net::Telnet::Cisco needs to log into a router to
|
|
-perform it\'s full suite of tests. To log in, we
|
|
-need a test router, a login, a password, an
|
|
-optional enable password, and an optional
|
|
-SecurID/TACACS PASSCODE.
|
|
-
|
|
-To skip these tests, hit "return".
|
|
-
|
|
-EOB
|
|
-
|
|
- $ROUTER = prompt("Router:", $ROUTER) or return;
|
|
- $LOGIN = prompt("Login:", $LOGIN) or return;
|
|
- $PASSWD = passprompt("Password:", $PASSWD) or return;
|
|
- $EN_PASS = passprompt("Enable password [optional]:", $EN_PASS);
|
|
- $PASSCODE = passprompt("SecurID/TACACS PASSCODE [optional]:", $PASSCODE);
|
|
+sub maskpass {
|
|
+ return 'not set' unless defined $_[0];
|
|
+ return ( '*' x ( length $_[0] ) ) . ' [masked]';
|
|
}
|
|
|
|
+sub get_login {
|
|
+ $ROUTER = $ENV{CISCO_TEST_ROUTER} or return;
|
|
+ $LOGIN = $ENV{CISCO_TEST_LOGIN} or return;
|
|
+ $PASSWD = $ENV{CISCO_TEST_PASSWORD} or return;
|
|
+ $EN_PASS = $ENV{CISCO_TEST_ENABLE_PASSWORD};
|
|
+ $PASSCODE = $ENV{CISCO_TEST_PASSCODE};
|
|
+
|
|
+ printf STDERR
|
|
+ <<EOB, $ROUTER, $LOGIN, maskpass($PASSWD), maskpass($EN_PASS), maskpass($PASSCODE);
|
|
+Using the following configuration for testing:
|
|
+ Router: %s
|
|
+ Login: %s
|
|
+ Password: %s
|
|
+ Enable Password: %s
|
|
+ SecureID/TACACS PASSCODE: %s
|
|
|
|
-# Lifted from ExtUtils::MakeMaker.
|
|
-#
|
|
-# If the user has Term::ReadKey, we can hide any passwords
|
|
-# they type from shoulder-surfing attacks.
|
|
-#
|
|
-# Args: "Question for user", "optional default answer"
|
|
-sub passprompt ($;$) {
|
|
- my($mess,$def)=@_;
|
|
- $ISA_TTY = -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)) ; # Pipe?
|
|
- Carp::confess("prompt function called without an argument") unless defined $mess;
|
|
- my $dispdef = defined $def ? "[$def] " : " ";
|
|
- $def = defined $def ? $def : "";
|
|
- my $ans;
|
|
- local $|=1;
|
|
- print "$mess $dispdef";
|
|
- if ($ISA_TTY) {
|
|
- if ( $Term::ReadKey::VERSION ) {
|
|
- ReadMode( 'noecho' );
|
|
- chomp($ans = ReadLine(0));
|
|
- ReadMode( 'normal' );
|
|
- print "\n";
|
|
- } else {
|
|
- chomp($ans = <STDIN>);
|
|
- }
|
|
- } else {
|
|
- print "$def\n";
|
|
- }
|
|
- return ($ans ne '') ? $ans : $def;
|
|
+EOB
|
|
}
|
|
--
|
|
2.14.3
|
|
|