Tomáš Pecka | 991e4d5 | 2021-01-11 10:03:14 +0100 | [diff] [blame^] | 1 | #include "trompeloeil_doctest.h" |
| 2 | #include "dbus-helpers/dbus_rauc_server.h" |
| 3 | #include "pretty_printers.h" |
| 4 | #include "system/RAUC.h" |
| 5 | #include "test_log_setup.h" |
| 6 | |
| 7 | using namespace std::chrono_literals; |
| 8 | |
| 9 | TEST_CASE("Fetch RAUC data over DBus") |
| 10 | { |
| 11 | using namespace std::literals::chrono_literals; |
| 12 | |
| 13 | TEST_INIT_LOGS; |
| 14 | trompeloeil::sequence seq1; |
| 15 | |
| 16 | // setup separate connections for both client and server. Can be done using one connection only but this way it is more generic |
| 17 | auto serverConnection = sdbus::createSessionBusConnection("de.pengutronix.rauc"); |
| 18 | auto clientConnection = sdbus::createSessionBusConnection(); |
| 19 | |
| 20 | // enter client and servers event loops |
| 21 | clientConnection->enterEventLoopAsync(); |
| 22 | serverConnection->enterEventLoopAsync(); |
| 23 | |
| 24 | std::string primarySlot; |
| 25 | std::map<std::string, velia::system::RAUC::SlotProperties> status; |
| 26 | |
| 27 | SECTION("real data") |
| 28 | { |
| 29 | primarySlot = "rootfs.1"; |
| 30 | status = { |
| 31 | {"rootfs.1", { |
| 32 | {"activated.count", uint32_t {39}}, |
| 33 | {"activated.timestamp", "2021-01-13T17:20:18Z"}, |
| 34 | {"bootname", "B"}, |
| 35 | {"boot-status", "good"}, |
| 36 | {"bundle.compatible", "czechlight-clearfog"}, |
| 37 | {"bundle.version", "v4-103-g34d2f48"}, |
| 38 | {"class", "rootfs"}, |
| 39 | {"device", "/dev/mmcblk0p3"}, |
| 40 | {"installed.count", uint32_t {39}}, |
| 41 | {"installed.timestamp", "2021-01-13T17:20:15Z"}, |
| 42 | {"mountpoint", "/"}, |
| 43 | {"sha256", "07b30d065c7aad64d2006ce99fd339c929d3ca97b666fca4584b9ef726469fc4"}, |
| 44 | {"size", uint64_t {45601892}}, |
| 45 | {"state", "booted"}, |
| 46 | {"status", "ok"}, |
| 47 | {"type", "ext4"}, |
| 48 | }}, |
| 49 | {"rootfs.0", { |
| 50 | {"activated.count", uint32_t {41}}, |
| 51 | {"activated.timestamp", "2021-01-13T17:15:54Z"}, |
| 52 | {"bootname", "A"}, |
| 53 | {"boot-status", "bad"}, |
| 54 | {"bundle.compatible", "czechlight-clearfog"}, |
| 55 | {"bundle.version", "v4-104-ge80fcd4"}, |
| 56 | {"class", "rootfs"}, |
| 57 | {"device", "/dev/mmcblk0p1"}, |
| 58 | {"installed.count", uint32_t {41}}, |
| 59 | {"installed.timestamp", "2021-01-13T17:15:50Z"}, |
| 60 | {"sha256", "6d81e8f341edd17c127811f7347c7e23d18c2fc25c0bdc29ac56999cc9c25629"}, |
| 61 | {"size", uint64_t {45647664}}, |
| 62 | {"state", "inactive"}, |
| 63 | {"status", "ok"}, |
| 64 | {"type", "ext4"}, |
| 65 | }}, |
| 66 | {"cfg.1", { |
| 67 | {"bundle.compatible", "czechlight-clearfog"}, |
| 68 | {"bundle.version", "v4-103-g34d2f48"}, |
| 69 | {"class", "cfg"}, |
| 70 | {"device", "/dev/mmcblk0p4"}, |
| 71 | {"installed.count", uint32_t {39}}, |
| 72 | {"installed.timestamp", "2021-01-13T17:20:18Z"}, |
| 73 | {"mountpoint", "/cfg"}, |
| 74 | {"parent", "rootfs.1"}, |
| 75 | {"sha256", "5ca1b6c461fc194055d52b181f57c63dc1d34c19d041f6395e6f6abc039692bb"}, |
| 76 | {"size", uint64_t {108}}, |
| 77 | {"state", "active"}, |
| 78 | {"status", "ok"}, |
| 79 | {"type", "ext4"}, |
| 80 | }}, |
| 81 | {"cfg.0", { |
| 82 | {"bundle.compatible", "czechlight-clearfog"}, |
| 83 | {"bundle.version", "v4-104-ge80fcd4"}, |
| 84 | {"class", "cfg"}, |
| 85 | {"device", "/dev/mmcblk0p2"}, |
| 86 | {"installed.count", uint32_t {41}}, |
| 87 | {"installed.timestamp", "2021-01-13T17:15:54Z"}, |
| 88 | {"parent", "rootfs.0"}, |
| 89 | {"sha256", "5ca1b6c461fc194055d52b181f57c63dc1d34c19d041f6395e6f6abc039692bb"}, |
| 90 | {"size", uint64_t {108}}, |
| 91 | {"state", "inactive"}, |
| 92 | {"status", "ok"}, |
| 93 | {"type", "ext4"}, |
| 94 | }}, |
| 95 | }; |
| 96 | } |
| 97 | |
| 98 | auto server = DBusRAUCServer(*serverConnection, primarySlot, status); |
| 99 | auto rauc = std::make_shared<velia::system::RAUC>(*clientConnection); |
| 100 | |
| 101 | REQUIRE(rauc->primarySlot() == primarySlot); |
| 102 | REQUIRE(rauc->slotStatus() == status); |
| 103 | } |