Re: [PATCH v3] Make '{add-,}symbol-file' not care about the position of command line arguments

Pedro Alves
2017-11-30T17:37:51Z

On 11/30/2017 05:26 PM, Sergio Durigan Junior wrote:

>> (Another thing that I noticed but I'm kind of ignoring is the fact
>> that gdb_test treats the question as optional gdb output, so
>> pedantically gdb could stop outputting the question and answer
>> "n" automatically and the testcase wouldn't notice.)
>
> Would you prefer if I made the tests answer "y" instead? Or maybe I'm
> misunderstanding your concern.
>

Take a look at how gdb_test implements the question/response. The
question argument is a question that GDB _may_ ask, not one that
GDB _must_ ask.

So pedantically if add-symbol-file's query ever becomes broken in a way
that makes GDB simply automatically assume "n" without GDB printing
the question in the first place, like:

(gdb) add-symbol-file -s .text 0x200 $binfile 0x100
Not confirmed.
(gdb)

then this:

gdb_test "add-symbol-file -s .text 0x200 $binfile 0x100" \
"Not confirmed\." \
"add-symbol-file different -s .text, before file" \
"add symbol table from file \"${binfile}\" at\r\n\t\.text_addr = x100\r\n\t\.text_addr = 0x200\r\n\\(y or n\\) " \
"n"

won't notice it, it'll still PASS.

The usual way to test must-ask questions is to use
one gdb_test_multiple up to the question, and another gdb_test for
answering the question. Something like (untested):

set test "add-symbol-file different -s .text, before file"
gdb_test_multiple "add-symbol-file -s .text 0x200 $binfile 0x100" $test {
-re "add symbol table from file \"${binfile}\" at\r\n\t\.text_addr = x100\r\n\t\.text_addr = 0x200\r\n\\(y or n\\) " {
gdb_test "n" "Not confirmed\." $test
}
}

Thanks,
Pedro Alves