blob: b90d90c64e80599216d1d901fbb21b2bf6cf8fae [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#
robbiewb2f68e52003-04-16 21:24:10 +000045#! /bin/bash
46
47# Function: cleanup
48#
49# Description: Remove all temporary files created by this program. Cleanup
50# always called on program exit.
51#
52# Input: NONE
53#
54# Output: NONE
55cleanup()
56{
57 rm -f /tmp/runltp.*
58}
59
60
61# Function: display_info_msg
62#
63# Description: Displays informational messages window. This window may
64# may be used to display information like errors, instructions
65# etc to the user. The window is dismissed when the user hits
66# the [ENTER] key.
67#
68# Input: $1 - Title the needs to be displayed on the window.
69# eg: ERROR: Compiling LTP
70# $2 - Message text.
71#
72# Output: Information message window.
73display_info_msg()
74{
75 dialog --backtitle "Linux Test Project Control Centre" \
76 --title " $1 " \
77 --msgbox " $2 " 10 70
78 return $?
79}
80
81
82# Function: compile_ltp
83#
84# Description: Checks for commands that are pre-reqs for compiling and
85# installing LTP. It displays a confirmation window inorder to
86# confirm the choice made by the user.
87#
88# Calls: do_make_clean()
89# do_make()
90# do_make_install()
91#
92# Input: NONE
93#
94# Output: Confirmation window.
95compile_ltp()
96{
97 dialog --backtitle "Linux Test Project Control Centre" \
98 --title "Compiling LTP testsuite"\
99 --yesno "This will compile all the test cases in\
100 LTP test suite and place the executables\
101 in testcases/bin directory. Do\
102 you wish to continue ??" 7 70 || RC=$?
103 case $RC in
104 0) \
105 for cmd in cc make lex ;
106 do \
107 which $cmd &>/tmp/runltp.err.$$ ;
108 if [ $? -ne 0 ] ;
109 then \
110 display_info_msg "Compiling LTP testsuite" \
111 "ERROR: command $cmd not found, $cmd is\
112 required to compile LTP test cases. Please\
113 install $cmd or export PATH correctly before\
114 running this program" ;
115 return ;
116 fi ;
117 done ;
118 make clean;
119 if [ $? -ne 0 ];then
120 echo "ERROR in \'make clean\' - exiting."
121 exit
122 fi
123 make ;
124 if [ $? -ne 0 ];then
125 echo "ERROR in \'make all\' - exiting."
126 exit
127 fi
128 make install ;
129 if [ $? -ne 0 ];then
130 echo "ERROR in \'make install\' - exiting."
131 exit
132 fi
133 return ;;
134
135 1) return ;;
136
137 255) return ;;
138 esac
139}
140
141
142# Function: disp_ltpres
143#
144# Description: The results generated after the ltp execution located under
145# ltp-mmddyy/results/ directory in a text (ASCII) file called
146# results.todaysdate. This function displays this file in a
147# window. If the results file does not exit it displays an
148# info message window notifing the user that LTP test cases
149# need to be executed inorder to view results.
150#
151# Input: ltp-mmddyy/results/results.todaysdate
152#
153# Output: Window displaying results of testcases that were executed.
154disp_ltpres()
155{
156 RC=0
157 if ! [ -f ./results/results.$(date -I) ]
158 then
159 display_info_msg "LTP Test Results" \
160 "Sorry cannot display test results, you have to run \
161 the test cases first. Please choose the Execute LTP \
162 option in the Main Menu."
163 return
164 fi
165
166 dialog --backtitle "Linux Test Project Control Centre" \
167 --title "LTP Test Results. Scroll [UP] [DOWN]/[PGUP] [PGDN]" \
168 --textbox ./results/results.$(date -I) 17 70
169
170 dialog --backtitle "Linux Test Project Control Centre" \
171 --title "LTP Test Results." \
172 --yesno "Would you like to share these results with the LTP \
173 community by posting it to the LTP results mailing list?" \
174 7 70 || RC=$?
175 case $RC in
176 0) \
177 mail ltp-results@lists.sourceforge.net < \
178 ./results/results.$(date -I) ;
179 return ;;
180
181 1) return ;;
182
183 255) return ;;
184 esac
185 return
186}
187
188
189# Function: exectest_screenout
190#
191# Description: Execute tests by calling runalltests.sh, display test status
192# in a window.
193#
194# Input: $1 - Flag to be passed to runalltests.sh inorder to run
195# networking tests.
196#
197# Output: messages printed by testcases.
198exectest_screenout()
199{
200 RC=0 # setting return code to 0, to loop in while
201
202 # remove old results file
203 rm ./results/results.$(date -I) &>/dev/null
204
205 # execute runalltests.sh with user defined command file.
206 ./runalltests.sh -q -p $1 -l results.$(date -I) \
207 -f /tmp/runltp.test.list.$$
208 sleep 2
209 return
210}
211
212
213# Function: execute_ltp
214#
215# Description: This function provides a menu of testcases that can be
216# selected for execution. If networking tests are selected,
217# they require a remote machine and remote machines root
218# users password. The user will be prompted to enter this
219# information in a text box.
220# The function checks to see if the ltp-mmddyy/testcases/bin
221# directory was created, this directory is created when the
222# testcases are compiled and installed, if it is not found
223# an info message window will notify the user that LTP needs to
224# be compiled before tests can be executed.
225# This function creates the senatrio file based on the users
226# choice of testcases and uses the runalltests.sh script to
227# execute these tests.
228# The messages printed by the testcases are displayed on this
229# terminal.
230#
231# Input: Users selection of testcases; scenario file.
232#
233# Output: Test selection window, Message window,
234# information message window
235execute_ltp()
236{
237 RC=0
238 host_name=" "
239 rhost_passwd=" "
240 run_net_test=" "
241
242 if ! [ -d ./testcases/bin ]
243 then
244 display_info_msg "Executing LTP testcases" \
245 "The testcases must to be compiled inorder\
246 to execute them. Returning to main menu. \
247 Please select the Compile option."
248 return
249 fi
250
251 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)
252 dialog --backtitle "Linux Test Project Control Centre"\
253 --title "Execute LTP" --clear\
254 --checklist "Select [SPACEBAR] tests to run" 20 80 5 \
255 $LIST \
256 2>/tmp/runltp.choice.$$ || RC=$?
257 size=`wc -m /tmp/runltp.choice.$$|awk '{print $1}'`
258 if [ $size -eq 0 ];then
259 tst_choice=$(echo "NULL")
260 else
261 tst_choice=$(cat /tmp/runltp.choice.$$)
262 fi
263 if [[ $tst_choice == NULL ]];then
264 RC=1
265 fi
266 case $RC in
267 0) \
268 for i in $tst_choice ;
269 do \
270 cat ./runtest/$(echo $i | sed -e 's/"//g') \
271 >> /tmp/runltp.test.list.$$ ;
272 if [[ $(echo $i | sed -e 's/"//g') == "tcp_cmds" || \
273 $(echo $i | sed -e 's/"//g') == "tcp_cmds_noexpect" || \
274 $(echo $i | sed -e 's/"//g') == "multicast" || \
275 $(echo $i | sed -e 's/"//g') == "ipv6" || \
276 $(echo $i | sed -e 's/"//g') == "ipv6_noexpect" || \
277 $(echo $i | sed -e 's/"//g') == "nfs" || \
278 $(echo $i | sed -e 's/"//g') == "multicast" ]] ;
279 then \
280 run_net_test=" -N " ;
281 fi ;
282
283 done ;
284 if ! [ -z $run_net_test ] ;
285 then \
286 dialog --backtitle "Linux Test Project Control Centre"\
287 --title "Execute LTP test cases" \
288 --clear \
289 --inputbox "You have chosen to execute testcases \
290 that require a Remote Machine. \
291 Please enter the fully qualified host \
292 name" 17 80 $(hostname --long) \
293 2>/tmp/runltp.out.$$ ;
294 host_name=$(cat /tmp/runltp.out.$$ | awk '{print $1}') ;
295 unset $RHOST ;
296 RHOST=$host_name ;
297 export RHOST;
298
299 dialog --backtitle "Linux Test Project Control Centre"\
300 --title "Execute LTP test cases" \
301 --clear \
302 --inputbox " Please enter the root password \
303 of this remote machine" 17 80 \
304 2>/tmp/runltp.out.$$ ;
305 rhost_passwd=$(cat /tmp/runltp.out.$$ | awk '{print $1}') ;
306
307 PASSWD=$rhost_passwd ;
308 export PASSWD;
309 fi ;
310
311 if ! [ -d ./testcases/bin ] ;
312 then \
313 display_info_msg "Executing LTP testcases" \
314 "The testcases must to be compiled inorder\
315 to execute them. Returning to main menu. \
316 Please select the Compile option." ;
317 return ;
318 fi ;
319
320 dialog --clear ;
321
322 exectest_screenout $run_net_test ;
323
324 return ;;
325 1) \
326 # echo "Cancel pressed" ;
327 return ;;
328 255) \
329 # echo "ESC pressed" ;
330 return ;;
331 esac
332}
333
334
335# Function: about_ltpcc
336#
337# Description: This function displays a window containing a brief message
338# describing this programs functionality, and credits the author.
339#
340# Input: NONE
341#
342# Output: Message window, description of LTP Control Center.
343about_ltpcc()
344{
345 display_info_msg "About LTP Control Centre" \
346 "The LTP Control Centre can be used to\
347 to compile, install and execute\
348 The Linux Test Project test suite. Written by\
349 Manoj Iyer <manjo@mail.utexas.edu>"
350 return
351}
robbiew99a05032003-04-17 13:53:02 +0000352
353
354# Function: ltp_scenarios
355#
356# Description: This function displays a list of scenario files located
357# in /runtest. Users can list the contents of each file.
358#
359# Input: Files from /runtest
360#
361# Output: 1) Menu selection containing each file as an option to list.
362# 2) Contents of selected scenario.
363ltp_scenarios()
364{
365
366RC=0
367SCENARIOS=$(for i in `ls -1 -A -I "CVS" runtest`;do echo -n "$i <- "; done)
368
369while [ $RC -ne "1" ]
370do
371 dialog --clear
372 dialog --backtitle "Linux Test Project Control Centre" \
373 --title "LTP Scenario Files" \
374 --menu "Move using[UP] [DOWN], Select using [ENTER]" 15 70 8 \
375 $SCENARIOS \
376 2>/tmp/runltp.scenario.$$ || RC=$?
377 scenario_item=$(cat /tmp/runltp.scenario.$$)
378 if ! [ -z $scenario_item ];then
379 dialog --clear
380 dialog --backtitle "Linux Test Project Control Centre" \
381 --title "LTP Scenario Files" \
382 --textbox runtest/$scenario_item 17 70
383 fi
384done
385}
386
387
robbiewb2f68e52003-04-16 21:24:10 +0000388
389# Function: main
390#
391# Description: Displays the main menu to the LTP Control Centre. The menu
392# provides options to Compile, Execute, and View test execution
393# results.
394#
395# Calls: about_ltpcc()
396# compile_ltp()
397# execute_ltp()
398# disp_ltpres()
399#
400# Input: NONE
401#
402# Output: Menu selection of actions to perform.
403
404# Global variables.
405RC=0 # return code from commands and local functions
406mmenu_item=" "
407RHOST=" "
408PASSWD=" "
409
410# call cleanup function on program exit.
411trap "cleanup" 0
412
413
414# wait in a loop until user hits [Cancel] button on the main menu.
415while :
416do
417 RC=0
418 dialog --clear
419 dialog --backtitle "Linux Test Project Control Centre" \
420 --title "Main Menu" \
robbiew99a05032003-04-17 13:53:02 +0000421 --menu "Move using[UP] [DOWN], Select using [ENTER]" 15 70 5 \
robbiewb2f68e52003-04-16 21:24:10 +0000422 About "About LTP Control Centre" \
423 Compile "Compile LTP testsuite" \
robbiew99a05032003-04-17 13:53:02 +0000424 Details "Details of scenario files" \
robbiewb2f68e52003-04-16 21:24:10 +0000425 Execute "Execute LTP testsuite" \
426 Results "Display a summary of test results" \
427 2>/tmp/runltp.mainmenu.$$ || RC=$?
428
429 case $RC in
430 0) mmenu_item=`cat /tmp/runltp.mainmenu.$$` ;
431 # echo "return code = $RC" ;
432 # echo "MENU ITEM = $mmenu_item" ;
433 case $mmenu_item in
434 About) about_ltpcc ;;
435 Compile) compile_ltp ;;
robbiew99a05032003-04-17 13:53:02 +0000436 Details) ltp_scenarios ;;
robbiewb2f68e52003-04-16 21:24:10 +0000437 Execute) execute_ltp ;;
438 Results) disp_ltpres ;;
439 esac ;;
440
441 1) display_info_msg "Good Bye!" \
442 "Thank you for using Linux Test Project test suite.\
443 Please visit our project website \
444 http://ltp.sourceforge.net \
445 for latest news on The Linux Test Project. "
446 exit ;;
447
448 255) display_info_msg "Good Bye!" \
449 "Thank you for using Linux Test Project test suite.\
450 Please visit our project website\
451 http://ltp.sourceforge.net for latest news\
452 on The Linux Test Project. "
453 exit;;
454 esac
455done