From nobody Fri May 3 00:54:48 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38DEBC7619A for ; Sat, 25 Mar 2023 06:10:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232098AbjCYGKw (ORCPT ); Sat, 25 Mar 2023 02:10:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232315AbjCYGKT (ORCPT ); Sat, 25 Mar 2023 02:10:19 -0400 Received: from out30-99.freemail.mail.aliyun.com (out30-99.freemail.mail.aliyun.com [115.124.30.99]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB6291A95C for ; Fri, 24 Mar 2023 23:09:57 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R611e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045168;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0VeZn9WA_1679724594; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VeZn9WA_1679724594) by smtp.aliyun-inc.com; Sat, 25 Mar 2023 14:09:55 +0800 From: Jingbo Xu To: xiang@kernel.org, chao@kernel.org, huyue2@coolpad.com, linux-erofs@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH] erofs-utils: tests: enhance erofs/019 Date: Sat, 25 Mar 2023 14:09:54 +0800 Message-Id: <20230325060954.63062-1-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Test xattr in following cases: - multiple inline xattrs for one single file - multiple share xattrs for one single file - mixed inline and share xattrs for one single file - name/value field of xattr crosses block boundary Signed-off-by: Jingbo Xu --- This is used to test the refactoring on xattr on kernel side[1]. This patch relies on the "-b #blocksize" feature, and thus it needs to be rebased to "-b experimental" branch of erofs-utils. [1] https://lore.kernel.org/all/20230323000949.57608-1-jefflexu@linux.aliba= ba.com/ --- tests/erofs/019 | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/tests/erofs/019 b/tests/erofs/019 index dac2ae3..f733516 100755 --- a/tests/erofs/019 +++ b/tests/erofs/019 @@ -15,6 +15,11 @@ cleanup() rm -rf $tmp.* } =20 +generate_random() +{ + head -20 /dev/urandom | base64 -w0 | head -c $1 +} + _require_erofs =20 # remove previous $seqres.full before test @@ -37,18 +42,37 @@ rm -rf $localdir mkdir -p $localdir =20 # set random xattrs -cp -nR ../ $localdir -dirs=3D`ls $localdir` -for d in $dirs; do - key=3D`head -20 /dev/urandom | cksum | cut -f1 -d " "` - val=3D"0s"`head -3 /dev/urandom | base64 -w0` - setfattr -n user.$key -v $val $localdir/$d -done =20 +# file1: multiple inline xattrs +touch $localdir/file1 +setfattr -n user.p$(generate_random 16) -v $(generate_random 16) $localdir= /file1 +# inline xattr (large name/value crossing block boundary) +setfattr -n user.p$(generate_random 249) -v $(generate_random 1024) $local= dir/file1 + +# file2: multiple share xattrs +s_key_1=3D$(generate_random 16) +s_key_2=3D$(generate_random 16) +s_val=3D$(generate_random 16) + +touch $localdir/file2 +setfattr -n user.s$s_key_1 -v $s_val $localdir/file2 +setfattr -n user.s$s_key_2 -v $s_val $localdir/file2 + +# file3: mixed inline and share xattrs +touch $localdir/file3 +setfattr -n user.p$(generate_random 16) -v $(generate_random 16) $localdir= /file3 +setfattr -n user.s$s_key_1 -v $s_val $localdir/file3 + +# file4: share xattr +touch $localdir/file4 +setfattr -n user.s$s_key_2 -v $s_val $localdir/file4 + +MKFS_OPTIONS=3D"$MKFS_OPTIONS -b1024 -x1" _scratch_mkfs $localdir >> $seqres.full 2>&1 || _fail "failed to mkfs" _scratch_mount 2>>$seqres.full =20 # check xattrs +dirs=3D`ls $localdir` for d in $dirs; do xattr1=3D`getfattr --absolute-names -d $localdir/$d | tail -n+2` xattr2=3D`getfattr --absolute-names -d $SCRATCH_MNT/$d | tail -n+2` --=20 1.8.3.1