]> xenbits.xensource.com Git - people/iwj/osstest.git/commitdiff
Serial: Refactor debug key sending into separate request_debug function
authorIan Campbell <ian.campbell@citrix.com>
Fri, 11 Oct 2013 15:27:05 +0000 (16:27 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 11 Oct 2013 15:40:10 +0000 (16:40 +0100)
This puts the list of keys to send into common code.

Osstest/Serial/noop.pm
Osstest/Serial/sympathy.pm
Osstest/TestSupport.pm

index 1b980c23f27de93e656b6cf3fe9c08f8682e22ef..d0de9cdd863db4c9245f39500213530d3439297a 100644 (file)
@@ -39,6 +39,10 @@ sub new {
     return bless { }, $class;
 }
 
+sub request_debug {
+    return 0;
+}
+
 sub fetch_logs {
     my ($mo) = @_;
     logm("serial access method \`noop',".
index 3128b684fd7415c99e6cd190710a8d6f7a8aaabe..d6bf425012c1ad0c659f26eaf8b4358ec6735a10 100644 (file)
@@ -57,21 +57,15 @@ sub new {
     return bless $mo, $class;
 }
 
-sub fetch_logs {
-    my ($mo) = @_;
-
-    my $started= $mjobdb->jobdb_flight_started_for_log_capture($flight);
+sub request_debug {
+    my ($mo,$conswitch,$xenkeys,$guestkeys) = @_;
 
-    my $ho = $mo->{Host};
-    my $logpat = $mo->{Pattern};
     my $targhost= $mo->{Server};
 
-    logm("requesting debug information");
-
     my ($sshopts) = sshopts();
     my $sympwrite= sub {
         my ($what,$str,$pause) = @_;
-        logm("sending $what");
+        logm("sympathy sending $what");
         if (!eval {
             local ($SIG{'PIPE'}) = 'IGNORE';
             my $sock= $mo->{Socket};
@@ -89,18 +83,32 @@ sub fetch_logs {
         }
         return 1;
     };
+
     my $debugkeys= sub {
-        my ($what, $keys) = @_;
-        foreach my $k (split //, $keys) {
-            $sympwrite->("$what debug info request, debug key $k", $k, 2);
-        }
+       my ($what, $keys) = @_;
+       foreach my $k (split //, $keys) {
+           $sympwrite->("$what debug info request, debug key $k", $k, 2);
+       }
     };
-    $sympwrite->('request for input to Xen',"\x18\x18\x18",1);
-    $debugkeys->('Xen',"0HMQacdegimnrstuvz");
+
+    $sympwrite->('request for input to Xen', $conswitch, 1);
+    $debugkeys->('Xen', $xenkeys);
     sleep(10);
-    $debugkeys->('guest',"q");
+    $debugkeys->('guest', $guestkeys);
     sleep(10);
-    $sympwrite->("RET to dom0","\x18\x18\x18\r", 5);
+    $sympwrite->("RET to dom0","$conswitch\r", 5);
+
+    return 1;
+}
+
+sub fetch_logs {
+    my ($mo) = @_;
+
+    my $started= $mjobdb->jobdb_flight_started_for_log_capture($flight);
+
+    my $ho = $mo->{Host};
+    my $logpat = $mo->{Pattern};
+    my $targhost= $mo->{Server};
 
     logm("collecting serial logs since $started from $targhost");
 
index 75fb7cc179dbaefb8816d3103b8f6eaf63438eb8..f4ec0557bd5e19b32c613c59da79d54b18e03ac6 100644 (file)
@@ -635,7 +635,19 @@ sub serial_host_setup ($) {
 
 sub serial_fetch_logs ($) {
     my ($ho) = @_;
+
+    logm("serial: requesting debug information from $ho->{Name}");
+
+    foreach my $mo (@{ $ho->{SerialMethobjs} }) {
+       $mo->request_debug("\x18\x18\x18",
+                          "0HMQacdegimnrstuvz",
+                          "q") or next;
+       # use the first method which supports ->request_debug.
+       last;
+    }
+
     logm("serial: collecting logs for $ho->{Name}");
+
     foreach my $mo (@{ $ho->{SerialMethobjs} }) {
        $mo->fetch_logs();
     }