Allow running utimensat test from a directory different from $LTPROOT/testcases/bin
[ltp-debian.git] / ltpmenu
blob0de6dfd78b2f4498c5e06ca7b523b9835b1759ba
1 #!/bin/sh
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.
55 # Function: cleanup
57 # Description: Remove all temporary files created by this program. Cleanup
58 # always called on program exit.
60 # Input: NONE
62 # Output: NONE
63 cleanup()
65 rm -f $TMPDIR/runltp.*
69 # Function: display_info_msg
71 # Description: Displays informational messages window. This window may
72 # may be used to display information like errors, instructions
73 # etc to the user. The window is dismissed when the user hits
74 # the [ENTER] key.
76 # Input: $1 - Title the needs to be displayed on the window.
77 # eg: ERROR: Compiling LTP
78 # $2 - Message text.
80 # Output: Information message window.
81 display_info_msg()
83 dialog --backtitle "Linux Test Project Control Centre" \
84 --title " $1 " \
85 --msgbox " $2 " 10 70
86 return $?
90 # Function: compile_ltp
92 # Description: Checks for commands that are pre-reqs for compiling and
93 # installing LTP. It displays a confirmation window inorder to
94 # confirm the choice made by the user.
96 # Calls: do_make_clean()
97 # do_make()
98 # do_make_install()
100 # Input: NONE
102 # Output: Confirmation window.
103 compile_ltp()
105 dialog --backtitle "Linux Test Project Control Centre" \
106 --title "Compiling LTP testsuite"\
107 --yesno "This will compile all the test cases in\
108 LTP test suite and place the executables\
109 in testcases/bin directory. Do\
110 you wish to continue ??" 7 70 || RC=$?
111 case $RC in
112 0) \
113 for cmd in cc make lex ;
114 do \
115 which $cmd >$TMPDIR/runltp.err.$$ 2>&1;
116 if [ $? -ne 0 ] ;
117 then \
118 display_info_msg "Compiling LTP testsuite" \
119 "ERROR: command $cmd not found, $cmd is\
120 required to compile LTP test cases. Please\
121 install $cmd or export PATH correctly before\
122 running this program" ;
123 return ;
124 fi ;
125 done ;
126 make clean;
127 if [ $? -ne 0 ];then
128 echo "ERROR in \'make clean\' - exiting."
129 exit
131 make ;
132 if [ $? -ne 0 ];then
133 echo "ERROR in \'make all\' - exiting."
134 exit
136 make install ;
137 if [ $? -ne 0 ];then
138 echo "ERROR in \'make install\' - exiting."
139 exit
141 return ;;
143 1) return ;;
145 255) return ;;
146 esac
150 # Function: disp_ltpres
152 # Description: The results generated after the ltp execution located under
153 # ltp-mmddyy/results/ directory in a text (ASCII) file called
154 # results.todaysdate. This function displays this file in a
155 # window. If the results file does not exit it displays an
156 # info message window notifing the user that LTP test cases
157 # need to be executed inorder to view results.
159 # Input: ltp-mmddyy/results/results.todaysdate.time
161 # Output: Window displaying results of testcases that were executed.
162 disp_ltpres()
164 RC=0
166 RESULTS_LIST=$(for i in `ls -1 -A -I "CVS" $LTPRESULTS`;do echo -n "$i [more...] "; done)
167 if ! [ -z $RESULTS_LIST ] ;then
168 while [ $RC -ne "1" ]
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>$TMPDIR/runltp.results.$$ || RC=$?
176 results_item=$(cat $TMPDIR/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 $LTPRESULTS/$results_item 17 70
183 dialog --backtitle "Linux Test Project Control Centre" \
184 --title "LTP Test Results." \
185 --yesno "Would you like to share these results with the LTP \
186 community by posting it to the LTP results mailing list?" \
187 7 70 || RESPONSE=$?
188 case $RESPONSE in
189 0) \
190 mail ltp-results@lists.sourceforge.net < \
191 $LTPRESULTS/$results_item ;
194 1) ;;
196 255) ;;
197 esac
199 done
200 else
201 dialog --clear
202 dialog --backtitle "Linux Test Project Control Centre" \
203 --title "LTP Test Results" \
204 --msgbox "ERROR: No files to view in $LTPRESULTS directory." 5 53
206 return
210 # Function: flags_prompt
212 # Description: Prompt for and record user options for run duration and
213 # test output direction
215 # Input: none
217 # Output: none
218 flags_prompt()
220 dialog --backtitle "Linux Test Project Control Centre"\
221 --title "Output Direction" --clear\
222 --yesno "Would you like test output recorded to a file, instead of STDOUT?" 7 80
223 RC=$?
224 if [ $RC -eq "0" ]
225 then
226 dialog --backtitle "Linux Test Project Control Centre"\
227 --title "Output Direction" --clear\
228 --inputbox " Please enter the full path and \
229 name of the file where you wish \
230 to redirect output to" 17 80 \
231 2>$TMPDIR/runltp.outdir.$$ ;
232 flags_outfile=$(cat $TMPDIR/runltp.outdir.$$ | awk '{print $1}')
233 $TOOLSDIR/ver_linux > $flags_outfile 2>&1
234 RUNALL_FLAGS=" -o $flags_outfile"
237 dialog --backtitle "Linux Test Project Control Centre"\
238 --title "Test Duration" --clear\
239 --yesno "Would you like to specify test duration? \
240 Default is the length of one loop." 7 80
241 RC=$?
242 if [ $RC -eq "0" ]
243 then
244 dialog --backtitle "Linux Test Project Control Centre"\
245 --title "Test Duration - Interval Selection" --clear\
246 --menu "Move using[UP] [DOWN], Select using [ENTER]" 15 70 4 \
247 s "Seconds" \
248 m "Minutes" \
249 h "Hours" \
250 d "Days" \
251 2>$TMPDIR/runltp.interval.$$ ;
252 flags_interval=$(cat $TMPDIR/runltp.interval.$$ | awk '{print $1}')
253 case $flags_interval in
254 s) INTERVAL="seconds" ;;
255 m) INTERVAL="minutes" ;;
256 h) INTERVAL="hours" ;;
257 d) INTERVAL="days" ;;
258 esac
260 echo $INTERVAL
261 WINDOW_MSG="Please enter the number of $INTERVAL to run"
262 dialog --backtitle "Linux Test Project Control Centre"\
263 --title "Test Duration - Length Specification" --clear\
264 --inputbox "$WINDOW_MSG" 7 80 \
265 2>$TMPDIR/runltp.length.$$ ;
266 flags_length=$(cat $TMPDIR/runltp.length.$$ | awk '{print $1}')
267 flags_duration="$flags_length$flags_interval"
268 RUNALL_FLAGS=" $RUNALL_FLAGS -t $flags_duration"
272 # Function: exectest_screenout
274 # Description: Execute tests by calling runltp, display test status
275 # in a window.
277 # Input: none
279 # Output: messages printed by testcases.
280 exectest_screenout()
282 RC=0 # setting return code to 0, to loop in while
284 RESULTS_FILE=$(date +%Y-%m-%d.%H.%M.%S).$$
286 # execute runltp with user defined command file.
287 $TOOLSDIR/runltp -q -p $RUNALL_FLAGS -l results.$RESULTS_FILE \
288 -f $TMPDIR/runltp.test.list.$$
290 sleep 2
292 return
296 # Function: execute_ltp
298 # Description: This function provides a menu of testcases that can be
299 # selected for execution. If networking tests are selected,
300 # they require a remote machine and remote machines root
301 # users password. The user will be prompted to enter this
302 # information in a text box.
303 # The function checks to see if the ltp-mmddyy/testcases/bin
304 # directory was created, this directory is created when the
305 # testcases are compiled and installed, if it is not found
306 # an info message window will notify the user that LTP needs to
307 # be compiled before tests can be executed.
308 # This function creates the senatrio file based on the users
309 # choice of testcases and uses the runltp script to
310 # execute these tests.
311 # The messages printed by the testcases are displayed on this
312 # terminal.
314 # Input: Users selection of testcases; scenario file.
316 # Output: Test selection window, Message window,
317 # information message window
318 execute_ltp()
320 RC=0
321 host_name=" "
322 rhost_passwd=" "
323 run_net_test=" "
325 # Pre-compiled in Debian
326 # if ! [ -d ./testcases/bin ]
327 # then
328 # display_info_msg "Executing LTP testcases" \
329 # "The testcases must to be compiled inorder\
330 # to execute them. Returning to main menu. \
331 # Please select the Compile option."
332 # return
333 # fi
335 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)
336 dialog --backtitle "Linux Test Project Control Centre"\
337 --title "Execute LTP" --clear\
338 --checklist "Select [SPACEBAR] tests to run" 20 80 5 \
339 $LIST \
340 2>$TMPDIR/runltp.choice.$$ || RC=$?
341 size=`wc -m $TMPDIR/runltp.choice.$$|awk '{print $1}'`
342 if [ $size -eq 0 ];then
343 tst_choice=$(echo "NULL")
344 else
345 tst_choice=$(cat $TMPDIR/runltp.choice.$$)
347 if [ $tst_choice = NULL ];then
348 RC=1
350 case $RC in
351 0) \
352 for i in $tst_choice ;
353 do \
354 cat $LTPROOT/runtest/$(echo $i | sed -e 's/"//g') \
355 >> $TMPDIR/runltp.test.list.$$ ;
356 case "$(echo $i | sed -e 's/"//g')" in
357 "tcp_cmds" | "tcp_cmds_noexpect" |\
358 "multicast" | "nfs" |\
359 "ipv6_noexpect" | "ipv6")
360 run_net_test="Y"
361 esac
363 done ;
364 if ! [ -z $run_net_test ] ;
365 then \
366 dialog --backtitle "Linux Test Project Control Centre"\
367 --title "Execute LTP test cases" \
368 --clear \
369 --inputbox "You have chosen to execute testcases \
370 that require a Remote Machine. \
371 Please enter the fully qualified host \
372 name" 17 80 $(hostname --long) \
373 2>$TMPDIR/runltp.out.$$ ;
374 host_name=$(cat $TMPDIR/runltp.out.$$ | awk '{print $1}') ;
375 unset $RHOST ;
376 RHOST=$host_name ;
377 export RHOST;
379 dialog --backtitle "Linux Test Project Control Centre"\
380 --title "Execute LTP test cases" \
381 --clear \
382 --inputbox " Please enter the root password \
383 of this remote machine" 17 80 \
384 2>$TMPDIR/runltp.out.$$ ;
385 rhost_passwd=$(cat $TMPDIR/runltp.out.$$ | awk '{print $1}') ;
387 PASSWD=$rhost_passwd ;
388 export PASSWD;
389 fi ;
391 # Precompiled in Debian
392 # if ! [ -d ./testcases/bin ] ;
393 # then \
394 # display_info_msg "Executing LTP testcases" \
395 # "The testcases must to be compiled inorder\
396 # to execute them. Returning to main menu. \
397 # Please select the Compile option." ;
398 # return ;
399 # fi ;
401 dialog --clear ;
403 flags_prompt ;
405 exectest_screenout ;
407 return ;;
408 1) \
409 # echo "Cancel pressed" ;
410 return ;;
411 255) \
412 # echo "ESC pressed" ;
413 return ;;
414 esac
418 # Function: about_ltpcc
420 # Description: This function displays a window containing a brief message
421 # describing this programs functionality, and credits the author.
423 # Input: NONE
425 # Output: Message window, description of LTP Control Center.
426 about_ltpcc()
428 display_info_msg "About LTP Control Centre" \
429 "The LTP Control Centre can be used to\
430 to compile, install and execute\
431 The Linux Test Project test suite. Written by\
432 Manoj Iyer <manjo@mail.utexas.edu>"
433 return
437 # Function: ltp_scenarios
439 # Description: This function displays a list of scenario files located
440 # in $LTPROOT/runtest. Users can list the contents of each file.
442 # Input: Files from $LTPROOT/runtest
444 # Output: 1) Menu selection containing each file as an option to list.
445 # 2) Contents of selected scenario.
446 ltp_scenarios()
449 RC=0
450 SCENARIOS=$(for i in `ls -1 -A -I "CVS" $LTPROOT/runtest`;do echo -n "$i [more...] "; done)
452 while [ $RC -ne "1" ]
454 dialog --clear
455 dialog --backtitle "Linux Test Project Control Centre" \
456 --title "LTP Scenario Files" \
457 --menu "Move using[UP] [DOWN], Select using [ENTER]" 15 70 8 \
458 $SCENARIOS \
459 2>$TMPDIR/runltp.scenario.$$ || RC=$?
460 scenario_item=$(cat $TMPDIR/runltp.scenario.$$)
461 if ! [ -z $scenario_item ];then
462 dialog --clear
463 dialog --backtitle "Linux Test Project Control Centre" \
464 --title "LTP Scenario Files" \
465 --textbox $LTPROOT/runtest/$scenario_item 17 70
467 done
472 # Function: main
474 # Description: Displays the main menu to the LTP Control Centre. The menu
475 # provides options to Compile, Execute, and View test execution
476 # results.
478 # Calls: about_ltpcc()
479 # compile_ltp()
480 # execute_ltp()
481 # disp_ltpres()
483 # Input: NONE
485 # Output: Menu selection of actions to perform.
487 # Global variables.
488 RC=0 # return code from commands and local functions
489 mmenu_item=" "
490 RHOST=" "
491 PASSWD=" "
492 RUNALL_FLAGS=" "
493 RESULTS_FILE=" "
494 TMPDIR=${TMPDIR:-/tmp}
495 LTPRESULTS=/var/cache/ltp/results
496 LTPROOT=/usr/lib/ltp/
497 TOOLSDIR=/usr/lib/ltp/tools
499 # test for dialog program exist
500 if [ ! -x /usr/bin/dialog ]; then
501 echo "Sorry, ltpmenu GUI not available, can't find dialog. Exiting...";
502 exit 1;
505 # call cleanup function on program exit.
506 trap "cleanup" 0
509 # wait in a loop until user hits [Cancel] button on the main menu.
510 while :
512 RC=0
513 dialog --clear
514 dialog --backtitle "Linux Test Project Control Centre" \
515 --title "Main Menu" \
516 --menu "Move using[UP] [DOWN], Select using [ENTER]" 15 70 5 \
517 About "About LTP Control Centre" \
518 Details "Details of scenario files" \
519 Execute "Execute LTP testsuite" \
520 Results "Display a summary of test results" \
521 2>${TMPDIR:-/tmp}/runltp.mainmenu.$$ || RC=$?
523 case $RC in
524 0) mmenu_item=`cat /tmp/runltp.mainmenu.$$` ;
525 # echo "return code = $RC" ;
526 # echo "MENU ITEM = $mmenu_item" ;
527 case $mmenu_item in
528 About) about_ltpcc ;;
529 # Compile) compile_ltp ;;
530 Details) ltp_scenarios ;;
531 Execute) execute_ltp ;;
532 Results) disp_ltpres ;;
533 esac ;;
535 1) display_info_msg "Good Bye!" \
536 "Thank you for using Linux Test Project test suite.\
537 Please visit our project website \
538 http://ltp.sourceforge.net \
539 for latest news on The Linux Test Project. "
540 exit ;;
542 255) 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 for latest news\
546 on The Linux Test Project. "
547 exit;;
548 esac
549 done