Re: [PATCH] diagnostics: Fix sporadic test failure

2021-08-25 Thread Jeff Law via Gcc-patches




On 8/25/2021 12:07 PM, H.J. Lu wrote:

On Sat, May 29, 2021 at 1:03 PM Jeff Law via Gcc-patches
 wrote:



On 5/29/2021 1:55 PM, Bernd Edlinger wrote:

On 5/29/21 9:31 PM, Jeff Law wrote:

On 5/28/2021 6:38 AM, Bernd Edlinger wrote:

Hi,

it turns out to be reproducible this way:

COLUMNS=80 make check-gcc-c RUNTESTFLAGS="plugin.exp=diagnostic*"

Running /home/ed/gnu/gcc-trunk/gcc/testsuite/gcc.dg/plugin/plugin.exp ...
FAIL: gcc.dg/plugin/diagnostic-test-expressions-1.c
-fplugin=./diagnostic_plugin_test_tree_expression_range.so  1 blank line(s) 
in output
FAIL: gcc.dg/plugin/diagnostic-test-expressions-1.c
-fplugin=./diagnostic_plugin_test_tree_expression_range.so  expected multiline 
pattern lines 550-551 not found: "
__builtin_types_compatible_p \(long, int\) \+ f \(i\)\);.*\n
~\^~~\n"
FAIL: gcc.dg/plugin/diagnostic-test-expressions-1.c
-fplugin=./diagnostic_plugin_test_tree_expression_range.so (test for excess 
errors)

a lot more errors happen with COLUMNS=20.

Tested on x86_64-pc-linux-gnu.
Is it OK for trunk?


Thanks
Bernd.


2021-05-28  Bernd Edlinger  

  * gcc.dg/plugin/diagnostic_plugin_show_trees.c (plugin_init): Fix 
caret_max_with.
  * gcc.dg/plugin/diagnostic_plugin_test_inlining.c
  (plugin_init): Likewise.
  * gcc.dg/plugin/diagnostic_plugin_test_paths.c (plugin_init): Likewise.
  * gcc.dg/plugin/diagnostic_plugin_test_string_literals.c
  (plugin_init): Likewise.
  * gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c
  (plugin_init): Likewise.

So while you've got a patch here, you haven't indicated what the problem 
actually was.  I'm guessing caret_max_width was uninitialized and thus we got 
random-ish values.  Presumably those randomish-values are what caused tests to 
occasionally appear to truncate their output and fail?

If that's the case, this is fine.  If it's something deeper, please provide a 
bit of background to help in evaluating the patch.


Yes, the problem is just the function get_terminal_width in diagnostic.c, can
somehow learn the X-terminal's window dimensions where the make check is
started:

int
get_terminal_width (void)
{
const char * s = getenv ("COLUMNS");
if (s != NULL) {
  int n = atoi (s);
  if (n > 0)
return n;
}

#ifdef TIOCGWINSZ
struct winsize w;
w.ws_col = 0;
if (ioctl (0, TIOCGWINSZ, ) == 0 && w.ws_col > 0)
  return w.ws_col;
#endif

return INT_MAX;
}

and this is used to initialize context->caret_max_width in 
diagnostic_set_caret_max_width,
and possibly also other places. This causes a small variation in the output that
is trips the test cases.  It is just an extra newline in some cases, that I 
have not
debugged why exactly this happens, but I assume this is intentional to make the
diagnostics spanning multiple lines better readable to a human.

Thanks.  So for the testsuite we certainly don't want to be doing that
:-)  OK for the trunk, thanks for chasing it down -- I've been seeing
these failures, but haven't had the time to chase down a root cause.


I'd like to backport it to GCC 11 branch to avoid random failures on
GCC 11 branch:

https://gcc.gnu.org/pipermail/gcc-regression/2021-August/075244.html

Sure.
jeff


Re: [PATCH] diagnostics: Fix sporadic test failure

2021-08-25 Thread H.J. Lu via Gcc-patches
On Sat, May 29, 2021 at 1:03 PM Jeff Law via Gcc-patches
 wrote:
