blob: de6df161d2f8c0e1518203ed0f7190e7182b957e [file] [log] [blame]
################################################################################
## ##
## Copyright (c) International Business Machines Corp., 2001 ##
## ##
## This program is free software; you can redistribute it and#or modify ##
## it under the terms of the GNU General Public License as published by ##
## the Free Software Foundation; either version 2 of the License, or ##
## (at your option) any later version. ##
## ##
## This program is distributed in the hope that it will be useful, but ##
## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ##
## for more details. ##
## ##
## You should have received a copy of the GNU General Public License ##
## along with this program; if not, write to the Free Software ##
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ##
## ##
################################################################################
#
# File: runltp
#
# Description: This program is a Graphical User Interface (GUI)
# Control Centre for LTP. The Control Centre provides
# functionality to Compile, Execute and View Results of
# LTP test cases.
#
# Note: The commands listed below are executed in the background and
# the function checks to see at priodic intervals (10s) if this
# program is still alive and runnning. If it is still
# running the output of this program is displayed on a window,
# or the status bar is updated to indicate progress.
# if anyone has a better idea, delete this "Note" and
# send me the patch.
# 1. make clean
# 2. make
# 3. make install
# 4. runalltests.sh
#
# Author: Manoj Iyer - manjo@mail.utexas.edu
#
# Thanks: Jim Choate - For suggesting the use of dialog command.
#
# History: March 26 2003 - Created.
#
#! /bin/bash
# Function: cleanup
#
# Description: Remove all temporary files created by this program. Cleanup
# always called on program exit.
#
# Input: NONE
#
# Output: NONE
cleanup()
{
rm -f /tmp/runltp.*
}
# Function: display_info_msg
#
# Description: Displays informational messages window. This window may
# may be used to display information like errors, instructions
# etc to the user. The window is dismissed when the user hits
# the [ENTER] key.
#
# Input: $1 - Title the needs to be displayed on the window.
# eg: ERROR: Compiling LTP
# $2 - Message text.
#
# Output: Information message window.
display_info_msg()
{
dialog --backtitle "Linux Test Project Control Centre" \
--cr-wrap \
--tab-correct \
--title " $1 " \
--msgbox " $2 " 10 70
return $?
}
# Function: do_make_clean
#
# Description: This function executes a "make clean" under the ltp-mmddyy/
# directory inorder to remove executables and object files
# that may exist from previous compilation. It displays the
# progress in a window, and indicated percent complete.
#
# Input: NONE
#
# Output: Progress window indicating percent completed.
do_make_clean()
{
RC=1
PCT=10
make clean &>/tmp/runltp.comperr.$$ &
(
while [ $RC -ne 0 ]
do
RC=$(ps -C make | grep make | wc -l | awk '{print $1}')
echo "XXX"
echo $PCT
echo "XXX"
PCT=`expr $PCT + 10`
sleep 1
done
) |
dialog --backtitle "Linux Test Project Control Centre" \
--title "Compiling LTP testsuite - clean" \
--gauge "Percent completed" 10 70
return
}
# Function: do_make
#
# Description: This function executes a "make" under the ltp-mmddyy/
# directory and creates executables, object files & libraries
# It displays the progress in a window, and indicated percent
# complete.
#
# Input: NONE
#
# Output: Progress window indicating percent completed.
do_make()
{
RC=1
PCT=1
make &>/tmp/runltp.comperr.$$ &
(
while [ $RC -ne 0 ]
do
RC=$(ps -C make | grep make | wc -l | awk '{print $1}')
echo "XXX"
echo $PCT
echo "XXX"
PCT=`expr $PCT + 1`
sleep 10s
done
) |
dialog --backtitle "Linux Test Project Control Centre" \
--title "Compiling LTP testsuite - make" \
--gauge "Percent completed" 10 70
}
# Function: do_make_install
#
# Description: This function executes a "make install" under the ltp-mmddyy/
# directory inorder to install executables and libraries,
# the install is done under ltp-mmddyy/testcases/bin/ .
# It displays the progress in a window, and indicated percent
# complete.
#
# Input: NONE
#
# Output: Progress window indicating percent completed.
do_make_install()
{
RC=1
PCT=1
make install &>/tmp/runltp.comperr.$$ &
(
while [ $RC -ne 0 ]
do
RC=$(ps -C make | grep make | wc -l | awk '{print $1}')
echo "XXX"
echo $PCT
echo "XXX"
PCT=`expr $PCT + 1`
sleep 10s
done
) |
dialog --backtitle "Linux Test Project Control Centre" \
--title "Compiling LTP testsuite - install" \
--gauge "Percent completed" 10 70
}
# Function: compile_ltp
#
# Description: Checks for commands that are pre-reqs for compiling and
# installing LTP. It displays a confirmation window inorder to
# confirm the choice made by the user.
#
# Calls: do_make_clean()
# do_make()
# do_make_install()
#
# Input: NONE
#
# Output: Confirmation window.
compile_ltp()
{
dialog --backtitle "Linux Test Project Control Centre" \
--title "Compiling LTP testsuite"\
--yesno "This will compile all the test cases in\
LTP test suite and place the executables\
in ltp-mmddyy/testcases/bin directory. Do\
you wish to continue ??" 7 70 || RC=$?
case $RC in
0) \
for cmd in cc make lex ;
do \
which $cmd &>/tmp/runltp.err.$$ ;
if [ $? -ne 0 ] ;
then \
display_info_msg "Compiling LTP testsuite" \
"ERROR: command $cmd not found, $cmd is\
required to compile LTP test cases. Please\
install $cmd or export PATH correctly before\
running this program" ;
return ;
fi ;
done ;
do_make_clean ;
do_make ;
do_make_install ;
return ;;
1) return ;;
255) return ;;
esac
}
# Function: disp_ltpres
#
# Description: The results generated after the ltp execution located under
# ltp-mmddyy/results/ directory in a text (ASCII) file called
# results.todaysdate. This function displays this file in a
# window. If the results file does not exit it displays an
# info message window notifing the user that LTP test cases
# need to be executed inorder to view results.
#
# Input: ltp-mmddyy/results/results.todaysdate
#
# Output: Window displaying results of testcases that were executed.
disp_ltpres()
{
RC=0
if ! [ -f ./results/results.$(date -I) ]
then
display_info_msg "LTP Test Results" \
"Sorry cannot display test results, you have to run \
the test cases first. Please choose the Execute LTP \
option in the Main Menu."
return
fi
dialog --backtitle "Linux Test Project Control Centre" \
--exit-label "Return to Main Menu" \
--title "LTP Test Results. Scroll [UP] [DOWN]/[PGUP] [PGDN]" \
--textbox ./results/results.$(date -I) 17 70
dialog --backtitle "Linux Test Project Control Centre" \
--defaultno \
--title "LTP Test Results." \
--yesno "Would you like to share these results with the LTP \
community by posting it to the LTP results mailing list?" \
7 70 || RC=$?
case $RC in
0) \
mail ltp-results@lists.sourceforge.net < \
./results/results.$(date -I) ;
return ;;
1) return ;;
255) return ;;
esac
return
}
# Function: exectest_screenout
#
# Description: Execute tests by calling runalltests.sh, display test status
# in a window.
#
# Input: $1 - Flag to be passed to runalltests.sh inorder to run
# networking tests.
#
# Output: Window showing messages printed by testcases.
exectest_screenout()
{
RC=1 # setting return code to 1, to loop in while
# remove old results file
rm ./results/results.$(date -I) &>/dev/null
# execute runalltests.sh with user defined command file.
./runalltests.sh -q -p $1 -l results.$(date -I) \
-f /tmp/runltp.test.list.$$ &>/tmp/runltp.runall.out.$$ &
(
while [ $RC -ne 0 ]
do
RC=$(ps -C runalltests.sh | grep runalltests.sh | wc -l | \
awk '{print $1}')
done
) |
dialog --backtitle "Linux Test Project Control Centre" \
--clear \
--exit-label "Return to Main Menu" \
--title "Executing LTP testsuite - Screen out" \
--tailbox /tmp/runltp.runall.out.$$ 17 70
dialog --clear
return
}
# Function: execute_ltp
#
# Description: This function provides a menu of testcases that can be
# selected for execution. If networking tests are selected,
# they require a remote machine and remote machines root
# users password. The user will be prompted to enter this
# information in a text box.
# The function checks to see if the ltp-mmddyy/testcases/bin
# directory was created, this directory is created when the
# testcases are compiled and installed, if it is not found
# an info message window will notify the user that LTP needs to
# be compiled before tests can be executed.
# This function creates the senatrio file based on the users
# choice of testcases and uses the runalltests.sh script to
# execute these tests.
# The messages printed by the testcases are displayed on this
# terminal.
#
# Input: Users selection of testcases; scenario file.
#
# Output: Test selection window, Message window,
# information message window
execute_ltp()
{
RC=0
host_name=" "
rhost_passwd=" "
run_net_test=" "
if ! [ -d ./testcases/bin ]
then
display_info_msg "Executing LTP testcases" \
"The testcases must to be compiled inorder\
to execute them. Returning to main menu. \
Please select the Compile option."
return
fi
dialog --backtitle "Linux Test Project Control Centre"\
--title "Execute LTP" --clear\
--cancel-label 'Exit' \
--checklist "Select [SPACEBAR] tests to run" 20 61 5 \
"commands" "General Linux commands" off\
"crashme" "Utility to crash your machine" off\
"dio" "Direct IO tests" off\
"fs" "Filesystem stress tests" ON\
"fsx" "Another filesystem stress test" ON\
"hyperthreading" "Hyperthreading stress tests" off\
"io" "General I/O stress" ON\
"ipc" "Interprocess communication stress" ON\
"ipv6" "IPV6 related tests" off\
"math" "Math library tests (CPU stress)" ON\
"mm" "Memory Mgmt tests" ON\
"multicast" "Multicast networking tests" off\
"nfs" "Network filesystem stress" off\
"pipes" "IPC pipes stress" ON\
"pty" "Terminal type stress" off\
"rpc" "Remote Procedure Call" off\
"sched" "Scheduler Stress Tests" ON\
"sctp_ipv6" "SCTP over IPv6" off\
"sctp_tcp" "SCTP over TCP" off\
"sctp_udp" "SCTP over UDP" off\
"super" "mknod and setuid tests" off\
"syscalls" "Kernel system calls" ON\
"tcp_cmds" "TCP/IP commands tests" off\
2>/tmp/runltp.choice.$$ || RC=$?
tst_choice=$(cat /tmp/runltp.choice.$$)
case $RC in
0) \
for i in $tst_choice ;
do \
cat ./runtest/$(echo $i | sed -e 's/"//g') \
>> /tmp/runltp.test.list.$$ ;
if [[ $(echo $i | sed -e 's/"//g') == "tcp_cmds" || \
$(echo $i | sed -e 's/"//g') == "multicast" || \
$(echo $i | sed -e 's/"//g') == "ipv6" || \
$(echo $i | sed -e 's/"//g') == "nfs" || \
$(echo $i | sed -e 's/"//g') == "multicast" ]] ;
then \
run_net_test=" -N " ;
fi ;
done ;
if ! [ -z $run_net_test ] ;
then \
dialog --backtitle "Linux Test Project Control Centre"\
--title "Execute LTP test cases" \
--cr-wrap --clear \
--inputbox "You have chosen to execute testcases \
that require a Remote Machine. \
Please enter the fully qualified host \
name" 0 0 $(hostname --long) \
2>/tmp/runltp.out.$$ ;
host_name=$(cat /tmp/runltp.out.$$ | awk '{print $1}') ;
unset $RHOST ;
RHOST=$host_name ;
export RHOST
dialog --backtitle "Linux Test Project Control Centre"\
--title "Execute LTP test cases" \
--passwordbox " Please enter the root password \
of this remote machine" 10 50 \
2>/tmp/runltp.out.$$ ;
rhost_passwd=$(cat /tmp/runltp.out.$$ | awk '{print $1}') ;
PASSWD=$rhost_passwd ;
export PASSWD
fi ;
if ! [ -d ./testcases/bin ] ;
then \
display_info_msg "Executing LTP testcases" \
"The testcases must to be compiled inorder\
to execute them. Returning to main menu. \
Please select the Compile option." ;
return ;
fi ;
dialog --clear ;
exectest_screenout $run_net_test ;
return ;;
1) \
# echo "Cancel pressed" ;
return ;;
255) \
# echo "ESC pressed" ;
return ;;
esac
}
# Function: about_ltpcc
#
# Description: This function displays a window containing a brief message
# describing this programs functionality, and credits the author.
#
# Input: NONE
#
# Output: Message window, description of LTP Control Center.
about_ltpcc()
{
display_info_msg "About LTP Control Centre" \
"The LTP Control Centre can be used to\
to compile, install and execute\
The Linux Test Project test suite. Written by\
Manoj Iyer - manjo@mail.utexas.edu"
return
}
# Function: main
#
# Description: Displays the main menu to the LTP Control Centre. The menu
# provides options to Compile, Execute, and View test execution
# results.
#
# Calls: about_ltpcc()
# compile_ltp()
# execute_ltp()
# disp_ltpres()
#
# Input: NONE
#
# Output: Menu selection of actions to perform.
# Global variables.
RC=0 # return code from commands and local functions
mmenu_item=" "
RHOST=" "
PASSWD=" "
# call cleanup function on program exit.
trap "cleanup" 0
# wait in a loop until user hits [Cancel] button on the main menu.
while :
do
RC=0
dialog --clear
dialog --backtitle "Linux Test Project Control Centre" \
--cancel-label "Exit" \
--title "Main Menu" \
--menu "Move using[UP] [DOWN], Select using [ENTER]" 15 70 4 \
About "About LTP Control Centre" \
Compile "Compile LTP testsuite" \
Execute "Execute LTP testsuite" \
Results "Display a Summery of test results" \
2>/tmp/runltp.mainmenu.$$ || RC=$?
case $RC in
0) mmenu_item=`cat /tmp/runltp.mainmenu.$$` ;
# echo "return code = $RC" ;
# echo "MENU ITEM = $mmenu_item" ;
case $mmenu_item in
About) about_ltpcc ;;
Compile) compile_ltp ;;
Execute) execute_ltp ;;
Results) disp_ltpres ;;
esac ;;
1) display_info_msg "Good Bye!" \
"Thank you for using Linux Test Project test suite.\
Please visit our project website \
http://ltp.sourceforge.net \
for latest news on The Linux Test Project. \
LTP Control Centre Author: Manoj Iyer - \
manjo@mail.utexas.edu" ;
exit ;;
255) display_info_msg "Good Bye!" \
"Thank you for using Linux Test Project test suite.\
Please visit our project website\
http://ltp.sourceforge.net for latest news\
on The Linux Test Project. \
LTP Control Centre Author: Manoj Iyer - \
manjo@mail.utexas.edu" ;
exit;;
esac
done