1 #
   2 # CDDL HEADER START
   3 #
   4 # The contents of this file are subject to the terms of the
   5 # Common Development and Distribution License (the "License").
   6 # You may not use this file except in compliance with the License.
   7 #
   8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9 # or http://www.opensolaris.org/os/licensing.
  10 # See the License for the specific language governing permissions
  11 # and limitations under the License.
  12 #
  13 # When distributing Covered Code, include this CDDL HEADER in each
  14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15 # If applicable, add the following below this CDDL HEADER, with the
  16 # fields enclosed by brackets "[]" replaced with your own identifying
  17 # information: Portions Copyright [yyyy] [name of copyright owner]
  18 #
  19 # CDDL HEADER END
  20 #
  21 
  22 # 
  23 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24 # Use is subject to license terms.
  25 #
  26 
  27 #
  28 # This ksh library file contains common ksh utility functions to be used by
  29 # tests in this directory and is intended to be "sourced" by said tests.
  30 #
  31 
  32 # Wait for the start/stop method to be executed
  33 function wait_process {
  34         count=0
  35 
  36         typeset wait_file=${1}
  37         typeset timeout=${2:-10} # default timeout = 10 seconds
  38 
  39         while [ $count -lt $timeout ]; do
  40 
  41                 echo "--INFO: [$assertion]
  42         Looking for $wait_file ..."
  43 
  44                 if [ -r $wait_file ]; then
  45                         echo "--INFO: [$assertion] 
  46                 $wait_file found"
  47                         return 0
  48                 else
  49                         sleep 1
  50                 fi
  51                 count=`expr $count + 1`
  52         done
  53 
  54         #If test process not started by service in given time
  55         #then fail and return 1
  56 
  57         if [ $count -ge $timeout ]; then
  58                 return 1
  59         fi
  60 
  61         echo "--INFO: [$assertion]
  62                 $wait_file found"
  63         return 0
  64 }
  65 
  66 # Wait for the start method
  67 function wait_process_start {
  68         wait_process ${1:-$start_file} ${2:-$startstop_timeout}
  69 }
  70 
  71 # Wait for the stop method
  72 function wait_process_stop {
  73         wait_process ${1:-$stop_file} ${2:-$startstop_timeout}
  74 }
  75 
  76 
  77 # This function is to cleanup leftovers after test execution
  78 function cleanup_leftovers {
  79         typeset targets="$@"
  80         typeset service_to_clean="${1}"
  81         typeset files_to_clean="${targets##$service_to_clean }"
  82         
  83         service_cleanup $service_to_clean
  84         /usr/bin/rm -f $files_to_clean
  85 }
  86 
  87 #
  88 ### END
  89 #