From c7fbae54c65a826e84b18723720507d6ea855b7f Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Wed, 23 Sep 2020 15:11:53 +1000 Subject: [PATCH] LU-13981 tests: use $TRUNCATE consistently and correctly. Two changes: 1/ tests should should always use $TRUNCATE rather than just "truncate" to ensure the tests/truncate programs is used rather than anything in /bin /usr/bin. This might not be needed in practice, but it is good to be consistent. 2/ The arguments provided should match what tests/truncate expects - "filename size". Using "-s size filename" as expected by /usr/bin/truncate is confusing and error prone. Signed-off-by: Mr NeilBrown Change-Id: Ic0adc0148ea0ff625695dbfc4cf339d0eca70241 Reviewed-on: https://review.whamcloud.com/40005 Tested-by: jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- lustre/tests/sanity-dom.sh | 4 ++-- lustre/tests/sanity.sh | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lustre/tests/sanity-dom.sh b/lustre/tests/sanity-dom.sh index 9385c21..783d45c 100644 --- a/lustre/tests/sanity-dom.sh +++ b/lustre/tests/sanity-dom.sh @@ -67,14 +67,14 @@ test_3() { # Write on one node to the DoM stripe and then truncate to over DoM size dd if=/dev/zero of=$DIR1/$tfile bs=$((DOM_SIZE-100)) count=1 || return 1 - truncate $DIR1/$tfile $((DOM_SIZE+700)) || return 2 + $TRUNCATE $DIR1/$tfile $((DOM_SIZE+700)) || return 2 # read on the second node inside DoM stripe to take a lock data from # the first client dd if=$DIR2/$tfile of=/dev/null bs=4096 count=1 seek=1 || return 3 $CHECKSTAT -t file -s $((DOM_SIZE+700)) $DIR2/$tfile || error "Wrong size after first truncate $tfile on first node" # now do local truncate over DoM size and check size is correct - truncate $DIR2/$tfile $((DOM_SIZE+500)) || return 4 + $TRUNCATE $DIR2/$tfile $((DOM_SIZE+500)) || return 4 $CHECKSTAT -t file -s $((DOM_SIZE+500)) $DIR2/$tfile || error "Wrong size after second truncate on the same node" $CHECKSTAT -t file -s $((DOM_SIZE+500)) $DIR1/$tfile || diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 079ac70..adcf85b 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -7028,7 +7028,7 @@ test_56xc() { error "cannot setstripe 20MB file" echo "done" echo -n "Sizing 20MB test file..." - truncate "$dir/20mb" 20971520 || error "cannot create 20MB test file" + $TRUNCATE "$dir/20mb" 20971520 || error "cannot create 20MB test file" echo "done" echo -n "Verifying small file autostripe count is 1..." $LFS_MIGRATE -y -A -C 1 "$dir/20mb" || @@ -7048,7 +7048,7 @@ test_56xc() { echo "done" echo -n "Sizing 1GB test file..." # File size is 1GB + 3KB - truncate "$dir/1gb" 1073744896 || error "cannot create 1GB test file" + $TRUNCATE "$dir/1gb" 1073744896 || error "cannot create 1GB test file" echo "done" # need at least 512MB per OST for 1GB file to fit in 2 stripes @@ -22099,7 +22099,7 @@ test_fake_rw() { [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum if [ "$read_write" = "read" ]; then - truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile + $TRUNCATE $DIR/$tfile $(expr 1048576 \* $blocks) fi local start_time=$(date +%s.%N) -- 1.8.3.1