[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:       Da Viper <yerimyah1 () gmail ! com>
Date:       2021-07-06 11:54:38
Message-ID: CAEtKUfiasJStbFGg=C0P+=6LQ-eGHP8y88NZSGDLKtc5+kzE-Q () mail ! gmail ! com
[Download RAW message or body]

Hello thanks for the above way to auto test the printers, however it maybe
hard to only test what matters the variables as the diff may include texts
not related to the variables, and may need to rewrite test and the cpp file

I was looking at the way boost implement it printers [here](
https://github.com/ruediger/Boost-Pretty-Printer/blob/master/tests/testsuite.py
).
i would try to implement something of that sort if it does not work i will
fall back to creating the gdb  batch test

thanks

On Mon, 5 Jul 2021 at 09:23, Ralf Habacker <ralf.habacker@freenet.de> wrote:

>         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
>
>
>
>
>
>
>

[Attachment #3 (text/html)]

<div dir="ltr">Hello thanks for the above way to auto test the printers, however it \
maybe hard to only test what matters the variables as the diff may include texts not \
related to the variables, and may need to rewrite test and the cpp file  \
<div><br></div><div>I was looking at the way boost implement it printers [here](<a \
href="https://github.com/ruediger/Boost-Pretty-Printer/blob/master/tests/testsuite.py" \
>https://github.com/ruediger/Boost-Pretty-Printer/blob/master/tests/testsuite.py</a>).</div><div>i \
> would try to implement something of that sort if it does not work i will fall back \
> to creating the gdb   batch test  </div><div><br></div><div>thanks  \
> </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, \
> 5 Jul 2021 at 09:23, Ralf Habacker &lt;<a \
> href="mailto:ralf.habacker@freenet.de">ralf.habacker@freenet.de</a>&gt; \
> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
> 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">            Am \
> 02.07.21 um 11:55 schrieb Thomas Baumgart:<br>
&gt; On Mittwoch, 30. Juni 2021 20:09:27 CEST Da Viper wrote:<br>
&gt; <br>
&gt; [...]<br>
&gt; <br>
&gt;&gt; The current problem i am facing now is how to automate the test cases,<br>
&gt;&gt; i am not sure how to go about that, it is to make sure that older \
classes<br> &gt;&gt; are not affected when new printer classes are created<br>
&gt; <br>
&gt; I investigated this a bit and here&#39;s what I came up with: you can use<br>
&gt; the gdb -batch mode feature to automate tests, collect the results in a<br>
&gt; first run and store them as ground truth. When run again, compare the<br>
&gt; current output against the ground truth and make sure it does not differ.<br>
&gt; <br>
&gt; Here&#39;s what I did in the tests subdir:<br>
&gt; <br>
&gt; a) I compiled your test program with<br>
&gt; <br>
&gt;      g++ -g -I /usr/include/qt5/QtCore/ -I /usr/include/qt5   -lstdc++ -lQt5Core \
-o test qstring.cpp<br> &gt; <br>
&gt; b) Next I wrote a file and called it &#39;autotest&#39;. Its content is<br>
&gt; <br>
&gt; ---8&lt;---<br>
&gt; file test<br>
&gt; break main<br>
&gt; run<br>
&gt; n<br>
&gt; p str<br>
&gt; n<br>
&gt; p str<br>
&gt; p flist<br>
&gt; n<br>
&gt; n<br>
&gt; n<br>
&gt; p flist<br>
&gt; ---8&lt;---<br>
<br>
To reduce the required number of steps here something like the<br>
following recipe may be useful:<br>
<br>
#include &lt;signal.h&gt;<br>
<br>
int main()<br>
{<br>
            // add test code<br>
            ...<br>
<br>
            // enter gdb<br>
            raise(SIGTRAP);<br>
<br>
            return 0;<br>
}<br>
<br>
then compile the code as mentioned by Thomas and create the mentioned<br>
`autotest` file as<br>
<br>
&gt; ---8&lt;---<br>
file test<br>
run<br>
frame 1<br>
info local<br>
&gt; ---8&lt;---<br>
<br>
then run<br>
<br>
      gdb -batch -x autotest<br>
<br>
to inspect the results manually or run<br>
<br>
      gdb -batch -x autotest   &gt; ground.truth<br>
<br>
to create the mentioned reference file.<br>
<br>
Regards<br>
Ralf<br>
<br>
<br>
<br>
<br>
<br>
<br>
</blockquote></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic