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 2014 Nexenta Systems, Inc. All rights reserved.
  16 #
  17 
  18 XGREP=${XGREP:=/usr/xpg4/bin/grep}
  19 FILEDIR=$MY_TESTS/tests/files
  20 
  21 fail() {
  22         echo $1
  23         exit -1
  24 }
  25 
  26 FLAGLIST="
  27 -n
  28 -c
  29 -q
  30 -v
  31 -nv
  32 -vc
  33 -A 5
  34 -nA 5
  35 -cA 5
  36 -qA 5
  37 -vA 5
  38 -nvA 5
  39 -vcA 5
  40 -B 5
  41 -nB 5
  42 -cB 5
  43 -qB 5
  44 -vB 5
  45 -nvB 5
  46 -vcB 5
  47 -C 5
  48 -nC 5
  49 -cC 5
  50 -qC 5
  51 -vC 5
  52 -nvC 5
  53 -vcC 5
  54 -B 5 -A 2
  55 -nB 5 -A 2
  56 -cB 5 -A 2
  57 -qB 5 -A 2
  58 -vB 5 -A 2
  59 -nvB 5 -A 2
  60 -vcB 5 -A 2
  61 -B 5 -A 2 -C 5
  62 -nB 5 -A 2 -C 5
  63 -cB 5 -A 2 -C 5
  64 -qB 5 -A 2 -C 5
  65 -vB 5 -A 2 -C 5
  66 -nvB 5 -A 2 -C 5
  67 -vcB 5 -A 2 -C 5
  68 -5
  69 -n -5
  70 -c -5
  71 -q -5
  72 -v -5
  73 -nv -5
  74 -vc -5
  75 -50000
  76 -n -50000
  77 -c -50000
  78 -q -50000
  79 -v -50000
  80 -nv -50000
  81 -vc -50000
  82 -C 5 -B 4 -A 2
  83 -nC 5 -B 4 -A 2
  84 -cC 5 -B 4 -A 2
  85 -qC 5 -B 4 -A 2
  86 -vC 5 -B 4 -A 2
  87 -nvC 5 -B 4 -A 2
  88 -vcC 5 -B 4 -A 2"
  89 
  90 echo "$FLAGLIST" > /tmp/flags
  91 
  92 cd $FILEDIR
  93 
  94 i=0
  95 while read flags; do
  96         print -n "grep $flags: "
  97         $XGREP $flags a test0 test1 test2 \
  98             test3 test4 test5 test6 \
  99             test7 > out
 100         if [[ $? -ne 0 ]]; then
 101                 fail "failed on exit"
 102         elif [ -n "$(diff out gout$i)" ]; then
 103                 fail "output is different"
 104         fi
 105         echo "passed"
 106         ((i++))
 107 done < /tmp/flags