>
>
>
> On 5/29/2021 1:55 PM, Bernd Edlinger wrote:
> >
> > On 5/29/21 9:31 PM, Jeff Law wrote:
> >>
> >> On 5/28/2021 6:38 AM, Bernd Edlinger wrote:
> >>> Hi,
> >>>
> >>> it turns out to be reproducible this way:
> >>>
> >>> COLUMNS=80 make check-gcc-c RUNTESTFLAGS="plugin.exp=diagnostic*"
> >>>
> >>> Running /home/ed/gnu/gcc-trunk/gcc/testsuite/gcc.dg/plugin/plugin.exp ...
> >>> FAIL: gcc.dg/plugin/diagnostic-test-expressions-1.c
> >>>-fplugin=./diagnostic_plugin_test_tree_expression_range.so  1 blank 
> >>> line(s) in output
> >>> FAIL: gcc.dg/plugin/diagnostic-test-expressions-1.c
> >>>-fplugin=./diagnostic_plugin_test_tree_expression_range.so  expected 
> >>> multiline pattern lines 550-551 not found: "
> >>> __builtin_types_compatible_p \(long, int\) \+ f \(i\)\);.*\n  
> >>>   ~\^~~\n"
> >>> FAIL: gcc.dg/plugin/diagnostic-test-expressions-1.c
> >>>-fplugin=./diagnostic_plugin_test_tree_expression_range.so (test for 
> >>> excess errors)
> >>>
> >>> a lot more errors happen with COLUMNS=20.
> >>>
> >>> Tested on x86_64-pc-linux-gnu.
> >>> Is it OK for trunk?
> >>>
> >>>
> >>> Thanks
> >>> Bernd.
> >>>
> >>>
> >>> 2021-05-28  Bernd Edlinger  
> >>>
> >>>  * gcc.dg/plugin/diagnostic_plugin_show_trees.c (plugin_init): Fix 
> >>> caret_max_with.
> >>>  * gcc.dg/plugin/diagnostic_plugin_test_inlining.c
> >>>  (plugin_init): Likewise.
> >>>  * gcc.dg/plugin/diagnostic_plugin_test_paths.c (plugin_init): 
> >>> Likewise.
> >>>  * gcc.dg/plugin/diagnostic_plugin_test_string_literals.c
> >>>  (plugin_init): Likewise.
> >>>  * gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c
> >>>  (plugin_init): Likewise.
> >> So while you've got a patch here, you haven't indicated what the problem 
> >> actually was.  I'm guessing caret_max_width was uninitialized and thus we 
> >> got random-ish values.  Presumably those randomish-values are what caused 
> >> tests to occasionally appear to truncate their output and fail?
> >>
> >> If that's the case, this is fine.  If it's something deeper, please 
> >> provide a bit of background to help in evaluating the patch.
> >>
> > Yes, the problem is just the function get_terminal_width in diagnostic.c, 
> > can
> > somehow learn the X-terminal's window dimensions where the make check is
> > started:
> >
> > int
> > get_terminal_width (void)
> > {
> >const char * s = getenv ("COLUMNS");
> >if (s != NULL) {
> >  int n = atoi (s);
> >  if (n > 0)
> >return n;
> >}
> >
> > #ifdef TIOCGWINSZ
> >struct winsize w;
> >w.ws_col = 0;
> >if (ioctl (0, TIOCGWINSZ, ) == 0 && w.ws_col > 0)
> >  return w.ws_col;
> > #endif
> >
> >return INT_MAX;
> > }
> >
> > and this is used to initialize context->caret_max_width in 
> > diagnostic_set_caret_max_width,
> > and possibly also other places. This causes a small variation in the output 
> > that
> > is trips the test cases.  It is just an extra newline in some cases, that I 
> > have not
> > debugged why exactly this happens, but I assume this is intentional to make 
> > the
> > diagnostics spanning multiple lines better readable to a human.
> Thanks.  So for the testsuite we certainly don't want to be doing that
> :-)  OK for the trunk, thanks for chasing it down -- I've been seeing
> these failures, but haven't had the time to chase down a root cause.
>

I'd like to backport it to GCC 11 branch to avoid random failures on
GCC 11 branch:

https://gcc.gnu.org/pipermail/gcc-regression/2021-August/075244.html

Thanks.

-- 
H.J.


Re: [PATCH] diagnostics: Fix sporadic test failure

2021-05-29 Thread Jeff Law via Gcc-patches




On 5/29/2021 1:55 PM, Bernd Edlinger wrote:


On 5/29/21 9:31 PM, Jeff Law wrote:


On 5/28/2021 6:38 AM, Bernd Edlinger wrote:

Hi,

it turns out to be reproducible this way:

COLUMNS=80 make check-gcc-c RUNTESTFLAGS="plugin.exp=diagnostic*"

