| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
|
| 3 |
#include "hexdecoct.h" |
| 4 |
#include "osc-context.h" |
| 5 |
#include "tests.h" |
| 6 |
#include "user-util.h" |
| 7 |
|
| 8 |
TEST(osc) { |
| 9 |
_cleanup_free_ char *seq = NULL; |
| 10 |
|
| 11 |
log_info("boot"); |
| 12 |
ASSERT_OK(osc_context_open_boot(&seq)); |
| 13 |
hexdump(/* f= */ NULL, seq, SIZE_MAX); |
| 14 |
seq = mfree(seq); |
| 15 |
|
| 16 |
ASSERT_OK(osc_context_close(SD_ID128_ALLF, &seq)); |
| 17 |
hexdump(/* f= */ NULL, seq, SIZE_MAX); |
| 18 |
seq = mfree(seq); |
| 19 |
|
| 20 |
log_info("container"); |
| 21 |
sd_id128_t id; |
| 22 |
ASSERT_OK(osc_context_open_container("foobar", &seq, &id)); |
| 23 |
hexdump(/* f= */ NULL, seq, SIZE_MAX); |
| 24 |
seq = mfree(seq); |
| 25 |
|
| 26 |
ASSERT_OK(osc_context_close(id, &seq)); |
| 27 |
hexdump(/* f= */ NULL, seq, SIZE_MAX); |
| 28 |
seq = mfree(seq); |
| 29 |
|
| 30 |
log_info("vm"); |
| 31 |
ASSERT_OK(osc_context_open_vm("foobar", &seq, &id)); |
| 32 |
hexdump(/* f= */ NULL, seq, SIZE_MAX); |
| 33 |
seq = mfree(seq); |
| 34 |
|
| 35 |
ASSERT_OK(osc_context_close(id, &seq)); |
| 36 |
hexdump(/* f= */ NULL, seq, SIZE_MAX); |
| 37 |
seq = mfree(seq); |
| 38 |
|
| 39 |
log_info("chpriv → root"); |
| 40 |
ASSERT_OK(osc_context_open_chpriv("root", &seq, &id)); |
| 41 |
hexdump(/* f= */ NULL, seq, SIZE_MAX); |
| 42 |
seq = mfree(seq); |
| 43 |
|
| 44 |
ASSERT_OK(osc_context_close(id, &seq)); |
| 45 |
hexdump(/* f= */ NULL, seq, SIZE_MAX); |
| 46 |
seq = mfree(seq); |
| 47 |
|
| 48 |
log_info("chpriv → userxyz"); |
| 49 |
ASSERT_OK(osc_context_open_chpriv("userxyz", &seq, &id)); |
| 50 |
hexdump(/* f= */ NULL, seq, SIZE_MAX); |
| 51 |
seq = mfree(seq); |
| 52 |
|
| 53 |
ASSERT_OK(osc_context_close(id, &seq)); |
| 54 |
hexdump(/* f= */ NULL, seq, SIZE_MAX); |
| 55 |
seq = mfree(seq); |
| 56 |
|
| 57 |
log_info("chpriv → self"); |
| 58 |
_cleanup_free_ char *self = ASSERT_PTR(getusername_malloc()); |
| 59 |
ASSERT_OK(osc_context_open_chpriv(self, &seq, &id)); |
| 60 |
hexdump(/* f= */ NULL, seq, SIZE_MAX); |
| 61 |
seq = mfree(seq); |
| 62 |
|
| 63 |
ASSERT_OK(osc_context_close(id, &seq)); |
| 64 |
hexdump(/* f= */ NULL, seq, SIZE_MAX); |
| 65 |
seq = mfree(seq); |
| 66 |
|
| 67 |
log_info("session"); |
| 68 |
ASSERT_OK(osc_context_open_session("foobaruser", "session1", &seq, &id)); |
| 69 |
hexdump(/* f= */ NULL, seq, SIZE_MAX); |
| 70 |
seq = mfree(seq); |
| 71 |
|
| 72 |
ASSERT_OK(osc_context_close(id, &seq)); |
| 73 |
hexdump(/* f= */ NULL, seq, SIZE_MAX); |
| 74 |
seq = mfree(seq); |
| 75 |
|
| 76 |
log_info("service"); |
| 77 |
sd_id128_t invocation_id; |
| 78 |
ASSERT_OK(sd_id128_randomize(&invocation_id)); |
| 79 |
ASSERT_OK(osc_context_open_service("[email protected]", invocation_id, &seq)); |
| 80 |
hexdump(/* f= */ NULL, seq, SIZE_MAX); |
| 81 |
seq = mfree(seq); |
| 82 |
|
| 83 |
ASSERT_OK(osc_context_id_from_invocation_id(invocation_id, &id)); |
| 84 |
ASSERT_OK(osc_context_close(id, &seq)); |
| 85 |
hexdump(/* f= */ NULL, seq, SIZE_MAX); |
| 86 |
seq = mfree(seq); |
| 87 |
} |
| 88 |
|
| 89 |
DEFINE_TEST_MAIN(LOG_INFO); |