blob: 48bfe171f543cc1d148d2a7bc23adbf176131798 [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#
robbiew3b324ef2003-04-30 16:32:06 +000050# April 30, 2003 - Recoded results display to allow selection
51# of results file.
52# - Created variable to hold results filename
53# - Added time to results filename.
robbiewb2f68e52003-04-16 21:24:10 +000054#! /bin/bash
55
56# Function: cleanup
57#
58# Description: Remove all temporary files created by this program. Cleanup
59# always called on program exit.
60#
61# Input: NONE
62#
63# Output: NONE
64cleanup()
65{
66 rm -f /tmp/runltp.*
67}
68
69
70# Function: display_info_msg
71#
72# Description: Displays informational messages window. This window may
73# may be used to display information like errors, instructions
74# etc to the user. The window is dismissed when the user hits
75# the [ENTER] key.
76#
77# Input: $1 - Title the needs to be displayed on the window.
78# eg: ERROR: Compiling LTP
79# $2 - Message text.
80#
81# Output: Information message window.
82display_info_msg()
83{
84 dialog --backtitle "Linux Test Project Control Centre" \
85 --title " $1 " \
86 --msgbox " $2 " 10 70
87 return $?
88}
89
90
91# Function: compile_ltp
92#
93# Description: Checks for commands that are pre-reqs for compiling and
94# installing LTP. It displays a confirmation window inorder to
95# confirm the choice made by the user.
96#
97# Calls: do_make_clean()
98# do_make()
99# do_make_install()
100#
101# Input: NONE
102#
103# Output: Confirmation window.
104compile_ltp()
105{
106 dialog --backtitle "Linux Test Project Control Centre" \
107 --title "Compiling LTP testsuite"\
108 --yesno "This will compile all the test cases in\
109 LTP test suite and place the executables\
110 in testcases/bin directory. Do\
111 you wish to continue ??" 7 70 || RC=$?
112 case $RC in
113 0) \
114 for cmd in cc make lex ;
115 do \
116 which $cmd &>/tmp/runltp.err.$$ ;
117 if [ $? -ne 0 ] ;
118 then \
119 display_info_msg "Compiling LTP testsuite" \
120 "ERROR: command $cmd not found, $cmd is\
121 required to compile LTP test cases. Please\
122 install $cmd or export PATH correctly before\
123 running this program" ;
124 return ;
125 fi ;
126 done ;
127 make clean;
128 if [ $? -ne 0 ];then
129 echo "ERROR in \'make clean\' - exiting."
130 exit
131 fi
132 make ;
133 if [ $? -ne 0 ];then
134 echo "ERROR in \'make all\' - exiting."
135 exit
136 fi
137 make install ;
138 if [ $? -ne 0 ];then
139 echo "ERROR in \'make install\' - exiting."
140 exit
141 fi
142 return ;;
143
144 1) return ;;
145
146 255) return ;;
147 esac
148}
149
150
151# Function: disp_ltpres
152#
153# Description: The results generated after the ltp execution located under
154# ltp-mmddyy/results/ directory in a text (ASCII) file called
155# results.todaysdate. This function displays this file in a
156# window. If the results file does not exit it displays an
157# info message window notifing the user that LTP test cases
158# need to be executed inorder to view results.
159#
robbiew3b324ef2003-04-30 16:32:06 +0000160# Input: ltp-mmddyy/results/results.todaysdate.time
robbiewb2f68e52003-04-16 21:24:10 +0000161#
162# Output: Window displaying results of testcases that were executed.
163disp_ltpres()
164{
165 RC=0
robbiewb2f68e52003-04-16 21:24:10 +0000166
robbiew43fc2492003-04-30 16:33:51 +0000167 RESULTS_LIST=$(for i in `ls -1 -A -I "CVS" results`;do echo -n "$i [more...] "; done)
robbiew3b324ef2003-04-30 16:32:06 +0000168 while [ $RC -ne "1" ]
169 do
170 dialog --clear
171 dialog --backtitle "Linux Test Project Control Centre" \
172 --title "LTP Test Results" \
173 --menu "Move using[UP] [DOWN], Select using [ENTER]" 15 70 8 \
174 $RESULTS_LIST \
175 2>/tmp/runltp.results.$$ || RC=$?
176 results_item=$(cat /tmp/runltp.results.$$)
177 if ! [ -z $results_item ];then
178 dialog --clear
179 dialog --backtitle "Linux Test Project Control Centre" \
180 --title "LTP Test Results" \
181 --textbox results/$results_item 17 70
robbiewf5137b42003-04-30 18:14:13 +0000182
183 dialog --backtitle "Linux Test Project Control Centre" \
184 --title "LTP Test Results." \
185 --yesno "Would you like to share these results with the LTP \
186 community by posting it to the LTP results mailing list?" \
187 7 70 || RESPONSE=$?
188 case $RESPONSE in
189 0) \
190 mail ltp-results@lists.sourceforge.net < \
191 ./results/$results_item ;
192 ;;
193
194 1) ;;
195
196 255) ;;
197 esac
robbiew3b324ef2003-04-30 16:32:06 +0000198 fi
199 done
robbiewb2f68e52003-04-16 21:24:10 +0000200 return
201}
202
203
robbiew5cc13812003-04-23 21:37:09 +0000204# Function: flags_prompt
205#
206# Description: Prompt for and record user options for run duration and
207# test output direction
208#
209# Input: none
210#
211# Output: none
212flags_prompt()
213{
214 dialog --backtitle "Linux Test Project Control Centre"\
215 --title "Output Direction" --clear\
216 --yesno "Would you like test output recorded to a file, instead of STDOUT?" 7 80
217 RC=$?
218 if [ $RC -eq "0" ]
219 then
220 dialog --backtitle "Linux Test Project Control Centre"\
221 --title "Output Direction" --clear\
222 --inputbox " Please enter the full path and \
223 name of the file where you wish \
224 to redirect output to" 17 80 \
225 2>/tmp/runltp.outdir.$$ ;
226 flags_outfile=$(cat /tmp/runltp.outdir.$$ | awk '{print $1}')
227 RUNALL_FLAGS=" -o $flags_outfile"
228 fi
229
230 dialog --backtitle "Linux Test Project Control Centre"\
231 --title "Test Duration" --clear\
232 --yesno "Would you like to specify test duration? \
233 Default is the length of one loop." 7 80
234 RC=$?
235 if [ $RC -eq "0" ]
236 then
237 dialog --backtitle "Linux Test Project Control Centre"\
238 --title "Test Duration - Interval Selection" --clear\
239 --menu "Move using[UP] [DOWN], Select using [ENTER]" 15 70 4 \
240 s "Seconds" \
241 m "Minutes" \
242 h "Hours" \
243 d "Days" \
244 2>/tmp/runltp.interval.$$ ;
245 flags_interval=$(cat /tmp/runltp.interval.$$ | awk '{print $1}')
246 case $flags_interval in
247 s) INTERVAL="seconds" ;;
248 m) INTERVAL="minutes" ;;
249 h) INTERVAL="hours" ;;
250 d) INTERVAL="days" ;;
251 esac
252
253 echo $INTERVAL
254 WINDOW_MSG="Please enter the number of $INTERVAL to run"
255 dialog --backtitle "Linux Test Project Control Centre"\
256 --title "Test Duration - Length Specification" --clear\
257 --inputbox "$WINDOW_MSG" 7 80 \
258 2>/tmp/runltp.length.$$ ;
259 flags_length=$(cat /tmp/runltp.length.$$ | awk '{print $1}')
260 flags_duration="$flags_length$flags_interval"
261 RUNALL_FLAGS=" $RUNALL_FLAGS -t $flags_duration"
262 fi
263}
264
robbiewb2f68e52003-04-16 21:24:10 +0000265# Function: exectest_screenout
266#
267# Description: Execute tests by calling runalltests.sh, display test status
268# in a window.
269#
robbiew5cc13812003-04-23 21:37:09 +0000270# Input: none
robbiewb2f68e52003-04-16 21:24:10 +0000271#
272# Output: messages printed by testcases.
273exectest_screenout()
274{
275 RC=0 # setting return code to 0, to loop in while
276
robbiew3b324ef2003-04-30 16:32:06 +0000277 RESULTS_FILE=$(date +%Y-%m-%d.%H.%M.%S).$$
robbiew5cc13812003-04-23 21:37:09 +0000278
robbiewb2f68e52003-04-16 21:24:10 +0000279 # execute runalltests.sh with user defined command file.
robbiew3b324ef2003-04-30 16:32:06 +0000280 ./runalltests.sh -q -p $RUNALL_FLAGS -l results.$RESULTS_FILE \
robbiewb2f68e52003-04-16 21:24:10 +0000281 -f /tmp/runltp.test.list.$$
robbiew5cc13812003-04-23 21:37:09 +0000282
robbiewb2f68e52003-04-16 21:24:10 +0000283 sleep 2
robbiew5cc13812003-04-23 21:37:09 +0000284
robbiewb2f68e52003-04-16 21:24:10 +0000285 return
286}
287
288
289# Function: execute_ltp
290#
291# Description: This function provides a menu of testcases that can be
292# selected for execution. If networking tests are selected,
293# they require a remote machine and remote machines root
294# users password. The user will be prompted to enter this
295# information in a text box.
296# The function checks to see if the ltp-mmddyy/testcases/bin
297# directory was created, this directory is created when the
298# testcases are compiled and installed, if it is not found
299# an info message window will notify the user that LTP needs to
300# be compiled before tests can be executed.
301# This function creates the senatrio file based on the users
302# choice of testcases and uses the runalltests.sh script to
303# execute these tests.
304# The messages printed by the testcases are displayed on this
305# terminal.
306#
307# Input: Users selection of testcases; scenario file.
308#
309# Output: Test selection window, Message window,
310# information message window
311execute_ltp()
312{
313 RC=0
314 host_name=" "
315 rhost_passwd=" "
316 run_net_test=" "
317
318 if ! [ -d ./testcases/bin ]
319 then
320 display_info_msg "Executing LTP testcases" \
321 "The testcases must to be compiled inorder\
322 to execute them. Returning to main menu. \
323 Please select the Compile option."
324 return
325 fi
326
327 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)
328 dialog --backtitle "Linux Test Project Control Centre"\
329 --title "Execute LTP" --clear\
330 --checklist "Select [SPACEBAR] tests to run" 20 80 5 \
331 $LIST \
332 2>/tmp/runltp.choice.$$ || RC=$?
333 size=`wc -m /tmp/runltp.choice.$$|awk '{print $1}'`
334 if [ $size -eq 0 ];then
335 tst_choice=$(echo "NULL")
336 else
337 tst_choice=$(cat /tmp/runltp.choice.$$)
338 fi
339 if [[ $tst_choice == NULL ]];then
340 RC=1
341 fi
342 case $RC in
343 0) \
344 for i in $tst_choice ;
345 do \
346 cat ./runtest/$(echo $i | sed -e 's/"//g') \
347 >> /tmp/runltp.test.list.$$ ;
348 if [[ $(echo $i | sed -e 's/"//g') == "tcp_cmds" || \
349 $(echo $i | sed -e 's/"//g') == "tcp_cmds_noexpect" || \
350 $(echo $i | sed -e 's/"//g') == "multicast" || \
351 $(echo $i | sed -e 's/"//g') == "ipv6" || \
352 $(echo $i | sed -e 's/"//g') == "ipv6_noexpect" || \
353 $(echo $i | sed -e 's/"//g') == "nfs" || \
354 $(echo $i | sed -e 's/"//g') == "multicast" ]] ;
355 then \
robbiew5cc13812003-04-23 21:37:09 +0000356 run_net_test="Y" ;
robbiewb2f68e52003-04-16 21:24:10 +0000357 fi ;
358
359 done ;
360 if ! [ -z $run_net_test ] ;
361 then \
362 dialog --backtitle "Linux Test Project Control Centre"\
363 --title "Execute LTP test cases" \
364 --clear \
365 --inputbox "You have chosen to execute testcases \
366 that require a Remote Machine. \
367 Please enter the fully qualified host \
368 name" 17 80 $(hostname --long) \
369 2>/tmp/runltp.out.$$ ;
370 host_name=$(cat /tmp/runltp.out.$$ | awk '{print $1}') ;
371 unset $RHOST ;
372 RHOST=$host_name ;
373 export RHOST;
374
375 dialog --backtitle "Linux Test Project Control Centre"\
376 --title "Execute LTP test cases" \
377 --clear \
378 --inputbox " Please enter the root password \
379 of this remote machine" 17 80 \
380 2>/tmp/runltp.out.$$ ;
381 rhost_passwd=$(cat /tmp/runltp.out.$$ | awk '{print $1}') ;
382
383 PASSWD=$rhost_passwd ;
384 export PASSWD;
385 fi ;
386
387 if ! [ -d ./testcases/bin ] ;
388 then \
389 display_info_msg "Executing LTP testcases" \
390 "The testcases must to be compiled inorder\
391 to execute them. Returning to main menu. \
392 Please select the Compile option." ;
393 return ;
394 fi ;
395
396 dialog --clear ;
robbiew5cc13812003-04-23 21:37:09 +0000397
398 flags_prompt ;
robbiewb2f68e52003-04-16 21:24:10 +0000399
robbiew5cc13812003-04-23 21:37:09 +0000400 exectest_screenout ;
robbiewb2f68e52003-04-16 21:24:10 +0000401
402 return ;;
403 1) \
404 # echo "Cancel pressed" ;
405 return ;;
406 255) \
407 # echo "ESC pressed" ;
408 return ;;
409 esac
410}
411
412
413# Function: about_ltpcc
414#
415# Description: This function displays a window containing a brief message
416# describing this programs functionality, and credits the author.
417#
418# Input: NONE
419#
420# Output: Message window, description of LTP Control Center.
421about_ltpcc()
422{
423 display_info_msg "About LTP Control Centre" \
424 "The LTP Control Centre can be used to\
425 to compile, install and execute\
426 The Linux Test Project test suite. Written by\
427 Manoj Iyer <manjo@mail.utexas.edu>"
428 return
429}
robbiew99a05032003-04-17 13:53:02 +0000430
431
432# Function: ltp_scenarios
433#
434# Description: This function displays a list of scenario files located
435# in /runtest. Users can list the contents of each file.
436#
437# Input: Files from /runtest
438#
439# Output: 1) Menu selection containing each file as an option to list.
440# 2) Contents of selected scenario.
441ltp_scenarios()
442{
443
444RC=0
robbiew43fc2492003-04-30 16:33:51 +0000445SCENARIOS=$(for i in `ls -1 -A -I "CVS" runtest`;do echo -n "$i [more...] "; done)
robbiew99a05032003-04-17 13:53:02 +0000446
447while [ $RC -ne "1" ]
448do
449 dialog --clear
450 dialog --backtitle "Linux Test Project Control Centre" \
451 --title "LTP Scenario Files" \
452 --menu "Move using[UP] [DOWN], Select using [ENTER]" 15 70 8 \
453 $SCENARIOS \
454 2>/tmp/runltp.scenario.$$ || RC=$?
455 scenario_item=$(cat /tmp/runltp.scenario.$$)
456 if ! [ -z $scenario_item ];then
457 dialog --clear
458 dialog --backtitle "Linux Test Project Control Centre" \
459 --title "LTP Scenario Files" \
460 --textbox runtest/$scenario_item 17 70
461 fi
462done
463}
464
465
robbiewb2f68e52003-04-16 21:24:10 +0000466
467# Function: main
468#
469# Description: Displays the main menu to the LTP Control Centre. The menu
470# provides options to Compile, Execute, and View test execution
471# results.
472#
473# Calls: about_ltpcc()
474# compile_ltp()
475# execute_ltp()
476# disp_ltpres()
477#
478# Input: NONE
479#
480# Output: Menu selection of actions to perform.
481
482# Global variables.
483RC=0 # return code from commands and local functions
484mmenu_item=" "
485RHOST=" "
486PASSWD=" "
robbiew5cc13812003-04-23 21:37:09 +0000487RUNALL_FLAGS=" "
robbiew3b324ef2003-04-30 16:32:06 +0000488RESULTS_FILE=" "
robbiewb2f68e52003-04-16 21:24:10 +0000489
490# call cleanup function on program exit.
491trap "cleanup" 0
492
493
494# wait in a loop until user hits [Cancel] button on the main menu.
495while :
496do
497 RC=0
498 dialog --clear
499 dialog --backtitle "Linux Test Project Control Centre" \
500 --title "Main Menu" \
robbiew99a05032003-04-17 13:53:02 +0000501 --menu "Move using[UP] [DOWN], Select using [ENTER]" 15 70 5 \
robbiewb2f68e52003-04-16 21:24:10 +0000502 About "About LTP Control Centre" \
503 Compile "Compile LTP testsuite" \
robbiew99a05032003-04-17 13:53:02 +0000504 Details "Details of scenario files" \
robbiewb2f68e52003-04-16 21:24:10 +0000505 Execute "Execute LTP testsuite" \
506 Results "Display a summary of test results" \
507 2>/tmp/runltp.mainmenu.$$ || RC=$?
508
509 case $RC in
510 0) mmenu_item=`cat /tmp/runltp.mainmenu.$$` ;
511 # echo "return code = $RC" ;
512 # echo "MENU ITEM = $mmenu_item" ;
513 case $mmenu_item in
514 About) about_ltpcc ;;
515 Compile) compile_ltp ;;
robbiew99a05032003-04-17 13:53:02 +0000516 Details) ltp_scenarios ;;
robbiewb2f68e52003-04-16 21:24:10 +0000517 Execute) execute_ltp ;;
518 Results) disp_ltpres ;;
519 esac ;;
520
521 1) display_info_msg "Good Bye!" \
522 "Thank you for using Linux Test Project test suite.\
523 Please visit our project website \
524 http://ltp.sourceforge.net \
525 for latest news on The Linux Test Project. "
526 exit ;;
527
528 255) display_info_msg "Good Bye!" \
529 "Thank you for using Linux Test Project test suite.\
530 Please visit our project website\
531 http://ltp.sourceforge.net for latest news\
532 on The Linux Test Project. "
533 exit;;
534 esac
535done