Running /home/ed/gnu/gcc-trunk/gcc/testsuite/gcc.dg/plugin/plugin.exp ...
FAIL: gcc.dg/plugin/diagnostic-test-expressions-1.c
   -fplugin=./diagnostic_plugin_test_tree_expression_range.so  1 blank line(s) 
in output
FAIL: gcc.dg/plugin/diagnostic-test-expressions-1.c
   -fplugin=./diagnostic_plugin_test_tree_expression_range.so  expected multiline pattern 
lines 550-551 not found: "    __builtin_types_compatible_p 
\(long, int\) \+ f \(i\)\);.*\n    
~\^~~\n"
FAIL: gcc.dg/plugin/diagnostic-test-expressions-1.c
   -fplugin=./diagnostic_plugin_test_tree_expression_range.so (test for excess 
errors)

a lot more errors happen with COLUMNS=20.

Tested on x86_64-pc-linux-gnu.
Is it OK for trunk?


Thanks
Bernd.


2021-05-28  Bernd Edlinger  

 * gcc.dg/plugin/diagnostic_plugin_show_trees.c (plugin_init): Fix 
caret_max_with.
 * gcc.dg/plugin/diagnostic_plugin_test_inlining.c
 (plugin_init): Likewise.
 * gcc.dg/plugin/diagnostic_plugin_test_paths.c (plugin_init): Likewise.
 * gcc.dg/plugin/diagnostic_plugin_test_string_literals.c
 (plugin_init): Likewise.
 * gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c
 (plugin_init): Likewise.

So while you've got a patch here, you haven't indicated what the problem 
actually was.  I'm guessing caret_max_width was uninitialized and thus we got 
random-ish values.  Presumably those randomish-values are what caused tests to 
occasionally appear to truncate their output and fail?

If that's the case, this is fine.  If it's something deeper, please provide a 
bit of background to help in evaluating the patch.


Yes, the problem is just the function get_terminal_width in diagnostic.c, can
somehow learn the X-terminal's window dimensions where the make check is
started:

int
get_terminal_width (void)
{
   const char * s = getenv ("COLUMNS");
   if (s != NULL) {
 int n = atoi (s);
 if (n > 0)
   return n;
   }

#ifdef TIOCGWINSZ
   struct winsize w;
   w.ws_col = 0;
   if (ioctl (0, TIOCGWINSZ, ) == 0 && w.ws_col > 0)
 return w.ws_col;
#endif

   return INT_MAX;
}

and this is used to initialize context->caret_max_width in 
diagnostic_set_caret_max_width,
and possibly also other places. This causes a small variation in the output that
is trips the test cases.  It is just an extra newline in some cases, that I 
have not
debugged why exactly this happens, but I assume this is intentional to make the
diagnostics spanning multiple lines better readable to a human.
Thanks.  So for the testsuite we certainly don't want to be doing that 
:-)  OK for the trunk, thanks for chasing it down -- I've been seeing 
these failures, but haven't had the time to chase down a root cause.


Jeff



Re: [PATCH] diagnostics: Fix sporadic test failure

2021-05-29 Thread Bernd Edlinger



On 5/29/21 9:31 PM, Jeff Law wrote:
> 
> 
> On 5/28/2021 6:38 AM, Bernd Edlinger wrote:
>> Hi,
>>
>> it turns out to be reproducible this way:
>>
>> COLUMNS=80 make check-gcc-c RUNTESTFLAGS="plugin.exp=diagnostic*"
>>
>> Running /home/ed/gnu/gcc-trunk/gcc/testsuite/gcc.dg/plugin/plugin.exp ...
>> FAIL: gcc.dg/plugin/diagnostic-test-expressions-1.c
>>   -fplugin=./diagnostic_plugin_test_tree_expression_range.so  1 blank 
>> line(s) in output
>> FAIL: gcc.dg/plugin/diagnostic-test-expressions-1.c
>>   -fplugin=./diagnostic_plugin_test_tree_expression_range.so  expected 
>> multiline pattern lines 550-551 not found: "    
>> __builtin_types_compatible_p \(long, int\) \+ f \(i\)\);.*\n 
>>    ~\^~~\n"
>> FAIL: gcc.dg/plugin/diagnostic-test-expressions-1.c
>>   -fplugin=./diagnostic_plugin_test_tree_expression_range.so (test for 
>> excess errors)
>>
>> a lot more errors happen with COLUMNS=20.
>>
>> Tested on x86_64-pc-linux-gnu.
>> Is it OK for trunk?
>>
>>
>> Thanks
>> Bernd.
>>
>>
>> 2021-05-28  Bernd Edlinger  
>>
>> * gcc.dg/plugin/diagnostic_plugin_show_trees.c (plugin_init): Fix 
>> caret_max_with.
>> * gcc.dg/plugin/diagnostic_plugin_test_inlining.c
>> (plugin_init): Likewise.
>> * gcc.dg/plugin/diagnostic_plugin_test_paths.c (plugin_init): Likewise.
>> * gcc.dg/plugin/diagnostic_plugin_test_string_literals.c
>> (plugin_init): Likewise.
>> * gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c
>> (plugin_init): Likewise.
> So while you've got a patch here, you haven't indicated what the problem 
> actually was.  I'm guessing caret_max_width was uninitialized and thus we got 
> random-ish values.  Presumably those randomish-values are what caused tests 
> to occasionally appear to truncate their output and fail?
> 
> If that's the case, this is fine.  If it's something deeper, please provide a 
> bit of background to help in evaluating the patch.
> 

