From: Michal Bloch Date: Tue, 4 Mar 2025 18:55:04 +0000 (+0100) Subject: Add advanced fixed-size backend tests. X-Git-Tag: accepted/tizen/unified/20250310.131215~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=14a79b59b39565ffb0ba6ce47a4850baf3c93c24;p=platform%2Fcore%2Fsystem%2Fsessiond.git Add advanced fixed-size backend tests. Covers more scenarios specific to the backend, and interaction between the two backends. Change-Id: I2ae980ffa8497dffc455761d1958c94db8390d5d --- diff --git a/tests/api_tests/test_api_add_remove_user.cpp b/tests/api_tests/test_api_add_remove_user.cpp index 8fd1b87..6e1a169 100644 --- a/tests/api_tests/test_api_add_remove_user.cpp +++ b/tests/api_tests/test_api_add_remove_user.cpp @@ -9,7 +9,7 @@ #include "test_hlp.hpp" -const int action_items = 8; +const int action_items = 20; TEST(subsession_add_remove_user_test, APIAddRemoveUserTest) { @@ -67,6 +67,84 @@ TEST(subsession_add_remove_user_test, APIAddRemoveUserTest) { .desc = "Check if remove " + std::string(TestUserStr::user_3) + " is successful (fixed-size backend)", .cb_expected = SUBSESSION_ERROR_NONE, .cb_desc = "Check if remove " + std::string(TestUserStr::user_3) + " callback is successful (fixed-size backend)", }, + + // Reuse same name, fixed-size backend, same size + + api_call_res_t{ .call_result = std::move(subsession_add_user_fixed_size_l( TestUserStr::user_3, 25*1024)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if add " + std::string(TestUserStr::user_3) + " is successful (reused name, fixed-size backend, 25 MB)", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if add " + std::string(TestUserStr::user_3) + " callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_remove_user_l(TestUserStr::user_3)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if remove " + std::string(TestUserStr::user_3) + " is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if remove " + std::string(TestUserStr::user_3) + " callback is successful", }, + + // Reuse same name, fixed-size backend, different size + + api_call_res_t{ .call_result = std::move(subsession_add_user_fixed_size_l( TestUserStr::user_3, 10*1024)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if add " + std::string(TestUserStr::user_3) + " is successful (reused name, fixed-size backend, different size 10 MB)", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if add " + std::string(TestUserStr::user_3) + " callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_remove_user_l(TestUserStr::user_3)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if remove " + std::string(TestUserStr::user_3) + " is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if remove " + std::string(TestUserStr::user_3) + " callback is successful", }, + + // Both backends reusing the same name alternatingly + + api_call_res_t{ .call_result = std::move(subsession_add_user_fixed_size_l( TestUserStr::user_5, 10*1024)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if add " + std::string(TestUserStr::user_5) + " is successful (fixed-size backend, 10 MB)", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if add " + std::string(TestUserStr::user_5) + " callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_remove_user_l(TestUserStr::user_5)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if remove " + std::string(TestUserStr::user_5) + " is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if remove " + std::string(TestUserStr::user_5) + " callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_add_user_l( TestUserStr::user_5)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if add " + std::string(TestUserStr::user_5) + " is successful (reused name, regular dir backend)", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if add " + std::string(TestUserStr::user_5) + " callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_remove_user_l(TestUserStr::user_5)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if remove " + std::string(TestUserStr::user_5) + " is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if remove " + std::string(TestUserStr::user_5) + " callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_add_user_fixed_size_l( TestUserStr::user_5, 25*1024)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if add " + std::string(TestUserStr::user_5) + " is successful (reused again, fixed-size backend, 25 MB)", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if add " + std::string(TestUserStr::user_5) + " callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_remove_user_l(TestUserStr::user_5)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if remove " + std::string(TestUserStr::user_5) + " is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if remove " + std::string(TestUserStr::user_5) + " callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_add_user_l( TestUserStr::user_5)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if add " + std::string(TestUserStr::user_5) + " is successful (reused again, regular dir backend)", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if add " + std::string(TestUserStr::user_5) + " callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_remove_user_l(TestUserStr::user_5)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if remove " + std::string(TestUserStr::user_5) + " is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if remove " + std::string(TestUserStr::user_5) + " callback is successful", }, } }; diff --git a/tests/api_tests/test_api_add_remove_user_err.cpp b/tests/api_tests/test_api_add_remove_user_err.cpp index ca05c86..0f62779 100644 --- a/tests/api_tests/test_api_add_remove_user_err.cpp +++ b/tests/api_tests/test_api_add_remove_user_err.cpp @@ -9,7 +9,7 @@ #include "test_hlp.hpp" -const int action_items = 26; +const int action_items = 40; TEST(subsession_add_remove_test, FailAtAddRemoveUser) { using ud_t = ud_data_t>; @@ -178,6 +178,118 @@ TEST(subsession_add_remove_test, FailAtAddRemoveUser) { .cb_expected = SUBSESSION_ERROR_INVALID_PARAMETER, .cb_desc = "Check if remove [ " + std::string(TestBadUserStr::bad_user_20) + " ] callback returns error (fixed-size backend)", }, + // Trying to add regular-dir subsession when fixed-size already exists under that name + + api_call_res_t{ .call_result = std::move(subsession_add_user_fixed_size_l( TestUserStr::user_3, 25*1024)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if add " + std::string(TestUserStr::user_3) + " is successful (fixed-size backend, 25 MB)", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if add " + std::string(TestUserStr::user_3) + " callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_add_user_l( TestUserStr::user_3)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if add " + std::string(TestUserStr::user_3) + " (regular dir backend) successfully sends request", + .cb_expected = SUBSESSION_ERROR_ALREADY_EXISTS, + .cb_desc = "Check if add " + std::string(TestUserStr::user_3) + " callback returns error ERROR_ALREADY_EXISTS", }, + + api_call_res_t{ .call_result = std::move(subsession_remove_user_l(TestUserStr::user_3)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if remove " + std::string(TestUserStr::user_3) + " is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if remove " + std::string(TestUserStr::user_3) + " callback is successful", }, + + // Trying to add fixed-size subsession when regular-dir already exists + + api_call_res_t{ .call_result = std::move(subsession_add_user_l( TestUserStr::user_4)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if add " + std::string(TestUserStr::user_4) + " is successful (regular dir backend)", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if add " + std::string(TestUserStr::user_4) + " callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_add_user_fixed_size_l( TestUserStr::user_4, 25*1024)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if add " + std::string(TestUserStr::user_4) + " (fixed-size backend, 25 MB) successfully sends request returns ERROR_ALREADY_EXISTS", + .cb_expected = SUBSESSION_ERROR_ALREADY_EXISTS, + .cb_desc = "Check if add " + std::string(TestUserStr::user_4) + " callback returns ERROR_ALREADY_EXISTS", }, + + api_call_res_t{ .call_result = std::move(subsession_remove_user_l(TestUserStr::user_4)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if remove " + std::string(TestUserStr::user_4) + " is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if remove " + std::string(TestUserStr::user_4) + " callback is successful", }, + + // Trying to add fixed-size subsession when fixed-size already exists + + api_call_res_t{ .call_result = std::move(subsession_add_user_fixed_size_l( TestUserStr::user_5, 25*1024)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if add " + std::string(TestUserStr::user_5) + " is successful (fixed-size backend, 25 MB)", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if add " + std::string(TestUserStr::user_5) + " callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_add_user_fixed_size_l( TestUserStr::user_5, 25*1024)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if add " + std::string(TestUserStr::user_5) + " (fixed-size backend, 25 MB) successfully sends request", + .cb_expected = SUBSESSION_ERROR_ALREADY_EXISTS, + .cb_desc = "Check if add " + std::string(TestUserStr::user_5) + " callback returns ERROR_ALREADY_EXISTS", }, + + api_call_res_t{ .call_result = std::move(subsession_add_user_fixed_size_l( TestUserStr::user_5, 25*1024)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if add " + std::string(TestUserStr::user_5) + " (fixed-size backend, 10 MB) successfully sends request", + .cb_expected = SUBSESSION_ERROR_ALREADY_EXISTS, + .cb_desc = "Check if add " + std::string(TestUserStr::user_5) + " callback returns ERROR_ALREADY_EXISTS", }, + + api_call_res_t{ .call_result = std::move(subsession_remove_user_l(TestUserStr::user_5)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if remove " + std::string(TestUserStr::user_5) + " is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if remove " + std::string(TestUserStr::user_5) + " callback is successful", }, + + // Trying to add fixed-size subsession with insufficient size for overhead + + api_call_res_t{ .call_result = std::move(subsession_add_user_fixed_size_l( TestUserStr::user_6, 0)), + .expected = SUBSESSION_ERROR_INVALID_PARAMETER, + .desc = "Check if add " + std::string(TestUserStr::user_6) + " (fixed-size backend, 0 kB) returns ERROR_INVALID_PARAMETER", + .cb_expected = SUBSESSION_ERROR_INVALID_PARAMETER, + .cb_desc = "Check if add " + std::string(TestUserStr::user_6) + " callback returns error", }, + + api_call_res_t{ .call_result = std::move(subsession_add_user_fixed_size_l( TestUserStr::user_6, 200)), + .expected = SUBSESSION_ERROR_INVALID_PARAMETER, + .desc = "Check if add " + std::string(TestUserStr::user_6) + " (fixed-size backend, 200 kB) returns ERROR_INVALID_PARAMETER", + .cb_expected = SUBSESSION_ERROR_INVALID_PARAMETER, + .cb_desc = "Check if add " + std::string(TestUserStr::user_6) + " callback returns error", }, + +#if 0 // don't forget action_items++ if you restore this + + /* FIXME: the "success" below is fake. We are counting on IO_ERROR caused by filesystem not being able to fit such huge image. + * We indeed receive IO_ERROR but it's actually because the service is busy trying to fill the entire FS and does not respond + * to calls, so we bail out on timeout which also happens to result in IO_ERROR. This is a deeper problem but hopefully, since + * the action here is privileged, we can count on nobody creating absurdly huge subsessions. */ + + // Trying to add fixed-size subsession which doesn't fit + api_call_res_t{ .call_result = std::move(subsession_add_user_fixed_size_l( TestUserStr::user_6, 2000000000)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if add " + std::string(TestUserStr::user_6) + " (fixed-size backend, 2 TB) successfully sends request", + .cb_expected = SUBSESSION_ERROR_IO_ERROR, + .cb_desc = "Check if add " + std::string(TestUserStr::user_6) + " callback returns ERROR_IO_ERROR", }, + + + /* FIXME 2: the below cannot be tested properly using the current testing framework alongside the call above, at least without + * a bit of a rewrite. All calls are done immediately and then their results are just received sequentially via async callback, + * while the service is single-threaded. This means that any call that runs into timeout also automatically fails all tests below it. */ +#endif + + // Make sure failed attempts don't prevent a valid subsession + api_call_res_t{ .call_result = std::move(subsession_add_user_fixed_size_l( TestUserStr::user_6, 25*1024)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if add " + std::string(TestUserStr::user_6) + " is successful (fixed-size backend, 25 MB)", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if add " + std::string(TestUserStr::user_6) + " callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_remove_user_l(TestUserStr::user_6)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if remove " + std::string(TestUserStr::user_6) + " is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if remove " + std::string(TestUserStr::user_6) + " callback is successful", }, } }; diff --git a/tests/api_tests/test_api_switch_user_completion.cpp b/tests/api_tests/test_api_switch_user_completion.cpp index ec0a789..68f0784 100644 --- a/tests/api_tests/test_api_switch_user_completion.cpp +++ b/tests/api_tests/test_api_switch_user_completion.cpp @@ -12,7 +12,7 @@ TEST(subsession_switch_user_completion, APISwitchUserCompletion) { - const int prologue_items = 4; + const int prologue_items = 12; using ud_prologue_t = ud_data_t>; ud_prologue_t prologue = { .loop = g_main_loop_new(NULL, FALSE), .results = std::array { @@ -37,18 +37,67 @@ TEST(subsession_switch_user_completion, APISwitchUserCompletion) { .cb_expected = SUBSESSION_ERROR_NONE, .cb_desc = "Check if add [ " + std::string(TestUserStr::user_2) + " ] callback is successful", }, + api_call_res_t{ .call_result = std::move(subsession_add_user_fixed_size_l( TestUserStr::user_3, 15*1024)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if add [ " + std::string(TestUserStr::user_3) + " ], fixed-size backend (15 MB), is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if add [ " + std::string(TestUserStr::user_3) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_add_user_fixed_size_l( TestUserStr::user_4, 40*1024)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if add [ " + std::string(TestUserStr::user_4) + " ], fixed-size backend (40 MB), is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if add [ " + std::string(TestUserStr::user_4) + " ] callback is successful", }, + + // Switch between them a bit api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_1)), .expected = SUBSESSION_ERROR_NONE, .desc = "Check if switch to [ " + std::string(TestUserStr::user_1) + " ] is successful", .cb_expected = SUBSESSION_ERROR_NONE, .cb_desc = "Check if switch to [" + std::string(TestUserStr::user_1) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_2)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_2) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to [ " + std::string(TestUserStr::user_2) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_3)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_3) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to [ " + std::string(TestUserStr::user_3) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_2)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_2) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to [ " + std::string(TestUserStr::user_2) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_4)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_4) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to [ " + std::string(TestUserStr::user_4) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_0)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_0) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to [ " + std::string(TestUserStr::user_0) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_1)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_1) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to [ " + std::string(TestUserStr::user_1) + " ] callback is successful", }, } }; loop_run_for_test(callback_pending, &prologue, prologue.loop); summarize(prologue.results); - const int action_items = 2; + const int action_items = 7; using ud_t = ud_data_t>; ud_t ud_data = { .loop = g_main_loop_new(NULL, FALSE), @@ -65,6 +114,36 @@ TEST(subsession_switch_user_completion, APISwitchUserCompletion) { .desc = "Check if switch to [ " + std::string(TestUserStr::user_2) + " ] is successful", .cb_expected = SUBSESSION_ERROR_NONE, .cb_desc = "Check if switch to [" + std::string(TestUserStr::user_2) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_3)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_3) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to [" + std::string(TestUserStr::user_3) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_2)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_2) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to [" + std::string(TestUserStr::user_2) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_4)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_4) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to [" + std::string(TestUserStr::user_4) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_0)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_0) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to [" + std::string(TestUserStr::user_0) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_4)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_4) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to [" + std::string(TestUserStr::user_4) + " ] callback is successful", }, } }; @@ -76,7 +155,7 @@ TEST(subsession_switch_user_completion, APISwitchUserCompletion) { EXPECT_EQ(res, SUBSESSION_ERROR_NONE); - const int epilogue_items = 3; + const int epilogue_items = 5; using ud_epilogue_t = ud_data_t>; ud_epilogue_t epilogue = { .loop = g_main_loop_new(NULL, FALSE), .results = std::array { @@ -98,6 +177,18 @@ TEST(subsession_switch_user_completion, APISwitchUserCompletion) { .desc = "Check if remove[ " + std::string(TestUserStr::user_2) + " ] is successful", .cb_expected = SUBSESSION_ERROR_NONE, .cb_desc = "Check if remove [ " + std::string(TestUserStr::user_2) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_remove_user_l( TestUserStr::user_3)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if remove [ " + std::string(TestUserStr::user_3) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if remove [ " + std::string(TestUserStr::user_3) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_remove_user_l( TestUserStr::user_4)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if remove[ " + std::string(TestUserStr::user_4) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if remove [ " + std::string(TestUserStr::user_4) + " ] callback is successful", }, } }; diff --git a/tests/api_tests/test_api_switch_user_wait.cpp b/tests/api_tests/test_api_switch_user_wait.cpp index 864e4c6..1007b66 100644 --- a/tests/api_tests/test_api_switch_user_wait.cpp +++ b/tests/api_tests/test_api_switch_user_wait.cpp @@ -12,7 +12,7 @@ TEST(subsession_switch_user_wait, APISwitchUserStarted) { - const int prologue_items = 4; + const int prologue_items = 12; using ud_prologue_t = ud_data_t>; ud_prologue_t prologue = { .loop = g_main_loop_new(NULL, FALSE), .results = std::array { @@ -35,18 +35,67 @@ TEST(subsession_switch_user_wait, APISwitchUserStarted) { .cb_expected = SUBSESSION_ERROR_NONE, .cb_desc = "Check if add [ " + std::string(TestUserStr::user_2) + " ] callback is successful", }, + api_call_res_t{ .call_result = std::move(subsession_add_user_fixed_size_l( TestUserStr::user_3, 20*1024)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if add [ " + std::string(TestUserStr::user_3) + " ] is successful (fixed-size backend, 20 MB)", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if add [ " + std::string(TestUserStr::user_3) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_add_user_fixed_size_l( TestUserStr::user_4, 30*1024)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if add [ " + std::string(TestUserStr::user_4) + " ] is successful (fixed-size backend, 30 MB)", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if add [ " + std::string(TestUserStr::user_4) + " ] callback is successful", }, + + // Switch between them a bit api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_1)), .expected = SUBSESSION_ERROR_NONE, .desc = "Check if switch to [ " + std::string(TestUserStr::user_1) + " ] is successful", .cb_expected = SUBSESSION_ERROR_NONE, .cb_desc = "Check if switch to [" + std::string(TestUserStr::user_1) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_2)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_2) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to [ " + std::string(TestUserStr::user_2) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_3)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_3) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to [ " + std::string(TestUserStr::user_3) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_2)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_2) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to [ " + std::string(TestUserStr::user_2) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_4)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_4) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to [ " + std::string(TestUserStr::user_4) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_0)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_0) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to [ " + std::string(TestUserStr::user_0) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_1)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_1) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to [ " + std::string(TestUserStr::user_1) + " ] callback is successful", }, } }; loop_run_for_test(callback_pending, &prologue, prologue.loop); summarize(prologue.results); - const int action_items = 2; + const int action_items = 7; using ud_t = ud_data_t>; ud_t ud_data = { .loop = g_main_loop_new(NULL, FALSE), @@ -63,6 +112,36 @@ TEST(subsession_switch_user_wait, APISwitchUserStarted) { .desc = "Check if switch to [ " + std::string(TestUserStr::user_2) + " ] is successful", .cb_expected = SUBSESSION_ERROR_NONE, .cb_desc = "Check if switch to [" + std::string(TestUserStr::user_2) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_3)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_3) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to [" + std::string(TestUserStr::user_3) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_2)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_2) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to [" + std::string(TestUserStr::user_2) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_4)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_4) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to [" + std::string(TestUserStr::user_4) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_0)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_0) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to [" + std::string(TestUserStr::user_0) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_4)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_4) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to [" + std::string(TestUserStr::user_4) + " ] callback is successful", }, } }; @@ -74,7 +153,7 @@ TEST(subsession_switch_user_wait, APISwitchUserStarted) { EXPECT_EQ(res, SUBSESSION_ERROR_NONE); - const int epilogue_items = 3; + const int epilogue_items = 5; using ud_epilogue_t = ud_data_t>; ud_epilogue_t epilogue = { .loop = g_main_loop_new(NULL, FALSE), .results = std::array { @@ -96,6 +175,18 @@ TEST(subsession_switch_user_wait, APISwitchUserStarted) { .desc = "Check if remove[ " + std::string(TestUserStr::user_2) + " ] is successful", .cb_expected = SUBSESSION_ERROR_NONE, .cb_desc = "Check if remove [ " + std::string(TestUserStr::user_2) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_remove_user_l( TestUserStr::user_3)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if remove [ " + std::string(TestUserStr::user_3) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if remove [ " + std::string(TestUserStr::user_3) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_remove_user_l( TestUserStr::user_4)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if remove[ " + std::string(TestUserStr::user_4) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if remove [ " + std::string(TestUserStr::user_4) + " ] callback is successful", }, } }; diff --git a/tests/api_tests/test_api_switchuser.cpp b/tests/api_tests/test_api_switchuser.cpp index e21a8c8..bf8e45d 100644 --- a/tests/api_tests/test_api_switchuser.cpp +++ b/tests/api_tests/test_api_switchuser.cpp @@ -7,7 +7,7 @@ // Test -const int action_items = 15; +const int action_items = 29; TEST(subsession_switch_user_test, APISwitchUserTest) { @@ -41,6 +41,19 @@ TEST(subsession_switch_user_test, APISwitchUserTest) { .cb_expected = SUBSESSION_ERROR_NONE, .cb_desc = "Check if add [ " + std::string(TestUserStr::user_3) + " ] callback is successful", }, + api_call_res_t{ .call_result = std::move(subsession_add_user_fixed_size_l( TestUserStr::user_4, 15*1024)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if add [ " + std::string(TestUserStr::user_4) + " ] is successful (fixed-size backend, 15 MB)", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if add [ " + std::string(TestUserStr::user_4) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_add_user_fixed_size_l( TestUserStr::user_5, 30*1024)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if add [ " + std::string(TestUserStr::user_5) + " ] is successful (fixed-size backend, 30 MB)", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if add [ " + std::string(TestUserStr::user_5) + " ] callback is successful", }, + + // Default -> regular dir api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_3)), .expected = SUBSESSION_ERROR_NONE, .desc = "Check if switch to [ " + std::string(TestUserStr::user_3) + " ] is successful", @@ -53,6 +66,7 @@ TEST(subsession_switch_user_test, APISwitchUserTest) { .cb_expected = SUBSESSION_ERROR_INVALID_PARAMETER, .cb_desc = "Check if getting current user [" + std::string(TestUserStr::user_3) + " ] is done", }, + // Regular dir -> regular dir api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_2)), .expected = SUBSESSION_ERROR_NONE, .desc = "Check if switch to [ " + std::string(TestUserStr::user_2) + " ] is successful", @@ -65,6 +79,33 @@ TEST(subsession_switch_user_test, APISwitchUserTest) { .cb_expected = SUBSESSION_ERROR_INVALID_PARAMETER, .cb_desc = "Check if getting current user [" + std::string(TestUserStr::user_2) + " ] is done", }, + // Regular dir -> fixed size + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_4)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_4) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to [" + std::string(TestUserStr::user_4) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_get_current_user_l( TestUserStr::user_4)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if current [ " + std::string(TestUserStr::user_4) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_INVALID_PARAMETER, + .cb_desc = "Check if getting current user [" + std::string(TestUserStr::user_4) + " ] is done", }, + + // Fixed size -> fixed size + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_5)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_5) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to [" + std::string(TestUserStr::user_5) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_get_current_user_l( TestUserStr::user_5)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if current [ " + std::string(TestUserStr::user_5) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_INVALID_PARAMETER, + .cb_desc = "Check if getting current user [" + std::string(TestUserStr::user_5) + " ] is done", }, + + // Fixed size -> regular dir api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_1)), .expected = SUBSESSION_ERROR_NONE, .desc = "Check if switch to [ " + std::string(TestUserStr::user_1) + " ] is successful", @@ -77,6 +118,20 @@ TEST(subsession_switch_user_test, APISwitchUserTest) { .cb_expected = SUBSESSION_ERROR_INVALID_PARAMETER, .cb_desc = "Check if getting current user [" + std::string(TestUserStr::user_1) + " ] is done", }, + // Regular dir -> default + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_0)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_0) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to" + std::string(TestUserStr::user_0) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_get_current_user_l( TestUserStr::user_0)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if current [ " + std::string(TestUserStr::user_0) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_INVALID_PARAMETER, + .cb_desc = "Check if getting current user [" + std::string(TestUserStr::user_0) + " ] is done", }, + + // Default -> default api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_0)), .expected = SUBSESSION_ERROR_NONE, .desc = "Check if switch to [ " + std::string(TestUserStr::user_0) + " ] is successful", @@ -89,6 +144,33 @@ TEST(subsession_switch_user_test, APISwitchUserTest) { .cb_expected = SUBSESSION_ERROR_INVALID_PARAMETER, .cb_desc = "Check if getting current user [" + std::string(TestUserStr::user_0) + " ] is done", }, + // Default -> fixed-size + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_5)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_5) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to" + std::string(TestUserStr::user_5) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_5)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_5) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to" + std::string(TestUserStr::user_5) + " ] callback is successful", }, + + // Fixed-size -> default + api_call_res_t{ .call_result = std::move(subsession_switch_user_l( TestUserStr::user_0)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if switch to [ " + std::string(TestUserStr::user_0) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if switch to" + std::string(TestUserStr::user_0) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_get_current_user_l( TestUserStr::user_0)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if current [ " + std::string(TestUserStr::user_0) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_INVALID_PARAMETER, + .cb_desc = "Check if getting current user [" + std::string(TestUserStr::user_0) + " ] is done", }, + + // Cleanup api_call_res_t{ .call_result = std::move(subsession_remove_user_l(TestUserStr::user_1)), .expected = SUBSESSION_ERROR_NONE, .desc = "Check if remove [ " + std::string(TestUserStr::user_1) + " ] is successful", @@ -106,6 +188,18 @@ TEST(subsession_switch_user_test, APISwitchUserTest) { .desc = "Check if remove [ " + std::string(TestUserStr::user_3) + " ] is successful", .cb_expected = SUBSESSION_ERROR_NONE, .cb_desc = "Check if remove [ " + std::string(TestUserStr::user_3) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_remove_user_l(TestUserStr::user_4)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if remove [ " + std::string(TestUserStr::user_4) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if remove [ " + std::string(TestUserStr::user_4) + " ] callback is successful", }, + + api_call_res_t{ .call_result = std::move(subsession_remove_user_l(TestUserStr::user_5)), + .expected = SUBSESSION_ERROR_NONE, + .desc = "Check if remove [ " + std::string(TestUserStr::user_5) + " ] is successful", + .cb_expected = SUBSESSION_ERROR_NONE, + .cb_desc = "Check if remove [ " + std::string(TestUserStr::user_5) + " ] callback is successful", }, } }; diff --git a/tests/api_tests/test_hlp.hpp b/tests/api_tests/test_hlp.hpp index 7ba36da..0d94599 100644 --- a/tests/api_tests/test_hlp.hpp +++ b/tests/api_tests/test_hlp.hpp @@ -28,6 +28,9 @@ namespace TestUserStr { [[maybe_unused]] static subsession_user_t user_1 = "user_1"; [[maybe_unused]] static subsession_user_t user_2 = "user_2"; [[maybe_unused]] static subsession_user_t user_3 = "user_3"; + [[maybe_unused]] static subsession_user_t user_4 = "user_4"; + [[maybe_unused]] static subsession_user_t user_5 = "user_5"; + [[maybe_unused]] static subsession_user_t user_6 = "user_6"; [[maybe_unused]] static subsession_user_t user_19 = "user__length__is_19"; };