Add dependencies for numa tests
[ltp-debian.git] / ltpmenu
blob97158dbb720092953f7bc82c16bbda016452005e
1 #! /bin/bash
2 ################################################################################
3 ## ##
4 ## Copyright (c) International Business Machines Corp., 2001 ##
5 ## ##
6 ## This program is free software; you can redistribute it and#or modify ##
7 ## it under the terms of the GNU General Public License as published by ##
8 ## the Free Software Foundation; either version 2 of the License, or ##
9 ## (at your option) any later version. ##
10 ## ##
11 ## This program is distributed in the hope that it will be useful, but ##
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
13 ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ##
14 ## for more details. ##
15 ## ##
16 ## You should have received a copy of the GNU General Public License ##
17 ## along with this program; if not, write to the Free Software ##
18 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ##
19 ## ##
20 ################################################################################
22 # File: runltp
24 # Description: This program is a Graphical User Interface (GUI)
25 # Control Centre for LTP. The Control Centre provides
26 # functionality to Compile, Execute and View Results of
27 # LTP test cases.
29 # Author: Manoj Iyer - manjo@mail.utexas.edu
31 # Thanks: Jim Choate - For suggesting the use of dialog command.
33 # History: March 26 2003 - Created.
35 # March 28 2003 - Removed gauges and put make commands in foreground.
36 # Robbie Williamson - robbiew@us.ibm.com
38 # March 31 2003 - Made scenario menu creation dynamic and code
39 # to pull the test descriptions from the scenario files.
40 # Robbie Williamson - robbiew@us.ibm.com
42 # April 17 2003 - Added menu selection to list contents of selected
43 # scenario file.
44 # Robbie Williamson - robbiew@us.ibm.com
46 # April 23 2003 - Added PID to results filename.
47 # - Added code to allow users to redirect output and
48 # specify test execution duration.
49 # Robbie Williamson - robbiew@us.ibm.com
51 # April 30, 2003 - Recoded results display to allow selection
52 # of results file.
53 # - Created variable to hold results filename
54 # - Added time to results filename.
58 # Function: cleanup
60 # Description: Remove all temporary files created by this program. Cleanup
61 # always called on program exit.
63 # Input: NONE
65 # Output: NONE
66 cleanup()
68 rm -f $TMPDIR/runltp.*
72 # Function: display_info_msg
74 # Description: Displays informational messages window. This window may
75 # may be used to display information like errors, instructions
76 # etc to the user. The window is dismissed when the user hits
77 # the [ENTER] key.
79 # Input: $1 - Title the needs to be displayed on the window.
80 # eg: ERROR: Compiling LTP
81 # $2 - Message text.
83 # Output: Information message window.
84 display_info_msg()
86 dialog --backtitle "Linux Test Project Control Centre" \
87 --title " $1 " \
88 --msgbox " $2 " 10 70
89 return $?
93 # Function: compile_ltp
95 # Description: Checks for commands that are pre-reqs for compiling and
96 # installing LTP. It displays a confirmation window inorder to
97 # confirm the choice made by the user.
99 # Calls: do_make_clean()
100 # do_make()
101 # do_make_install()
103 # Input: NONE
105 # Output: Confirmation window.
106 compile_ltp()
108 dialog --backtitle "Linux Test Project Control Centre" \
109 --title "Compiling LTP testsuite"\
110 --yesno "This will compile all the test cases in\
111 LTP test suite and place the executables\
112 in testcases/bin directory. Do\
113 you wish to continue ??" 7 70 || RC=$?
114 case $RC in
115 0) \
116 for cmd in cc make lex ;
117 do \
118 which $cmd &>$TMPDIR/runltp.err.$$ ;
119 if [ $? -ne 0 ] ;
120 then \
121 display_info_msg "Compiling LTP testsuite" \
122 "ERROR: command $cmd not found, $cmd is\
123 required to compile LTP test cases. Please\
124 install $cmd or export PATH correctly before\
125 running this program" ;
126 return ;
127 fi ;
128 done ;
129 make clean;
130 if [ $? -ne 0 ];then
131 echo "ERROR in \'make clean\' - exiting."
132 exit
134 make ;
135 if [ $? -ne 0 ];then
136 echo "ERROR in \'make all\' - exiting."
137 exit
139 make install ;
140 if [ $? -ne 0 ];then
141 echo "ERROR in \'make install\' - exiting."
142 exit
144 return ;;
146 1) return ;;
148 255) return ;;
149 esac
153 # Function: disp_ltpres
155 # Description: The results generated after the ltp execution located under
156 # ltp-mmddyy/results/ directory in a text (ASCII) file called
157 # results.todaysdate. This function displays this file in a
158 # window. If the results file does not exit it displays an
159 # info message window notifing the user that LTP test cases
160 # need to be executed inorder to view results.
162 # Input: ltp-mmddyy/results/results.todaysdate.time
164 # Output: Window displaying results of testcases that were executed.
165 disp_ltpres()
167 RC=0
169 RESULTS_LIST=$(for i in `ls -1 -A -I "CVS" $LTPRESULTS`;do echo -n "$i [more...] "; done)
170 if ! [ -z $RESULTS_LIST ] ;then
171 while [ $RC -ne "1" ]
173 dialog --clear
174 dialog --backtitle "Linux Test Project Control Centre" \
175 --title "LTP Test Results" \
176 --menu "Move using[UP] [DOWN], Select using [ENTER]" 15 70 8 \
177 $RESULTS_LIST \
178 2>$TMPDIR/runltp.results.$$ || RC=$?
179 results_item=$(cat $TMPDIR/runltp.results.$$)
180 if ! [ -z $results_item ];then
181 dialog --clear
182 dialog --backtitle "Linux Test Project Control Centre" \
183 --title "LTP Test Results" \
184 --textbox $LTPRESULTS/$results_item 17 70
186 dialog --backtitle "Linux Test Project Control Centre" \
187 --title "LTP Test Results." \
188 --yesno "Would you like to share these results with the LTP \
189 community by posting it to the LTP results mailing list?" \
190 7 70 || RESPONSE=$?
191 case $RESPONSE in
192 0) \
193 mail ltp-results@lists.sourceforge.net < \
194 $LTPRESULTS/$results_item ;
197 1) ;;
199 255) ;;
200 esac
202 done
203 else
204 dialog --clear
205 dialog --backtitle "Linux Test Project Control Centre" \
206 --title "LTP Test Results" \
207 --msgbox "ERROR: No files to view in $LTPRESULTS directory." 5 53
209 return
213 # Function: flags_prompt
215 # Description: Prompt for and record user options for run duration and
216 # test output direction
218 # Input: none
220 # Output: none
221 flags_prompt()
223 dialog --backtitle "Linux Test Project Control Centre"\
224 --title "Output Direction" --clear\
225 --yesno "Would you like test output recorded to a file, instead of STDOUT?" 7 80
226 RC=$?
227 if [ $RC -eq "0" ]
228 then
229 dialog --backtitle "Linux Test Project Control Centre"\
230 --title "Output Direction" --clear\
231 --inputbox " Please enter the full path and \
232 name of the file where you wish \
233 to redirect output to" 17 80 \
234 2>$TMPDIR/runltp.outdir.$$ ;
235 flags_outfile=$(cat $TMPDIR/runltp.outdir.$$ | awk '{print $1}')
236 $TOOLSDIR/ver_linux > $flags_outfile 2>&1
237 RUNALL_FLAGS=" -o $flags_outfile"
240 dialog --backtitle "Linux Test Project Control Centre"\
241 --title "Test Duration" --clear\
242 --yesno "Would you like to specify test duration? \
243 Default is the length of one loop." 7 80
244 RC=$?
245 if [ $RC -eq "0" ]
246 then
247 dialog --backtitle "Linux Test Project Control Centre"\
248 --title "Test Duration - Interval Selection" --clear\
249 --menu "Move using[UP] [DOWN], Select using [ENTER]" 15 70 4 \
250 s "Seconds" \
251 m "Minutes" \
252 h "Hours" \
253 d "Days" \
254 2>$TMPDIR/runltp.interval.$$ ;
255 flags_interval=$(cat $TMPDIR/runltp.interval.$$ | awk '{print $1}')
256 case $flags_interval in
257 s) INTERVAL="seconds" ;;
258 m) INTERVAL="minutes" ;;
259 h) INTERVAL="hours" ;;
260 d) INTERVAL="days" ;;
261 esac
263 echo $INTERVAL
264 WINDOW_MSG="Please enter the number of $INTERVAL to run"
265 dialog --backtitle "Linux Test Project Control Centre"\
266 --title "Test Duration - Length Specification" --clear\
267 --inputbox "$WINDOW_MSG" 7 80 \
268 2>$TMPDIR/runltp.length.$$ ;
269 flags_length=$(cat $TMPDIR/runltp.length.$$ | awk '{print $1}')
270 flags_duration="$flags_length$flags_interval"
271 RUNALL_FLAGS=" $RUNALL_FLAGS -t $flags_duration"
275 # Function: exectest_screenout
277 # Description: Execute tests by calling runltp, display test status
278 # in a window.
280 # Input: none
282 # Output: messages printed by testcases.
283 exectest_screenout()
285 RC=0 # setting return code to 0, to loop in while
287 RESULTS_FILE=$(date +%Y-%m-%d.%H.%M.%S).$$
289 # execute runltp with user defined command file.
290 $TOOLSDIR/runltp -q -p $RUNALL_FLAGS -l results.$RESULTS_FILE \
291 -f $TMPDIR/runltp.test.list.$$
293 sleep 2
295 return
299 # Function: execute_ltp
301 # Description: This function provides a menu of testcases that can be
302 # selected for execution. If networking tests are selected,
303 # they require a remote machine and remote machines root
304 # users password. The user will be prompted to enter this
305 # information in a text box.
306 # The function checks to see if the ltp-mmddyy/testcases/bin
307 # directory was created, this directory is created when the
308 # testcases are compiled and installed, if it is not found
309 # an info message window will notify the user that LTP needs to
310 # be compiled before tests can be executed.
311 # This function creates the senatrio file based on the users
312 # choice of testcases and uses the runltp script to
313 # execute these tests.
314 # The messages printed by the testcases are displayed on this
315 # terminal.
317 # Input: Users selection of testcases; scenario file.
319 # Output: Test selection window, Message window,
320 # information message window
321 execute_ltp()
323 RC=0
324 host_name=" "
325 rhost_passwd=" "
326 run_net_test=" "
328 # Pre-compiled in Debian
329 # if ! [ -d ./testcases/bin ]
330 # then
331 # display_info_msg "Executing LTP testcases" \
332 # "The testcases must to be compiled inorder\
333 # to execute them. Returning to main menu. \
334 # Please select the Compile option."
335 # return
336 # fi
338 LIST=$(for i in `ls -1 -A -I "CVS" $LTPROOT/runtest`; do echo -n "$i "; j=$(head -n1 $LTPROOT/runtest/$i | cut -d: -f2|sed s/" "/_/g); echo -n "$j off "; done)
339 dialog --backtitle "Linux Test Project Control Centre"\
340 --title "Execute LTP" --clear\
341 --checklist "Select [SPACEBAR] tests to run" 20 80 5 \
342 $LIST \
343 2>$TMPDIR/runltp.choice.$$ || RC=$?
344 size=`wc -m $TMPDIR/runltp.choice.$$|awk '{print $1}'`
345 if [ $size -eq 0 ];then
346 tst_choice=$(echo "NULL")
347 else
348 tst_choice=$(cat $TMPDIR/runltp.choice.$$)
350 if [[ $tst_choice == NULL ]];then
351 RC=1
353 case $RC in
354 0) \
355 for i in $tst_choice ;
356 do \
357 cat $LTPROOT/runtest/$(echo $i | sed -e 's/"//g') \
358 >> $TMPDIR/runltp.test.list.$$ ;
359 if [[ $(echo $i | sed -e 's/"//g') == "tcp_cmds" || \
360 $(echo $i | sed -e 's/"//g') == "tcp_cmds_noexpect" || \
361 $(echo $i | sed -e 's/"//g') == "multicast" || \
362 $(echo $i | sed -e 's/"//g') == "ipv6" || \
363 $(echo $i | sed -e 's/"//g') == "ipv6_noexpect" || \
364 $(echo $i | sed -e 's/"//g') == "nfs" || \
365 $(echo $i | sed -e 's/"//g') == "multicast" ]] ;
366 then \
367 run_net_test="Y" ;
368 fi ;
370 done ;
371 if ! [ -z $run_net_test ] ;
372 then \
373 dialog --backtitle "Linux Test Project Control Centre"\
374 --title "Execute LTP test cases" \
375 --clear \
376 --inputbox "You have chosen to execute testcases \
377 that require a Remote Machine. \
378 Please enter the fully qualified host \
379 name" 17 80 $(hostname --long) \
380 2>$TMPDIR/runltp.out.$$ ;
381 host_name=$(cat $TMPDIR/runltp.out.$$ | awk '{print $1}') ;
382 unset $RHOST ;
383 RHOST=$host_name ;
384 export RHOST;
386 dialog --backtitle "Linux Test Project Control Centre"\
387 --title "Execute LTP test cases" \
388 --clear \
389 --inputbox " Please enter the root password \
390 of this remote machine" 17 80 \
391 2>$TMPDIR/runltp.out.$$ ;
392 rhost_passwd=$(cat $TMPDIR/runltp.out.$$ | awk '{print $1}') ;
394 PASSWD=$rhost_passwd ;
395 export PASSWD;
396 fi ;
398 # Precompiled in Debian
399 # if ! [ -d ./testcases/bin ] ;
400 # then \
401 # display_info_msg "Executing LTP testcases" \
402 # "The testcases must to be compiled inorder\
403 # to execute them. Returning to main menu. \
404 # Please select the Compile option." ;
405 # return ;
406 # fi ;
408 dialog --clear ;
410 flags_prompt ;
412 exectest_screenout ;
414 return ;;
415 1) \
416 # echo "Cancel pressed" ;
417 return ;;
418 255) \
419 # echo "ESC pressed" ;
420 return ;;
421 esac
425 # Function: about_ltpcc
427 # Description: This function displays a window containing a brief message
428 # describing this programs functionality, and credits the author.
430 # Input: NONE
432 # Output: Message window, description of LTP Control Center.
433 about_ltpcc()
435 display_info_msg "About LTP Control Centre" \
436 "The LTP Control Centre can be used to\
437 to compile, install and execute\
438 The Linux Test Project test suite. Written by\
439 Manoj Iyer <manjo@mail.utexas.edu>"
440 return
444 # Function: ltp_scenarios
446 # Description: This function displays a list of scenario files located
447 # in $LTPROOT/runtest. Users can list the contents of each file.
449 # Input: Files from $LTPROOT/runtest
451 # Output: 1) Menu selection containing each file as an option to list.
452 # 2) Contents of selected scenario.
453 ltp_scenarios()
456 RC=0
457 SCENARIOS=$(for i in `ls -1 -A -I "CVS" $LTPROOT/runtest`;do echo -n "$i [more...] "; done)
459 while [ $RC -ne "1" ]
461 dialog --clear
462 dialog --backtitle "Linux Test Project Control Centre" \
463 --title "LTP Scenario Files" \
464 --menu "Move using[UP] [DOWN], Select using [ENTER]" 15 70 8 \
465 $SCENARIOS \
466 2>$TMPDIR/runltp.scenario.$$ || RC=$?
467 scenario_item=$(cat $TMPDIR/runltp.scenario.$$)
468 if ! [ -z $scenario_item ];then
469 dialog --clear
470 dialog --backtitle "Linux Test Project Control Centre" \
471 --title "LTP Scenario Files" \
472 --textbox $LTPROOT/runtest/$scenario_item 17 70
474 done
479 # Function: main
481 # Description: Displays the main menu to the LTP Control Centre. The menu
482 # provides options to Compile, Execute, and View test execution
483 # results.
485 # Calls: about_ltpcc()
486 # compile_ltp()
487 # execute_ltp()
488 # disp_ltpres()
490 # Input: NONE
492 # Output: Menu selection of actions to perform.
494 # Global variables.
495 RC=0 # return code from commands and local functions
496 mmenu_item=" "
497 RHOST=" "
498 PASSWD=" "
499 RUNALL_FLAGS=" "
500 RESULTS_FILE=" "
501 TMPDIR=${TMPDIR:-/tmp}
502 LTPRESULTS=/var/cache/ltp/results
503 LTPROOT=/usr/lib/ltp/tests/linux
504 TOOLSDIR=/usr/lib/ltp/tools
506 # test for dialog program exist
507 if [ ! -x /usr/bin/dialog ]; then
508 echo "Sorry, ltpmenu GUI not available, can't find dialog. Exiting...";
509 exit 1;
512 # call cleanup function on program exit.
513 trap "cleanup" 0
516 # wait in a loop until user hits [Cancel] button on the main menu.
517 while :
519 RC=0
520 dialog --clear
521 dialog --backtitle "Linux Test Project Control Centre" \
522 --title "Main Menu" \
523 --menu "Move using[UP] [DOWN], Select using [ENTER]" 15 70 5 \
524 About "About LTP Control Centre" \
525 Details "Details of scenario files" \
526 Execute "Execute LTP testsuite" \
527 Results "Display a summary of test results" \
528 2>${TMPDIR:-/tmp}/runltp.mainmenu.$$ || RC=$?
530 case $RC in
531 0) mmenu_item=`cat /tmp/runltp.mainmenu.$$` ;
532 # echo "return code = $RC" ;
533 # echo "MENU ITEM = $mmenu_item" ;
534 case $mmenu_item in
535 About) about_ltpcc ;;
536 # Compile) compile_ltp ;;
537 Details) ltp_scenarios ;;
538 Execute) execute_ltp ;;
539 Results) disp_ltpres ;;
540 esac ;;
542 1) display_info_msg "Good Bye!" \
543 "Thank you for using Linux Test Project test suite.\
544 Please visit our project website \
545 http://ltp.sourceforge.net \
546 for latest news on The Linux Test Project. "
547 exit ;;
549 255) display_info_msg "Good Bye!" \
550 "Thank you for using Linux Test Project test suite.\
551 Please visit our project website\
552 http://ltp.sourceforge.net for latest news\
553 on The Linux Test Project. "
554 exit;;
555 esac
556 done