1 #!/bin/ksh -p
   2 #
   3 # CDDL HEADER START
   4 #
   5 # The contents of this file are subject to the terms of the
   6 # Common Development and Distribution License (the "License").
   7 # You may not use this file except in compliance with the License.
   8 #
   9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10 # or http://www.opensolaris.org/os/licensing.
  11 # See the License for the specific language governing permissions
  12 # and limitations under the License.
  13 #
  14 # When distributing Covered Code, include this CDDL HEADER in each
  15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16 # If applicable, add the following below this CDDL HEADER, with the
  17 # fields enclosed by brackets "[]" replaced with your own identifying
  18 # information: Portions Copyright [yyyy] [name of copyright owner]
  19 #
  20 # CDDL HEADER END
  21 #
  22 
  23 #
  24 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  25 # Use is subject to license terms.
  26 #
  27 # ident "@(#)tc_add_dynamic.ksh 1.2     08/12/19 SMI"
  28 #
  29 
  30 . ${TET_SUITE_ROOT}/lofi-tests/lib/startup_cleanup_common
  31 
  32 tet_startup=startup
  33 tet_cleanup=cleanup
  34 
  35 reference_tree=$SCRATCH_DIR/$$_ref_tree
  36 
  37 function startup {
  38         cti_report "In startup"
  39 
  40         typical_startup_checks
  41         if (( $? != 0 )); then
  42                 exit 1
  43         fi
  44 
  45         cti_report "Building 'reference tree' $reference_tree"
  46         build_reference_tree $reference_tree
  47         if (( $? != 0 )); then
  48                 exit 1
  49         fi
  50 }
  51 
  52 
  53 function cleanup {
  54         cti_report "In cleanup"
  55         if [[ -d $reference_tree ]]; then
  56                 cti_report "Deleting 'reference tree' $reference_tree"
  57                 cti_execute "FAIL" "$RM -rf $reference_tree"
  58                 if (( $? != 0 )); then
  59                         exit 1
  60                 fi
  61         fi
  62 
  63         #
  64         # cleanup /dev/lofi to prepare for the next test
  65         #
  66         if [ -d /dev/lofi ]; then
  67                 rm -rf /dev/lofi
  68         fi
  69 }
  70 
  71 default_lofi_size="10M"
  72 
  73 #
  74 # The following sets of parameters will be used to build dynamic test cases.
  75 # All combinations of valid parameters will be built, while for negative
  76 # parameters only one negative parameter will be allowed per test case.
  77 #
  78 dynamic_config_file="$CTI_LOGDIR/tc_lofi_basic_create.cfg"
  79 cat /dev/null > $dynamic_config_file
  80 
  81 lofi_dev_pos_params="none full_path_block full_path_char"
  82 lofi_dev_neg_params="partial_path non_lofi_path"
  83 file_name_pos_params="full_path"
  84 file_name_neg_params="none partial invalid"
  85 file_size_pos_params="zero non_zero"
  86 
  87 ic_num=1
  88 
  89 # This block builds the set of all possible combinations of all positive
  90 # test case parameters.
  91 for lofi_dev_param in $lofi_dev_pos_params
  92 do
  93         for file_name_param in $file_name_pos_params
  94         do
  95                 for file_size_param in $file_size_pos_params
  96                 do
  97                         echo "pos $lofi_dev_param $file_name_param" \
  98                             "$file_size_param" >> $dynamic_config_file
  99                         let ic_num=$ic_num+1
 100                 done
 101         done
 102 done
 103 
 104 # This block builds a set of test cases based on the negative 'lofi dev'
 105 # parameters with all combinations of positive parameters for the other
 106 # areas.
 107 for lofi_dev_param in $lofi_dev_neg_params
 108 do
 109         for file_name_param in $file_name_pos_params
 110         do
 111                 for file_size_param in $file_size_pos_params
 112                 do
 113                         echo "neg $lofi_dev_param $file_name_param" \
 114                             "$file_size_param" >> $dynamic_config_file
 115                         let ic_num=$ic_num+1
 116                 done
 117         done
 118 done
 119 
 120 # This block builds a set of test cases based on the negative 'file name'
 121 # parameters with all combinations of positive parameters for the other
 122 # areas.
 123 for file_name_param in $file_name_neg_params
 124 do
 125         for lofi_dev_param in $lofi_dev_pos_params
 126         do
 127                 for file_size_param in $file_size_pos_params
 128                 do
 129                         echo "neg $lofi_dev_param $file_name_param" \
 130                             "$file_size_param" >> $dynamic_config_file
 131                         let ic_num=$ic_num+1
 132                 done
 133         done
 134 done
 135 
 136 # Build the 'icN' and 'iclist' variables.
 137 counter=1
 138 iclist=""
 139 while (( $counter < $ic_num )); do
 140         eval ic$counter=\"tp_add_dynamic\"
 141         eval iclist=\"$iclist ic$counter\"
 142         let counter=$counter+1
 143 done
 144 
 145 . ./tp_add_dynamic      # Contains test purpose for dynamic test cases
 146 
 147 . ${TET_ROOT:?}/common/lib/ctiutils.ksh
 148 . ${TET_ROOT}/lib/ksh/tcm.ksh
 149 . ${TET_SUITE_ROOT}/src/lib/ksh/fs_common.ksh