~aleteoryx/muditaos

7797a2eaf0ca3d9e1132e9e957273b85750faf35 — Jakub Pyszczak 5 years ago 97336d9
[EGD-5266] Fix test harness

Covers harness issues that occures on experimental branch
due to the new filesystem implementation.
M board/linux/libiosyscalls/src/iosyscalls.cpp => board/linux/libiosyscalls/src/iosyscalls.cpp +1 -1
@@ 26,9 26,9 @@ namespace
                                        "/run/user",
                                        "/home",
                                        "/proc",
                                        "/dev/shm",
                                        "PurePhone.img",
                                        "MuditaOS.log",
                                        "/tmp",
                                        nullptr};

    constexpr const char *IMAGE_PATHS[]{"/sys", nullptr};

M module-db/tests/EventsTable_tests.cpp => module-db/tests/EventsTable_tests.cpp +39 -39
@@ 165,11 165,11 @@ TEST_CASE("Events Table tests")
        }
        CHECK(eventsTbl.count() == 0);

        uint32_t numberOfEvents       = 7;
        TimePoint startDate           = TimePointFromString("2019-10-20 14:30:00");
        TimePoint endDate             = TimePointFromString("2019-10-20 15:30:00");
        testRow1.date_from            = startDate;
        testRow1.date_till            = endDate;
        uint32_t numberOfEvents = 7;
        TimePoint startDate     = TimePointFromString("2019-10-20 14:30:00");
        TimePoint endDate       = TimePointFromString("2019-10-20 15:30:00");
        testRow1.date_from      = startDate;
        testRow1.date_till      = endDate;
        CHECK(eventsTbl.addDaily(testRow1));
        CHECK(eventsTbl.count() == numberOfEvents);



@@ 200,11 200,11 @@ TEST_CASE("Events Table tests")
        }
        CHECK(eventsTbl.count() == 0);

        uint32_t numberOfEvents       = 4;
        TimePoint startDate           = TimePointFromString("2019-10-20 14:30:00");
        TimePoint endDate             = TimePointFromString("2019-10-20 15:30:00");
        testRow1.date_from            = startDate;
        testRow1.date_till            = endDate;
        uint32_t numberOfEvents = 4;
        TimePoint startDate     = TimePointFromString("2019-10-20 14:30:00");
        TimePoint endDate       = TimePointFromString("2019-10-20 15:30:00");
        testRow1.date_from      = startDate;
        testRow1.date_till      = endDate;
        CHECK(eventsTbl.addWeekly(testRow1));
        CHECK(eventsTbl.count() == numberOfEvents);



@@ 235,11 235,11 @@ TEST_CASE("Events Table tests")
        }
        CHECK(eventsTbl.count() == 0);

        uint32_t numberOfEvents       = 4;
        TimePoint startDate           = TimePointFromString("2019-10-20 14:30:00");
        TimePoint endDate             = TimePointFromString("2019-10-20 15:30:00");
        testRow1.date_from            = startDate;
        testRow1.date_till            = endDate;
        uint32_t numberOfEvents = 4;
        TimePoint startDate     = TimePointFromString("2019-10-20 14:30:00");
        TimePoint endDate       = TimePointFromString("2019-10-20 15:30:00");
        testRow1.date_from      = startDate;
        testRow1.date_till      = endDate;
        CHECK(eventsTbl.addTwoWeeks(testRow1));
        CHECK(eventsTbl.count() == numberOfEvents);



@@ 438,9 438,9 @@ TEST_CASE("Events Table tests")
        {
            uint32_t customRepeatOption =
                static_cast<uint32_t>(weekDayOption::monday) + static_cast<uint32_t>(weekDayOption::wednesday);
            uint32_t numberOfEvents               = 9;
            TimePoint originalStartDate           = TimePointFromString("2020-12-10 14:30:00"); // thursday
            TimePoint originalEndDate             = TimePointFromString("2020-12-10 15:30:00"); // thursday
            uint32_t numberOfEvents     = 9;
            TimePoint originalStartDate = TimePointFromString("2020-12-10 14:30:00"); // thursday
            TimePoint originalEndDate   = TimePointFromString("2020-12-10 15:30:00"); // thursday

            check_custom_repeat(customRepeatOption, numberOfEvents, originalStartDate, originalEndDate);
        }


