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