Print this page
XXX Remove nawk(1)


  53         log_must $ZFS create $rootfs
  54 
  55         for file in $output $oldoutput ; do
  56                 if [[ -f $file ]]; then
  57                         log_must $RM -f $file
  58                 fi
  59         done
  60 }
  61 
  62 log_assert "Executing 'zfs upgrade' command succeeds."
  63 log_onexit cleanup
  64 
  65 rootfs=$TESTPOOL/$TESTFS
  66 typeset output=/tmp/zfs-versions.$$
  67 typeset oldoutput=/tmp/zfs-versions-old.$$
  68 typeset expect_str1="This system is currently running ZFS filesystem version"
  69 typeset expect_str2="All filesystems are formatted with the current version"
  70 typeset expect_str3="The following filesystems are out of date, and can be upgraded"
  71 typeset -i COUNT OLDCOUNT
  72 
  73 $ZFS upgrade | $NAWK '$1 ~ "^[0-9]+$" {print $2}'> $oldoutput
  74 OLDCOUNT=$( $WC -l $oldoutput | $AWK '{print $1}' )
  75 
  76 old_datasets=""
  77 for version in $ZFS_ALL_VERSIONS ; do
  78         typeset verfs
  79         eval verfs=\$ZFS_VERSION_$version
  80         typeset current_fs=$rootfs/$verfs
  81         typeset current_snap=${current_fs}@snap
  82         typeset current_clone=$rootfs/clone$verfs
  83         log_must $ZFS create -o version=${version} ${current_fs}
  84         log_must $ZFS snapshot ${current_snap}
  85         log_must $ZFS clone ${current_snap} ${current_clone}
  86 
  87         if (( version != $ZFS_VERSION )); then
  88                 old_datasets="$old_datasets ${current_fs} ${current_clone}"
  89         fi
  90 done
  91 
  92 if is_global_zone; then
  93         log_must $ZFS create -V 100m $rootfs/$TESTVOL
  94 fi
  95 
  96 log_must eval '$ZFS upgrade > $output 2>&1'
  97 
  98 # we also check that the usage message contains at least a description
  99 # of the current ZFS version.
 100 log_must eval '$GREP "${expect_str1} $ZFS_VERSION" $output > /dev/null 2>&1'
 101 $ZFS upgrade | $NAWK '$1 ~ "^[0-9]+$" {print $2}'> $output
 102 COUNT=$( $WC -l $output | $AWK '{print $1}' )
 103 
 104 typeset -i i=0
 105 for fs in ${old_datasets}; do
 106         log_must $GREP "^$fs$" $output
 107         (( i = i + 1 ))
 108 done
 109 
 110 if (( i != COUNT - OLDCOUNT )); then
 111         $CAT $output
 112         log_fail "More old-version filesystems print out than expect."
 113 fi
 114 
 115 for fs in $old_datasets ; do
 116         if datasetexists $fs ; then
 117                 log_must $ZFS destroy -Rf $fs
 118         fi
 119 done
 120 
 121 log_must eval '$ZFS upgrade > $output 2>&1'
 122 log_must eval '$GREP "${expect_str1} $ZFS_VERSION" $output > /dev/null 2>&1'
 123 if (( OLDCOUNT == 0 )); then
 124         log_must eval '$GREP "${expect_str2}" $output > /dev/null 2>&1'
 125 else
 126         log_must eval '$GREP "${expect_str3}" $output > /dev/null 2>&1'
 127 fi
 128 $ZFS upgrade | $NAWK '$1 ~ "^[0-9]+$" {print $2}'> $output
 129 COUNT=$( $WC -l $output | $AWK '{print $1}' )
 130 
 131 if (( COUNT != OLDCOUNT )); then
 132         $CAT $output
 133         log_fail "Unexpect old-version filesystems print out."
 134 fi
 135 
 136 log_pass "Executing 'zfs upgrade' command succeeds."


  53         log_must $ZFS create $rootfs
  54 
  55         for file in $output $oldoutput ; do
  56                 if [[ -f $file ]]; then
  57                         log_must $RM -f $file
  58                 fi
  59         done
  60 }
  61 
  62 log_assert "Executing 'zfs upgrade' command succeeds."
  63 log_onexit cleanup
  64 
  65 rootfs=$TESTPOOL/$TESTFS
  66 typeset output=/tmp/zfs-versions.$$
  67 typeset oldoutput=/tmp/zfs-versions-old.$$
  68 typeset expect_str1="This system is currently running ZFS filesystem version"
  69 typeset expect_str2="All filesystems are formatted with the current version"
  70 typeset expect_str3="The following filesystems are out of date, and can be upgraded"
  71 typeset -i COUNT OLDCOUNT
  72 
  73 $ZFS upgrade | $AWK '$1 ~ "^[0-9]+$" {print $2}'> $oldoutput
  74 OLDCOUNT=$( $WC -l $oldoutput | $AWK '{print $1}' )
  75 
  76 old_datasets=""
  77 for version in $ZFS_ALL_VERSIONS ; do
  78         typeset verfs
  79         eval verfs=\$ZFS_VERSION_$version
  80         typeset current_fs=$rootfs/$verfs
  81         typeset current_snap=${current_fs}@snap
  82         typeset current_clone=$rootfs/clone$verfs
  83         log_must $ZFS create -o version=${version} ${current_fs}
  84         log_must $ZFS snapshot ${current_snap}
  85         log_must $ZFS clone ${current_snap} ${current_clone}
  86 
  87         if (( version != $ZFS_VERSION )); then
  88                 old_datasets="$old_datasets ${current_fs} ${current_clone}"
  89         fi
  90 done
  91 
  92 if is_global_zone; then
  93         log_must $ZFS create -V 100m $rootfs/$TESTVOL
  94 fi
  95 
  96 log_must eval '$ZFS upgrade > $output 2>&1'
  97 
  98 # we also check that the usage message contains at least a description
  99 # of the current ZFS version.
 100 log_must eval '$GREP "${expect_str1} $ZFS_VERSION" $output > /dev/null 2>&1'
 101 $ZFS upgrade | $AWK '$1 ~ "^[0-9]+$" {print $2}'> $output
 102 COUNT=$( $WC -l $output | $AWK '{print $1}' )
 103 
 104 typeset -i i=0
 105 for fs in ${old_datasets}; do
 106         log_must $GREP "^$fs$" $output
 107         (( i = i + 1 ))
 108 done
 109 
 110 if (( i != COUNT - OLDCOUNT )); then
 111         $CAT $output
 112         log_fail "More old-version filesystems print out than expect."
 113 fi
 114 
 115 for fs in $old_datasets ; do
 116         if datasetexists $fs ; then
 117                 log_must $ZFS destroy -Rf $fs
 118         fi
 119 done
 120 
 121 log_must eval '$ZFS upgrade > $output 2>&1'
 122 log_must eval '$GREP "${expect_str1} $ZFS_VERSION" $output > /dev/null 2>&1'
 123 if (( OLDCOUNT == 0 )); then
 124         log_must eval '$GREP "${expect_str2}" $output > /dev/null 2>&1'
 125 else
 126         log_must eval '$GREP "${expect_str3}" $output > /dev/null 2>&1'
 127 fi
 128 $ZFS upgrade | $AWK '$1 ~ "^[0-9]+$" {print $2}'> $output
 129 COUNT=$( $WC -l $output | $AWK '{print $1}' )
 130 
 131 if (( COUNT != OLDCOUNT )); then
 132         $CAT $output
 133         log_fail "Unexpect old-version filesystems print out."
 134 fi
 135 
 136 log_pass "Executing 'zfs upgrade' command succeeds."