Skip to contentSkip to conversation

isofs: Convert to new library

PATCH New Joerg Vehlow 2 participants 5 messages Dec 9, 2019 – Dec 18, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 isofs: Convert to new library

From: Joerg Vehlow <[email protected]>

---
 testcases/kernel/fs/iso9660/isofs.sh | 193 ++++++++++-----------------
 1 file changed, 71 insertions(+), 122 deletions(-)
testcases/kernel/fs/iso9660/isofs.sh +71 -122
index 5f90354d9..43a079a14 100755
@@ -1,21 +1,6 @@
 #!/bin/sh
-#
+# SPDX-License-Identifier: GPL-2.0-or-later
 # Copyright (c) International Business Machines  Corp., 2003
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
 # Written by Prakash Narayana ([email protected])
 # and Michael Reed ([email protected])
 #
@@ -24,40 +9,25 @@
 # mounts the ISO9660 file system with different mount options.
 #
 
-TCID=isofs
-TST_TOTAL=77
-. test.sh
+TST_NEEDS_CMDS="mkisofs"
+TST_NEEDS_TMPDIR=1
+TST_TESTFUNC=do_test
 
-NO_CLEANUP=""
+. tst_test.sh
 
-usage()
-{
-	echo "USAGE: $0 <optional> -n -h"
-	exit
-}
-
-cleanup()
-{
-	if [ "$NO_CLEANUP" = "no" ]; then
-		tst_resm TINFO "Temporary directory $PWD was not removed"
-	else
-		tst_rmdir
-	fi
-}
-
-max_depth=3
-max_dirs=4
+MAX_DEPTH=3
+MAX_DIRS=4
 
 gen_fs_tree()
 {
 	local cur_path="$1"
 	local cur_depth="$2"
 
-	if [ "$cur_depth" -gt "$max_depth" ]; then
+	if [ "$cur_depth" -gt "$MAX_DEPTH" ]; then
 		return
 	fi
 
-	for i in $(seq 1 $max_dirs); do
+	for i in $(seq 1 $MAX_DIRS); do
 		local new_path="$cur_path/subdir_$i"
 
 		mkdir -p "$new_path"
@@ -68,94 +38,73 @@ gen_fs_tree()
 	done
 }
 
-while getopts :hnd: arg; do
-	case $arg in
-	h)
-		echo ""
-		echo "n - The directories created will not be removed"
-		echo "h - Help options"
-		echo ""
-		usage
-		echo ""
-		;;
-	n)
-		NO_CLEANUP="no"
-		;;
-	esac
-done
-
-tst_require_root
-
-tst_tmpdir
-TST_CLEANUP=cleanup
-
-MNT_POINT="$PWD/mnt"
-MAKE_FILE_SYS_DIR="$PWD/files"
-
-mkdir -p -m 777 $MNT_POINT
-mkdir -p $MAKE_FILE_SYS_DIR
-
-# Generated directories and files
-mkdir -p $MAKE_FILE_SYS_DIR
-gen_fs_tree "$MAKE_FILE_SYS_DIR" 1
-
-# Make ISO9660 file system with different options.
-# Mount the ISO9660 file system with different mount options.
-
-tst_require_cmds mkisofs
-
-for mkisofs_opt in \
-	" " \
-	"-J" \
-	"-hfs -D" \
-	" -R " \
-	"-R -J" \
-	"-f -l -D -J -allow-leading-dots -R" \
-	"-allow-lowercase -allow-multidot -iso-level 3 -f -l -D -J -allow-leading-dots -R"
-do
-	rm -f isofs.iso
-	mkisofs -o isofs.iso -quiet $mkisofs_opt $MAKE_FILE_SYS_DIR 2> /dev/null
-	if [ $? -eq 0 ]; then
-		tst_resm TPASS \
-			"mkisofs -o isofs.iso -quiet $mkisofs_opt $MAKE_FILE_SYS_DIR"
-	else
-		tst_resm TFAIL \
-			tst_resm TFAIL "mkisofs -o isofs.iso -quiet $mkisofs_opt $MAKE_FILE_SYS_DIR"
-		continue
-	fi
+do_test() {
+	local mnt_point="$PWD/mnt"
+	local make_file_sys_dir="$PWD/files"
+
+	mkdir -p -m 777 $mnt_point
+	mkdir -p $make_file_sys_dir
+
+	# Generated directories and files
+	mkdir -p $make_file_sys_dir
+	gen_fs_tree "$make_file_sys_dir" 1
+
+	# Make ISO9660 file system with different options.
+	# Mount the ISO9660 file system with different mount options.
 
-	for mount_opt in \
-		"loop" \
-		"loop,norock" \
-		"loop,nojoliet" \
-		"loop,block=512,unhide" \
-		"loop,block=1024,cruft" \
-		"loop,block=2048,nocompress" \
-		"loop,check=strict,map=off,gid=bin,uid=bin" \
-		"loop,check=strict,map=acorn,gid=bin,uid=bin" \
-		"loop,check=relaxed,map=normal" \
-		"loop,block=512,unhide,session=2"
-		# "loop,sbsector=32"
+	for mkisofs_opt in \
+		" " \
+		"-J" \
+		"-hfs -D" \
+		" -R " \
+		"-R -J" \
+		"-f -l -D -J -allow-leading-dots -R" \
+		"-allow-lowercase -allow-multidot -iso-level 3 -f -l -D -J -allow-leading-dots -R"
 	do
-		mount -t iso9660 -o $mount_opt isofs.iso $MNT_POINT
-		if [ $? -ne 0 ]; then
+		rm -f isofs.iso
+		mkisofs -o isofs.iso -quiet $mkisofs_opt $make_file_sys_dir 2> /dev/null
+		if [ $? -eq 0 ]; then
+			tst_res TPASS \
+				"mkisofs -o isofs.iso -quiet $mkisofs_opt $make_file_sys_dir"
+		else
 			tst_resm TFAIL \
-				"mount -t iso9660 -o $mount_opt isofs.iso $MNT_POINT"
+				tst_res TFAIL "mkisofs -o isofs.iso -quiet $mkisofs_opt $make_file_sys_dir"
 			continue
 		fi
 
-		ls -lR $MNT_POINT > /dev/null
-		if [ $? -ne 0 ]; then
-			tst_resm TFAIL "ls -lR $MNT_POINT"
-		fi
-
-		umount $MNT_POINT
-		if [ $? -ne 0 ]; then
-			tst_brkm TFAIL "umount $MNT_POINT"
-		fi
-
-		tst_resm TPASS "mount/umount with \"$mount_opt\" options"
+		for mount_opt in \
+			"loop" \
+			"loop,norock" \
+			"loop,nojoliet" \
+			"loop,block=512,unhide" \
+			"loop,block=1024,cruft" \
+			"loop,block=2048,nocompress" \
+			"loop,check=strict,map=off,gid=bin,uid=bin" \
+			"loop,check=strict,map=acorn,gid=bin,uid=bin" \
+			"loop,check=relaxed,map=normal" \
+			"loop,block=512,unhide,session=2"
+			# "loop,sbsector=32"
+		do
+			mount -t iso9660 -o $mount_opt isofs.iso $mnt_point
+			if [ $? -ne 0 ]; then
+				tst_res TFAIL \
+					"mount -t iso9660 -o $mount_opt isofs.iso $mnt_point"
+				continue
+			fi
+
+			ls -lR $mnt_point > /dev/null
+			if [ $? -ne 0 ]; then
+				tst_res TFAIL "ls -lR $mnt_point"
+			fi
+
+			umount $mnt_point
+			if [ $? -ne 0 ]; then
+				tst_brk TFAIL "umount $mnt_point"
+			fi
+
+			tst_res TPASS "mount/umount with \"$mount_opt\" options"
+		done
 	done
-done
+}
 
