Skip to contentSkip to conversation

selftests: floppy: basic tests

RFC PATCH In review Denis Efremov 5 participants 21 messages Aug 18, 2021 – Aug 21, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover selftests: floppy: basic tests

Add basic tests to cover some regressions that we had. It's hard to test floppy because some tests require presence or absense of a diskette in a drive. To simulate test conditions and automate the testing I added "run_*.sh" wrapper scripts that run tests in QEMU.

The first patch just improves check for reverted commits in a commit message. The second patch is required to generate a minimal initrd used in next commits. Rest of commits are basic floppy tests.

Please, comment the approach, selftests integration and suggest tests that you would like to add.

I thought about adding a possibility to remove/insert diskettes inside a test. This is possible if we give the guest an access to the QEMU monitor (eject/change cmds). But I didn't find a better way to do it than to map a monitor to an external port:
-monitor tcp:<ip>:<port>,server,nowait
and access this ip from the guest.
Maybe it's also possible to do with virtserialport.

Denis Efremov (5):
checkpatch: improve handling of revert commits gen_initramfs.sh: use absolute path for gen_init_cpio
selftests: floppy: add basic tests for opening an empty device
selftests: floppy: add basic tests for a readonly disk
selftests: floppy: add basic rdwr tests

 MAINTAINERS                                  |  1 +
 scripts/checkpatch.pl                        | 12 +--
 tools/testing/selftests/floppy/.gitignore    |  8 ++
 tools/testing/selftests/floppy/Makefile      | 10 ++
 tools/testing/selftests/floppy/config        |  1 +
 tools/testing/selftests/floppy/empty.c       | 58 ++++++++++++
 tools/testing/selftests/floppy/init.c        | 43 +++++++++
 tools/testing/selftests/floppy/lib.sh        | 67 +++++++++++++
 tools/testing/selftests/floppy/rdonly.c      | 99 ++++++++++++++++++++
 tools/testing/selftests/floppy/rdwr.c        | 67 +++++++++++++
 tools/testing/selftests/floppy/run_empty.sh  | 16 ++++
 tools/testing/selftests/floppy/run_rdonly.sh | 22 +++++
 tools/testing/selftests/floppy/run_rdwr.sh   | 22 +++++
 usr/gen_initramfs.sh                         |  2 +-
 14 files changed, 421 insertions(+), 7 deletions(-)
 create mode 100644 tools/testing/selftests/floppy/.gitignore
 create mode 100644 tools/testing/selftests/floppy/Makefile
 create mode 100644 tools/testing/selftests/floppy/config
 create mode 100644 tools/testing/selftests/floppy/empty.c
 create mode 100644 tools/testing/selftests/floppy/init.c
 create mode 100644 tools/testing/selftests/floppy/lib.sh
 create mode 100644 tools/testing/selftests/floppy/rdonly.c
 create mode 100644 tools/testing/selftests/floppy/rdwr.c
 create mode 100755 tools/testing/selftests/floppy/run_empty.sh
 create mode 100755 tools/testing/selftests/floppy/run_rdonly.sh
 create mode 100755 tools/testing/selftests/floppy/run_rdwr.sh
Signature · 1 line
2.31.1
#1 lore raw

RFC PATCH 1/5 checkpatch: improve handling of revert commits

Properly handle commits like:
commit f2791e7eadf4 ("Revert "floppy: refactor open() flags handling"")

---
 scripts/checkpatch.pl | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
