1 #!/usr/bin/ksh
   2 
   3 #
   4 # This file and its contents are supplied under the terms of the
   5 # Common Development and Distribution License ("CDDL"), version 1.0.
   6 # You may only use this file in accordance with the terms of version
   7 # 1.0 of the CDDL.
   8 #
   9 # A full copy of the text of the CDDL should have accompanied this
  10 # source.  A copy of the CDDL is also available via the Internet at
  11 # http://www.illumos.org/license/CDDL.
  12 #
  13 
  14 #
  15 # Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  16 #
  17 
  18 #
  19 # Test wrapper for SMF tests
  20 #
  21 # Define necessary environments and config variables here
  22 #
  23 export STF_SUITE=/opt/smf-tests
  24 export RUNFILE=$STF_SUITE/tests/stf_description
  25 export STF_TOOLS=/opt/SUNWstc-stf
  26 PATH=$PATH:/opt/SUNWstc-stf/bin/$(isainfo -n)   # stf_ tools
  27 PATH=$PATH:/opt/SUNWstc-genutils/bin            # genutils tools
  28 PATH=$PATH:/opt/SUNWstc-checkenv/bin            # checkenv tools
  29 export PATH
  30 
  31 usage() {
  32         echo "Usage: $0 tests"
  33         echo "Where"
  34         echo "   tests  tests to run separated by space"
  35         echo "          run all if not specified"
  36         exit 1
  37 }
  38 
  39 #
  40 # Must be run by root
  41 #
  42 if [ `id -u` -ne 0 ]; then
  43         echo Must run by root
  44         exit 1
  45 fi
  46 
  47 TESTS=$1
  48 #
  49 # Some global environments
  50 # Modify test specific config.vars to reset test specific envs
  51 #
  52 ALL="svcadm svccfg svc.startd manifests"
  53 
  54 if [ -z "$TESTS" ]; then        # run all
  55         TESTS=$ALL
  56 fi
  57 
  58 #
  59 # Override STF test log setup
  60 #
  61 #STF_LOGDIR=/var/tmp/smf-tests/results
  62 #export STF_LOGDIR
  63 
  64 #
  65 # Set RUNFILE to run test
  66 #
  67 for t in `echo $TESTS`; do
  68         #
  69         # Is test valid?
  70         #
  71         if [ "${ALL#*$t}" = "$ALL" ]; then
  72                 echo $t is not a valid test, skip
  73                 continue
  74         fi
  75         #       
  76         # Reset STF_EXECUTE_SUBDIRS in RUNFILE
  77         # to run the test
  78         #
  79         eval sed -i "s/^STF_EXECUTE_SUBDIRS=.*/STF_EXECUTE_SUBDIRS='$t'/g" $RUNFILE
  80         #
  81         # Configure test
  82         #
  83         stf_configure
  84 
  85         #
  86         # Run test
  87         #
  88         stf_execute
  89 
  90         #
  91         # Unconfigure test
  92         #
  93         stf_unconfigure
  94 
  95         #
  96         # Save individual test log
  97         #
  98         #mv $STF_LOGDIR/journal* $STF_LOGDIR/$t.$(date +%Y%m%d%H%M)
  99 done