Deleted the open_hpi_testsuite, as we won't need it
[ltp-debian.git] / ltpmenu
blob0a5e3e818c1bf883da9e0bcb4f7c1cbbb208673c
1 ################################################################################
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 ################################################################################
21 # File:        runltp
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
30 # Thanks:      Jim Choate - For suggesting the use of dialog command.
32 # History:     March 26 2003 - Created.
34 #              March 28 2003 - Removed gauges and put make commands in foreground.
35 #                            Robbie Williamson - robbiew@us.ibm.com
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
41 #              April 17 2003 - Added menu selection to list contents of selected
42 #                              scenario file.
43 #                            Robbie Williamson - robbiew@us.ibm.com
45 #              April 23 2003 - Added PID to results filename.
46 #                            - Added code to allow users to redirect output and
47 #                              specify test execution duration.
48 #                            Robbie Williamson - robbiew@us.ibm.com
50 #              April 30, 2003 - Recoded results display to allow selection
51 #                               of results file.
52 #                             - Created variable to hold results filename
53 #                             - Added time to results filename.
54 #! /bin/bash
56 # Function:    cleanup
58 # Description: Remove all temporary files created by this program. Cleanup 
59 #              always called on program exit.
61 # Input:       NONE
63 # Output:      NONE
64 cleanup()
66     rm -f /tmp/runltp.*
70 # Function:    display_info_msg 
72 # Description: Displays informational messages window. This window may
73 #              may be used to display information like errors, instructions
74 #              etc to the user. The window is dismissed when the user hits
75 #              the [ENTER] key.
77 # Input:       $1 - Title the needs to be displayed on the window. 
78 #                   eg: ERROR: Compiling LTP
79 #              $2 - Message text.
81 # Output:      Information message window.
82 display_info_msg()
84     dialog --backtitle "Linux Test Project Control Centre" \
85            --title " $1 " \
86            --msgbox " $2 " 10 70 
87     return $?
91 # Function:    compile_ltp
93 # Description: Checks for commands that are pre-reqs for compiling and 
94 #              installing LTP. It displays a confirmation window inorder to 
95 #              confirm the choice made by the user.
97 # Calls:       do_make_clean()
98 #              do_make()
99 #              do_make_install()
101 # Input:       NONE
103 # Output:      Confirmation window.
104 compile_ltp()
106     dialog --backtitle "Linux Test Project Control Centre" \
107            --title "Compiling LTP testsuite"\
108            --yesno "This will compile all the test cases in\
109                     LTP test suite and place the executables\
110                     in testcases/bin directory. Do\
111                     you wish to continue ??" 7 70 || RC=$?
112     case $RC in
113         0) \
114             for cmd in cc make lex ;
115             do \
116                 which $cmd &>/tmp/runltp.err.$$ ;
117                 if [ $? -ne 0 ] ;
118                     then \
119                         display_info_msg "Compiling LTP testsuite" \
120                                  "ERROR: command $cmd not found, $cmd is\
121                                   required to compile LTP test cases. Please\
122                                   install $cmd or export PATH correctly before\
123                                   running this program" ;
124                     return ;
125                 fi ;
126             done ;
127             make clean;
128             if [ $? -ne 0 ];then
129               echo "ERROR in \'make clean\' - exiting."
130               exit
131             fi 
132             make ;
133             if [ $? -ne 0 ];then
134               echo "ERROR in \'make all\' - exiting."
135               exit
136             fi 
137             make install ;
138             if [ $? -ne 0 ];then
139               echo "ERROR in \'make install\' - exiting."
140               exit
141             fi 
142             return ;;
144         1)  return ;;
146         255) return ;;
147     esac
151 # Function:    disp_ltpres
153 # Description: The results generated after the ltp execution located under
154 #              ltp-mmddyy/results/ directory in a text (ASCII) file called 
155 #              results.todaysdate. This function displays this file in a
156 #              window. If the results file does not exit it displays an 
157 #              info message window notifing the user that LTP test cases
158 #              need to be executed inorder to view results.
160 # Input:       ltp-mmddyy/results/results.todaysdate.time
162 # Output:      Window displaying results of testcases that were executed.
163 disp_ltpres()
165     RC=0
167     RESULTS_LIST=$(for i in `ls -1 -A -I "CVS" results`;do echo -n "$i [more...] "; done)
168     if ! [ -z $RESULTS_LIST ] ;then
169       while [ $RC -ne "1" ] 
170       do
171         dialog --clear
172         dialog --backtitle "Linux Test Project Control Centre" \
173                --title "LTP Test Results" \
174                --menu "Move using[UP] [DOWN], Select using [ENTER]" 15 70 8 \
175                       $RESULTS_LIST \
176                       2>/tmp/runltp.results.$$ || RC=$?
177         results_item=$(cat /tmp/runltp.results.$$)
178         if ! [ -z $results_item ];then
179           dialog --clear
180           dialog --backtitle "Linux Test Project Control Centre" \
181                  --title "LTP Test Results" \
182                  --textbox results/$results_item 17 70
183         
184           dialog --backtitle "Linux Test Project Control Centre" \
185                  --title "LTP Test Results." \
186                  --yesno "Would you like to share these results with the LTP \
187                           community by posting it to the LTP results mailing list?" \
188                           7 70 || RESPONSE=$?
189           case $RESPONSE in 
190               0) \
191                   mail ltp-results@lists.sourceforge.net < \
192                           ./results/$results_item ;
193                   ;;
194     
195               1)  ;;
196      
197               255)  ;;
198           esac
199         fi
200       done
201     else
202       dialog --clear
203       dialog --backtitle "Linux Test Project Control Centre" \
204              --title "LTP Test Results" \
205              --msgbox "ERROR: No files to view in /results directory." 5 53 
206     fi
207     return
211 # Function:    flags_prompt
213 # Description: Prompt for and record user options for run duration and 
214 #              test output direction
216 # Input:       none
218 # Output:      none 
219 flags_prompt()
221     dialog --backtitle "Linux Test Project Control Centre"\
222            --title "Output Direction" --clear\
223            --yesno "Would you like test output recorded to a file, instead of STDOUT?" 7 80
224     RC=$?
225     if [ $RC -eq "0" ]
226     then
227         dialog --backtitle "Linux Test Project Control Centre"\
228                --title "Output Direction" --clear\
229                --inputbox " Please enter the full path and \
230                             name of the file where you wish \
231                             to redirect output to" 17 80 \
232                           2>/tmp/runltp.outdir.$$ ;
233         flags_outfile=$(cat /tmp/runltp.outdir.$$ | awk '{print $1}') 
234         ./ver_linux > $flags_outfile 2>&1
235         RUNALL_FLAGS=" -o $flags_outfile"
236     fi
237     
238     dialog --backtitle "Linux Test Project Control Centre"\
239            --title "Test Duration" --clear\
240            --yesno "Would you like to specify test duration? \
241                     Default is the length of one loop." 7 80
242     RC=$?
243     if [ $RC -eq "0" ]
244     then
245         dialog --backtitle "Linux Test Project Control Centre"\
246                --title "Test Duration - Interval Selection" --clear\
247                --menu "Move using[UP] [DOWN], Select using [ENTER]" 15 70 4 \
248                        s    "Seconds" \
249                        m    "Minutes" \
250                        h    "Hours" \
251                        d    "Days" \
252                   2>/tmp/runltp.interval.$$ ;
253         flags_interval=$(cat /tmp/runltp.interval.$$ | awk '{print $1}') 
254         case $flags_interval in
255                 s)      INTERVAL="seconds" ;;      
256                 m)      INTERVAL="minutes" ;;      
257                 h)      INTERVAL="hours"   ;;      
258                 d)      INTERVAL="days"    ;;      
259         esac 
261         echo $INTERVAL
262         WINDOW_MSG="Please enter the number of $INTERVAL to run"
263         dialog --backtitle "Linux Test Project Control Centre"\
264                --title "Test Duration - Length Specification" --clear\
265                --inputbox "$WINDOW_MSG" 7 80 \
266                           2>/tmp/runltp.length.$$ ;
267         flags_length=$(cat /tmp/runltp.length.$$ | awk '{print $1}')
268         flags_duration="$flags_length$flags_interval"   
269         RUNALL_FLAGS=" $RUNALL_FLAGS -t $flags_duration"
270     fi
273 # Function:    exectest_screenout
275 # Description: Execute tests by calling runltp, display test status 
276 #              in a window.
278 # Input:       none
280 # Output:      messages printed by testcases.
281 exectest_screenout()
283     RC=0    # setting return code to 0, to loop in while
285     RESULTS_FILE=$(date +%Y-%m-%d.%H.%M.%S).$$
287     # execute runltp with user defined command file.
288     ./runltp -q -p $RUNALL_FLAGS -l results.$RESULTS_FILE \
289         -f /tmp/runltp.test.list.$$  
290     
291     sleep 2
293     return
297 # Function:    execute_ltp
299 # Description: This function provides a menu of testcases that can be
300 #              selected for execution. If networking tests are selected,
301 #              they require a remote machine and remote machines root
302 #              users password. The user will be prompted to enter this 
303 #              information in a text box.
304 #              The function checks to see if the ltp-mmddyy/testcases/bin
305 #              directory was created, this directory is created when the 
306 #              testcases are compiled and installed, if it is not found
307 #              an info message window will notify the user that LTP needs to
308 #              be compiled before tests can be executed.
309 #              This function creates the senatrio file based on the users
310 #              choice of testcases and uses the runltp script to 
311 #              execute these tests.
312 #              The messages printed by the testcases are displayed on this 
313 #              terminal.
315 # Input:       Users selection of testcases; scenario file.
316 #              
317 # Output:      Test selection window, Message window, 
318 #              information message window
319 execute_ltp()
321     RC=0
322     host_name=" "
323     rhost_passwd=" "
324     run_net_test=" "    
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" runtest`; do echo -n "$i "; j=$(head -n1 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>/tmp/runltp.choice.$$ || RC=$?
341     size=`wc -m /tmp/runltp.choice.$$|awk '{print $1}'` 
342     if [ $size -eq 0 ];then
343       tst_choice=$(echo "NULL")
344     else
345       tst_choice=$(cat /tmp/runltp.choice.$$)
346     fi
347     if [[ $tst_choice == NULL ]];then
348       RC=1
349     fi
350     case $RC in 
351         0)    \
352             for i in $tst_choice ;
353             do \
354                 cat ./runtest/$(echo $i | sed -e 's/"//g') \
355                    >> /tmp/runltp.test.list.$$ ;
356                 if [[ $(echo $i | sed -e 's/"//g') == "tcp_cmds" || \
357                       $(echo $i | sed -e 's/"//g') == "tcp_cmds_noexpect" || \
358                       $(echo $i | sed -e 's/"//g') == "multicast" || \
359                       $(echo $i | sed -e 's/"//g') == "ipv6" || \
360                       $(echo $i | sed -e 's/"//g') == "ipv6_noexpect" || \
361                       $(echo $i | sed -e 's/"//g') == "nfs" || \
362                       $(echo $i | sed -e 's/"//g') == "multicast" ]] ;
363                 then \
364                     run_net_test="Y" ;
365                 fi ;
366                                        
367             done ;
368             if ! [ -z $run_net_test ] ;
369             then \
370                 dialog --backtitle "Linux Test Project Control Centre"\
371                        --title "Execute LTP test cases" \
372                        --clear \
373                        --inputbox "You have chosen to execute testcases \
374                                   that require a Remote Machine. \
375                                   Please enter the fully qualified host \
376                                   name" 17 80 $(hostname --long) \
377                                   2>/tmp/runltp.out.$$ ;
378                 host_name=$(cat /tmp/runltp.out.$$ | awk '{print $1}') ;
379                 unset $RHOST ;
380                 RHOST=$host_name ;
381                 export RHOST;
382                 
383                 dialog --backtitle "Linux Test Project Control Centre"\
384                        --title "Execute LTP test cases" \
385                        --clear \
386                        --inputbox " Please enter the root password \
387                                      of this remote machine" 17 80 \
388                         2>/tmp/runltp.out.$$ ;
389                 rhost_passwd=$(cat /tmp/runltp.out.$$ | awk '{print $1}') ;
391                 PASSWD=$rhost_passwd ;
392                 export PASSWD;
393             fi ;
395             if ! [ -d ./testcases/bin ] ;
396             then \
397                 display_info_msg "Executing LTP testcases" \
398                     "The testcases must to be compiled inorder\
399                      to execute them. Returning to main menu. \
400                      Please select the Compile option." ;
401                 return ;
402             fi ;
403         
404             dialog --clear ;
406             flags_prompt ;
407         
408             exectest_screenout ;
410             return ;;
411         1)    \
412             # echo "Cancel pressed" ;
413             return ;;
414         255)    \
415             # echo "ESC pressed" ;
416             return ;;
417     esac
421 # Function:    about_ltpcc
423 # Description: This function displays a window containing a brief message
424 #              describing this programs functionality, and credits the author.
426 # Input:       NONE 
428 # Output:      Message window, description of LTP Control Center.
429 about_ltpcc()
431     display_info_msg "About LTP Control Centre" \
432                      "The LTP Control Centre can be used to\
433                      to compile, install and execute\
434                      The Linux Test Project test suite. Written by\
435                      Manoj Iyer <manjo@mail.utexas.edu>"
436     return
440 # Function:    ltp_scenarios
442 # Description: This function displays a list of scenario files located 
443 #              in /runtest.  Users can list the contents of each file.
445 # Input:       Files from /runtest
447 # Output:      1) Menu selection containing each file as an option to list.
448 #              2) Contents of selected scenario.
449 ltp_scenarios()
452 RC=0
453 SCENARIOS=$(for i in `ls -1 -A -I "CVS" runtest`;do echo -n "$i [more...] "; done)
455 while [ $RC -ne "1" ] 
457   dialog --clear
458   dialog --backtitle "Linux Test Project Control Centre" \
459          --title "LTP Scenario Files" \
460          --menu "Move using[UP] [DOWN], Select using [ENTER]" 15 70 8 \
461                 $SCENARIOS \
462                 2>/tmp/runltp.scenario.$$ || RC=$?
463   scenario_item=$(cat /tmp/runltp.scenario.$$)
464   if ! [ -z $scenario_item ];then
465     dialog --clear
466     dialog --backtitle "Linux Test Project Control Centre" \
467            --title "LTP Scenario Files" \
468            --textbox runtest/$scenario_item 17 70
469   fi
470 done            
474                  
475 # Function:    main
477 # Description: Displays the main menu to the LTP Control Centre. The menu
478 #              provides options to Compile, Execute, and View test execution
479 #              results.
481 # Calls:       about_ltpcc()      
482 #              compile_ltp()
483 #              execute_ltp()
484 #              disp_ltpres()
486 # Input:       NONE
488 # Output:      Menu selection of actions to perform.
490 # Global variables.
491 RC=0              # return code from commands and local functions
492 mmenu_item=" "
493 RHOST=" "
494 PASSWD=" "
495 RUNALL_FLAGS=" "
496 RESULTS_FILE=" "
498 # test for dialog program exist
499 if [ ! -x /usr/bin/dialog ]; then
500        echo "Sorry, ltpmenu GUI not available, can't find dialog. Exiting...";
501        exit 1;
504 # call cleanup function on program exit.
505 trap "cleanup" 0
508 # wait in a loop until user hits [Cancel] button on the main menu.
509 while :
511     RC=0
512     dialog --clear
513     dialog --backtitle "Linux Test Project Control Centre" \
514            --title "Main Menu" \
515            --menu "Move using[UP] [DOWN], Select using [ENTER]" 15 70 5 \
516                   About        "About LTP Control Centre" \
517                   Compile      "Compile LTP testsuite" \
518                   Details      "Details of scenario files" \
519                   Execute      "Execute LTP testsuite" \
520                   Results      "Display a summary of test results" \
521                   2>/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