Skip to content

Commit

Permalink
Merge "Add VtsHidlAllocatorV1_0TargetTest to vts." into rvc-dev am: c…
Browse files Browse the repository at this point in the history
…cea7be

Change-Id: Ic20fb755b4e65b11affd16abc237a1fadc03cbbe
  • Loading branch information
smore-lore authored and android-build-merge-worker-robot committed Apr 9, 2020
2 parents db7ccd3 + ccea7be commit 02a5a57
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 78 deletions.
3 changes: 3 additions & 0 deletions TEST_MAPPING
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
{
"name": "libhidl_test"
},
{
"name": "VtsHidlAllocatorV1_0TargetTest"
},
{
"name": "hal_implementation_test"
}
Expand Down
1 change: 1 addition & 0 deletions transport/allocator/1.0/vts/functional/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ cc_test {
static_libs: [
"[email protected]",
],
test_suites: ["general-tests", "vts"],
}

22 changes: 0 additions & 22 deletions transport/allocator/1.0/vts/functional/Android.mk

This file was deleted.

32 changes: 0 additions & 32 deletions transport/allocator/1.0/vts/functional/AndroidTest.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
* limitations under the License.
*/

#include <VtsHalHidlTargetTestBase.h>
#include <VtsHalHidlTargetTestEnvBase.h>
#include <android-base/logging.h>
#include <android/hidl/allocator/1.0/IAllocator.h>
#include <android/hidl/memory/1.0/IMemory.h>
#include <gtest/gtest.h>
#include <hidl/GtestPrinter.h>
#include <hidl/ServiceManagement.h>
#include <hidlmemory/mapping.h>

using ::android::sp;
Expand All @@ -32,20 +33,10 @@ using ::android::hidl::memory::V1_0::IMemory;
#define ASSERT_OK(ret) ASSERT_TRUE((ret).isOk())
#define EXPECT_OK(ret) EXPECT_TRUE((ret).isOk())

class AllocatorEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
public:
virtual void registerTestServices() override { registerTestService<IAllocator>(); }

static AllocatorEnvironment* instance() {
static AllocatorEnvironment* instance = new AllocatorEnvironment();
return instance;
};
};

class AllocatorHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
class AllocatorHidlTest : public ::testing::TestWithParam<std::string> {
public:
virtual void SetUp() override {
allocator = getService<IAllocator>(AllocatorEnvironment::instance());
allocator = IAllocator::getService(GetParam());
ASSERT_NE(allocator, nullptr);
}

Expand Down Expand Up @@ -88,21 +79,21 @@ class AllocatorHidlTest : public ::testing::VtsHalHidlTargetTestBase {
sp<IAllocator> allocator;
};

TEST_F(AllocatorHidlTest, TestAllocateSizes) {
TEST_P(AllocatorHidlTest, TestAllocateSizes) {
for (size_t size : {1, 1023, 1024, 1025, 4096}) {
expectAllocateSuccess(size);
}
}

TEST_F(AllocatorHidlTest, TestBatchAllocateSizes) {
TEST_P(AllocatorHidlTest, TestBatchAllocateSizes) {
for (size_t count : {1, 1, 2, 3, 10}) {
for (size_t size : {1, 1023, 1024, 1025, 4096}) {
expectBatchAllocateSuccess(size, count);
}
}
}

TEST_F(AllocatorHidlTest, TestCommit) {
TEST_P(AllocatorHidlTest, TestCommit) {
constexpr size_t kSize = 1337;

sp<IMemory> memory = expectAllocateSuccess(kSize);
Expand Down Expand Up @@ -131,9 +122,7 @@ TEST_F(AllocatorHidlTest, TestCommit) {
}
}

int main(int argc, char** argv) {
::testing::AddGlobalTestEnvironment(AllocatorEnvironment::instance());
::testing::InitGoogleTest(&argc, argv);
AllocatorEnvironment::instance()->init(&argc, argv);
return RUN_ALL_TESTS();
}
INSTANTIATE_TEST_SUITE_P(
PerInstance, AllocatorHidlTest,
testing::ValuesIn(android::hardware::getAllHalInstanceNames(IAllocator::descriptor)),
android::hardware::PrintInstanceNameToString);

0 comments on commit 02a5a57

Please sign in to comment.