robbiew | dc9e3c2 | 2003-04-01 17:14:33 +0000 | [diff] [blame] | 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 | ################################################################################ |
| 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 | # Note: The commands listed below are executed in the background and |
| 29 | # the function checks to see at priodic intervals (10s) if this |
| 30 | # program is still alive and runnning. If it is still |
| 31 | # running the output of this program is displayed on a window, |
| 32 | # or the status bar is updated to indicate progress. |
| 33 | # if anyone has a better idea, delete this "Note" and |
| 34 | # send me the patch. |
| 35 | # 1. make clean |
| 36 | # 2. make |
| 37 | # 3. make install |
| 38 | # 4. runalltests.sh |
| 39 | # |
| 40 | # Author: Manoj Iyer - manjo@mail.utexas.edu |
| 41 | # |
| 42 | # Thanks: Jim Choate - For suggesting the use of dialog command. |
| 43 | # |
| 44 | # History: March 26 2003 - Created. |
| 45 | # |
| 46 | #! /bin/bash |
| 47 | |
| 48 | # Function: cleanup |
| 49 | # |
| 50 | # Description: Remove all temporary files created by this program. Cleanup |
| 51 | # always called on program exit. |
| 52 | # |
| 53 | # Input: NONE |
| 54 | # |
| 55 | # Output: NONE |
| 56 | cleanup() |
| 57 | { |
| 58 | rm -f /tmp/runltp.* |
| 59 | } |
| 60 | |
| 61 | |
| 62 | # Function: display_info_msg |
| 63 | # |
| 64 | # Description: Displays informational messages window. This window may |
| 65 | # may be used to display information like errors, instructions |
| 66 | # etc to the user. The window is dismissed when the user hits |
| 67 | # the [ENTER] key. |
| 68 | # |
| 69 | # Input: $1 - Title the needs to be displayed on the window. |
| 70 | # eg: ERROR: Compiling LTP |
| 71 | # $2 - Message text. |
| 72 | # |
| 73 | # Output: Information message window. |
| 74 | display_info_msg() |
| 75 | { |
| 76 | dialog --backtitle "Linux Test Project Control Centre" \ |
| 77 | --cr-wrap \ |
| 78 | --tab-correct \ |
| 79 | --title " $1 " \ |
| 80 | --msgbox " $2 " 10 70 |
| 81 | return $? |
| 82 | } |
| 83 | |
| 84 | |
| 85 | # Function: do_make_clean |
| 86 | # |
| 87 | # Description: This function executes a "make clean" under the ltp-mmddyy/ |
| 88 | # directory inorder to remove executables and object files |
| 89 | # that may exist from previous compilation. It displays the |
| 90 | # progress in a window, and indicated percent complete. |
| 91 | # |
| 92 | # Input: NONE |
| 93 | # |
| 94 | # Output: Progress window indicating percent completed. |
| 95 | do_make_clean() |
| 96 | { |
| 97 | RC=1 |
| 98 | PCT=10 |
| 99 | make clean &>/tmp/runltp.comperr.$$ & |
| 100 | ( |
| 101 | while [ $RC -ne 0 ] |
| 102 | do |
| 103 | RC=$(ps -C make | grep make | wc -l | awk '{print $1}') |
| 104 | echo "XXX" |
| 105 | echo $PCT |
| 106 | echo "XXX" |
| 107 | PCT=`expr $PCT + 10` |
| 108 | sleep 1 |
| 109 | done |
| 110 | ) | |
| 111 | dialog --backtitle "Linux Test Project Control Centre" \ |
| 112 | --title "Compiling LTP testsuite - clean" \ |
| 113 | --gauge "Percent completed" 10 70 |
| 114 | return |
| 115 | } |
| 116 | |
| 117 | |
| 118 | # Function: do_make |
| 119 | # |
| 120 | # Description: This function executes a "make" under the ltp-mmddyy/ |
| 121 | # directory and creates executables, object files & libraries |
| 122 | # It displays the progress in a window, and indicated percent |
| 123 | # complete. |
| 124 | # |
| 125 | # Input: NONE |
| 126 | # |
| 127 | # Output: Progress window indicating percent completed. |
| 128 | do_make() |
| 129 | { |
| 130 | RC=1 |
| 131 | PCT=1 |
| 132 | make &>/tmp/runltp.comperr.$$ & |
| 133 | ( |
| 134 | while [ $RC -ne 0 ] |
| 135 | do |
| 136 | RC=$(ps -C make | grep make | wc -l | awk '{print $1}') |
| 137 | echo "XXX" |
| 138 | echo $PCT |
| 139 | echo "XXX" |
| 140 | PCT=`expr $PCT + 1` |
| 141 | sleep 10s |
| 142 | done |
| 143 | ) | |
| 144 | dialog --backtitle "Linux Test Project Control Centre" \ |
| 145 | --title "Compiling LTP testsuite - make" \ |
| 146 | --gauge "Percent completed" 10 70 |
| 147 | } |
| 148 | |
| 149 | |
| 150 | # Function: do_make_install |
| 151 | # |
| 152 | # Description: This function executes a "make install" under the ltp-mmddyy/ |
| 153 | # directory inorder to install executables and libraries, |
| 154 | # the install is done under ltp-mmddyy/testcases/bin/ . |
| 155 | # It displays the progress in a window, and indicated percent |
| 156 | # complete. |
| 157 | # |
| 158 | # Input: NONE |
| 159 | # |
| 160 | # Output: Progress window indicating percent completed. |
| 161 | do_make_install() |
| 162 | { |
| 163 | RC=1 |
| 164 | PCT=1 |
| 165 | make install &>/tmp/runltp.comperr.$$ & |
| 166 | ( |
| 167 | while [ $RC -ne 0 ] |
| 168 | do |
| 169 | RC=$(ps -C make | grep make | wc -l | awk '{print $1}') |
| 170 | echo "XXX" |
| 171 | echo $PCT |
| 172 | echo "XXX" |
| 173 | PCT=`expr $PCT + 1` |
| 174 | sleep 10s |
| 175 | done |
| 176 | ) | |
| 177 | dialog --backtitle "Linux Test Project Control Centre" \ |
| 178 | --title "Compiling LTP testsuite - install" \ |
| 179 | --gauge "Percent completed" 10 70 |
| 180 | } |
| 181 | |
| 182 | |
| 183 | # Function: compile_ltp |
| 184 | # |
| 185 | # Description: Checks for commands that are pre-reqs for compiling and |
| 186 | # installing LTP. It displays a confirmation window inorder to |
| 187 | # confirm the choice made by the user. |
| 188 | # |
| 189 | # Calls: do_make_clean() |
| 190 | # do_make() |
| 191 | # do_make_install() |
| 192 | # |
| 193 | # Input: NONE |
| 194 | # |
| 195 | # Output: Confirmation window. |
| 196 | compile_ltp() |
| 197 | { |
| 198 | dialog --backtitle "Linux Test Project Control Centre" \ |
| 199 | --title "Compiling LTP testsuite"\ |
| 200 | --yesno "This will compile all the test cases in\ |
| 201 | LTP test suite and place the executables\ |
| 202 | in ltp-mmddyy/testcases/bin directory. Do\ |
| 203 | you wish to continue ??" 7 70 || RC=$? |
| 204 | case $RC in |
| 205 | 0) \ |
| 206 | for cmd in cc make lex ; |
| 207 | do \ |
| 208 | which $cmd &>/tmp/runltp.err.$$ ; |
| 209 | if [ $? -ne 0 ] ; |
| 210 | then \ |
| 211 | display_info_msg "Compiling LTP testsuite" \ |
| 212 | "ERROR: command $cmd not found, $cmd is\ |
| 213 | required to compile LTP test cases. Please\ |
| 214 | install $cmd or export PATH correctly before\ |
| 215 | running this program" ; |
| 216 | return ; |
| 217 | fi ; |
| 218 | done ; |
| 219 | |
| 220 | do_make_clean ; |
| 221 | do_make ; |
| 222 | do_make_install ; |
| 223 | return ;; |
| 224 | |
| 225 | 1) return ;; |
| 226 | |
| 227 | 255) return ;; |
| 228 | esac |
| 229 | } |
| 230 | |
| 231 | |
| 232 | # Function: disp_ltpres |
| 233 | # |
| 234 | # Description: The results generated after the ltp execution located under |
| 235 | # ltp-mmddyy/results/ directory in a text (ASCII) file called |
| 236 | # results.todaysdate. This function displays this file in a |
| 237 | # window. If the results file does not exit it displays an |
| 238 | # info message window notifing the user that LTP test cases |
| 239 | # need to be executed inorder to view results. |
| 240 | # |
| 241 | # Input: ltp-mmddyy/results/results.todaysdate |
| 242 | # |
| 243 | # Output: Window displaying results of testcases that were executed. |
| 244 | disp_ltpres() |
| 245 | { |
| 246 | RC=0 |
| 247 | if ! [ -f ./results/results.$(date -I) ] |
| 248 | then |
| 249 | display_info_msg "LTP Test Results" \ |
| 250 | "Sorry cannot display test results, you have to run \ |
| 251 | the test cases first. Please choose the Execute LTP \ |
| 252 | option in the Main Menu." |
| 253 | return |
| 254 | fi |
| 255 | |
| 256 | dialog --backtitle "Linux Test Project Control Centre" \ |
| 257 | --exit-label "Return to Main Menu" \ |
| 258 | --title "LTP Test Results. Scroll [UP] [DOWN]/[PGUP] [PGDN]" \ |
| 259 | --textbox ./results/results.$(date -I) 17 70 |
| 260 | |
| 261 | dialog --backtitle "Linux Test Project Control Centre" \ |
| 262 | --defaultno \ |
| 263 | --title "LTP Test Results." \ |
| 264 | --yesno "Would you like to share these results with the LTP \ |
| 265 | community by posting it to the LTP results mailing list?" \ |
| 266 | 7 70 || RC=$? |
| 267 | case $RC in |
| 268 | 0) \ |
| 269 | mail ltp-results@lists.sourceforge.net < \ |
| 270 | ./results/results.$(date -I) ; |
| 271 | return ;; |
| 272 | |
| 273 | 1) return ;; |
| 274 | |
| 275 | 255) return ;; |
| 276 | esac |
| 277 | return |
| 278 | } |
| 279 | |
| 280 | |
| 281 | # Function: exectest_screenout |
| 282 | # |
| 283 | # Description: Execute tests by calling runalltests.sh, display test status |
| 284 | # in a window. |
| 285 | # |
| 286 | # Input: $1 - Flag to be passed to runalltests.sh inorder to run |
| 287 | # networking tests. |
| 288 | # |
| 289 | # Output: Window showing messages printed by testcases. |
| 290 | exectest_screenout() |
| 291 | { |
| 292 | RC=1 # setting return code to 1, to loop in while |
| 293 | |
| 294 | # remove old results file |
| 295 | rm ./results/results.$(date -I) &>/dev/null |
| 296 | |
| 297 | # execute runalltests.sh with user defined command file. |
| 298 | ./runalltests.sh -q -p $1 -l results.$(date -I) \ |
| 299 | -f /tmp/runltp.test.list.$$ &>/tmp/runltp.runall.out.$$ & |
| 300 | ( |
| 301 | while [ $RC -ne 0 ] |
| 302 | do |
| 303 | RC=$(ps -C runalltests.sh | grep runalltests.sh | wc -l | \ |
| 304 | awk '{print $1}') |
| 305 | done |
| 306 | ) | |
| 307 | dialog --backtitle "Linux Test Project Control Centre" \ |
| 308 | --clear \ |
| 309 | --exit-label "Return to Main Menu" \ |
| 310 | --title "Executing LTP testsuite - Screen out" \ |
| 311 | --tailbox /tmp/runltp.runall.out.$$ 17 70 |
| 312 | |
| 313 | dialog --clear |
| 314 | |
| 315 | return |
| 316 | } |
| 317 | |
| 318 | |
| 319 | # Function: execute_ltp |
| 320 | # |
| 321 | # Description: This function provides a menu of testcases that can be |
| 322 | # selected for execution. If networking tests are selected, |
| 323 | # they require a remote machine and remote machines root |
| 324 | # users password. The user will be prompted to enter this |
| 325 | # information in a text box. |
| 326 | # The function checks to see if the ltp-mmddyy/testcases/bin |
| 327 | # directory was created, this directory is created when the |
| 328 | # testcases are compiled and installed, if it is not found |
| 329 | # an info message window will notify the user that LTP needs to |
| 330 | # be compiled before tests can be executed. |
| 331 | # This function creates the senatrio file based on the users |
| 332 | # choice of testcases and uses the runalltests.sh script to |
| 333 | # execute these tests. |
| 334 | # The messages printed by the testcases are displayed on this |
| 335 | # terminal. |
| 336 | # |
| 337 | # Input: Users selection of testcases; scenario file. |
| 338 | # |
| 339 | # Output: Test selection window, Message window, |
| 340 | # information message window |
| 341 | execute_ltp() |
| 342 | { |
| 343 | RC=0 |
| 344 | host_name=" " |
| 345 | rhost_passwd=" " |
| 346 | run_net_test=" " |
| 347 | |
| 348 | if ! [ -d ./testcases/bin ] |
| 349 | then |
| 350 | display_info_msg "Executing LTP testcases" \ |
| 351 | "The testcases must to be compiled inorder\ |
| 352 | to execute them. Returning to main menu. \ |
| 353 | Please select the Compile option." |
| 354 | return |
| 355 | fi |
| 356 | |
| 357 | dialog --backtitle "Linux Test Project Control Centre"\ |
| 358 | --title "Execute LTP" --clear\ |
| 359 | --cancel-label 'Exit' \ |
| 360 | --checklist "Select [SPACEBAR] tests to run" 20 61 5 \ |
| 361 | "commands" "General Linux commands" off\ |
| 362 | "crashme" "Utility to crash your machine" off\ |
| 363 | "dio" "Direct IO tests" off\ |
| 364 | "fs" "Filesystem stress tests" ON\ |
| 365 | "fsx" "Another filesystem stress test" ON\ |
| 366 | "hyperthreading" "Hyperthreading stress tests" off\ |
| 367 | "io" "General I/O stress" ON\ |
| 368 | "ipc" "Interprocess communication stress" ON\ |
| 369 | "ipv6" "IPV6 related tests" off\ |
| 370 | "math" "Math library tests (CPU stress)" ON\ |
| 371 | "mm" "Memory Mgmt tests" ON\ |
| 372 | "multicast" "Multicast networking tests" off\ |
| 373 | "nfs" "Network filesystem stress" off\ |
| 374 | "pipes" "IPC pipes stress" ON\ |
| 375 | "pty" "Terminal type stress" off\ |
| 376 | "rpc" "Remote Procedure Call" off\ |
| 377 | "sched" "Scheduler Stress Tests" ON\ |
| 378 | "sctp_ipv6" "SCTP over IPv6" off\ |
| 379 | "sctp_tcp" "SCTP over TCP" off\ |
| 380 | "sctp_udp" "SCTP over UDP" off\ |
| 381 | "super" "mknod and setuid tests" off\ |
| 382 | "syscalls" "Kernel system calls" ON\ |
| 383 | "tcp_cmds" "TCP/IP commands tests" off\ |
| 384 | 2>/tmp/runltp.choice.$$ || RC=$? |
| 385 | |
| 386 | tst_choice=$(cat /tmp/runltp.choice.$$) |
| 387 | case $RC in |
| 388 | 0) \ |
| 389 | for i in $tst_choice ; |
| 390 | do \ |
| 391 | cat ./runtest/$(echo $i | sed -e 's/"//g') \ |
| 392 | >> /tmp/runltp.test.list.$$ ; |
| 393 | if [[ $(echo $i | sed -e 's/"//g') == "tcp_cmds" || \ |
| 394 | $(echo $i | sed -e 's/"//g') == "multicast" || \ |
| 395 | $(echo $i | sed -e 's/"//g') == "ipv6" || \ |
| 396 | $(echo $i | sed -e 's/"//g') == "nfs" || \ |
| 397 | $(echo $i | sed -e 's/"//g') == "multicast" ]] ; |
| 398 | then \ |
| 399 | run_net_test=" -N " ; |
| 400 | fi ; |
| 401 | |
| 402 | done ; |
| 403 | if ! [ -z $run_net_test ] ; |
| 404 | then \ |
| 405 | dialog --backtitle "Linux Test Project Control Centre"\ |
| 406 | --title "Execute LTP test cases" \ |
| 407 | --cr-wrap --clear \ |
| 408 | --inputbox "You have chosen to execute testcases \ |
| 409 | that require a Remote Machine. \ |
| 410 | Please enter the fully qualified host \ |
| 411 | name" 0 0 $(hostname --long) \ |
| 412 | 2>/tmp/runltp.out.$$ ; |
| 413 | host_name=$(cat /tmp/runltp.out.$$ | awk '{print $1}') ; |
| 414 | unset $RHOST ; |
| 415 | RHOST=$host_name ; |
| 416 | export RHOST |
| 417 | |
| 418 | dialog --backtitle "Linux Test Project Control Centre"\ |
| 419 | --title "Execute LTP test cases" \ |
| 420 | --passwordbox " Please enter the root password \ |
| 421 | of this remote machine" 10 50 \ |
| 422 | 2>/tmp/runltp.out.$$ ; |
| 423 | rhost_passwd=$(cat /tmp/runltp.out.$$ | awk '{print $1}') ; |
| 424 | |
| 425 | PASSWD=$rhost_passwd ; |
| 426 | export PASSWD |
| 427 | fi ; |
| 428 | |
| 429 | if ! [ -d ./testcases/bin ] ; |
| 430 | then \ |
| 431 | display_info_msg "Executing LTP testcases" \ |
| 432 | "The testcases must to be compiled inorder\ |
| 433 | to execute them. Returning to main menu. \ |
| 434 | Please select the Compile option." ; |
| 435 | return ; |
| 436 | fi ; |
| 437 | |
| 438 | dialog --clear ; |
| 439 | |
| 440 | exectest_screenout $run_net_test ; |
| 441 | |
| 442 | return ;; |
| 443 | 1) \ |
| 444 | # echo "Cancel pressed" ; |
| 445 | return ;; |
| 446 | 255) \ |
| 447 | # echo "ESC pressed" ; |
| 448 | return ;; |
| 449 | esac |
| 450 | } |
| 451 | |
| 452 | |
| 453 | # Function: about_ltpcc |
| 454 | # |
| 455 | # Description: This function displays a window containing a brief message |
| 456 | # describing this programs functionality, and credits the author. |
| 457 | # |
| 458 | # Input: NONE |
| 459 | # |
| 460 | # Output: Message window, description of LTP Control Center. |
| 461 | about_ltpcc() |
| 462 | { |
| 463 | display_info_msg "About LTP Control Centre" \ |
| 464 | "The LTP Control Centre can be used to\ |
| 465 | to compile, install and execute\ |
| 466 | The Linux Test Project test suite. Written by\ |
| 467 | Manoj Iyer - manjo@mail.utexas.edu" |
| 468 | return |
| 469 | } |
| 470 | |
| 471 | |
| 472 | # Function: main |
| 473 | # |
| 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. |
| 477 | # |
| 478 | # Calls: about_ltpcc() |
| 479 | # compile_ltp() |
| 480 | # execute_ltp() |
| 481 | # disp_ltpres() |
| 482 | # |
| 483 | # Input: NONE |
| 484 | # |
| 485 | # Output: Menu selection of actions to perform. |
| 486 | |
| 487 | # Global variables. |
| 488 | RC=0 # return code from commands and local functions |
| 489 | mmenu_item=" " |
| 490 | RHOST=" " |
| 491 | PASSWD=" " |
| 492 | |
| 493 | # call cleanup function on program exit. |
| 494 | trap "cleanup" 0 |
| 495 | |
| 496 | |
| 497 | # wait in a loop until user hits [Cancel] button on the main menu. |
| 498 | while : |
| 499 | do |
| 500 | RC=0 |
| 501 | dialog --clear |
| 502 | dialog --backtitle "Linux Test Project Control Centre" \ |
| 503 | --cancel-label "Exit" \ |
| 504 | --title "Main Menu" \ |
| 505 | --menu "Move using[UP] [DOWN], Select using [ENTER]" 15 70 4 \ |
| 506 | About "About LTP Control Centre" \ |
| 507 | Compile "Compile LTP testsuite" \ |
| 508 | Execute "Execute LTP testsuite" \ |
| 509 | Results "Display a Summery of test results" \ |
| 510 | 2>/tmp/runltp.mainmenu.$$ || RC=$? |
| 511 | |
| 512 | case $RC in |
| 513 | 0) mmenu_item=`cat /tmp/runltp.mainmenu.$$` ; |
| 514 | # echo "return code = $RC" ; |
| 515 | # echo "MENU ITEM = $mmenu_item" ; |
| 516 | case $mmenu_item in |
| 517 | About) about_ltpcc ;; |
| 518 | Compile) compile_ltp ;; |
| 519 | Execute) execute_ltp ;; |
| 520 | Results) disp_ltpres ;; |
| 521 | esac ;; |
| 522 | |
| 523 | 1) display_info_msg "Good Bye!" \ |
| 524 | "Thank you for using Linux Test Project test suite.\ |
| 525 | Please visit our project website \ |
| 526 | http://ltp.sourceforge.net \ |
| 527 | for latest news on The Linux Test Project. \ |
| 528 | LTP Control Centre Author: Manoj Iyer - \ |
| 529 | manjo@mail.utexas.edu" ; |
| 530 | exit ;; |
| 531 | |
| 532 | 255) display_info_msg "Good Bye!" \ |
| 533 | "Thank you for using Linux Test Project test suite.\ |
| 534 | Please visit our project website\ |
| 535 | http://ltp.sourceforge.net for latest news\ |
| 536 | on The Linux Test Project. \ |
| 537 | LTP Control Centre Author: Manoj Iyer - \ |
| 538 | manjo@mail.utexas.edu" ; |
| 539 | exit;; |
| 540 | esac |
| 541 | done |