scripts/checkpatch.pl +6 -6
index 461d4221e4a4..cf31e8c994d3 100755
@@ -3200,20 +3200,20 @@ sub process {
 			$long = 1 if ($line =~ /\bcommit\s+[0-9a-f]{41,}/i);
 			$space = 0 if ($line =~ /\bcommit [0-9a-f]/i);
 			$case = 0 if ($line =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/);
-			if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) {
+			if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("(.+)"\)/i) {
 				$orig_desc = $1;
 				$hasparens = 1;
 			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&
 				 defined $rawlines[$linenr] &&
-				 $rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) {
+				 $rawlines[$linenr] =~ /^\s*\("(.+)"\)/) {
 				$orig_desc = $1;
 				$hasparens = 1;
-			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i &&
+			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\(".+$/i &&
 				 defined $rawlines[$linenr] &&
-				 $rawlines[$linenr] =~ /^\s*[^"]+"\)/) {
-				$line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i;
+				 $rawlines[$linenr] =~ /^\s*.+"\)/) {
+				$line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("(.+)$/i;
 				$orig_desc = $1;
-				$rawlines[$linenr] =~ /^\s*([^"]+)"\)/;
+				$rawlines[$linenr] =~ /^\s*(.+)"\)/;
 				$orig_desc .= " " . $1;
 				$hasparens = 1;
 			}
Signature · 1 line
2.31.1
maintainer
#2 lore raw

Re: [RFC PATCH 1/5] checkpatch: improve handling of revert commits

Quoted 2 lines · Denis Efremov

Properly handle commits like:
commit f2791e7eadf4 ("Revert "floppy: refactor open() flags handling"")

Try this one:

https://lore.kernel.org/lkml/[email protected]/

Quoted 38 lines

---
 scripts/checkpatch.pl | 12 ++++++------

 1 file changed, 6 insertions(+), 6 deletions(-)
scripts/checkpatch.pl +1 -1
index 461d4221e4a4..cf31e8c994d3 100755
@@ -3200,20 +3200,20 @@ sub process {
  			$long = 1 if ($line =~ /\bcommit\s+[0-9a-f]{41,}/i);
  			$space = 0 if ($line =~ /\bcommit [0-9a-f]/i);
  			$case = 0 if ($line =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/);
-			if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) {
+			if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("(.+)"\)/i) {
  				$orig_desc = $1;
  				$hasparens = 1;
  			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&

  defined $rawlines[$linenr] &&

scripts/checkpatch.pl +1 -1
-				 $rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) {
+				 $rawlines[$linenr] =~ /^\s*\("(.+)"\)/) {

  $orig_desc = $1;
  $hasparens = 1;

scripts/checkpatch.pl +1 -1
-			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i &&
+			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\(".+$/i &&

  defined $rawlines[$linenr] &&

scripts/checkpatch.pl +2 -2
-				 $rawlines[$linenr] =~ /^\s*[^"]+"\)/) {
-				$line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i;
+				 $rawlines[$linenr] =~ /^\s*.+"\)/) {
+				$line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("(.+)$/i;

  $orig_desc = $1;

scripts/checkpatch.pl +1 -1
-				$rawlines[$linenr] =~ /^\s*([^"]+)"\)/;
+				$rawlines[$linenr] =~ /^\s*(.+)"\)/;

  $orig_desc .= " " . $1; $hasparens = 1; }

#3 lore raw

Re: [RFC PATCH 1/5] checkpatch: improve handling of revert commits

Quoted 8 lines · Joe Perches
Quoted 2 lines · Denis Efremov

Properly handle commits like:
commit f2791e7eadf4 ("Revert "floppy: refactor open() flags handling"")

Try this one:

https://lore.kernel.org/lkml/[email protected]/

It works but why not to use .+? then?
I'm not sure that non-greedy patterns will properly handle commits like:

$ git log --oneline | fgrep '")'

e.g.
commit ece2619fe8ed ("extcon: arizona: Fix flags parameter to the gpiod_get("wlf,micd-pol") call")

Quoted 39 lines
Quoted 38 lines

---
 scripts/checkpatch.pl | 12 ++++++------

 1 file changed, 6 insertions(+), 6 deletions(-)
scripts/checkpatch.pl +1 -1
index 461d4221e4a4..cf31e8c994d3 100755
@@ -3200,20 +3200,20 @@ sub process {
  			$long = 1 if ($line =~ /\bcommit\s+[0-9a-f]{41,}/i);
  			$space = 0 if ($line =~ /\bcommit [0-9a-f]/i);
  			$case = 0 if ($line =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/);
-			if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) {
+			if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("(.+)"\)/i) {
  				$orig_desc = $1;
  				$hasparens = 1;
  			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&

  defined $rawlines[$linenr] &&

scripts/checkpatch.pl +1 -1
-				 $rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) {
+				 $rawlines[$linenr] =~ /^\s*\("(.+)"\)/) {

  $orig_desc = $1;
  $hasparens = 1;

scripts/checkpatch.pl +1 -1
-			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i &&
+			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\(".+$/i &&

  defined $rawlines[$linenr] &&

scripts/checkpatch.pl +2 -2
-				 $rawlines[$linenr] =~ /^\s*[^"]+"\)/) {
-				$line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i;
+				 $rawlines[$linenr] =~ /^\s*.+"\)/) {
+				$line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("(.+)$/i;

  $orig_desc = $1;

scripts/checkpatch.pl +1 -1
-				$rawlines[$linenr] =~ /^\s*([^"]+)"\)/;
+				$rawlines[$linenr] =~ /^\s*(.+)"\)/;

  $orig_desc .= " " . $1; $hasparens = 1; }

maintainer
#4 lore raw

Re: [RFC PATCH 1/5] checkpatch: improve handling of revert commits

Quoted 11 lines · Denis Efremov
Quoted 8 lines · Joe Perches
Quoted 2 lines · Denis Efremov

Properly handle commits like:
commit f2791e7eadf4 ("Revert "floppy: refactor open() flags handling"")

Try this one:

https://lore.kernel.org/lkml/[email protected]/

Quoted 6 lines

It works but why not to use .+? then?
I'm not sure that non-greedy patterns will properly handle commits like:

$ git log --oneline | fgrep '")'

e.g.
commit ece2619fe8ed ("extcon: arizona: Fix flags parameter to the gpiod_get("wlf,micd-pol") call")

The only way to handle that is to use the $balanced_parens test but it wouldn't work on Andrew's perl version 5.8

Andrew? Do you still use perl 5.8? It's almost 20 years old now. Does anyone still use perl versions 5.8 or lower?

From checkpatch:

# Using $balanced_parens, $LvalOrFunc, or $FuncArg

# requires at least perl version v5.10.0
# Any use must be runtime checked with $^V

our $balanced_parens = qr/(\((?:[^\(\)]++|(?-1))*\))/;
our $LvalOrFunc = qr{((?:[\&\*]\s*)?$Lval)\s*($balanced_parens{0,1})\s*};
our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant|$String)};

So maybe:

Quoted 1 line
Quoted 1 line

scripts/checkpatch.pl

Quoted 1 line
scripts/checkpatch.pl +0 -0

[]

Quoted 6 lines
Quoted 6 lines

scripts/checkpatch.pl sub process { · line 3203

Quoted 6 lines
scripts/checkpatch.pl +1 -1
@@ -3200,20 +3200,20 @@ sub process {
  			$long = 1 if ($line =~ /\bcommit\s+[0-9a-f]{41,}/i);
  			$space = 0 if ($line =~ /\bcommit [0-9a-f]/i);
  			$case = 0 if ($line =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/);
-			if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) {
+			if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("(.+)"\)/i) {

So that could be:

			if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+($balanced_parens)/i
Quoted 6 lines
Quoted 6 lines

scripts/checkpatch.pl sub process { · line 3208

Quoted 6 lines
scripts/checkpatch.pl +0 -0
  				$orig_desc = $1;
  				$hasparens = 1;
  			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&

  defined $rawlines[$linenr] &&

scripts/checkpatch.pl +1 -1
-				 $rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) {
+				 $rawlines[$linenr] =~ /^\s*\("(.+)"\)/) {

and

  } elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&
  defined $rawlines[$linenr] &&

				"$line $rawlines[$linenr]" =~ /\bcommit\s+[0-9a-f]{5,}\s+($balanced_parens)/i
Quoted 9 lines
Quoted 9 lines

scripts/checkpatch.pl sub process { · line 3214

Quoted 9 lines

  $orig_desc = $1;
  $hasparens = 1;

scripts/checkpatch.pl +1 -1
-			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i &&
+			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\(".+$/i &&

  defined $rawlines[$linenr] &&

scripts/checkpatch.pl +2 -2
-				 $rawlines[$linenr] =~ /^\s*[^"]+"\)/) {
-				$line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i;
+				 $rawlines[$linenr] =~ /^\s*.+"\)/) {
+				$line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("(.+)$/i;

etc...

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

  $orig_desc = $1;

scripts/checkpatch.pl +1 -1
-				$rawlines[$linenr] =~ /^\s*([^"]+)"\)/;
+				$rawlines[$linenr] =~ /^\s*(.+)"\)/;

  $orig_desc .= " " . $1; $hasparens = 1; }

#5 lore raw

Re: [RFC PATCH 1/5] checkpatch: improve handling of revert commits

Quoted 1 line · On Wed, 18 Aug 2021 13:21:16 -0700 Joe Perches <[email protected]> wrote:

Andrew? Do you still use perl 5.8? It's almost 20 years old now.

5.26 is the oldest I appear to be using.

maintainer
#6 lore raw

Re: [RFC PATCH 1/5] checkpatch: improve handling of revert commits

In reply to Denis Efremov

Hey Denis:

Try this one please and let me know what you think...

---
 scripts/checkpatch.pl | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)
scripts/checkpatch.pl +13 -18
index 161ce7fe5d1e5..4e2e79eff9b8c 100755
@@ -3196,26 +3196,21 @@ sub process {
 				$orig_commit = lc($1);
 			}
 
-			$short = 0 if ($line =~ /\bcommit\s+[0-9a-f]{12,40}/i);
-			$long = 1 if ($line =~ /\bcommit\s+[0-9a-f]{41,}/i);
-			$space = 0 if ($line =~ /\bcommit [0-9a-f]/i);
-			$case = 0 if ($line =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/);
-			if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) {
-				$orig_desc = $1;
-				$hasparens = 1;
-			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&
-				 defined $rawlines[$linenr] &&
-				 $rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) {
-				$orig_desc = $1;
-				$hasparens = 1;
-			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i &&
-				 defined $rawlines[$linenr] &&
-				 $rawlines[$linenr] =~ /^\s*[^"]+"\)/) {
-				$line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i;
+			my $input = $line;
+			for (my $n = 0; $n < 2; $n++) {
+				$input .= " $rawlines[$linenr + $n]" if ($#lines >= $linenr + $n);
+			}
+
+			$short = 0 if ($input =~ /\bcommit\s+[0-9a-f]{12,40}/i);
+			$long = 1 if ($input =~ /\bcommit\s+[0-9a-f]{41,}/i);
+			$space = 0 if ($input =~ /\bcommit [0-9a-f]/i);
+			$case = 0 if ($input =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/);
+			if ($input =~ /\bcommit\s+[0-9a-f]{5,}\s+($balanced_parens)/i) {
 				$orig_desc = $1;
-				$rawlines[$linenr] =~ /^\s*([^"]+)"\)/;
-				$orig_desc .= " " . $1;
 				$hasparens = 1;
+				# Always strip leading/trailing parens then double quotes if existing
+				$orig_desc = substr($orig_desc, 1, -1);
+				$orig_desc = substr($orig_desc, 1, -1) if ($orig_desc =~ /^".*"$/);
 			}
 
 			($id, $description) = git_commit_info($orig_commit,
#7 lore raw

Re: [RFC PATCH 1/5] checkpatch: improve handling of revert commits

Hi,

Quoted 3 lines · Joe Perches

Hey Denis:

Try this one please and let me know what you think...

Looks good to me. Couple of nitpicks below

Quoted 36 lines
---
 scripts/checkpatch.pl | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)
scripts/checkpatch.pl +7 -16
index 161ce7fe5d1e5..4e2e79eff9b8c 100755
@@ -3196,26 +3196,21 @@ sub process {
 				$orig_commit = lc($1);
 			}
 
-			$short = 0 if ($line =~ /\bcommit\s+[0-9a-f]{12,40}/i);
-			$long = 1 if ($line =~ /\bcommit\s+[0-9a-f]{41,}/i);
-			$space = 0 if ($line =~ /\bcommit [0-9a-f]/i);
-			$case = 0 if ($line =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/);
-			if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) {
-				$orig_desc = $1;
-				$hasparens = 1;
-			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&
-				 defined $rawlines[$linenr] &&
-				 $rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) {
-				$orig_desc = $1;
-				$hasparens = 1;
-			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i &&
-				 defined $rawlines[$linenr] &&
-				 $rawlines[$linenr] =~ /^\s*[^"]+"\)/) {
-				$line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i;
+			my $input = $line;
+			for (my $n = 0; $n < 2; $n++) {
+				$input .= " $rawlines[$linenr + $n]" if ($#lines >= $linenr + $n);
+			}
+
+			$short = 0 if ($input =~ /\bcommit\s+[0-9a-f]{12,40}/i);
+			$long = 1 if ($input =~ /\bcommit\s+[0-9a-f]{41,}/i);

scripts/checkpatch.pl sub process { · line 3213

Quoted 10 lines
scripts/checkpatch.pl +6 -2
+			$space = 0 if ($input =~ /\bcommit [0-9a-f]/i);
+			$case = 0 if ($input =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/);
+			if ($input =~ /\bcommit\s+[0-9a-f]{5,}\s+($balanced_parens)/i) {
 				$orig_desc = $1;
-				$rawlines[$linenr] =~ /^\s*([^"]+)"\)/;
-				$orig_desc .= " " . $1;
 				$hasparens = 1;
+				# Always strip leading/trailing parens then double quotes if existing
+				$orig_desc = substr($orig_desc, 1, -1);
+				$orig_desc = substr($orig_desc, 1, -1) if ($orig_desc =~ /^".*"$/);

Why do you want to add "if ($orig_desc =~ /^".*"$/);" here? and not just substr($orig_desc, 2, -2);?

scripts/checkpatch.pl sub process { · line 3216

Quoted 4 lines
scripts/checkpatch.pl +0 -0
 			}
 
 			($id, $description) = git_commit_info($orig_commit,

In your previous patch with '.*?' you added a branch to allow also newlines between commit and shas:

```
commit
c3f157259438 (Revert "floppy: reintroduce O_NDELAY fix")
```

Maybe something like this will work (adding a last word from a prevline if line doesn't start from commit)

+                       my $input = $line;
                        if ($line =~ /\b(c)ommit\s+([0-9a-f]{5,})\b/i) {
                                $init_char = $1;
                                $orig_commit = lc($2);
                        } elsif ($line =~ /\b([0-9a-f]{12,40})\b/i) {
                                $orig_commit = lc($1);
+                               $prevline =~ /(\w+)$/;
+                               $line = $1 . " " . $prevline;
                        }
-                       my $input = $line;
                        for (my $n = 0; $n < 2; $n++) {
                                $input .= " $rawlines[$linenr + $n]" if ($#lines >= $linenr + $n);
                        }

Thanks,
Denis

maintainer
#8 lore raw

Re: [RFC PATCH 1/5] checkpatch: improve handling of revert commits

Quoted 8 lines · Denis Efremov

Hi,

Quoted 3 lines · Joe Perches

Hey Denis:

Try this one please and let me know what you think...

Looks good to me. Couple of nitpicks below

yeah, thanks.

How about this one:

---
 scripts/checkpatch.pl | 72 ++++++++++++++++++++++++++++++---------------------
 1 file changed, 43 insertions(+), 29 deletions(-)
scripts/checkpatch.pl +43 -29
index 161ce7fe5d1e5..4988515a0dfb3 100755
@@ -1181,7 +1181,8 @@ sub git_commit_info {
 #		    git log --format='%H %s' -1 $line |
 #		    echo "commit $(cut -c 1-12,41-)"
 #		done
-	} elsif ($lines[0] =~ /^fatal: ambiguous argument '$commit': unknown revision or path not in the working tree\./) {
+	} elsif ($lines[0] =~ /^fatal: ambiguous argument '$commit': unknown revision or path not in the working tree\./ ||
+		 $lines[0] =~ /^fatal: bad object $commit/) {
 		$id = undef;
 	} else {
 		$id = substr($lines[0], 0, 12);
@@ -2587,6 +2588,8 @@ sub process {
 	my $reported_maintainer_file = 0;
 	my $non_utf8_charset = 0;
 
+	my $last_git_commit_id_linenr = -1;
+
 	my $last_blank_line = 0;
 	my $last_coalesced_string_linenr = -1;
 
@@ -3173,7 +3176,8 @@ sub process {
 		if ($in_commit_log && !$commit_log_possible_stack_dump &&
 		    $line !~ /^\s*(?:Link|Patchwork|http|https|BugLink|base-commit):/i &&
 		    $line !~ /^This reverts commit [0-9a-f]{7,40}/ &&
-		    ($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i ||
+		    (($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i ||
+		      ($line =~ /\bcommit\s*$/i && defined($rawlines[$linenr]) && $rawlines[$linenr] =~ /^\s*[0-9a-f]{5,}\b/i)) ||
 		     ($line =~ /(?:\s|^)[0-9a-f]{12,40}(?:[\s"'\(\[]|$)/i &&
 		      $line !~ /[\<\[][0-9a-f]{12,40}[\>\]]/i &&
 		      $line !~ /\bfixes:\s*[0-9a-f]{12,40}/i))) {
@@ -3183,49 +3187,59 @@ sub process {
 			my $long = 0;
 			my $case = 1;
 			my $space = 1;
-			my $hasdesc = 0;
 			my $hasparens = 0;
 			my $id = '0123456789ab';
 			my $orig_desc = "commit description";
 			my $description = "";
+			my $herectx = $herecurr;
+			my $has_parens = 0;
+
+			my $input = $line;
+			if ($line =~ /(?:\bcommit\s+[0-9a-f]{5,}|\bcommit\s*$)/i) {
+				for (my $n = 0; $n < 2; $n++) {
+					if ($input =~ /\bcommit\s+[0-9a-f]{5,}\s*$balanced_parens/i) {
+						$has_parens = 1;
+						last;
+					}
+					last if ($#lines < $linenr + $n);
+					$input .= " " . trim($rawlines[$linenr + $n]);
+					$herectx .= "$rawlines[$linenr + $n]\n";
+				}
+				$herectx = $herecurr if (!$has_parens);
+			}
 
-			if ($line =~ /\b(c)ommit\s+([0-9a-f]{5,})\b/i) {
+			if ($input =~ /\b(c)ommit\s+([0-9a-f]{5,})\b/i) {
 				$init_char = $1;
 				$orig_commit = lc($2);
-			} elsif ($line =~ /\b([0-9a-f]{12,40})\b/i) {
+				$short = 0 if ($input =~ /\bcommit\s+[0-9a-f]{12,40}/i);
+				$long = 1 if ($input =~ /\bcommit\s+[0-9a-f]{41,}/i);
+				$space = 0 if ($input =~ /\bcommit [0-9a-f]/i);
+				$case = 0 if ($input =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/);
+
+				if ($input =~ /\bcommit\s+[0-9a-f]{5,}\s+($balanced_parens)/i) {
+					$orig_desc = $1;
+					# Always strip leading/trailing parens then double quotes if existing
+					$orig_desc = substr($orig_desc, 1, -1);
+					if ($orig_desc =~ /^".*"$/) {
+						$orig_desc = substr($orig_desc, 1, -1);
+						$hasparens = 1;
+					}
+				}
+			} elsif ($input =~ /\b([0-9a-f]{12,40})\b/i) {
 				$orig_commit = lc($1);
 			}
 
-			$short = 0 if ($line =~ /\bcommit\s+[0-9a-f]{12,40}/i);
-			$long = 1 if ($line =~ /\bcommit\s+[0-9a-f]{41,}/i);
-			$space = 0 if ($line =~ /\bcommit [0-9a-f]/i);
-			$case = 0 if ($line =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/);
-			if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) {
-				$orig_desc = $1;
-				$hasparens = 1;
-			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&
-				 defined $rawlines[$linenr] &&
-				 $rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) {
-				$orig_desc = $1;
-				$hasparens = 1;
-			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i &&
-				 defined $rawlines[$linenr] &&
-				 $rawlines[$linenr] =~ /^\s*[^"]+"\)/) {
-				$line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i;
-				$orig_desc = $1;
-				$rawlines[$linenr] =~ /^\s*([^"]+)"\)/;
-				$orig_desc .= " " . $1;
-				$hasparens = 1;
-			}
-
 			($id, $description) = git_commit_info($orig_commit,
 							      $id, $orig_desc);
 
 			if (defined($id) &&
-			   ($short || $long || $space || $case || ($orig_desc ne $description) || !$hasparens)) {
+			    ($short || $long || $space || $case || ($orig_desc ne $description) || !$hasparens) &&
+			    $last_git_commit_id_linenr != $linenr - 1) {
 				ERROR("GIT_COMMIT_ID",
-				      "Please use git commit description style 'commit <12+ chars of sha1> (\"<title line>\")' - ie: '${init_char}ommit $id (\"$description\")'\n" . $herecurr);
+				      "Please use git commit description style 'commit <12+ chars of sha1> (\"<title line>\")' - ie: '${init_char}ommit $id (\"$description\")'\n" . $herectx);
 			}
+			#don't report the next line if this line ends in commit and the sha1 hash is the next line
+			$last_git_commit_id_linenr = $linenr if ($line =~ /\bcommit\s*$/i);
 		}
 
 # Check for added, moved or deleted files
maintainer
#9 lore raw

Re: [RFC PATCH 1/5] checkpatch: improve handling of revert commits

In reply to Denis Efremov
Quoted 5 lines · Denis Efremov

Hi,

Why do you want to add "if ($orig_desc =~ /^".*"$/);" here? and not just substr($orig_desc, 2, -2);?

Because commit descriptions sometimes to not have quotes like

commit <deadbeef> (Multiple word description)

btw:

I tested the last proposal with this script:

$ git log --grep="commit [0-9a-f]" -i --format=%h -1000 | \
  while read commit ; do \
    echo $commit; \
    ./scripts/checkpatch.pl --git --no-summary --quiet --types=GIT_COMMIT_ID $commit ; \
  done

and there are still a fair number of ERRORs.

And I'm not sure if this particular ERROR is that useful overall.

#10 lore raw

Re: [RFC PATCH 1/5] checkpatch: improve handling of revert commits

Quoted 2 lines · Joe Perches

And I'm not sure if this particular ERROR is that useful overall.

I find it useful to check commit-id and that it matches a title. It's easy to make a typo in commit-id and get an invalid one.

Denis

maintainer
#11 lore raw

Re: [RFC PATCH 1/5] checkpatch: improve handling of revert commits

Quoted 7 lines · Denis Efremov
Quoted 2 lines · Joe Perches

And I'm not sure if this particular ERROR is that useful overall.

I find it useful to check commit-id and that it matches a title. It's easy to make a typo in commit-id and get an invalid one.

That's true, but I meant requiring the sha1 hash to contain both the word "commit" and use ("title").

Looking at checkpatch's errors produced by this GIT_COMMIT_ID test makes the required form seem a bit too inflexible to me.

For instance: a sha1 hash may be repeated in a commit message where the first instance has the correct form but the second use is just the hash and the warning is still produced.

#12 lore raw

Re: [RFC PATCH 1/5] checkpatch: improve handling of revert commits

Quoted 12 lines · Joe Perches
Quoted 7 lines · Denis Efremov
Quoted 2 lines · Joe Perches

And I'm not sure if this particular ERROR is that useful overall.

I find it useful to check commit-id and that it matches a title. It's easy to make a typo in commit-id and get an invalid one.

That's true, but I meant requiring the sha1 hash to contain both the word "commit" and use ("title").

Quoted 7 lines

Looking at checkpatch's errors produced by this GIT_COMMIT_ID test makes the required form seem a bit too inflexible to me.

For instance: a sha1 hash may be repeated in a commit message where the first instance has the correct form but the second use is just the hash and the warning is still produced.

I agree with you. There is also another example with list of commits:
- commit <id-1> ("Title1")
- commit <id-2> ("Title2")
...

I see no reason in writing "commit" on each line.

#13 lore raw

RFC PATCH 2/5 gen_initramfs.sh: use absolute path for gen_init_cpio

In reply to Denis Efremov

Use absolute path to call gen_init_cpio. This allows one to use gen_initramfs.sh from any directory.

Cc Masahiro Yamada <[email protected]>
---
 usr/gen_initramfs.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
usr/gen_initramfs.sh +1 -1
index 63476bb70b41..2e4a86181c79 100755
@@ -244,4 +244,4 @@ if test -n "$KBUILD_BUILD_TIMESTAMP"; then
 		timestamp="-t $timestamp"
 	fi
 fi
-usr/gen_init_cpio $timestamp $cpio_list > $output
+"$(dirname "$0")"/gen_init_cpio $timestamp $cpio_list > $output
Signature · 1 line
2.31.1
#14 lore raw

Re: [RFC PATCH 2/5] gen_initramfs.sh: use absolute path for gen_init_cpio

[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch]

Hi Denis,

[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on kselftest/next]
[also build test ERROR on linux/master linus/master v5.14-rc6 next-20210818] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Denis-Efremov/selftests-floppy-basic-tests/20210818-235242
base:   https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git next
config: x86_64-randconfig-c022-20210818 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/9794c683e44ce85ae80f3d3b018466d3bc1b5807
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Denis-Efremov/selftests-floppy-basic-tests/20210818-235242
        git checkout 9794c683e44ce85ae80f3d3b018466d3bc1b5807
        # save the attached .config to linux build tree
        make W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

>> usr/gen_initramfs.sh: 247: usr/gen_initramfs.sh: usr/gen_init_cpio: not found

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#15 lore raw

Re: [RFC PATCH 2/5] gen_initramfs.sh: use absolute path for gen_init_cpio

In reply to Denis Efremov
Quoted 3 lines · Denis Efremov

Use absolute path to call gen_init_cpio. This allows one to use gen_initramfs.sh from any directory.

I do not mind this, but $(dirname "$0")
is not necessarily an absolute path, is it?

I added test code:

   echo dirname is $(dirname $0)

in this script, and I saw

dirname is usr

Quoted 18 lines
Cc Masahiro Yamada <[email protected]>
---
 usr/gen_initramfs.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
usr/gen_initramfs.sh +1 -2
index 63476bb70b41..2e4a86181c79 100755
@@ -244,4 +244,4 @@ if test -n "$KBUILD_BUILD_TIMESTAMP"; then
                timestamp="-t $timestamp"
        fi
 fi
-usr/gen_init_cpio $timestamp $cpio_list > $output
+"$(dirname "$0")"/gen_init_cpio $timestamp $cpio_list > $output
--
Quoted 2 lines

2.31.1

--
Best Regards
Masahiro Yamada

#16 lore raw

Re: [RFC PATCH 2/5] gen_initramfs.sh: use absolute path for gen_init_cpio

Quoted 9 lines · Masahiro Yamada
Quoted 3 lines · Denis Efremov

Use absolute path to call gen_init_cpio. This allows one to use gen_initramfs.sh from any directory.

I do not mind this, but $(dirname "$0")
is not necessarily an absolute path, is it?

Quoted 7 lines

I added test code:

   echo dirname is $(dirname $0)

in this script, and I saw

dirname is usr

Oh, sorry, commit message is wrong. Would that be ok for you if I will change it in v2 to something like:

Prepend gen_init_cpio call with the same path as gen_initramfs.sh called. This allows one to use gen_initramfs.sh from any directory, not only from the kernel's topdir.

Quoted 30 lines
Quoted 22 lines
Cc Masahiro Yamada <[email protected]>
---
 usr/gen_initramfs.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
usr/gen_initramfs.sh +1 -2
index 63476bb70b41..2e4a86181c79 100755
@@ -244,4 +244,4 @@ if test -n "$KBUILD_BUILD_TIMESTAMP"; then
                timestamp="-t $timestamp"
        fi
 fi
-usr/gen_init_cpio $timestamp $cpio_list > $output
+"$(dirname "$0")"/gen_init_cpio $timestamp $cpio_list > $output
--
Quoted 2 lines

2.31.1

--
Best Regards
Masahiro Yamada

Reviewed-by
#17 lore raw

Re: [RFC PATCH 2/5] gen_initramfs.sh: use absolute path for gen_init_cpio

Quoted 19 lines · Denis Efremov
Quoted 15 lines · Masahiro Yamada
Quoted 3 lines · Denis Efremov

Use absolute path to call gen_init_cpio. This allows one to use gen_initramfs.sh from any directory.

I do not mind this, but $(dirname "$0")
is not necessarily an absolute path, is it?

I added test code:

   echo dirname is $(dirname $0)

in this script, and I saw

Quoted 8 lines
Quoted 1 line

dirname is usr

Oh, sorry, commit message is wrong. Would that be ok for you if I will change it in v2 to something like:

Prepend gen_init_cpio call with the same path as gen_initramfs.sh called. This allows one to use gen_initramfs.sh from any directory, not only from the kernel's topdir.

I am fine with it.

This patch is prefixed with 2/5, so I assume
you expect another person to pick up
the entire series.

With the commit message updated,

Quoted 30 lines
Quoted 30 lines
Quoted 22 lines
Cc Masahiro Yamada <[email protected]>
---
 usr/gen_initramfs.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
usr/gen_initramfs.sh +1 -2
index 63476bb70b41..2e4a86181c79 100755
@@ -244,4 +244,4 @@ if test -n "$KBUILD_BUILD_TIMESTAMP"; then
                timestamp="-t $timestamp"
        fi
 fi
-usr/gen_init_cpio $timestamp $cpio_list > $output
+"$(dirname "$0")"/gen_init_cpio $timestamp $cpio_list > $output
--
Quoted 2 lines

2.31.1

--
Best Regards
Masahiro Yamada

Signature · 2 lines
Best Regards
Masahiro Yamada
#18 lore raw

RFC PATCH 3/5 selftests: floppy: add basic tests for opening an empty device

In reply to Denis Efremov

Add basic tests for O_NDELAY and O_ACCMODE open of an empty floppy device. "empty" test works under assumption that there is no disk in "/dev/fd0". It's possible to run it on a real hardware. "run_empty.sh" automates the testing process by creating a minimal initrd image with "init" and "test" binaries and running the kernel in QEMU.

The tests cover these regressions:
- commit f2791e7eadf4 ("Revert "floppy: refactor open() flags handling"")
- commit ff06db1efb2a ("floppy: fix open(O_ACCMODE) for ioctl-only open")

---
 MAINTAINERS                                 |  1 +
 tools/testing/selftests/floppy/.gitignore   |  5 ++
 tools/testing/selftests/floppy/Makefile     | 10 ++++
 tools/testing/selftests/floppy/config       |  1 +
 tools/testing/selftests/floppy/empty.c      | 58 +++++++++++++++++++++
 tools/testing/selftests/floppy/init.c       | 43 +++++++++++++++
 tools/testing/selftests/floppy/lib.sh       | 57 ++++++++++++++++++++
 tools/testing/selftests/floppy/run_empty.sh | 16 ++++++
 8 files changed, 191 insertions(+)
 create mode 100644 tools/testing/selftests/floppy/.gitignore
 create mode 100644 tools/testing/selftests/floppy/Makefile
 create mode 100644 tools/testing/selftests/floppy/config
 create mode 100644 tools/testing/selftests/floppy/empty.c
 create mode 100644 tools/testing/selftests/floppy/init.c
 create mode 100644 tools/testing/selftests/floppy/lib.sh
 create mode 100755 tools/testing/selftests/floppy/run_empty.sh
MAINTAINERS +1 -0
index fd25e4ecf0b9..f2a08b793b54 100644
@@ -7227,6 +7227,7 @@ M:	Denis Efremov <[email protected]>
 L:	[email protected]
 S:	Odd Fixes
 F:	drivers/block/floppy.c
+F:	tools/testing/selftests/floppy/
 
 FLYSKY FSIA6B RC RECEIVER
 M:	Markus Koch <[email protected]>
tools/testing/selftests/floppy/.gitignore new file +5 -0
new file mode 100644
index 000000000000..a9fdf1dbaa97
@@ -0,0 +1,5 @@
+init
+cpio_list
+initrd
+
+empty
tools/testing/selftests/floppy/Makefile new file +10 -0
new file mode 100644
index 000000000000..83e18cd63210
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: GPL-2.0
+CFLAGS := -static -I../../../../usr/include
+
+TEST_PROGS := run_empty.sh
+TEST_GEN_FILES := init empty
+TEST_FILES := lib.sh
+
+include ../lib.mk
+
+EXTRA_CLEAN := initrd cpio_list
tools/testing/selftests/floppy/config new file +1 -0
new file mode 100644
index 000000000000..d0c2cd8edfb2
@@ -0,0 +1 @@
+CONFIG_BLK_DEV_FD=y
tools/testing/selftests/floppy/empty.c new file +58 -0

58 lines not on this page · raw message

tools/testing/selftests/floppy/init.c new file +43 -0

43 lines not on this page · raw message

tools/testing/selftests/floppy/lib.sh new file +57 -0

57 lines not on this page · raw message

tools/testing/selftests/floppy/run_empty.sh new file +16 -0
new file mode 100755
index 000000000000..f018107dc6a5
@@ -0,0 +1,16 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+
+source "$(dirname $0)"/lib.sh
+
+while getopts d flag; do
+  case "${flag}" in
+    d) debug=1;;
+  esac
+done
+
+gen_cpio_list empty
+gen_initrd empty
+run_qemu_empty $debug
Signature · 1 line
2.31.1
#19 lore raw

RFC PATCH 4/5 selftests: floppy: add basic tests for a readonly disk

In reply to Denis Efremov

Add basic tests for a floppy with a readonly disk. "rdonly" test works under following assumptions:
- there is a readonly disk in "/dev/fd0"
- the disk is VFAT formatted
- there is "test" file with "TEST" in it on the disk

"run_rdonly.sh" script simulates the conditions and automates the testing process.

The tests cover the regression:
- commit f2791e7eadf4 ("Revert "floppy: refactor open() flags handling"")

---
 tools/testing/selftests/floppy/.gitignore    |  2 +
 tools/testing/selftests/floppy/Makefile      |  6 +-
 tools/testing/selftests/floppy/lib.sh        |  6 ++
 tools/testing/selftests/floppy/rdonly.c      | 99 ++++++++++++++++++++
 tools/testing/selftests/floppy/run_rdonly.sh | 22 +++++
 5 files changed, 132 insertions(+), 3 deletions(-)
 create mode 100644 tools/testing/selftests/floppy/rdonly.c
 create mode 100755 tools/testing/selftests/floppy/run_rdonly.sh
tools/testing/selftests/floppy/.gitignore +2 -0
index a9fdf1dbaa97..7642dc0ef281 100644
@@ -1,5 +1,7 @@
 init
 cpio_list
 initrd
+testdir/
 
 empty
+rdonly
tools/testing/selftests/floppy/Makefile +3 -3
index 83e18cd63210..ed8fdeb79aea 100644
@@ -1,10 +1,10 @@
 # SPDX-License-Identifier: GPL-2.0
 CFLAGS := -static -I../../../../usr/include
 
-TEST_PROGS := run_empty.sh
-TEST_GEN_FILES := init empty
+TEST_PROGS := run_empty.sh run_rdonly.sh
+TEST_GEN_FILES := init empty rdonly
 TEST_FILES := lib.sh
 
 include ../lib.mk
 
-EXTRA_CLEAN := initrd cpio_list
+EXTRA_CLEAN := initrd cpio_list testdir
tools/testing/selftests/floppy/lib.sh +6 -0
index 22b711ec32ee..9988be187bc9 100644
@@ -55,3 +55,9 @@ run_qemu_empty() {
   detect_debug "$1"
   $run -drive index=0,if=floppy
 }
+
+run_qemu_rdonly_fat() {
+  detect_debug "$2"
+  $run -drive file=fat:floppy:"$1",index=0,if=floppy,readonly
+}
+
tools/testing/selftests/floppy/rdonly.c new file +99 -0

99 lines not on this page · raw message

tools/testing/selftests/floppy/run_rdonly.sh new file +22 -0
new file mode 100755
index 000000000000..a358a1b6e58d
@@ -0,0 +1,22 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+
+source "$(dirname $0)"/lib.sh
+
+while getopts d flag; do
+  case "${flag}" in
+    d) debug=1;;
+  esac
+done
+
+if [ -z $debug ]; then
+  trap "rm -rf testdir" EXIT
+fi
+mkdir -p testdir
+echo -n TEST > testdir/test
+
+gen_cpio_list rdonly
+gen_initrd rdonly
+run_qemu_rdonly_fat testdir $debug
Signature · 1 line
2.31.1
#20 lore raw

RFC PATCH 5/5 selftests: floppy: add basic rdwr tests

In reply to Denis Efremov

Add basic tests for a floppy with writable disk. "rdwr" test works under following assumptions:
- writable disk in "/dev/fd0"

To simulate the conditions and automate the testing process there is "run_rdwr.sh".

---
 tools/testing/selftests/floppy/.gitignore  |  1 +
 tools/testing/selftests/floppy/Makefile    |  4 +-
 tools/testing/selftests/floppy/lib.sh      |  4 ++
 tools/testing/selftests/floppy/rdwr.c      | 67 ++++++++++++++++++++++
 tools/testing/selftests/floppy/run_rdwr.sh | 22 +++++++
 5 files changed, 96 insertions(+), 2 deletions(-)
 create mode 100644 tools/testing/selftests/floppy/rdwr.c
 create mode 100755 tools/testing/selftests/floppy/run_rdwr.sh
tools/testing/selftests/floppy/.gitignore +1 -0
index 7642dc0ef281..f53e70197edd 100644
@@ -5,3 +5,4 @@ testdir/
 
 empty
 rdonly
+rdwr
tools/testing/selftests/floppy/Makefile +2 -2
index ed8fdeb79aea..c5d010dd4445 100644
@@ -1,8 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0
 CFLAGS := -static -I../../../../usr/include
 
-TEST_PROGS := run_empty.sh run_rdonly.sh
-TEST_GEN_FILES := init empty rdonly
+TEST_PROGS := run_empty.sh run_rdonly.sh run_rdwr.sh
+TEST_GEN_FILES := init empty rdonly rdwr
 TEST_FILES := lib.sh
 
 include ../lib.mk
tools/testing/selftests/floppy/lib.sh +4 -0
index 9988be187bc9..0eab702b355a 100644
@@ -61,3 +61,7 @@ run_qemu_rdonly_fat() {
   $run -drive file=fat:floppy:"$1",index=0,if=floppy,readonly
 }
 
+run_qemu_rdwr_img() {
+  detect_debug "$2"
+  $run -drive file="$1",index=0,if=floppy,format=raw
+}
tools/testing/selftests/floppy/rdwr.c new file +67 -0

67 lines not on this page · raw message

tools/testing/selftests/floppy/run_rdwr.sh new file +22 -0
new file mode 100755
index 000000000000..0ebe8bd6bc69
@@ -0,0 +1,22 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+
+set -e
+
+source "$(dirname $0)"/lib.sh
+
+while getopts d flag; do
+  case "${flag}" in
+    d) debug=1;;
+  esac
+done
+
+if [ -z $debug ]; then
+  trap "rm -rf testdir" EXIT
+fi
+mkdir -p testdir
+head -c 1474560 /dev/zero > testdir/floppy.raw
+
+gen_cpio_list rdwr
+gen_initrd rdwr
+run_qemu_rdwr_img testdir/floppy.raw $debug
Signature · 1 line
2.31.1