public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] testsuite: prune DOS drive letter in test outputs
@ 2023-02-21 16:14 Clément Chigot
  2023-02-22  8:26 ` Jan Beulich
  0 siblings, 1 reply; 3+ messages in thread
From: Clément Chigot @ 2023-02-21 16:14 UTC (permalink / raw)
  To: binutils; +Cc: jbeulich, amodra, Clément Chigot

On DOS systems, absolute paths start with the drive letter. This can
trigger failures in the regexp from dump tests, especially for those
checking for warnings or errors. They are usually skipping everything
before the first ":" as it has to be the file path.
  | [^:]*: warning: ...

In order to avoid modifying many regexps to allow such drive letters,
prune them from all the outputs if they are found at the beginning of
a line.

binutils/ChangeLog:

	* testsuite/lib/binutils-common.exp (prune_dump_output): New
	(run_dump_test): Use it.

ld/ChangeLog:

	* testsuite/ld-elf/noinit-sections-2.l: Remove DOS drive letter
	handler.
---
 binutils/testsuite/lib/binutils-common.exp | 18 +++++++++++++++++-
 ld/testsuite/ld-elf/noinit-sections-2.l    |  4 ++--
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/binutils/testsuite/lib/binutils-common.exp b/binutils/testsuite/lib/binutils-common.exp
index ab752417295..89990be845f 100644
--- a/binutils/testsuite/lib/binutils-common.exp
+++ b/binutils/testsuite/lib/binutils-common.exp
@@ -687,6 +687,22 @@ if ![string length [info proc prune_warnings]] {
     }
 }
 
+# prune_dump_output OUTPUT
+#
+# Clean up the output from system specific or unwanted characters.
+# This allows to simplify the regexp inside dump tests.
+proc prune_dump_output { output } {
+    if [ishost "*-*-mingw*"] {
+	# Prune DOS drive letter from an absolute path if it appears
+	# at the beginning of a line.
+	regsub -all "(^|\n)\[\[:upper:\]\]:" $output "\\1" output
+    }
+
+    # Prune last end of line.
+    regsub "\n$" $output "" output
+    return $output
+}
+
 # run_dump_test FILE (optional:) EXTRA_OPTIONS
 #
 # Assemble a .s file, then run some utility on it and check the output.
@@ -1450,7 +1466,7 @@ proc run_dump_test { name {extra_options {}} } {
 	    }
 	}
 
-	regsub "\n$" $comp_output "" comp_output
+	set comp_output [prune_dump_output $comp_output]
 	if { $cmdret != 0 || $comp_output != "" || $want_out(source) != "" } {
 	    set exitstat "succeeded"
 	    if { $cmdret != 0 } { set exitstat "failed" }
diff --git a/ld/testsuite/ld-elf/noinit-sections-2.l b/ld/testsuite/ld-elf/noinit-sections-2.l
index 8ed2716c549..0784c9e3e12 100644
--- a/ld/testsuite/ld-elf/noinit-sections-2.l
+++ b/ld/testsuite/ld-elf/noinit-sections-2.l
@@ -1,5 +1,5 @@
 #...
-(|.:)[^:]*: warning: orphan section `.noinit.var_noinit' from \S+ being placed in section `.noinit.var_noinit'
+[^:]*: warning: orphan section `.noinit.var_noinit' from \S+ being placed in section `.noinit.var_noinit'
 #...
-(|.:)[^:]*: warning: orphan section `.gnu.linkonce.n.var_noinit2' from \S+ being placed in section `.gnu.linkonce.n.var_noinit2'
+[^:]*: warning: orphan section `.gnu.linkonce.n.var_noinit2' from \S+ being placed in section `.gnu.linkonce.n.var_noinit2'
 #pass
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] testsuite: prune DOS drive letter in test outputs
  2023-02-21 16:14 [PATCH] testsuite: prune DOS drive letter in test outputs Clément Chigot
@ 2023-02-22  8:26 ` Jan Beulich
  2023-02-22 12:57   ` Clément Chigot
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2023-02-22  8:26 UTC (permalink / raw)
  To: Clément Chigot; +Cc: amodra, binutils

