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