<div dir="ltr">Hello Iulian,<br><br>> So, I am new on testing tools in C, and until now  I<br>> managed to find some useful tools like 'Check'[1] and 'Google<br>> Test framework'[2].<br>><br>> I would like to know your opinion about those tools, or if you<br>
> know some others tools, and which one will fit with mercurial.<br>><br>> I had tried to get some advice from C community, and there<br>> was just one guy that told me, he is using the 'Check' tool.<br>
><br>> [1]: <a href="http://check.sourceforge.net/">http://check.sourceforge.net/</a><br>> [2]: <a href="http://code.google.com/p/googletest/">http://code.google.com/p/googletest/</a><br>> [3]: <a href="http://stackoverflow.com/questions/65820/unit-testing-c-code">http://stackoverflow.com/questions/65820/unit-testing-c-code</a><br>
<br>First off, I am as experienced as you on C.<br>Take what I say with a grain of salt; it's all things I've been told,<br>not first hand experience.<br><br>A few remarks:<br><br>(1) googletest is for C++, i.e. it doesn't compile with a C compiler.<br>
(2) the framework you mention doesn't look bad, it's used by GStreamer<br>(3) If me myself had to make a choice in the next five minutes, I would<br>    go for the framework shipped with glib, <a href="https://developer.gnome.org/glib/2.34/glib-Testing.html">https://developer.gnome.org/glib/2.34/glib-Testing.html</a><br>
    since... it's glib, c'mon. It's not gonna disappear anytime soon.<br>(4) Consider that the framework you choose will be, AFAICT, a dependency<br>    for hg like... forever. It better be good & with a long life ahead.<br>
(5) Maybe too simplistic, but just for you to know: in the C standard library<br>    there is a assert.h header file: `man 3 assert`<br>(6) I have been told about cUnit, <a href="http://cunit.sourceforge.net/index.html">http://cunit.sourceforge.net/index.html</a> ,<br>
    but I wouldn't go for it since it doesn't look very popular<br>    (what big project uses it?). Also, I've been told it doesn't support<br>    timeouts in tests<br><br>I have been spamming the whole freenode (and more) this afternoon, asking<br>
to all big C projects I know of how they test their code.<br>I have asked to GCC, Wayland, Wine, Tor, Gnome, Bluez, Clutter,<br>ffmpeg, VLC, CPython, MariaDB, Postgres, Redis.<br><br>Apart from GCC (DejaGNU, not really for unit testing), they all<br>
wrote their own framework. And among these, I'd go for<br>the glib one (Gnome & friends) with blind eyes.<br><br>= Personal advice =<br><br>Test the test framework !<br>Write down the kind of test you think you'll need to perform.<br>
Then write dummy function on which perform such tests.<br><br>Then, *write those minimal tests* in your framework of choice.<br>Is it as expressive as you want it to be?<br><br>Like:<br>* I want to test return value of functions<br>
* I want to test memory leaks<br>* I want to do tests that involve timeouts<br>* I want to do tests that involve a client and a server<br>* ...<br><br>then try to write those test on tiny dummy functions in<br>the framework you chose, try *all* the feature you need.<br>
Soon better than later!<br><br>Cheers,<br>Giovanni<br>ggherdov<br></div>