[v3] arc: Don't use multiline in arc-disassembler-options.exp test

Message ID CY8PR12MB7516FEC832A24A3F7FB50B8DA8482@CY8PR12MB7516.namprd12.prod.outlook.com
State New
Headers
Series [v3] arc: Don't use multiline in arc-disassembler-options.exp test |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed

Commit Message

Yuriy Kolerov Feb. 12, 2024, 9:59 a.m. UTC
  Breaking a TCL string to several lines leads to adding of extra
symbols to the resulting expect string. In turn, this leads to
failing of all test cases in gdb.arch/arc-disassembler-options.exp
testsuite. It's necessary to use multi_line function in such
cases.

Signed-off-by: Yuriy Kolerov <ykolerov@synopsys.com>
---
 gdb/testsuite/gdb.arch/arc-disassembler-options.exp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
  

Comments

Shahab Vahedi Feb. 12, 2024, 10:14 a.m. UTC | #1
On 2/12/24 10:59, Yuriy Kolerov wrote:
> Breaking a TCL string to several lines leads to adding of extra
> symbols to the resulting expect string. In turn, this leads to
> failing of all test cases in gdb.arch/arc-disassembler-options.exp
> testsuite. It's necessary to use multi_line function in such
> cases.
> 
> Signed-off-by: Yuriy Kolerov <ykolerov@synopsys.com>

Looks good to me. Thank you!
  
Andreas Schwab Feb. 12, 2024, 10:27 a.m. UTC | #2
On Feb 12 2024, Yuriy Kolerov wrote:

> diff --git a/gdb/testsuite/gdb.arch/arc-disassembler-options.exp b/gdb/testsuite/gdb.arch/arc-disassembler-options.exp
> index 655edcc774b..497e0aba91e 100644
> --- a/gdb/testsuite/gdb.arch/arc-disassembler-options.exp
> +++ b/gdb/testsuite/gdb.arch/arc-disassembler-options.exp
> @@ -28,10 +28,11 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {}] \
>  clean_restart ${objfile}
>  
>  proc arc_disassemble_test { func insn mesg } {
> -    gdb_test "disassemble $func" \
> -	"Dump of assembler code for function $func:\r\n\
> -	\[^:\]+:\t$insn\r\nEnd of assembler dump\." \
> -	$mesg
> +    set pass_re [multi_line \
> +			"Dump of assembler code for function $func:" \
> +			"\[^:\]+:\t$insn" \
> +			"End of assembler dump\."]

If you want to regexp-quote a period, you need to write it as "\\.", so
that the backslash is not eaten by the string reader.
  
Tom de Vries Feb. 12, 2024, 3:33 p.m. UTC | #3
On 2/12/24 11:27, Andreas Schwab wrote:
> On Feb 12 2024, Yuriy Kolerov wrote:
> 
>> diff --git a/gdb/testsuite/gdb.arch/arc-disassembler-options.exp b/gdb/testsuite/gdb.arch/arc-disassembler-options.exp
>> index 655edcc774b..497e0aba91e 100644
>> --- a/gdb/testsuite/gdb.arch/arc-disassembler-options.exp
>> +++ b/gdb/testsuite/gdb.arch/arc-disassembler-options.exp
>> @@ -28,10 +28,11 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {}] \
>>   clean_restart ${objfile}
>>   
>>   proc arc_disassemble_test { func insn mesg } {
>> -    gdb_test "disassemble $func" \
>> -	"Dump of assembler code for function $func:\r\n\
>> -	\[^:\]+:\t$insn\r\nEnd of assembler dump\." \
>> -	$mesg
>> +    set pass_re [multi_line \
>> +			"Dump of assembler code for function $func:" \
>> +			"\[^:\]+:\t$insn" \
>> +			"End of assembler dump\."]
> 
> If you want to regexp-quote a period, you need to write it as "\\.", so
> that the backslash is not eaten by the string reader.
> 

FWIW, it's also possible to let string_to_regexp worry about escaping, 
and use:
...
+			[string_to_regexp "End of assembler dump."]]
...

Thanks,
- Tom
  

Patch

diff --git a/gdb/testsuite/gdb.arch/arc-disassembler-options.exp b/gdb/testsuite/gdb.arch/arc-disassembler-options.exp
index 655edcc774b..497e0aba91e 100644
--- a/gdb/testsuite/gdb.arch/arc-disassembler-options.exp
+++ b/gdb/testsuite/gdb.arch/arc-disassembler-options.exp
@@ -28,10 +28,11 @@  if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {}] \
 clean_restart ${objfile}
 
 proc arc_disassemble_test { func insn mesg } {
-    gdb_test "disassemble $func" \
-	"Dump of assembler code for function $func:\r\n\
-	\[^:\]+:\t$insn\r\nEnd of assembler dump\." \
-	$mesg
+    set pass_re [multi_line \
+			"Dump of assembler code for function $func:" \
+			"\[^:\]+:\t$insn" \
+			"End of assembler dump\."]
+    gdb_test "disassemble $func" $pass_re $mesg
 }
 
 # Verify defaults.