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