[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-finance-apps
Subject: Re: GSoc GDB pretty printers: Automatic testing and printing class pointers
From: Thomas Baumgart <thb () net-bembel ! de>
Date: 2021-07-02 9:55:41
Message-ID: 2060065.OBFZWjSADL () thb-nb
[Download RAW message or body]
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'
-------------------------------------------------------------
["signature.asc" (application/pgp-signature)]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic