blob: e44d485c2e3e968aaf2eb8d04396deb5221fd805 [file] [log] [blame]
robbiewb2f68e52003-04-16 21:24:10 +00001################################################################################
2## ##
3## Copyright (c) International Business Machines Corp., 2001 ##
4## ##
5## This program is free software; you can redistribute it and#or modify ##
6## it under the terms of the GNU General Public License as published by ##
7## the Free Software Foundation; either version 2 of the License, or ##
8## (at your option) any later version. ##
9## ##
10## This program is distributed in the hope that it will be useful, but ##
11## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
12## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ##
13## for more details. ##
14## ##
15## You should have received a copy of the GNU General Public License ##
16## along with this program; if not, write to the Free Software ##
17## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ##
18## ##
19################################################################################
20#
21# File: runltp
22#
23# Description: This program is a Graphical User Interface (GUI)
24# Control Centre for LTP. The Control Centre provides
25# functionality to Compile, Execute and View Results of
26# LTP test cases.
27#
28# Author: Manoj Iyer - manjo@mail.utexas.edu
29#
30# Thanks: Jim Choate - For suggesting the use of dialog command.
31#
32# History: March 26 2003 - Created.
33#
34# March 28 2003 - Removed gauges and put make commands in foreground.
35# Robbie Williamson - robbiew@us.ibm.com
36#
37# March 31 2003 - Made scenario menu creation dynamic and code
38# to pull the test descriptions from the scenario files.
39# Robbie Williamson - robbiew@us.ibm.com
40#
robbiew99a05032003-04-17 13:53:02 +000041# April 17 2003 - Added menu selection to list contents of selected
42# scenario file.
43# Robbie Williamson - robbiew@us.ibm.com
44#
robbiewa362bdc2003-04-23 18:41:38 +000045# April 23 2003 - Added PID to results filename.
robbiew5cc13812003-04-23 21:37:09 +000046# - Added code to allow users to redirect output and
47# specify test execution duration.
48# Robbie Williamson - robbiew@us.ibm.com
robbiewa362bdc2003-04-23 18:41:38 +000049#
robbiewb2f68e52003-04-16 21:24:10 +000050#! /bin/bash
51
52# Function: cleanup
53#
54# Description: Remove all temporary files created by this program. Cleanup
55# always called on program exit.
56#
57# Input: NONE
58#
59# Output: NONE
60cleanup()
61{
62 rm -f /tmp/runltp.*
63}
64
65
66# Function: display_info_msg
67#
68# Description: Displays informational messages window. This window may
69# may be used to display information like errors, instructions
70# etc to the user. The window is dismissed when the user hits
71# the [ENTER] key.
72#
73# Input: $1 - Title the needs to be displayed on the window.
74# eg: ERROR: Compiling LTP
75# $2 - Message text.
76#
77# Output: Information message window.
78display_info_msg()
79{
80 dialog --backtitle "Linux Test Project Control Centre" \
81 --title " $1 " \
82 --msgbox " $2 " 10 70
83 return $?
84}
85
86
87# Function: compile_ltp
88#
89# Description: Checks for commands that are pre-reqs for compiling and
90# installing LTP. It displays a confirmation window inorder to
91# confirm the choice made by the user.
92#
93# Calls: do_make_clean()
94# do_make()
95# do_make_install()
96#
97# Input: NONE
98#
99# Output: Confirmation window.
100compile_ltp()
101{
102 dialog --backtitle "Linux Test Project Control Centre" \
103 --title "Compiling LTP testsuite"\
104 --yesno "This will compile all the test cases in\
105 LTP test suite and place the executables\
106 in testcases/bin directory. Do\
107 you wish to continue ??" 7 70 || RC=$?
108 case $RC in
109 0) \
110 for cmd in cc make lex ;
111 do \
112 which $cmd &>/tmp/runltp.err.$$ ;
113 if [ $? -ne 0 ] ;
114 then \
115 display_info_msg "Compiling LTP testsuite" \
116 "ERROR: command $cmd not found, $cmd is\
117 required to compile LTP test cases. Please\
118 install $cmd or export PATH correctly before\
119 running this program" ;
120 return ;
121 fi ;
122 done ;
123 make clean;
124 if [ $? -ne 0 ];then
125 echo "ERROR in \'make clean\' - exiting."
126 exit
127 fi
128 make ;
129 if [ $? -ne 0 ];then
130 echo "ERROR in \'make all\' - exiting."
131 exit
132 fi
133 make install ;
134 if [ $? -ne 0 ];then
135 echo "ERROR in \'make install\' - exiting."
136 exit
137 fi
138 return ;;
139
140 1) return ;;
141
142 255) return ;;
143 esac
144}
145
146
147# Function: disp_ltpres
148#
149# Description: The results generated after the ltp execution located under
150# ltp-mmddyy/results/ directory in a text (ASCII) file called
151# results.todaysdate. This function displays this file in a
152# window. If the results file does not exit it displays an
153# info message window notifing the user that LTP test cases
154# need to be executed inorder to view results.
155#
156# Input: ltp-mmddyy/results/results.todaysdate
157#
158# Output: Window displaying results of testcases that were executed.
159disp_ltpres()
160{
161 RC=0
robbiewa362bdc2003-04-23 18:41:38 +0000162 if ! [ -f ./results/results.$(date -I).$$ ]
robbiewb2f68e52003-04-16 21:24:10 +0000163 then
164 display_info_msg "LTP Test Results" \
165 "Sorry cannot display test results, you have to run \
166 the test cases first. Please choose the Execute LTP \
167 option in the Main Menu."
168 return
169 fi
170
171 dialog --backtitle "Linux Test Project Control Centre" \
172 --title "LTP Test Results. Scroll [UP] [DOWN]/[PGUP] [PGDN]" \
robbiewa362bdc2003-04-23 18:41:38 +0000173 --textbox ./results/results.$(date -I).$$ 17 70
robbiewb2f68e52003-04-16 21:24:10 +0000174
175 dialog --backtitle "Linux Test Project Control Centre" \
176 --title "LTP Test Results." \
177 --yesno "Would you like to share these results with the LTP \
178 community by posting it to the LTP results mailing list?" \
179 7 70 || RC=$?
180 case $RC in
181 0) \
182 mail ltp-results@lists.sourceforge.net < \
robbiewa362bdc2003-04-23 18:41:38 +0000183 ./results/results.$(date -I).$$ ;
robbiewb2f68e52003-04-16 21:24:10 +0000184 return ;;
185
186 1) return ;;
187
188 255) return ;;
189 esac
190 return
191}
192
193
robbiew5cc13812003-04-23 21:37:09 +0000194# Function: flags_prompt
195#
196# Description: Prompt for and record user options for run duration and
197# test output direction
198#
199# Input: none
200#
201# Output: none
202flags_prompt()
203{
204 dialog --backtitle "Linux Test Project Control Centre"\
205 --title "Output Direction" --clear\
206 --yesno "Would you like test output recorded to a file, instead of STDOUT?" 7 80
207 RC=$?
208 if [ $RC -eq "0" ]
209 then
210 dialog --backtitle "Linux Test Project Control Centre"\
211 --title "Output Direction" --clear\
212 --inputbox " Please enter the full path and \
213 name of the file where you wish \
214 to redirect output to" 17 80 \
215 2>/tmp/runltp.outdir.$$ ;
216 flags_outfile=$(cat /tmp/runltp.outdir.$$ | awk '{print $1}')
217 RUNALL_FLAGS=" -o $flags_outfile"
218 fi
219
220 dialog --backtitle "Linux Test Project Control Centre"\
221 --title "Test Duration" --clear\
222 --yesno "Would you like to specify test duration? \
223 Default is the length of one loop." 7 80
224 RC=$?
225 if [ $RC -eq "0" ]
226 then
227 dialog --backtitle "Linux Test Project Control Centre"\
228 --title "Test Duration - Interval Selection" --clear\
229 --menu "Move using[UP] [DOWN], Select using [ENTER]" 15 70 4 \
230 s "Seconds" \
231 m "Minutes" \
232 h "Hours" \
233 d "Days" \
234 2>/tmp/runltp.interval.$$ ;
235 flags_interval=$(cat /tmp/runltp.interval.$$ | awk '{print $1}')
236 case $flags_interval in
237 s) INTERVAL="seconds" ;;
238 m) INTERVAL="minutes" ;;
239 h) INTERVAL="hours" ;;
240 d) INTERVAL="days" ;;
241 esac
242
243 echo $INTERVAL
244 WINDOW_MSG="Please enter the number of $INTERVAL to run"
245 dialog --backtitle "Linux Test Project Control Centre"\
246 --title "Test Duration - Length Specification" --clear\
247 --inputbox "$WINDOW_MSG" 7 80 \
248 2>/tmp/runltp.length.$$ ;
249 flags_length=$(cat /tmp/runltp.length.$$ | awk '{print $1}')
250 flags_duration="$flags_length$flags_interval"
251 RUNALL_FLAGS=" $RUNALL_FLAGS -t $flags_duration"
252 fi
253}
254
robbiewb2f68e52003-04-16 21:24:10 +0000255# Function: exectest_screenout
256#
257# Description: Execute tests by calling runalltests.sh, display test status
258# in a window.
259#
robbiew5cc13812003-04-23 21:37:09 +0000260# Input: none
robbiewb2f68e52003-04-16 21:24:10 +0000261#
262# Output: messages printed by testcases.
263exectest_screenout()
264{
265 RC=0 # setting return code to 0, to loop in while
266
267 # remove old results file
robbiewa362bdc2003-04-23 18:41:38 +0000268 rm ./results/results.$(date -I).$$ &>/dev/null
robbiew5cc13812003-04-23 21:37:09 +0000269
robbiewb2f68e52003-04-16 21:24:10 +0000270 # execute runalltests.sh with user defined command file.
robbiew5cc13812003-04-23 21:37:09 +0000271 ./runalltests.sh -q -p $RUNALL_FLAGS -l results.$(date -I).$$ \
robbiewb2f68e52003-04-16 21:24:10 +0000272 -f /tmp/runltp.test.list.$$
robbiew5cc13812003-04-23 21:37:09 +0000273
robbiewb2f68e52003-04-16 21:24:10 +0000274 sleep 2
robbiew5cc13812003-04-23 21:37:09 +0000275
robbiewb2f68e52003-04-16 21:24:10 +0000276 return
277}
278
279
280# Function: execute_ltp
281#
282# Description: This function provides a menu of testcases that can be
283# selected for execution. If networking tests are selected,
284# they require a remote machine and remote machines root
285# users password. The user will be prompted to enter this
286# information in a text box.
287# The function checks to see if the ltp-mmddyy/testcases/bin
288# directory was created, this directory is created when the
289# testcases are compiled and installed, if it is not found
290# an info message window will notify the user that LTP needs to
291# be compiled before tests can be executed.
292# This function creates the senatrio file based on the users
293# choice of testcases and uses the runalltests.sh script to
294# execute these tests.
295# The messages printed by the testcases are displayed on this
296# terminal.
297#
298# Input: Users selection of testcases; scenario file.
299#
300# Output: Test selection window, Message window,
301# information message window
302execute_ltp()
303{
304 RC=0
305 host_name=" "
306 rhost_passwd=" "
307 run_net_test=" "
308
309 if ! [ -d ./testcases/bin ]
310 then
311 display_info_msg "Executing LTP testcases" \
312 "The testcases must to be compiled inorder\
313 to execute them. Returning to main menu. \
314 Please select the Compile option."
315 return
316 fi
317
318 LIST=$(for i in `ls -1 -A -I "CVS" runtest`; do echo -n "$i "; j=$(head -n1 runtest/$i | cut -d: -f2|sed s/" "/_/g); echo -n "$j off "; done)
319 dialog --backtitle "Linux Test Project Control Centre"\
320 --title "Execute LTP" --clear\
321 --checklist "Select [SPACEBAR] tests to run" 20 80 5 \
322 $LIST \
323 2>/tmp/runltp.choice.$$ || RC=$?
324 size=`wc -m /tmp/runltp.choice.$$|awk '{print $1}'`
325 if [ $size -eq 0 ];then
326 tst_choice=$(echo "NULL")
327 else
328 tst_choice=$(cat /tmp/runltp.choice.$$)
329 fi
330 if [[ $tst_choice == NULL ]];then
331 RC=1
332 fi
333 case $RC in
334 0) \
335 for i in $tst_choice ;
336 do \
337 cat ./runtest/$(echo $i | sed -e 's/"//g') \
338 >> /tmp/runltp.test.list.$$ ;
339 if [[ $(echo $i | sed -e 's/"//g') == "tcp_cmds" || \
340 $(echo $i | sed -e 's/"//g') == "tcp_cmds_noexpect" || \
341 $(echo $i | sed -e 's/"//g') == "multicast" || \
342 $(echo $i | sed -e 's/"//g') == "ipv6" || \
343 $(echo $i | sed -e 's/"//g') == "ipv6_noexpect" || \
344 $(echo $i | sed -e 's/"//g') == "nfs" || \
345 $(echo $i | sed -e 's/"//g') == "multicast" ]] ;
346 then \
robbiew5cc13812003-04-23 21:37:09 +0000347 run_net_test="Y" ;
robbiewb2f68e52003-04-16 21:24:10 +0000348 fi ;
349
350 done ;
351 if ! [ -z $run_net_test ] ;
352 then \
353 dialog --backtitle "Linux Test Project Control Centre"\
354 --title "Execute LTP test cases" \
355 --clear \
356 --inputbox "You have chosen to execute testcases \
357 that require a Remote Machine. \
358 Please enter the fully qualified host \
359 name" 17 80 $(hostname --long) \
360 2>/tmp/runltp.out.$$ ;
361 host_name=$(cat /tmp/runltp.out.$$ | awk '{print $1}') ;
362 unset $RHOST ;
363 RHOST=$host_name ;
364 export RHOST;
365
366 dialog --backtitle "Linux Test Project Control Centre"\
367 --title "Execute LTP test cases" \
368 --clear \
369 --inputbox " Please enter the root password \
370 of this remote machine" 17 80 \
371 2>/tmp/runltp.out.$$ ;
372 rhost_passwd=$(cat /tmp/runltp.out.$$ | awk '{print $1}') ;
373
374 PASSWD=$rhost_passwd ;
375 export PASSWD;
376 fi ;
377
378 if ! [ -d ./testcases/bin ] ;
379 then \
380 display_info_msg "Executing LTP testcases" \
381 "The testcases must to be compiled inorder\
382 to execute them. Returning to main menu. \
383 Please select the Compile option." ;
384 return ;
385 fi ;
386
387 dialog --clear ;
robbiew5cc13812003-04-23 21:37:09 +0000388
389 flags_prompt ;
robbiewb2f68e52003-04-16 21:24:10 +0000390
robbiew5cc13812003-04-23 21:37:09 +0000391 exectest_screenout ;
robbiewb2f68e52003-04-16 21:24:10 +0000392
393 return ;;
394 1) \
395 # echo "Cancel pressed" ;
396 return ;;
397 255) \
398 # echo "ESC pressed" ;
399 return ;;
400 esac
401}
402
403
404# Function: about_ltpcc
405#
406# Description: This function displays a window containing a brief message
407# describing this programs functionality, and credits the author.
408#
409# Input: NONE
410#
411# Output: Message window, description of LTP Control Center.
412about_ltpcc()
413{
414 display_info_msg "About LTP Control Centre" \
415 "The LTP Control Centre can be used to\
416 to compile, install and execute\
417 The Linux Test Project test suite. Written by\
418 Manoj Iyer <manjo@mail.utexas.edu>"
419 return
420}
robbiew99a05032003-04-17 13:53:02 +0000421
422
423# Function: ltp_scenarios
424#
425# Description: This function displays a list of scenario files located
426# in /runtest. Users can list the contents of each file.
427#
428# Input: Files from /runtest
429#
430# Output: 1) Menu selection containing each file as an option to list.
431# 2) Contents of selected scenario.
432ltp_scenarios()
433{
434
435RC=0
436SCENARIOS=$(for i in `ls -1 -A -I "CVS" runtest`;do echo -n "$i <- "; done)
437
438while [ $RC -ne "1" ]
439do
440 dialog --clear
441 dialog --backtitle "Linux Test Project Control Centre" \
442 --title "LTP Scenario Files" \
443 --menu "Move using[UP] [DOWN], Select using [ENTER]" 15 70 8 \
444 $SCENARIOS \
445 2>/tmp/runltp.scenario.$$ || RC=$?
446 scenario_item=$(cat /tmp/runltp.scenario.$$)
447 if ! [ -z $scenario_item ];then
448 dialog --clear
449 dialog --backtitle "Linux Test Project Control Centre" \
450 --title "LTP Scenario Files" \
451 --textbox runtest/$scenario_item 17 70
452 fi
453done
454}
455
456
robbiewb2f68e52003-04-16 21:24:10 +0000457
458# Function: main
459#
460# Description: Displays the main menu to the LTP Control Centre. The menu
461# provides options to Compile, Execute, and View test execution
462# results.
463#
464# Calls: about_ltpcc()
465# compile_ltp()
466# execute_ltp()
467# disp_ltpres()
468#
469# Input: NONE
470#
471# Output: Menu selection of actions to perform.
472
473# Global variables.
474RC=0 # return code from commands and local functions
475mmenu_item=" "
476RHOST=" "
477PASSWD=" "
robbiew5cc13812003-04-23 21:37:09 +0000478RUNALL_FLAGS=" "
robbiewb2f68e52003-04-16 21:24:10 +0000479
480# call cleanup function on program exit.
481trap "cleanup" 0
482
483
484# wait in a loop until user hits [Cancel] button on the main menu.
485while :
486do
487 RC=0
488 dialog --clear
489 dialog --backtitle "Linux Test Project Control Centre" \
490 --title "Main Menu" \
robbiew99a05032003-04-17 13:53:02 +0000491 --menu "Move using[UP] [DOWN], Select using [ENTER]" 15 70 5 \
robbiewb2f68e52003-04-16 21:24:10 +0000492 About "About LTP Control Centre" \
493 Compile "Compile LTP testsuite" \
robbiew99a05032003-04-17 13:53:02 +0000494 Details "Details of scenario files" \
robbiewb2f68e52003-04-16 21:24:10 +0000495 Execute "Execute LTP testsuite" \
496 Results "Display a summary of test results" \
497 2>/tmp/runltp.mainmenu.$$ || RC=$?
498
499 case $RC in
500 0) mmenu_item=`cat /tmp/runltp.mainmenu.$$` ;
501 # echo "return code = $RC" ;
502 # echo "MENU ITEM = $mmenu_item" ;
503 case $mmenu_item in
504 About) about_ltpcc ;;
505 Compile) compile_ltp ;;
robbiew99a05032003-04-17 13:53:02 +0000506 Details) ltp_scenarios ;;
robbiewb2f68e52003-04-16 21:24:10 +0000507 Execute) execute_ltp ;;
508 Results) disp_ltpres ;;
509 esac ;;
510
511 1) display_info_msg "Good Bye!" \
512 "Thank you for using Linux Test Project test suite.\
513 Please visit our project website \
514 http://ltp.sourceforge.net \
515 for latest news on The Linux Test Project. "
516 exit ;;
517
518 255) display_info_msg "Good Bye!" \
519 "Thank you for using Linux Test Project test suite.\
520 Please visit our project website\
521 http://ltp.sourceforge.net for latest news\
522 on The Linux Test Project. "
523 exit;;
524 esac
525done