I installed the CMocka testing framework and tried the sample code:
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
/* A test case that does nothing and succeeds. */
static void null_test_success(void **state) {
(void) state; /* unused */
}
int main(void) {
const struct CMUnitTest tests[] = {
cmocka_unit_test(null_test_success),
};
return cmocka_run_group_tests(tests, NULL, NULL);
}
But when I try to compile I get the following error:
$ gcc -o Tests tests.c
/tmp/ccbwAXrr.o: In function `main':
tests.c:(.text+0x5e): undefined reference to `_cmocka_run_group_tests'
collect2: error: ld returned 1 exit status
What am I missing?
gcc -o Tests tests.c -l cmocka -L /usr/local/lib
but I'm pretty sure the-L
is redundant. I had forgotten to doldconfig
too, but thankfully there is always a StackOverflow question. – Interlocutrix