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