-tst_exit
+tst_run
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 isofs: Convert to new library

Hi Joerg,

thanks a lot for your patch, merged with few minor changes:
(mostly changing style + remove forgotten 'tst_resm TFAIL \', use ROD_SILENT and remove commented out '# "loop,sbsector=32"').

You correctly removed getopt options: -n just set NO_CLEANUP, which is not used any more on test.sh. Both libraries support TST_NO_CLEANUP, so we should document it (going to send a patch).

Kind regards,
Petr

#2 lore raw

PATCH 1/1 isofs: Convert to new library

Hi Joerg,

Quoted 3 lines

You correctly removed getopt options: -n just set NO_CLEANUP, which is not used any more on test.sh. Both libraries support TST_NO_CLEANUP, so we should document it (going to send a patch).

In the end I just merged that simple doc change.
I wonder if there would be use for variable keeping $TST_TMPDIR (because it's deleted even with $TST_NO_CLEANUP).

Kind regards,
Petr

#3 lore raw

PATCH 1/1 isofs: Convert to new library

Hi Petr,

thanks for merging

Quoted 6 lines
Quoted 3 lines

You correctly removed getopt options: -n just set NO_CLEANUP, which is not used any more on test.sh. Both libraries support TST_NO_CLEANUP, so we should document it (going to send a patch).

In the end I just merged that simple doc change.
I wonder if there would be use for variable keeping $TST_TMPDIR (because it's deleted even with $TST_NO_CLEANUP).

I think that was the reason why I completely removed the flag in the first place.
Also I did not see any reason to keep the tempdir. If I ever needed this in the past, I just modified the test.

J?rg

#4 lore raw

PATCH 1/1 isofs: Convert to new library

Hi J?rg,

Quoted 9 lines

thanks for merging

Quoted 6 lines
Quoted 3 lines

You correctly removed getopt options: -n just set NO_CLEANUP, which is not used any more on test.sh. Both libraries support TST_NO_CLEANUP, so we should document it (going to send a patch).

In the end I just merged that simple doc change.
I wonder if there would be use for variable keeping $TST_TMPDIR (because it's deleted even with $TST_NO_CLEANUP).

I think that was the reason why I completely removed the flag in the first place.

+1.

Quoted 2 lines

Also I did not see any reason to keep the tempdir. If I ever needed this in the past, I just modified the test.

Thanks for info. You're right, it's probably useless.

Kind regards,
Petr