snapuesrd: Build snapuserd_test on host.

Bug: 288273605
Test: snapuserd_test
Change-Id: I10e099feff30f09b8c9f0b9dcca64336cb0861b9
This commit is contained in:
David Anderson 2023-08-07 15:25:07 -07:00
parent 27add51152
commit 0ec9b0eb92
3 changed files with 14 additions and 3 deletions

View file

@ -90,6 +90,7 @@ cc_library_static {
ramdisk_available: true,
vendor_ramdisk_available: true,
recovery_available: true,
host_supported: true,
}
cc_defaults {
@ -256,4 +257,5 @@ cc_test {
},
auto_gen_config: true,
require_root: false,
host_supported: true,
}

View file

@ -14,6 +14,8 @@
#pragma once
#include <linux/types.h>
namespace android {
namespace snapshot {
@ -70,7 +72,7 @@ struct disk_header {
/* In sectors */
uint32_t chunk_size;
} __packed;
} __attribute__((packed));
// A disk exception is a mapping of old_chunk to new_chunk
// old_chunk is the chunk ID of a dm-snapshot device.
@ -78,7 +80,7 @@ struct disk_header {
struct disk_exception {
uint64_t old_chunk;
uint64_t new_chunk;
} __packed;
} __attribute__((packed));
// Control structures to communicate with dm-user
// It comprises of header and a payload

View file

@ -41,6 +41,7 @@
#include "handler_manager.h"
#include "snapuserd_core.h"
#include "testing/dm_user_harness.h"
#include "testing/host_harness.h"
#include "testing/temp_device.h"
#include "utility.h"
@ -80,7 +81,11 @@ class SnapuserdTestBase : public ::testing::Test {
};
void SnapuserdTestBase::SetUp() {
#if __ANDROID__
harness_ = std::make_unique<DmUserTestHarness>();
#else
harness_ = std::make_unique<HostTestHarness>();
#endif
}
void SnapuserdTestBase::TearDown() {}
@ -269,7 +274,9 @@ void SnapuserdTest::TearDown() {
}
void SnapuserdTest::Shutdown() {
ASSERT_TRUE(dmuser_dev_->Destroy());
if (dmuser_dev_) {
ASSERT_TRUE(dmuser_dev_->Destroy());
}
auto misc_device = "/dev/dm-user/" + system_device_ctrl_name_;
ASSERT_TRUE(handlers_->DeleteHandler(system_device_ctrl_name_));