@@ 450,19 450,19 @@ TEST_CASE("Events Table tests")
            uint32_t customRepeatOption =
                static_cast<uint32_t>(weekDayOption::monday) + static_cast<uint32_t>(weekDayOption::wednesday) +
                static_cast<uint32_t>(weekDayOption::tuesday) + static_cast<uint32_t>(weekDayOption::sunday);
            uint32_t numberOfEvents               = 17;
            TimePoint originalStartDate           = TimePointFromString("2020-12-10 14:30:00"); // thursday
            TimePoint originalEndDate             = TimePointFromString("2020-12-10 15:30:00"); // thursday
            uint32_t numberOfEvents     = 17;
            TimePoint originalStartDate = TimePointFromString("2020-12-10 14:30:00"); // thursday
            TimePoint originalEndDate   = TimePointFromString("2020-12-10 15:30:00"); // thursday

            check_custom_repeat(customRepeatOption, numberOfEvents, originalStartDate, originalEndDate);
        }

        SECTION("Repeat Saturdays (original thursday)")
        {
            uint32_t customRepeatOption           = static_cast<uint32_t>(weekDayOption::saturday);
            uint32_t numberOfEvents               = 5;
            TimePoint originalStartDate           = TimePointFromString("2020-12-10 14:30:00"); // thursday
            TimePoint originalEndDate             = TimePointFromString("2020-12-10 15:30:00"); // thursday
            uint32_t customRepeatOption = static_cast<uint32_t>(weekDayOption::saturday);
            uint32_t numberOfEvents     = 5;
            TimePoint originalStartDate = TimePointFromString("2020-12-10 14:30:00"); // thursday
            TimePoint originalEndDate   = TimePointFromString("2020-12-10 15:30:00"); // thursday

            check_custom_repeat(customRepeatOption, numberOfEvents, originalStartDate, originalEndDate);
        }


@@ 516,10 516,10 @@ TEST_CASE("Events Table tests")
        CHECK(eventsTbl.count() == 6);

        std::string newTitle = "Updated Title", newProviderID = "PurePhoneUpdated";
        TimePoint newDateFrom           = TimePointFromString("2020-10-20 15:00:00"),
                  newDateTill           = TimePointFromString("2020-10-20 16:00:00");
        uint32_t newReminder            = static_cast<uint32_t>(Reminder::one_week_before);
        uint32_t newRepeatOption        = static_cast<uint32_t>(Repeat::biweekly);
        TimePoint newDateFrom    = TimePointFromString("2020-10-20 15:00:00"),
                  newDateTill    = TimePointFromString("2020-10-20 16:00:00");
        uint32_t newReminder     = static_cast<uint32_t>(Reminder::one_week_before);
        uint32_t newRepeatOption = static_cast<uint32_t>(Repeat::biweekly);

        /// check title and provider id update
        auto entryToUpdate        = eventsTbl.getById(testRow6.ID);


@@ 571,11 571,11 @@ TEST_CASE("Events Table tests")
        CHECK(eventsTbl.count() == 6);

        std::string newTitle = "Updated Title", newProviderType = "PurePhoneUpdate", newProviderID = "newID",
                    newProvideriCalUid  = "new iCalUid";
        TimePoint newDateFrom           = TimePointFromString("2020-10-20 15:00:00"),
                  newDateTill           = TimePointFromString("2020-10-20 16:00:00");
        uint32_t newReminder            = static_cast<uint32_t>(Reminder::one_week_before);
        uint32_t newRepeatOption        = static_cast<uint32_t>(Repeat::biweekly);
                    newProvideriCalUid = "new iCalUid";
        TimePoint newDateFrom          = TimePointFromString("2020-10-20 15:00:00"),
                  newDateTill          = TimePointFromString("2020-10-20 16:00:00");
        uint32_t newReminder           = static_cast<uint32_t>(Reminder::one_week_before);
        uint32_t newRepeatOption       = static_cast<uint32_t>(Repeat::biweekly);

        /// check title and provider id update
        auto entryToUpdate             = eventsTbl.getById(testRow6.ID);


