Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Di Pierro <[email protected]>
  • Loading branch information
FedeDP committed Jun 9, 2023
1 parent 3843a44 commit 781ceca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ int main(void) {
cmocka_unit_test(test_mod_rm_fd_NULL_self),
cmocka_unit_test(test_mod_rm_fd),

// cmocka_unit_test(test_mod_srcs),
cmocka_unit_test(test_mod_srcs),

/* Test module subscribe */
cmocka_unit_test(test_mod_subscribe_NULL_topic),
Expand Down
11 changes: 7 additions & 4 deletions tests/test_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,21 +265,24 @@ void test_mod_add_fd(void **state) {
void test_mod_srcs(void **state) {
(void) state; /* unused */

int ret = m_mod_src_register_tmr(test_mod, &(const m_src_tmr_t){.ns = 50000}, M_SRC_FD_AUTOCLOSE, NULL);
// 1000s just to test
const m_src_tmr_t my_tmr = {.ns = 1000000000000 };

int ret = m_mod_src_register_tmr(test_mod, &my_tmr, M_SRC_FD_AUTOCLOSE, NULL);
assert_true(ret == 0);

/* Try to register again, expect -EEXIST error */
ret = m_mod_src_register_tmr(test_mod, &(const m_src_tmr_t){.ns = 50000}, M_SRC_FD_AUTOCLOSE, NULL);
ret = m_mod_src_register_tmr(test_mod, &my_tmr, M_SRC_FD_AUTOCLOSE, NULL);
assert_true(ret == -EEXIST);

/* Register again, forcing the registration. */
ret = m_mod_src_register_tmr(test_mod, &(const m_src_tmr_t){.ns = 50000}, M_SRC_FD_AUTOCLOSE | M_SRC_FORCE, NULL);
ret = m_mod_src_register_tmr(test_mod, &my_tmr, M_SRC_FD_AUTOCLOSE | M_SRC_FORCE, NULL);
assert_true(ret == 0);

size_t len = m_mod_src_len(test_mod, M_SRC_TYPE_TMR);
assert_true(len == 1);

ret = m_mod_src_deregister_tmr(test_mod, &(const m_src_tmr_t){.ns = 50000});
ret = m_mod_src_deregister_tmr(test_mod, &my_tmr);
assert_true(ret == 0);

len = m_mod_src_len(test_mod, M_SRC_TYPE_TMR);
Expand Down

0 comments on commit 781ceca

Please sign in to comment.