[LON-CAPA-cvs] cvs: loncom / londtest
foxr
lon-capa-cvs@mail.lon-capa.org
Tue, 30 Mar 2004 12:16:37 -0000
foxr Tue Mar 30 07:16:37 2004 EDT
Modified files:
/loncom londtest
Log:
Add load/userload tests (pretty pathetic tests, but tests nonetheless).
Index: loncom/londtest
diff -u loncom/londtest:1.2 loncom/londtest:1.3
--- loncom/londtest:1.2 Tue Mar 30 06:55:51 2004
+++ loncom/londtest Tue Mar 30 07:16:37 2004
@@ -2,7 +2,7 @@
# The LearningOnline Network
# lond "LON Daemon" Server (port "LOND" 5663)
#
-# $Id: londtest,v 1.2 2004/03/30 11:55:51 foxr Exp $
+# $Id: londtest,v 1.3 2004/03/30 12:16:37 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -100,6 +100,37 @@
return $status
}
+#------------------------------ Test load, userload.
+#
+# Test to see if load/userload work
+# Each should produce a valid number (only digits and a decimal point in the string).
+# Parameters:
+# TargetHost - The name of the host being tested.
+# Socket - The socket connected to the lonc.
+# Returns:
+# Test result string.
+sub LoadTests {
+ my $TargetHost = shift;
+ my $Socket = shift;
+
+ my $result = "Load: ";
+
+ my $reply = Transact($Socket, "load");
+ if($reply =~ /[^0-9.]/) {
+ $result .= " load failed expected number got $reply\n";
+ } else {
+ $result .= "load ok ";
+}
+
+ $reply = Transact($Socket, "userload");
+ if($reply =~ /[^0-9.]/) {
+ $result .= " userload failed expected number got $reply\n";
+ } else {
+ $result .= "userload ok";
+ }
+ return $result;
+}
+
#------------------------------- Test driver ----------------------------------
#
# Sequentially run the test groupings.
@@ -114,8 +145,16 @@
my $TargetHost = shift;
my $Socket = shift;
+ # ping/pong...
+
print STDERR "Testing ping/pong\n";
my $TestOutput = PingPongTest($TargetHost, $Socket);
+ print STDERR "$TestOutput\n";
+
+ # load...
+
+ print STDERR "Testing load/userload\n";
+ $TestOutput = LoadTests($TargetHost, $Socket);
print STDERR "$TestOutput\n";
}