On 21.02.2023 17:14, Clément Chigot wrote:
> --- a/binutils/testsuite/lib/binutils-common.exp
> +++ b/binutils/testsuite/lib/binutils-common.exp
> @@ -687,6 +687,22 @@ if ![string length [info proc prune_warnings]] {
>      }
>  }
>  
> +# prune_dump_output OUTPUT
> +#
> +# Clean up the output from system specific or unwanted characters.
> +# This allows to simplify the regexp inside dump tests.
> +proc prune_dump_output { output } {
> +    if [ishost "*-*-mingw*"] {

Cygwin as well then?

> +	# Prune DOS drive letter from an absolute path if it appears
> +	# at the beginning of a line.
> +	regsub -all "(^|\n)\[\[:upper:\]\]:" $output "\\1" output

Drive letters aren't guaranteed upper case, are they? I also think this
may end up too lax, as there may be messages which don't start with a
path. I would expect that you want to also match "warning:", "error:",
and alike infixes. Plus wouldn't you better match (but not remove) the
first \ or / following the colon?

> --- a/ld/testsuite/ld-elf/noinit-sections-2.l
> +++ b/ld/testsuite/ld-elf/noinit-sections-2.l
> @@ -1,5 +1,5 @@
>  #...
> -(|.:)[^:]*: warning: orphan section `.noinit.var_noinit' from \S+ being placed in section `.noinit.var_noinit'
> +[^:]*: warning: orphan section `.noinit.var_noinit' from \S+ being placed in section `.noinit.var_noinit'
>  #...
> -(|.:)[^:]*: warning: orphan section `.gnu.linkonce.n.var_noinit2' from \S+ being placed in section `.gnu.linkonce.n.var_noinit2'
> +[^:]*: warning: orphan section `.gnu.linkonce.n.var_noinit2' from \S+ being placed in section `.gnu.linkonce.n.var_noinit2'
>  #pass

Did you commit the earlier patch, which now needs reverting?

Jan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] testsuite: prune DOS drive letter in test outputs
  2023-02-22  8:26 ` Jan Beulich
@ 2023-02-22 12:57   ` Clément Chigot
  0 siblings, 0 replies; 3+ messages in thread
From: Clément Chigot @ 2023-02-22 12:57 UTC (permalink / raw)
  To: Jan Beulich; +Cc: amodra, binutils

Hi Jan,

On Wed, Feb 22, 2023 at 9:26 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 21.02.2023 17:14, Clément Chigot wrote:
> > --- a/binutils/testsuite/lib/binutils-common.exp
> > +++ b/binutils/testsuite/lib/binutils-common.exp
> > @@ -687,6 +687,22 @@ if ![string length [info proc prune_warnings]] {
> >      }
> >  }
> >
> > +# prune_dump_output OUTPUT
> > +#
> > +# Clean up the output from system specific or unwanted characters.
> > +# This allows to simplify the regexp inside dump tests.
> > +proc prune_dump_output { output } {
> > +    if [ishost "*-*-mingw*"] {
>
> Cygwin as well then?

I don't think so. AFAIK, Cygwin is using Unix path not DOS like ones.
Moreover, include/filenames.h seems to say the same. HAS_DRIVE_SPEC is
not defined for Cygwin.

> > +     # Prune DOS drive letter from an absolute path if it appears
> > +     # at the beginning of a line.
> > +     regsub -all "(^|\n)\[\[:upper:\]\]:" $output "\\1" output
>
> Drive letters aren't guaranteed upper case, are they?

I thought so, but it seems not. I'll change that.

> I also think this
> may end up too lax, as there may be messages which don't start with a
> path. I would expect that you want to also match "warning:", "error:",
> and alike infixes. Plus wouldn't you better match (but not remove) the
> first \ or / following the colon?

Yeah, that was my opinion too. But I had trouble with TCL regexps not
wanting to detect \... So, I still submit a first patch to have your
feedbacks on that. I'm not sure how common "LETTER:" can appear in
binutils tests, thus it might have been false concerns on my side. But
it seems not. I'll try to improve that.

> > --- a/ld/testsuite/ld-elf/noinit-sections-2.l
> > +++ b/ld/testsuite/ld-elf/noinit-sections-2.l
> > @@ -1,5 +1,5 @@
> >  #...
> > -(|.:)[^:]*: warning: orphan section `.noinit.var_noinit' from \S+ being placed in section `.noinit.var_noinit'
> > +[^:]*: warning: orphan section `.noinit.var_noinit' from \S+ being placed in section `.noinit.var_noinit'
> >  #...
> > -(|.:)[^:]*: warning: orphan section `.gnu.linkonce.n.var_noinit2' from \S+ being placed in section `.gnu.linkonce.n.var_noinit2'
> > +[^:]*: warning: orphan section `.gnu.linkonce.n.var_noinit2' from \S+ being placed in section `.gnu.linkonce.n.var_noinit2'
> >  #pass
>
> Did you commit the earlier patch, which now needs reverting?

No, this is not the same. I submitted two commits dealing with that issue.
 - ld/testsuite: handle Windows drive letter in a noinit test. which
was merged on Monday.
 - ld/testsuite: handle Windows drive letter in persistent section.
which ends up with this patch.

Thus I'm reverting the one that I've been already merged.

Clément

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-22 12:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-21 16:14 [PATCH] testsuite: prune DOS drive letter in test outputs Clément Chigot
2023-02-22  8:26 ` Jan Beulich
2023-02-22 12:57   ` Clément Chigot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).