From kde-finance-apps Mon Jul 05 08:23:25 2021 From: Ralf Habacker Date: Mon, 05 Jul 2021 08:23:25 +0000 To: kde-finance-apps Subject: Re: GSoc GDB pretty printers: Automatic testing and printing class pointers Message-Id: X-MARC-Message: https://marc.info/?l=kde-finance-apps&m=162547341518252 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 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