Add more test methods to IMemoryTest
Add haveSomeMemoryBlock to test transport of the hidl_memory_block. Add set(hidl_memory) & get(IMemoryToken) to test IMemoryToken Test: hidl_test Bug: 68295540 Change-Id: I08bcfae256de9db7dd647cde0ccbee214b598f47
This commit is contained in:
parent
6a5daf8cac
commit
4e7ccc4cb9
5 changed files with 40 additions and 2 deletions
|
@ -7,6 +7,8 @@ hidl_interface {
|
|||
"IMemoryTest.hal",
|
||||
],
|
||||
interfaces: [
|
||||
"android.hidl.memory.token@1.0",
|
||||
"android.hidl.memory.block@1.0",
|
||||
"android.hidl.base@1.0",
|
||||
],
|
||||
gen_java: false,
|
||||
|
|
|
@ -16,7 +16,13 @@
|
|||
|
||||
package android.hardware.tests.memory@1.0;
|
||||
|
||||
import android.hidl.memory.token@1.0::IMemoryToken;
|
||||
import android.hidl.memory.block@1.0::MemoryBlock;
|
||||
|
||||
interface IMemoryTest {
|
||||
haveSomeMemory(memory mem) generates(memory mem);
|
||||
fillMemory(memory memory_in, uint8_t filler);
|
||||
haveSomeMemoryBlock(MemoryBlock blk) generates(MemoryBlock blk);
|
||||
set(memory mem) generates();
|
||||
get()generates(IMemoryToken token);
|
||||
};
|
||||
|
|
|
@ -28,6 +28,7 @@ cc_library {
|
|||
"liblog",
|
||||
"libutils",
|
||||
"android.hidl.memory@1.0",
|
||||
"android.hidl.memory.token@1.0",
|
||||
],
|
||||
|
||||
// These are static libs only for testing purposes and portability. Shared
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include <log/log.h>
|
||||
|
||||
#include <hidlmemory/HidlMemoryToken.h>
|
||||
#include <hidlmemory/mapping.h>
|
||||
|
||||
#include <android/hidl/memory/1.0/IMemory.h>
|
||||
|
@ -60,6 +61,22 @@ Return<void> Memory::fillMemory(const hidl_memory& memory_in, uint8_t filler) {
|
|||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Memory::haveSomeMemoryBlock(const MemoryBlock& blk, haveSomeMemoryBlock_cb _hidl_cb) {
|
||||
_hidl_cb(blk);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Memory::set(const hidl_memory& mem) {
|
||||
sp<HidlMemory> hidlMem = HidlMemory::getInstance(mem);
|
||||
if (hidlMem->valid()) {
|
||||
mSavedMemoryToken = new HidlMemoryToken(hidlMem);
|
||||
}
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<sp<IMemoryToken>> Memory::get() {
|
||||
return mSavedMemoryToken;
|
||||
}
|
||||
|
||||
IMemoryTest* HIDL_FETCH_IMemoryTest(const char* /* name */) {
|
||||
return new Memory();
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <android/hardware/tests/memory/1.0/IMemoryTest.h>
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <hidlmemory/HidlMemoryToken.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
|
@ -28,14 +29,17 @@ namespace memory {
|
|||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::tests::memory::V1_0::IMemoryTest;
|
||||
using ::android::sp;
|
||||
using ::android::hardware::hidl_array;
|
||||
using ::android::hardware::hidl_memory;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::HidlMemoryToken;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::sp;
|
||||
using ::android::hardware::tests::memory::V1_0::IMemoryTest;
|
||||
using ::android::hidl::memory::block::V1_0::MemoryBlock;
|
||||
using ::android::hidl::memory::token::V1_0::IMemoryToken;
|
||||
|
||||
struct Memory : public IMemoryTest {
|
||||
// Methods from ::android::hardware::tests::memory::V1_0::IMemoryTest follow.
|
||||
|
@ -43,6 +47,14 @@ struct Memory : public IMemoryTest {
|
|||
|
||||
Return<void> fillMemory(const hidl_memory& memory_in, uint8_t filler) override;
|
||||
|
||||
Return<void> haveSomeMemoryBlock(const MemoryBlock& blk,
|
||||
haveSomeMemoryBlock_cb _hidl_cb) override;
|
||||
Return<void> set(const ::android::hardware::hidl_memory& mem) override;
|
||||
|
||||
Return<sp<IMemoryToken>> get() override;
|
||||
|
||||
protected:
|
||||
sp<HidlMemoryToken> mSavedMemoryToken;
|
||||
};
|
||||
|
||||
extern "C" IMemoryTest* HIDL_FETCH_IMemoryTest(const char* name);
|
||||
|
|
Loading…
Reference in a new issue