From patchwork Mon Sep 16 06:21:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jianhong.Yin" X-Patchwork-Id: 11146373 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 74A2C1745 for ; Mon, 16 Sep 2019 06:21:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4DF6D2067D for ; Mon, 16 Sep 2019 06:21:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728109AbfIPGVy (ORCPT ); Mon, 16 Sep 2019 02:21:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51438 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728106AbfIPGVy (ORCPT ); Mon, 16 Sep 2019 02:21:54 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 297F03084032; Mon, 16 Sep 2019 06:21:54 +0000 (UTC) Received: from dhcp-12-115.nay.redhat.com (dhcp-12-115.nay.redhat.com [10.66.12.115]) by smtp.corp.redhat.com (Postfix) with ESMTP id 907DE608C0; Mon, 16 Sep 2019 06:21:52 +0000 (UTC) From: "Jianhong.Yin" To: fstests@vger.kernel.org Cc: guaneryu@gmail.com, jiyin@redhat.com, "Jianhong.Yin" Subject: [PATCH v4] generic/430: add copy in same file test Date: Mon, 16 Sep 2019 14:21:46 +0800 Message-Id: <20190916062146.3577-1-yin-jianhong@163.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 16 Sep 2019 06:21:54 +0000 (UTC) Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org now xfstests has not cover the senario that copy in same file related bug: copy_file_range return "Invalid argument" when copy in the same file https://bugzilla.kernel.org/show_bug.cgi?id=202935 step1: copy whole file to end of itself, and compare the two halves with the original file step2: recover from original file. Signed-off-by: Jianhong Yin --- tests/generic/430 | 10 ++++++++++ tests/generic/430.out | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/tests/generic/430 b/tests/generic/430 index 1b11f60d..2c06c96f 100755 --- a/tests/generic/430 +++ b/tests/generic/430 @@ -6,6 +6,7 @@ # # Tests vfs_copy_file_range(): # - Copy a file +# - Copy in same file # - Copy beginning of original to new file # - Copy middle of original to a new file # - Copy end of original to new file @@ -52,6 +53,15 @@ cmp $testdir/file $testdir/copy echo "Original md5sums:" md5sum $testdir/{file,copy} | _filter_test_dir +fsize=$(stat -c %s $testdir/copy) +echo "Copy in same file" +$XFS_IO_PROG -c "copy_range -l $fsize -d $fsize $testdir/copy" "$testdir/copy" +cmp -n $fsize $testdir/file $testdir/copy +cmp -i 0:$fsize $testdir/file $testdir/copy +$XFS_IO_PROG -t -f -c "copy_range $testdir/file" "$testdir/copy" +echo "md5sums after copying in same file and recover:" +md5sum $testdir/{file,copy} | _filter_test_dir + echo "Copy beginning of original file" $XFS_IO_PROG -f -c "copy_range -l 1000 $testdir/file" "$testdir/beginning" cmp -n 1000 $testdir/file $testdir/beginning diff --git a/tests/generic/430.out b/tests/generic/430.out index 4b4ca75d..57584957 100644 --- a/tests/generic/430.out +++ b/tests/generic/430.out @@ -3,6 +3,10 @@ Create the original file and then copy Original md5sums: e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/file e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/copy +Copy in same file +md5sums after copying in same file and recover: +e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/file +e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/copy Copy beginning of original file md5sums after copying beginning: e11fbace556cba26bf0076e74cab90a3 TEST_DIR/test-430/file