Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 08afd215 authored by David Anderson's avatar David Anderson
Browse files

vts_libsnapshot_test: Address flake in scratch metadata test.

Clean up a previous failed/interrupted test run before proceeding with
the test.

Bug: 377398696
Test: manual test
Change-Id: I7479ebc06bff6738597702a568ac66c2a2b7ab22
parent ea5715c1
Loading
Loading
Loading
Loading
+17 −7
Original line number Diff line number Diff line
@@ -25,6 +25,13 @@
#include <sys/vfs.h>
#include <unistd.h>

#include <algorithm>
#include <filesystem>
#include <memory>
#include <optional>
#include <string>
#include <vector>

#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/macros.h>
@@ -41,12 +48,6 @@
#include <fstab/fstab.h>
#include <liblp/builder.h>
#include <storage_literals/storage_literals.h>
#include <algorithm>
#include <filesystem>
#include <memory>
#include <optional>
#include <string>
#include <vector>

#include "device_info.h"
#include "scratch_super.h"
@@ -60,9 +61,18 @@ namespace android {
namespace snapshot {

static bool UmountScratch() {
    Fstab fstab;
    if (!ReadFstabFromProcMounts(&fstab)) {
        LOG(ERROR) << "Cannot read /proc/mounts";
        return false;
    }
    if (GetEntryForMountPoint(&fstab, kOtaMetadataMount) == nullptr) {
        return true;
    }

    auto ota_dir = std::string(kOtaMetadataMount) + "/" + "ota";
    std::error_code ec;

    std::error_code ec;
    if (std::filesystem::remove_all(ota_dir, ec) == static_cast<std::uintmax_t>(-1)) {
        LOG(ERROR) << "Failed to remove OTA directory: " << ec.message();
        return false;
+1 −0
Original line number Diff line number Diff line
@@ -1345,6 +1345,7 @@ class SnapshotUpdateTest : public SnapshotTest {

TEST_F(SnapshotUpdateTest, SuperOtaMetadataTest) {
    auto info = new TestDeviceInfo(fake_super);
    ASSERT_TRUE(CleanupScratchOtaMetadataIfPresent(info));
    ASSERT_TRUE(CreateScratchOtaMetadataOnSuper(info));
    std::string scratch_device = GetScratchOtaMetadataPartition();
    ASSERT_NE(scratch_device, "");