Whamcloud - gitweb
LU-2805 tests: compare the file correctly for layout swapping
authorJinshan Xiong <jinshan.xiong@intel.com>
Wed, 13 Feb 2013 21:34:53 +0000 (13:34 -0800)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 4 Mar 2013 19:26:59 +0000 (14:26 -0500)
The size of file ref2 may be less than copied bytes so the result of
command cmp will be false due to EOF. Check differ string instead.

Signed-off-by: Jinshan Xiong <jinshan.xiong@intel.com>
Change-Id: I344f90bf4b75f535961f1acdc5574aeca8e85126
Reviewed-on: http://review.whamcloud.com/5420
Tested-by: Hudson
Reviewed-by: Jian Yu <jian.yu@intel.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/tests/sanity.sh

index 16a0410..e2a17db 100644 (file)
@@ -9394,23 +9394,26 @@ run_test 184b "Forbidden layout swap (will generate errors)"
 test_184c() {
        check_swap_layouts_support && return 0
 
 test_184c() {
        check_swap_layouts_support && return 0
 
-       dir0=$DIR/$tdir/$testnum
+       local dir0=$DIR/$tdir/$testnum
        mkdir -p $dir0 || error "creating dir $dir0"
        mkdir -p $dir0 || error "creating dir $dir0"
-       ref1=$dir0/ref1
-       ref2=$dir0/ref2
-       file1=$dir0/file1
-       file2=$dir0/file2
+
+       local ref1=$dir0/ref1
+       local ref2=$dir0/ref2
+       local file1=$dir0/file1
+       local file2=$dir0/file2
        # create a file large enough for the concurent test
        dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
        dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
        echo "ref file size: ref1(`stat -c %s $ref1`), ref2(`stat -c %s $ref2`)"
 
        cp $ref2 $file2
        # create a file large enough for the concurent test
        dd if=/dev/urandom of=$ref1 bs=1M count=$((RANDOM % 50 + 20))
        dd if=/dev/urandom of=$ref2 bs=1M count=$((RANDOM % 50 + 20))
        echo "ref file size: ref1(`stat -c %s $ref1`), ref2(`stat -c %s $ref2`)"
 
        cp $ref2 $file2
-       dd if=$ref1 of=$file1 bs=64k &
+       dd if=$ref1 of=$file1 bs=16k &
+       local DD_PID=$!
+
        sleep 0.$((RANDOM % 5 + 1))
 
        $LFS swap_layouts $file1 $file2
        sleep 0.$((RANDOM % 5 + 1))
 
        $LFS swap_layouts $file1 $file2
-       rc=$?
+       local rc=$?
        wait $DD_PID
        [[ $? == 0 ]] || error "concurrent write on $file1 failed"
        [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
        wait $DD_PID
        [[ $? == 0 ]] || error "concurrent write on $file1 failed"
        [[ $rc == 0 ]] || error "swap of $file1 and $file2 failed"
@@ -9421,7 +9424,7 @@ test_184c() {
        remaining=$((remaining - copied))
        echo "Copied $copied bytes before swapping layout..."
 
        remaining=$((remaining - copied))
        echo "Copied $copied bytes before swapping layout..."
 
-       cmp -n $copied $file1 $ref2 ||
+       cmp -n $copied $file1 $ref2 | grep differ &&
                error "Content mismatch [0, $copied) of ref2 and file1"
        cmp -n $copied $file2 $ref1 ||
                error "Content mismatch [0, $copied) of ref1 and file2"
                error "Content mismatch [0, $copied) of ref2 and file1"
        cmp -n $copied $file2 $ref1 ||
                error "Content mismatch [0, $copied) of ref1 and file2"