Skip to contentSkip to conversation

erofs-utils: tests: convert test cases to bash

PATCH In review Jingbo Xu 2 participants 4 messages Jul 25, 2023

lore
Share & tools
lore

Jingbo Xu

author
#0 lore raw

PATCH 1/3 erofs-utils: tests: convert test cases to bash

Convert to bash script so that some featues e.g. array and string substitution could be used.

---
 tests/common/rc | 2 +-
 tests/erofs/001 | 2 +-
 tests/erofs/002 | 2 +-
 tests/erofs/003 | 2 +-
 tests/erofs/004 | 2 +-
 tests/erofs/005 | 2 +-
 tests/erofs/006 | 2 +-
 tests/erofs/007 | 2 +-
 tests/erofs/008 | 2 +-
 tests/erofs/009 | 2 +-
 tests/erofs/010 | 2 +-
 tests/erofs/011 | 2 +-
 tests/erofs/012 | 2 +-
 tests/erofs/013 | 2 +-
 tests/erofs/014 | 2 +-
 tests/erofs/015 | 2 +-
 tests/erofs/017 | 2 +-
 tests/erofs/018 | 2 +-
 tests/erofs/019 | 2 +-
 tests/erofs/020 | 2 +-
 tests/erofs/021 | 2 +-
 tests/erofs/022 | 2 +-
 22 files changed, 22 insertions(+), 22 deletions(-)
tests/common/rc +1 -1
index f234fdc..f54b5c1 100644
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0+
 
 tmp=/tmp/$$
tests/erofs/001 +1 -1
index 0f8a6d8..8f587fb 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0+
 #
 # test if unknown algorithm is specificed
tests/erofs/002 +1 -1
index b59c846..0f38bf4 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0+
 #
 # test short symlink (fast symlink)
tests/erofs/003 +1 -1
index 6ec242d..9c60453 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0+
 #
 # test long symlink (non-fast symlink)
tests/erofs/004 +1 -1
index 25e22e6..de96d32 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0+
 #
 # test character/block device
tests/erofs/005 +1 -1
index a003e57..cd7b58b 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0+
 #
 # test pipe files
tests/erofs/006 +1 -1
index 2ebd1ae..18458b0 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0+
 #
 # verify the uncompressed image
tests/erofs/007 +1 -1
index 616e093..711759f 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0+
 seq=`basename $0`
 seqres=$RESULT_DIR/$(echo $0 | awk '{print $((NF-1))"/"$NF}' FS="/")
tests/erofs/008 +1 -1
index aa8ba1d..69b8cde 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0+
 #
 # verify lz4 compressed image
tests/erofs/009 +1 -1
index 2ce0e0a..68f801f 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0+
 #
 # verify lz4hc compressed image
tests/erofs/010 +1 -1
index a4f4180..befdac2 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0+
 #
 # (legacy image) verify lz4 compressed image
tests/erofs/011 +1 -1
index 945998b..aa8971f 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0+
 #
 # (legacy image) verify lz4hc compressed image
tests/erofs/012 +1 -1
index fbc0dac..5e4729c 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0+
 #
 # check the hard-link functionality
tests/erofs/013 +1 -1
index 9e674b9..4d52422 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0+
 #
 # check if hardlinked directories are allowed
tests/erofs/014 +1 -1
index 4b8c02f..0fcefb1 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0+
 #
 # check if cross-device submounts are handled properly
tests/erofs/015 +1 -1
index 71c39b7..e008e98 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0+
 #
 # regression test for battach on full buffer block
tests/erofs/017 +1 -1
index 0ba391f..65a897a 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0+
 #
 # check the compress-hints functionality
tests/erofs/018 +1 -1
index 3e4963a..92483d8 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0+
 #
 # verify lzma compressed image
tests/erofs/019 +1 -1
index 0b89b77..f58eec4 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0+
 #
 # 019 - check extended attribute functionality
tests/erofs/020 +1 -1
index 5f98be2..265bde4 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0+
 #
 # 020 - check extended attributes in different layouts
tests/erofs/021 +1 -1
index d36aa56..231066a 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0+
 #
 # 021 - check extended attributes crossing block boundary
tests/erofs/022 +1 -1
index a773205..7a837cb 100755
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # SPDX-License-Identifier: GPL-2.0+
 #
 # 022 - check long extended attribute name prefixes
Signature · 1 line
2.19.1.6.gb485710b
author
#1 lore raw

PATCH 2/3 erofs-utils: tests: pass mkfs options with MKFS_OPTIONS for erofs/015

---
 tests/erofs/015 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tests/erofs/015 +2 -1
index e008e98..8e562f6 100755
@@ -38,7 +38,8 @@ head -c 4032 /dev/urandom > $localdir/1
 head -c 4095 /dev/urandom > $localdir/2
 head -c 12345 /dev/urandom > $localdir/3  # arbitrary size
 
