conmux: initial import of the Console Multiplexor

Import the Console Multiplexor (CONMUX) subsystem, developed by
the IBM Linux Technology Center.  CONMUX is a console abstractor,
presenting any console with a consistent location, naming and
semantic.  Access to the console and hardreset of the machine is
the same regardless of the underlying access methodology.

Through this abstraction we create a simple and consistent interface
to disparate consoles simplifying programatic use of the console.
This provides for easy integration of console handling into a
test harness.  This allow CONMUX to be used to capture Linux kernel
messages only available on the external system console, as well
as providing a framework for detecting, diagnosing and rescuing
paniced and hung systems.

Signed-off-by: Andy Whitcroft <andyw@uk.ibm.com>
Acked-by: Dustin Kirkland <dustin.kirkland@us.ibm.com>


git-svn-id: http://test.kernel.org/svn/autotest/trunk@425 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/conmux/helpers/tickle-helper b/conmux/helpers/tickle-helper
new file mode 100755
index 0000000..2623c52
--- /dev/null
+++ b/conmux/helpers/tickle-helper
@@ -0,0 +1,99 @@
+#! /usr/bin/expect
+#
+# tickle-helper -- watch for reboots and 'tickle' the console during them
+#
+# Some consoles get broken when the machine reboots.  There are normally
+# fixed by trying to use them at or arround the reboot.  Watch for reboots
+# and initiate use of the console to trigger a drop/reconnect cycle.
+#
+# (C) Copyright IBM Corp. 2004, 2005, 2006
+# Author: Andy Whitcroft <andyw@uk.ibm.com>
+#
+# The Console Multiplexor is released under the GNU Public License V2
+#
+set P "tickle-helper"
+log_user 0
+
+if {$argc != 0} {
+	puts stderr "Usage: $P"
+	exit 1
+}
+
+proc note {msg} {
+	global P
+	puts stderr "$P: $msg"
+}
+proc warn {msg} {
+	global P
+	puts stderr "$P: $msg"
+	puts "~\$msg $msg"
+}
+
+proc tickle {} {
+	set timeout 5
+	warn "tickling console ..."
+	puts ""
+	set now [clock seconds]
+	expect_user {
+		{blade: ERROR: console lost} {
+		}
+		{Elapsed time since release of system processors:} {
+		}
+		"*\n" {
+			if {([clock seconds] - $now) > 5} {
+				set now [clock seconds]
+				warn "tickling console ..."
+				puts ""
+			}
+			exp_continue
+		}
+		timeout {
+			set now [clock seconds]
+			warn "tickling console ..."
+			puts ""
+			exp_continue
+		}
+	}
+	set timeout -1
+	warn "tickle complete ..."
+}
+
+set timeout -1
+set likely 0
+expect_user {
+	{TEST;} {
+		warn "test trigger detected"
+		exp_continue
+	}
+	-re {Unmounting file systems|Unmounting local filesystems...} {
+		note "controlled reboot in progress ..."
+		set likely [clock seconds]
+		exp_continue
+	}
+	-ex {***** REBOOT LINUX *****} {
+		note "fsck failure occured ..."
+		set likely [clock seconds]
+		exp_continue
+	}
+	-re {HARDBOOT INITIATED|initated a hard reset} {
+		tickle
+		exp_continue
+	}
+	-re {Please stand by while rebooting the system|Restarting system} {
+		if {$likely != 0} {
+			warn "shutdown complete, restart indicated"
+			tickle
+			set likely 0
+		} else {
+			warn "likely false positive"
+		}
+		exp_continue
+	}
+	"*\n" {
+		if {$likely > 0 && ([clock seconds] - $likely) > 60} {
+			warn "trigger timeout"
+			set likely 0
+		}
+		exp_continue
+	}
+}