GSoc GDB pretty printers: Automatic testing and printing class pointers
Thomas Baumgart
thb at net-bembel.de
Fri Jul 2 10:55:41 BST 2021
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<---
c) Then I ran
gdb -batch -x autotest > ground.truth
and made sure that the content of ground.truth is what I expected. The file here
contains
---8<---
Breakpoint 1 at 0x400ec8: file qstring.cpp, line 7.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Breakpoint 1, main (argc=1, argv=0x7fffffffd908) at qstring.cpp:7
7 QString str("firstString");
8 QList<QString> flist;
$1 = "firstString"
9 flist.append(str);
$2 = "firstString"
$3 = <empty>
10 flist.append("second");
11 flist.append("third");
13 QList<QString> alist{ "thsit", "ssfldsf", "sfsfs"};
$4 = {"firstString", "second", "third"}
---8<---
d) At this point, you usually want to make changes to your code. Once done
you continue with
e) and run
gdb -batch -x autotest > verification
diff ground.truth verification
and make sure that there is no difference.
Hope that gives you some ideas.
--
Regards
Thomas Baumgart
https://www.signal.org/ Signal, the better WhatsApp
-------------------------------------------------------------
'The compiler doesn't read comments and neither do I'
-------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 868 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-finance-apps/attachments/20210702/659a68d6/attachment.sig>
More information about the Kde-finance-apps
mailing list