151 lines (122 with data), 4.4 kB
#!/usr/bin/expect -f
#
# 1) timing - A surprising number of programs (rn, ksh, zsh, telnet,
# etc.) and devices discard or ignore keystrokes that arrive "too
# quickly" after prompts. If you find your new script hanging up at
# one spot, try adding a short sleep just before the previous send.
# Setting "force_conservative" to 1 (see below) makes Expect do this
# automatically - pausing briefly before sending each character. This
# pacifies every program I know of. The -c flag makes the script do
# this in the first place. The -C flag allows you to define a
# character to toggle this mode off and on.
set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .8
exp_send -s -- $arg
}
}
#
# 2) differing output - Some programs produce different output each time
# they run. The "date" command is an obvious example. Another is
# ftp, if it produces throughput statistics at the end of a file
# transfer. If this causes a problem, delete these patterns or replace
# them with wildcards. An alternative is to use the -p flag (for
# "prompt") which makes Expect only look for the last line of output
# (i.e., the prompt). The -P flag allows you to define a character to
# toggle this mode off and on.
#
# Read the man page for more info.
#
# This script can be used to do regresion testing for the OMC-CLP
# application. It will start the CLP and execute the contained
# commands as if a user were typing the commands at the console.
# To add a new test, copy the send and expect lines and add the
# new command as an argument to the "send --" command. Your
# CLP test command should include \t <tabs> instead of hardcoding
# the user friendly suffix. This will allow the command to run
# against any CIMOM.
#
# The Expect application must be installed before running this script.
# If the Expect application is not installed in /usr/bin, then the first
# line of this script must be changed to match the location where the
# Expect application is installed. To run the script, first copy the
# script to the same location where the omcclp application was installed.
# Then execute the script from the command line. If an error occurs, the
# script will stop immediately.
set timeout -1
spawn ./omcclp
match_max 100000
expect_before "FAILED" {exit}
expect "CLP-->"
send -- "version\r"
expect "CLP-->"
# Test the show command with the -display options
send -- "show -dis\tproperties /sys\t\t/cpu\t80\t\r"
expect "CLP-->"
send -- "show -dis\tproperties /sys\t\t/boot\t\t/oem\ten\t\t\r"
expect "CLP-->"
send -- "show -dis\tassociations /sys\t\t/fan\t\r"
expect "CLP-->"
send -- "show -dis\ttargets /sys\t\t/fan\t\r"
expect "CLP-->"
send -- "show -dis\tverbs /sys\t\t/fan\t\r"
expect "CLP-->"
send -- "show -dis\tproperties,associations,targets,verbs /sys\t\t/fan\t\r"
expect "CLP-->"
send -- "show -dis\tproperties /sys\t\t/cpu*\r"
expect "CLP-->"
send -- "show -dis\tproperties /sys\t\t/logs\t/log* name==\"/var/log/messages\""
expect "CLP-->"
# Test the -level option
send -- "show -dis\tproperties -l\t 2 /sys\t\t/setti\t\t\r"
expect "CLP-->"
# Test target associations
send -- "show -dis\tproperties /sys\t\t=>instal\t=>\t\r"
expect "CLP-->"
send -- "show -dis\tproperties /sys\t\t=>hostedfir\t\r"
expect "CLP-->"
# Test embedded assocations
send -- "show -dis\tproperties /sys\t\t>>hostedfir\t>>\t1\t\r"
expect "CLP-->"
# Test the stop/start commands
send -- "stop /sys\t\t/cpu8\t\r"
expect "CLP-->"
send -- "show -dis\t properties=status /sys\t\t/cpu8\t\r"
expect {
"Status = OK" {exit}
"CLP-->"
}
send -- "start /sys\t\t/cpu8\t\r"
expect "CLP-->"
send -- "show -dis\t properties=status /sys\t\t/cpu8\t\r"
expect {
"Status = Stopped" {exit}
"CLP-->"
}
# Test the cd command and relative paths
send -- "cd /sys\t\t/fan\t\r"
expect "CLP-->"
send -- "show -dis\tproperties\r"
expect "CLP-->"
send -- "cd ..\r"
expect "CLP-->"
send -- "show -dis\tproperties\r"
expect "CLP-->"
send -- "show -dis\tproperties ./fan\t\r"
expect "CLP-->"
# Test the create command
# Test the delete command
# Test the set command
# Test the reset command
# Test the help command
send -- "help show\r"
expect "CLP-->"
# Test the version command
send -- "version\r"
expect "CLP-->"
# Test the exit command
send -- "exit\r"
expect eof