-_scratch_mkfs -Eforce-inode-compact --ignore-mtime $localdir >> $seqres.full 2>&1 \
+MKFS_OPTIONS="$MKFS_OPTIONS -Eforce-inode-compact --ignore-mtime"
+_scratch_mkfs $localdir >> $seqres.full 2>&1 \
 	|| _fail "failed to mkfs"
 _scratch_mount 2>>$seqres.full
 
Signature · 1 line
2.19.1.6.gb485710b
author
#2 lore raw

PATCH 3/3 erofs-utils: tests: enable test cases for tarfs mode

In reply to Jingbo Xu

Now tarfs mode could be tested with "make check FSTYP=erofstar".

---
 tests/common/rc | 24 ++++++++++++++++++++++--
 tests/erofs/006 |  2 +-
 tests/erofs/015 |  2 +-
 tests/erofs/016 |  2 +-
 4 files changed, 25 insertions(+), 5 deletions(-)
tests/common/rc +22 -2
index f54b5c1..aab1926 100644
@@ -90,6 +90,9 @@ _require_xattr()
 {
 	which setfattr >/dev/null 2>&1 ||
 		_notrun "attr isn't installed, skipped."
+
+	[ $FSTYP = "erofstar" ] &&
+		_notrun "erofstar doesn't support xattr yet, skipped."
 }
 
 _require_mkfs_blksize()
@@ -197,9 +200,26 @@ _mkfs()
 	return $mkfs_status
 }
 
+_scratch_mkfs_tar()
+{
+	local scratch_dir=${@:-1}
+	local mkfs_options=${@:1:$#-1}
+	local tarfile=${scratch_dir}.tar
+
+	pushd $scratch_dir
+	tar -cf $tarfile .
+	popd
+
+	_mkfs $SCRATCH_DEV --tar=f $mkfs_options $tarfile
+}
+
 _scratch_mkfs()
 {
-	_mkfs $SCRATCH_DEV "$*"
+	if [ "$FSTYP" = "erofstar" ]; then
+		_scratch_mkfs_tar "$*"
+	else
+		_mkfs $SCRATCH_DEV "$*"
+	fi
 }
 
 _test_mkfs()
@@ -216,7 +236,7 @@ _do_mount()
 	local tmp=`mktemp -u`
 	local mount_filter="awk '{print \$NF}' FS=":" | sed 's/^ *//g'"
 
-	eval "$MOUNT_PROG -t $FSTYP $extra_mount_options" \
+	eval "$MOUNT_PROG $extra_mount_options" \
 		1>$tmp.mountstd 2>$tmp.mounterr
 	mount_status=$?
 
tests/erofs/006 +1 -1
index 18458b0..3a2c8c4 100755
@@ -48,7 +48,7 @@ _scratch_mkfs $localdir >> $seqres.full 2>&1 || _fail "failed to mkfs"
 _scratch_mount 2>>$seqres.full
 
 FSSUM_OPTS="-MAC"
-[ $FSTYP = "erofsfuse" ] && FSSUM_OPTS="${FSSUM_OPTS}T"
+[ $FSTYP = "erofsfuse" -o $FSTYP = "erofstar" ] && FSSUM_OPTS="${FSSUM_OPTS}T"
 
 sum1=`$FSSUM_PROG $FSSUM_OPTS $localdir`
 echo "$localdir checksum is $sum1" >>$seqres.full
tests/erofs/015 +1 -1
index 8e562f6..c2c0c99 100755
@@ -45,7 +45,7 @@ _scratch_mount 2>>$seqres.full
 
 # verify the uncompressed image
 FSSUM_OPTS="-MAC"
-[ $FSTYP = "erofsfuse" ] && FSSUM_OPTS="${FSSUM_OPTS}T"
+[ $FSTYP = "erofsfuse" -o $FSTYP = "erofstar" ] && FSSUM_OPTS="${FSSUM_OPTS}T"
 
 sum1=`$FSSUM_PROG $FSSUM_OPTS $localdir`
 echo "$localdir checksum is $sum1" >>$seqres.full
tests/erofs/016 +1 -1
index 3e84e2b..568aea6 100755
@@ -51,7 +51,7 @@ _scratch_mount 2>>$seqres.full
 
 # verify the uncompressed image
 FSSUM_OPTS="-MAC"
-[ $FSTYP = "erofsfuse" ] && FSSUM_OPTS="${FSSUM_OPTS}T"
+[ $FSTYP = "erofsfuse" -o $FSTYP = "erofstar" ] && FSSUM_OPTS="${FSSUM_OPTS}T"
 
 sum1=`$FSSUM_PROG $FSSUM_OPTS $localdir`
 echo "$localdir checksum is $sum1" >>$seqres.full
Signature · 1 line
2.19.1.6.gb485710b
#3 lore raw

Re: [PATCH 3/3] erofs-utils: tests: enable test cases for tarfs mode

Quoted 1 line · Jingbo Xu

Now tarfs mode could be tested with "make check FSTYP=erofstar".

I think we need another option in addition to FSTYP.