#include "test_hlp.hpp"
-const int action_items = 8;
+const int action_items = 20;
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<subsession_5001>( 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<subsession_5001>(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<subsession_5001>( 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<subsession_5001>(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<subsession_5001>( 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<subsession_5001>(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<subsession_5001>( 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<subsession_5001>(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<subsession_5001>( 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<subsession_5001>(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<subsession_5001>( 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<subsession_5001>(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", },
}
};
#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<std::array<api_call_res_t, action_items>>;
.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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>(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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>(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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>(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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>(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", },
}
};
TEST(subsession_switch_user_completion, APISwitchUserCompletion) {
- const int prologue_items = 4;
+ const int prologue_items = 12;
using ud_prologue_t = ud_data_t<std::array<api_call_res_t, prologue_items>>;
ud_prologue_t prologue = { .loop = g_main_loop_new(NULL, FALSE),
.results = std::array<api_call_res_t, prologue_items> {
.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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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<ud_prologue_t, api_call_res_t>, &prologue, prologue.loop);
summarize<prologue_items>(prologue.results);
- const int action_items = 2;
+ const int action_items = 7;
using ud_t = ud_data_t<std::array<api_call_res_t, action_items>>;
ud_t ud_data = { .loop = g_main_loop_new(NULL, FALSE),
.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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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", },
}
};
EXPECT_EQ(res, SUBSESSION_ERROR_NONE);
- const int epilogue_items = 3;
+ const int epilogue_items = 5;
using ud_epilogue_t = ud_data_t<std::array<api_call_res_t, epilogue_items>>;
ud_epilogue_t epilogue = { .loop = g_main_loop_new(NULL, FALSE),
.results = std::array<api_call_res_t, epilogue_items> {
.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<subsession_5001>( 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<subsession_5001>( 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", },
}
};
TEST(subsession_switch_user_wait, APISwitchUserStarted) {
- const int prologue_items = 4;
+ const int prologue_items = 12;
using ud_prologue_t = ud_data_t<std::array<api_call_res_t, prologue_items>>;
ud_prologue_t prologue = { .loop = g_main_loop_new(NULL, FALSE),
.results = std::array<api_call_res_t, prologue_items> {
.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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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<ud_prologue_t, api_call_res_t>, &prologue, prologue.loop);
summarize<prologue_items>(prologue.results);
- const int action_items = 2;
+ const int action_items = 7;
using ud_t = ud_data_t<std::array<api_call_res_t, action_items>>;
ud_t ud_data = { .loop = g_main_loop_new(NULL, FALSE),
.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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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", },
}
};
EXPECT_EQ(res, SUBSESSION_ERROR_NONE);
- const int epilogue_items = 3;
+ const int epilogue_items = 5;
using ud_epilogue_t = ud_data_t<std::array<api_call_res_t, epilogue_items>>;
ud_epilogue_t epilogue = { .loop = g_main_loop_new(NULL, FALSE),
.results = std::array<api_call_res_t, epilogue_items> {
.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<subsession_5001>( 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<subsession_5001>( 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", },
}
};
// Test
-const int action_items = 15;
+const int action_items = 29;
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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( TestUserStr::user_3)),
.expected = SUBSESSION_ERROR_NONE,
.desc = "Check if switch to [ " + std::string(TestUserStr::user_3) + " ] is successful",
.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<subsession_5001>( TestUserStr::user_2)),
.expected = SUBSESSION_ERROR_NONE,
.desc = "Check if switch to [ " + std::string(TestUserStr::user_2) + " ] is successful",
.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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( TestUserStr::user_1)),
.expected = SUBSESSION_ERROR_NONE,
.desc = "Check if switch to [ " + std::string(TestUserStr::user_1) + " ] is successful",
.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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( TestUserStr::user_0)),
.expected = SUBSESSION_ERROR_NONE,
.desc = "Check if switch to [ " + 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 -> fixed-size
+ api_call_res_t{ .call_result = std::move(subsession_switch_user_l<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>( 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<subsession_5001>(TestUserStr::user_1)),
.expected = SUBSESSION_ERROR_NONE,
.desc = "Check if remove [ " + std::string(TestUserStr::user_1) + " ] is successful",
.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<subsession_5001>(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<subsession_5001>(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", },
}
};
[[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";
};