Yes, the problem is just the function get_terminal_width in diagnostic.c, can
somehow learn the X-terminal's window dimensions where the make check is
started:

int
get_terminal_width (void)
{
  const char * s = getenv ("COLUMNS");
  if (s != NULL) {
int n = atoi (s);
if (n > 0)
  return n;
  }

#ifdef TIOCGWINSZ
  struct winsize w;
  w.ws_col = 0;
  if (ioctl (0, TIOCGWINSZ, ) == 0 && w.ws_col > 0)
return w.ws_col;
#endif

  return INT_MAX;
}

and this is used to initialize context->caret_max_width in 
diagnostic_set_caret_max_width,
and possibly also other places. This causes a small variation in the output that
is trips the test cases.  It is just an extra newline in some cases, that I 
have not
debugged why exactly this happens, but I assume this is intentional to make the
diagnostics spanning multiple lines better readable to a human.


Thanks,
Bernd.

> Thanks,
> jeff
> 


Re: [PATCH] diagnostics: Fix sporadic test failure

2021-05-29 Thread Jeff Law via Gcc-patches




On 5/28/2021 6:38 AM, Bernd Edlinger wrote:

Hi,

it turns out to be reproducible this way:

COLUMNS=80 make check-gcc-c RUNTESTFLAGS="plugin.exp=diagnostic*"

Running /home/ed/gnu/gcc-trunk/gcc/testsuite/gcc.dg/plugin/plugin.exp ...
FAIL: gcc.dg/plugin/diagnostic-test-expressions-1.c
  -fplugin=./diagnostic_plugin_test_tree_expression_range.so  1 blank line(s) 
in output
FAIL: gcc.dg/plugin/diagnostic-test-expressions-1.c
  -fplugin=./diagnostic_plugin_test_tree_expression_range.so  expected multiline pattern 
lines 550-551 not found: "__builtin_types_compatible_p 
\(long, int\) \+ f \(i\)\);.*\n
~\^~~\n"
FAIL: gcc.dg/plugin/diagnostic-test-expressions-1.c
  -fplugin=./diagnostic_plugin_test_tree_expression_range.so (test for excess 
errors)

a lot more errors happen with COLUMNS=20.

Tested on x86_64-pc-linux-gnu.
Is it OK for trunk?


Thanks
Bernd.


2021-05-28  Bernd Edlinger  

* gcc.dg/plugin/diagnostic_plugin_show_trees.c (plugin_init): Fix 
caret_max_with.
* gcc.dg/plugin/diagnostic_plugin_test_inlining.c
(plugin_init): Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_paths.c (plugin_init): Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_string_literals.c
(plugin_init): Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c
(plugin_init): Likewise.
So while you've got a patch here, you haven't indicated what the problem 
actually was.  I'm guessing caret_max_width was uninitialized and thus 
we got random-ish values.  Presumably those randomish-values are what 
caused tests to occasionally appear to truncate their output and fail?


If that's the case, this is fine.  If it's something deeper, please 
provide a bit of background to help in evaluating the patch.


Thanks,
jeff



[PATCH] diagnostics: Fix sporadic test failure

2021-05-28 Thread Bernd Edlinger
Hi,

it turns out to be reproducible this way:

COLUMNS=80 make check-gcc-c RUNTESTFLAGS="plugin.exp=diagnostic*"

