GSoc GDB pretty printers: Automatic testing and printing class pointers

Ralf Habacker ralf.habacker at freenet.de
Mon Jul 5 09:23:25 BST 2021


	Am 02.07.21 um 11:55 schrieb Thomas Baumgart:
> On Mittwoch, 30. Juni 2021 20:09:27 CEST Da Viper wrote:
> 
> [...]
> 
>> The current problem i am facing now is how to automate the test cases,
>> i am not sure how to go about that, it is to make sure that older classes
>> are not affected when new printer classes are created
> 
> I investigated this a bit and here's what I came up with: you can use
> the gdb -batch mode feature to automate tests, collect the results in a
> first run and store them as ground truth. When run again, compare the
> current output against the ground truth and make sure it does not differ.
> 
> Here's what I did in the tests subdir:
> 
> a) I compiled your test program with
> 
>    g++ -g -I /usr/include/qt5/QtCore/ -I /usr/include/qt5  -lstdc++ -lQt5Core -o test qstring.cpp
> 
> b) Next I wrote a file and called it 'autotest'. Its content is
> 
> ---8<---
> file test
> break main
> run
> n
> p str
> n
> p str
> p flist
> n
> n
> n
> p flist
> ---8<---

To reduce the required number of steps here something like the
following recipe may be useful:

#include <signal.h>

int main()
{
	// add test code
	...

	// enter gdb
	raise(SIGTRAP);

        return 0;
}

then compile the code as mentioned by Thomas and create the mentioned
`autotest` file as

> ---8<---
file test
run
frame 1
info local
> ---8<---

then run

    gdb -batch -x autotest

to inspect the results manually or run

    gdb -batch -x autotest  > ground.truth

to create the mentioned reference file.

Regards
Ralf








More information about the Kde-finance-apps mailing list