blob: ae9ee73444dd7ff15ed9a38568bbe75d7a825ebc [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)
robbiewf68ad332003-04-30 18:32:18 +0000168 if ! [ -z $RESULTS_LIST ] ;then
169 while [ $RC -ne "1" ]
170 do
robbiew3b324ef2003-04-30 16:32:06 +0000171 dialog --clear
172 dialog --backtitle "Linux Test Project Control Centre" \
173 --title "LTP Test Results" \
robbiewf68ad332003-04-30 18:32:18 +0000174 --menu "Move using[UP] [DOWN], Select using [ENTER]" 15 70 8 \
175 $RESULTS_LIST \
176 2>/tmp/runltp.results.$$ || RC=$?
177 results_item=$(cat /tmp/runltp.results.$$)
178 if ! [ -z $results_item ];then
179 dialog --clear
180 dialog --backtitle "Linux Test Project Control Centre" \
181 --title "LTP Test Results" \
182 --textbox results/$results_item 17 70
183
184 dialog --backtitle "Linux Test Project Control Centre" \
185 --title "LTP Test Results." \
186 --yesno "Would you like to share these results with the LTP \
187 community by posting it to the LTP results mailing list?" \
188 7 70 || RESPONSE=$?
189 case $RESPONSE in
190 0) \
191 mail ltp-results@lists.sourceforge.net < \
192 ./results/$results_item ;
193 ;;
194
195 1) ;;
196
197 255) ;;
198 esac
199 fi
200 done
201 else
202 dialog --clear
203 dialog --backtitle "Linux Test Project Control Centre" \
204 --title "LTP Test Results" \
205 --msgbox "ERROR: No files to view in /results directory." 5 53
206 fi
robbiewb2f68e52003-04-16 21:24:10 +0000207 return
208}
209
210
robbiew5cc13812003-04-23 21:37:09 +0000211# Function: flags_prompt
212#
213# Description: Prompt for and record user options for run duration and
214# test output direction
215#
216# Input: none
217#
218# Output: none
219flags_prompt()
220{
221 dialog --backtitle "Linux Test Project Control Centre"\
222 --title "Output Direction" --clear\
223 --yesno "Would you like test output recorded to a file, instead of STDOUT?" 7 80
224 RC=$?
225 if [ $RC -eq "0" ]
226 then
227 dialog --backtitle "Linux Test Project Control Centre"\
228 --title "Output Direction" --clear\
229 --inputbox " Please enter the full path and \
230 name of the file where you wish \
231 to redirect output to" 17 80 \
232 2>/tmp/runltp.outdir.$$ ;
233 flags_outfile=$(cat /tmp/runltp.outdir.$$ | awk '{print $1}')
234 RUNALL_FLAGS=" -o $flags_outfile"
235 fi
236
237 dialog --backtitle "Linux Test Project Control Centre"\
238 --title "Test Duration" --clear\
239 --yesno "Would you like to specify test duration? \
240 Default is the length of one loop." 7 80
241 RC=$?
242 if [ $RC -eq "0" ]
243 then
244 dialog --backtitle "Linux Test Project Control Centre"\
245 --title "Test Duration - Interval Selection" --clear\
246 --menu "Move using[UP] [DOWN], Select using [ENTER]" 15 70 4 \
247 s "Seconds" \
248 m "Minutes" \
249 h "Hours" \
250 d "Days" \
251 2>/tmp/runltp.interval.$$ ;
252 flags_interval=$(cat /tmp/runltp.interval.$$ | awk '{print $1}')
253 case $flags_interval in
254 s) INTERVAL="seconds" ;;
255 m) INTERVAL="minutes" ;;
256 h) INTERVAL="hours" ;;
257 d) INTERVAL="days" ;;
258 esac
259
260 echo $INTERVAL
261 WINDOW_MSG="Please enter the number of $INTERVAL to run"
262 dialog --backtitle "Linux Test Project Control Centre"\
263 --title "Test Duration - Length Specification" --clear\
264 --inputbox "$WINDOW_MSG" 7 80 \
265 2>/tmp/runltp.length.$$ ;
266 flags_length=$(cat /tmp/runltp.length.$$ | awk '{print $1}')
267 flags_duration="$flags_length$flags_interval"
268 RUNALL_FLAGS=" $RUNALL_FLAGS -t $flags_duration"
269 fi
270}
271
robbiewb2f68e52003-04-16 21:24:10 +0000272# Function: exectest_screenout
273#
274# Description: Execute tests by calling runalltests.sh, display test status
275# in a window.
276#
robbiew5cc13812003-04-23 21:37:09 +0000277# Input: none
robbiewb2f68e52003-04-16 21:24:10 +0000278#
279# Output: messages printed by testcases.
280exectest_screenout()
281{
282 RC=0 # setting return code to 0, to loop in while
283
robbiew3b324ef2003-04-30 16:32:06 +0000284 RESULTS_FILE=$(date +%Y-%m-%d.%H.%M.%S).$$
robbiew5cc13812003-04-23 21:37:09 +0000285
robbiewb2f68e52003-04-16 21:24:10 +0000286 # execute runalltests.sh with user defined command file.
robbiew3b324ef2003-04-30 16:32:06 +0000287 ./runalltests.sh -q -p $RUNALL_FLAGS -l results.$RESULTS_FILE \
robbiewb2f68e52003-04-16 21:24:10 +0000288 -f /tmp/runltp.test.list.$$
robbiew5cc13812003-04-23 21:37:09 +0000289
robbiewb2f68e52003-04-16 21:24:10 +0000290 sleep 2
robbiew5cc13812003-04-23 21:37:09 +0000291
robbiewb2f68e52003-04-16 21:24:10 +0000292 return
293}
294
295
296# Function: execute_ltp
297#
298# Description: This function provides a menu of testcases that can be
299# selected for execution. If networking tests are selected,
300# they require a remote machine and remote machines root
301# users password. The user will be prompted to enter this
302# information in a text box.
303# The function checks to see if the ltp-mmddyy/testcases/bin
304# directory was created, this directory is created when the
305# testcases are compiled and installed, if it is not found
306# an info message window will notify the user that LTP needs to
307# be compiled before tests can be executed.
308# This function creates the senatrio file based on the users
309# choice of testcases and uses the runalltests.sh script to
310# execute these tests.
311# The messages printed by the testcases are displayed on this
312# terminal.
313#
314# Input: Users selection of testcases; scenario file.
315#
316# Output: Test selection window, Message window,
317# information message window
318execute_ltp()
319{
320 RC=0
321 host_name=" "
322 rhost_passwd=" "
323 run_net_test=" "
324
325 if ! [ -d ./testcases/bin ]
326 then
327 display_info_msg "Executing LTP testcases" \
328 "The testcases must to be compiled inorder\
329 to execute them. Returning to main menu. \
330 Please select the Compile option."
331 return
332 fi
333
334 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)
335 dialog --backtitle "Linux Test Project Control Centre"\
336 --title "Execute LTP" --clear\
337 --checklist "Select [SPACEBAR] tests to run" 20 80 5 \
338 $LIST \
339 2>/tmp/runltp.choice.$$ || RC=$?
340 size=`wc -m /tmp/runltp.choice.$$|awk '{print $1}'`
341 if [ $size -eq 0 ];then
342 tst_choice=$(echo "NULL")
343 else
344 tst_choice=$(cat /tmp/runltp.choice.$$)
345 fi
346 if [[ $tst_choice == NULL ]];then
347 RC=1
348 fi
349 case $RC in
350 0) \
351 for i in $tst_choice ;
352 do \
353 cat ./runtest/$(echo $i | sed -e 's/"//g') \
354 >> /tmp/runltp.test.list.$$ ;
355 if [[ $(echo $i | sed -e 's/"//g') == "tcp_cmds" || \
356 $(echo $i | sed -e 's/"//g') == "tcp_cmds_noexpect" || \
357 $(echo $i | sed -e 's/"//g') == "multicast" || \
358 $(echo $i | sed -e 's/"//g') == "ipv6" || \
359 $(echo $i | sed -e 's/"//g') == "ipv6_noexpect" || \
360 $(echo $i | sed -e 's/"//g') == "nfs" || \
361 $(echo $i | sed -e 's/"//g') == "multicast" ]] ;
362 then \
robbiew5cc13812003-04-23 21:37:09 +0000363 run_net_test="Y" ;
robbiewb2f68e52003-04-16 21:24:10 +0000364 fi ;
365
366 done ;
367 if ! [ -z $run_net_test ] ;
368 then \
369 dialog --backtitle "Linux Test Project Control Centre"\
370 --title "Execute LTP test cases" \
371 --clear \
372 --inputbox "You have chosen to execute testcases \
373 that require a Remote Machine. \
374 Please enter the fully qualified host \
375 name" 17 80 $(hostname --long) \
376 2>/tmp/runltp.out.$$ ;
377 host_name=$(cat /tmp/runltp.out.$$ | awk '{print $1}') ;
378 unset $RHOST ;
379 RHOST=$host_name ;
380 export RHOST;
381
382 dialog --backtitle "Linux Test Project Control Centre"\
383 --title "Execute LTP test cases" \
384 --clear \
385 --inputbox " Please enter the root password \
386 of this remote machine" 17 80 \
387 2>/tmp/runltp.out.$$ ;
388 rhost_passwd=$(cat /tmp/runltp.out.$$ | awk '{print $1}') ;
389
390 PASSWD=$rhost_passwd ;
391 export PASSWD;
392 fi ;
393
394 if ! [ -d ./testcases/bin ] ;
395 then \
396 display_info_msg "Executing LTP testcases" \
397 "The testcases must to be compiled inorder\
398 to execute them. Returning to main menu. \
399 Please select the Compile option." ;
400 return ;
401 fi ;
402
403 dialog --clear ;
robbiew5cc13812003-04-23 21:37:09 +0000404
405 flags_prompt ;
robbiewb2f68e52003-04-16 21:24:10 +0000406
robbiew5cc13812003-04-23 21:37:09 +0000407 exectest_screenout ;
robbiewb2f68e52003-04-16 21:24:10 +0000408
409 return ;;
410 1) \
411 # echo "Cancel pressed" ;
412 return ;;
413 255) \
414 # echo "ESC pressed" ;
415 return ;;
416 esac
417}
418
419
420# Function: about_ltpcc
421#
422# Description: This function displays a window containing a brief message
423# describing this programs functionality, and credits the author.
424#
425# Input: NONE
426#
427# Output: Message window, description of LTP Control Center.
428about_ltpcc()
429{
430 display_info_msg "About LTP Control Centre" \
431 "The LTP Control Centre can be used to\
432 to compile, install and execute\
433 The Linux Test Project test suite. Written by\
434 Manoj Iyer <manjo@mail.utexas.edu>"
435 return
436}
robbiew99a05032003-04-17 13:53:02 +0000437
438
439# Function: ltp_scenarios
440#
441# Description: This function displays a list of scenario files located
442# in /runtest. Users can list the contents of each file.
443#
444# Input: Files from /runtest
445#
446# Output: 1) Menu selection containing each file as an option to list.
447# 2) Contents of selected scenario.
448ltp_scenarios()
449{
450
451RC=0
robbiew43fc2492003-04-30 16:33:51 +0000452SCENARIOS=$(for i in `ls -1 -A -I "CVS" runtest`;do echo -n "$i [more...] "; done)
robbiew99a05032003-04-17 13:53:02 +0000453
454while [ $RC -ne "1" ]
455do
456 dialog --clear
457 dialog --backtitle "Linux Test Project Control Centre" \
458 --title "LTP Scenario Files" \
459 --menu "Move using[UP] [DOWN], Select using [ENTER]" 15 70 8 \
460 $SCENARIOS \
461 2>/tmp/runltp.scenario.$$ || RC=$?
462 scenario_item=$(cat /tmp/runltp.scenario.$$)
463 if ! [ -z $scenario_item ];then
464 dialog --clear
465 dialog --backtitle "Linux Test Project Control Centre" \
466 --title "LTP Scenario Files" \
467 --textbox runtest/$scenario_item 17 70
468 fi
469done
470}
471
472
robbiewb2f68e52003-04-16 21:24:10 +0000473
474# Function: main
475#
476# Description: Displays the main menu to the LTP Control Centre. The menu
477# provides options to Compile, Execute, and View test execution
478# results.
479#
480# Calls: about_ltpcc()
481# compile_ltp()
482# execute_ltp()
483# disp_ltpres()
484#
485# Input: NONE
486#
487# Output: Menu selection of actions to perform.
488
489# Global variables.
490RC=0 # return code from commands and local functions
491mmenu_item=" "
492RHOST=" "
493PASSWD=" "
robbiew5cc13812003-04-23 21:37:09 +0000494RUNALL_FLAGS=" "
robbiew3b324ef2003-04-30 16:32:06 +0000495RESULTS_FILE=" "
robbiewb2f68e52003-04-16 21:24:10 +0000496
497# call cleanup function on program exit.
498trap "cleanup" 0
499
500
501# wait in a loop until user hits [Cancel] button on the main menu.
502while :
503do
504 RC=0
505 dialog --clear
506 dialog --backtitle "Linux Test Project Control Centre" \
507 --title "Main Menu" \
robbiew99a05032003-04-17 13:53:02 +0000508 --menu "Move using[UP] [DOWN], Select using [ENTER]" 15 70 5 \
robbiewb2f68e52003-04-16 21:24:10 +0000509 About "About LTP Control Centre" \
510 Compile "Compile LTP testsuite" \
robbiew99a05032003-04-17 13:53:02 +0000511 Details "Details of scenario files" \
robbiewb2f68e52003-04-16 21:24:10 +0000512 Execute "Execute LTP testsuite" \
513 Results "Display a summary of test results" \
514 2>/tmp/runltp.mainmenu.$$ || RC=$?
515
516 case $RC in
517 0) mmenu_item=`cat /tmp/runltp.mainmenu.$$` ;
518 # echo "return code = $RC" ;
519 # echo "MENU ITEM = $mmenu_item" ;
520 case $mmenu_item in
521 About) about_ltpcc ;;
522 Compile) compile_ltp ;;
robbiew99a05032003-04-17 13:53:02 +0000523 Details) ltp_scenarios ;;
robbiewb2f68e52003-04-16 21:24:10 +0000524 Execute) execute_ltp ;;
525 Results) disp_ltpres ;;
526 esac ;;
527
528 1) 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 \
532 for latest news on The Linux Test Project. "
533 exit ;;
534
535 255) display_info_msg "Good Bye!" \
536 "Thank you for using Linux Test Project test suite.\
537 Please visit our project website\
538 http://ltp.sourceforge.net for latest news\
539 on The Linux Test Project. "
540 exit;;
541 esac
542done