Running /home/ed/gnu/gcc-trunk/gcc/testsuite/gcc.dg/plugin/plugin.exp ...
FAIL: gcc.dg/plugin/diagnostic-test-expressions-1.c
 -fplugin=./diagnostic_plugin_test_tree_expression_range.so  1 blank line(s) in 
output
FAIL: gcc.dg/plugin/diagnostic-test-expressions-1.c
 -fplugin=./diagnostic_plugin_test_tree_expression_range.so  expected multiline 
pattern lines 550-551 not found: "
__builtin_types_compatible_p \(long, int\) \+ f \(i\)\);.*\n
~\^~~\n"
FAIL: gcc.dg/plugin/diagnostic-test-expressions-1.c
 -fplugin=./diagnostic_plugin_test_tree_expression_range.so (test for excess 
errors)

a lot more errors happen with COLUMNS=20.

Tested on x86_64-pc-linux-gnu.
Is it OK for trunk?


Thanks
Bernd.


2021-05-28  Bernd Edlinger  

* gcc.dg/plugin/diagnostic_plugin_show_trees.c (plugin_init): Fix 
caret_max_with.
* gcc.dg/plugin/diagnostic_plugin_test_inlining.c
(plugin_init): Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_paths.c (plugin_init): Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_string_literals.c
(plugin_init): Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c
(plugin_init): Likewise.
From 50420cb535560ec1388d34c2d3d2a3f0d339a132 Mon Sep 17 00:00:00 2001
From: Bernd Edlinger 
Date: Fri, 28 May 2021 14:26:02 +0200
Subject: [PATCH] diagnostics: Fix sporadic test failure

it turns out to be reproducible this way:

COLUMNS=80 make check-gcc-c RUNTESTFLAGS="plugin.exp=diagnostic*"

Running /home/ed/gnu/gcc-trunk/gcc/testsuite/gcc.dg/plugin/plugin.exp ...
FAIL: gcc.dg/plugin/diagnostic-test-expressions-1.c
 -fplugin=./diagnostic_plugin_test_tree_expression_range.so  1 blank line(s) in output
FAIL: gcc.dg/plugin/diagnostic-test-expressions-1.c
 -fplugin=./diagnostic_plugin_test_tree_expression_range.so  expected multiline pattern lines 550-551 not found: "__builtin_types_compatible_p \(long, int\) \+ f \(i\)\);.*\n~\^~~\n"
FAIL: gcc.dg/plugin/diagnostic-test-expressions-1.c
 -fplugin=./diagnostic_plugin_test_tree_expression_range.so (test for excess errors)

a lot more errors happen with COLUMNS=20.

2021-05-28  Bernd Edlinger  

	* gcc.dg/plugin/diagnostic_plugin_show_trees.c (plugin_init): Fix caret_max_with.
	* gcc.dg/plugin/diagnostic_plugin_test_inlining.c
	(plugin_init): Likewise.
	* gcc.dg/plugin/diagnostic_plugin_test_paths.c (plugin_init): Likewise.
	* gcc.dg/plugin/diagnostic_plugin_test_string_literals.c
	(plugin_init): Likewise.
	* gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c
	(plugin_init): Likewise.
---
 gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c  | 2 ++
 gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_inlining.c   | 2 ++
 gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c  | 2 ++
 gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_string_literals.c| 2 ++
 .../gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c| 2 ++
 5 files changed, 10 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c
index 71e6740..ac72503 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_show_trees.c
@@ -115,6 +115,8 @@ plugin_init (struct plugin_name_args *plugin_info,
   if (!plugin_default_version_check (version, _version))
 return 1;
 
+  global_dc->caret_max_width = 80;
+
   register_callback (plugin_name,
 		 PLUGIN_PRE_GENERICIZE,
 		 callback,
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_inlining.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_inlining.c
index 49b78cc..02c4629 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_inlining.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_inlining.c
@@ -169,6 +169,8 @@ plugin_init (struct plugin_name_args *plugin_info,
   if (!plugin_default_version_check (version, _version))
 return 1;
 
+  global_dc->caret_max_width = 80;
+
   pass_info.pass = new pass_test_inlining (g);
   pass_info.reference_pass_name = "*warn_function_noreturn";
   pass_info.ref_pass_instance_number = 1;
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c
index 7672875..5c2da02 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c
@@ -450,6 +450,8 @@ plugin_init (struct plugin_name_args *plugin_info,
   if (!plugin_default_version_check (version, _versi