mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-25 06:36:22 +00:00
Refactor tests to use the new cmocka test runner
## Summary Fixes https://github.com/profanity-im/profanity/issues/1907 Update functional and unit test code to comply with the current cmocka test runner. ## Changes - `UnitTest` struct to `CMUnitTest` struct - `unit_test()` macro to `cmocka_unit_test(f)` macro - `unit_test_setup_teardown()` macro to `cmocka_unit_test_setup_teardown` macro - `run_tests()` macro to `cmocka_run_group_tests()` function - Setup and teardown functions return `int` instead of `void` ## Testing ### Unit Tests `make check` ### Functional Tests I did not compile or run functional tests because they are *shelved* for now. ### Valgrind I'm not entirely sure how to fun Valgrind in this case. I did not do fancy memory management, so it should be fine.
This commit is contained in:
@@ -23,11 +23,11 @@
|
||||
#include "test_muc.h"
|
||||
#include "test_disconnect.h"
|
||||
|
||||
#define PROF_FUNC_TEST(test) unit_test_setup_teardown(test, init_prof_test, close_prof_test)
|
||||
#define PROF_FUNC_TEST(test) cmocka_unit_test_setup_teardown(test, init_prof_test, close_prof_test)
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
const UnitTest all_tests[] = {
|
||||
const struct CMUnitTest all_tests[] = {
|
||||
|
||||
PROF_FUNC_TEST(connect_jid_requests_roster),
|
||||
PROF_FUNC_TEST(connect_jid_sends_presence_after_receiving_roster),
|
||||
@@ -111,5 +111,5 @@ int main(int argc, char* argv[]) {
|
||||
PROF_FUNC_TEST(disconnect_ends_session),
|
||||
};
|
||||
|
||||
return run_tests(all_tests);
|
||||
return cmocka_run_group_tests(all_tests, NULL, NULL);
|
||||
}
|
||||
|
||||
@@ -138,12 +138,12 @@ prof_start(void)
|
||||
setbuf(fp, (char *)0);
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
init_prof_test(void **state)
|
||||
{
|
||||
if (stbbr_start(STBBR_LOGDEBUG ,5230, 0) != 0) {
|
||||
assert_true(FALSE);
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
config_orig = getenv("XDG_CONFIG_HOME");
|
||||
@@ -190,9 +190,10 @@ init_prof_test(void **state)
|
||||
assert_true(prof_output_exact("Private chat time display disabled."));
|
||||
prof_input("/time xml off");
|
||||
assert_true(prof_output_exact("XML Console time display disabled."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
close_prof_test(void **state)
|
||||
{
|
||||
prof_input("/quit");
|
||||
@@ -203,6 +204,7 @@ close_prof_test(void **state)
|
||||
setenv("XDG_DATA_HOME", data_orig, 1);
|
||||
|
||||
stbbr_stop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#define XDG_CONFIG_HOME "./tests/functionaltests/files/xdg_config_home"
|
||||
#define XDG_DATA_HOME "./tests/functionaltests/files/xdg_data_home"
|
||||
|
||||
void init_prof_test(void **state);
|
||||
void close_prof_test(void **state);
|
||||
int init_prof_test(void **state);
|
||||
int close_prof_test(void **state);
|
||||
|
||||
void prof_start(void);
|
||||
void prof_connect(void);
|
||||
|
||||
Reference in New Issue
Block a user