@@ 629,11 629,11 @@ TEST_CASE("Events Table tests")
        CHECK(eventsTbl.count() == 6);

        std::string newTitle = "Updated Title", newProviderType = "PurePhoneUpdate", newProviderID = "newID",
                    newProvideriCalUid  = "new iCalUid";
        TimePoint newDateFrom           = TimePointFromString("2020-10-20 15:00:00"),
                  newDateTill           = TimePointFromString("2020-10-20 16:00:00");
        uint32_t newReminder            = static_cast<uint32_t>(Reminder::one_week_before);
        uint32_t newRepeatOption        = static_cast<uint32_t>(Repeat::biweekly);
                    newProvideriCalUid = "new iCalUid";
        TimePoint newDateFrom          = TimePointFromString("2020-10-20 15:00:00"),
                  newDateTill          = TimePointFromString("2020-10-20 16:00:00");
        uint32_t newReminder           = static_cast<uint32_t>(Reminder::one_week_before);
        uint32_t newRepeatOption       = static_cast<uint32_t>(Repeat::biweekly);

        /// check title and provider id update
        auto entryToUpdate             = eventsTbl.getByUID(testRow6.UID);

M module-services/service-desktop/endpoints/backup/BackupRestore.cpp => module-services/service-desktop/endpoints/backup/BackupRestore.cpp +8 -2
@@ 105,8 105,14 @@ bool BackupRestore::CreateBackupDir()
    LOG_INFO("CreateBackupDir: creating backup directory %s...", backupOSPath.c_str());

    if (!std::filesystem::is_directory(backupOSPath.c_str())) {
        if (!std::filesystem::create_directory(backupOSPath.c_str())) {
            LOG_ERROR("CreateBackupDir: creating backup directory %s failed.", backupOSPath.c_str());
        try {
            if (!std::filesystem::create_directory(backupOSPath.c_str())) {
                LOG_ERROR("CreateBackupDir: creating backup directory %s failed.", backupOSPath.c_str());
                return false;
            }
        }
        catch (const std::filesystem::filesystem_error &err) {
            LOG_FATAL("Exception while creating dir %s", backupOSPath.c_str());
            return false;
        }
    }

M module-services/service-desktop/endpoints/deviceInfo/DeviceInfoEndpoint.cpp => module-services/service-desktop/endpoints/deviceInfo/DeviceInfoEndpoint.cpp +1 -1
@@ 40,7 40,7 @@ auto DeviceInfoEndpoint::getDeviceInfo(Context &context) -> bool
        return false;
    }
    auto totalMbytes = (vfstat.f_frsize * vfstat.f_blocks) / 1024LLU / 1024LLU;
    auto freeMbytes  = (vfstat.f_ffree * vfstat.f_bsize) / 1024LLU / 1024LLU;
    auto freeMbytes  = (vfstat.f_bfree * vfstat.f_bsize) / 1024LLU / 1024LLU;
    auto freePercent = (freeMbytes * 100) / totalMbytes;

    context.setResponseBody(json11::Json::object(

M module-services/service-desktop/endpoints/factoryReset/FactoryReset.cpp => module-services/service-desktop/endpoints/factoryReset/FactoryReset.cpp +8 -2
@@ 144,8 144,14 @@ namespace FactoryReset

                LOG_INFO("FactoryReset: restoring dir  %s into %s...", sourcepath.c_str(), targetpath.c_str());

                if (std::filesystem::create_directory(targetpath.c_str())) {
                    LOG_ERROR("FactoryReset: create dir %s failed", targetpath.c_str());
                try {
                    if (std::filesystem::create_directory(targetpath.c_str())) {
                        LOG_ERROR("FactoryReset: create dir %s failed", targetpath.c_str());
                        return false;
                    }
                }
                catch (const std::filesystem::filesystem_error &err) {
                    LOG_FATAL("Exception while creating dir %s", targetpath.c_str());
                    return false;
                }


M test/pytest/service-desktop/test_backup.py => test/pytest/service-desktop/test_backup.py +1 -1
@@ 29,5 29,5 @@ def test_backup(harness):
    body = {"backupUpload": True}
    ret = harness.endpoint_request("backup", "post", body)
    assert ret["status"] == status["OK"]
    assert ret["body"]["backupUpload"] is False
    assert ret["body"]["backupUpload"] is True