diff options
author | Andrew Scull <ascull@google.com> | 2017-06-27 10:48:34 +0100 |
---|---|---|
committer | Andrew Scull <ascull@google.com> | 2017-06-27 10:49:44 +0100 |
commit | 6ec4f1c105bcde68a90319baf3ddf5cf5089a960 (patch) | |
tree | 9a86ea9287695fee6a1877ae4562a38d8ae5b721 | |
parent | 84d53668687add7d71db0dbb72f3745039593647 (diff) | |
download | libese-6ec4f1c105bcde68a90319baf3ddf5cf5089a960.tar.gz |
esed: remove integration tests
They are replaced by functional VTS tests.
Fix: 37530310
Fix: 37530412
Test: VtsHalWeaverV1_0TargetTest
Test: VtsHalOemLockV1_0TargetTest
Change-Id: If00e379f9803713ae7674ce487f0076bf7462eee
-rw-r--r-- | esed/Android.bp | 2 | ||||
-rw-r--r-- | esed/tests/Android.bp | 34 | ||||
-rw-r--r-- | esed/tests/oemlock_integration_tests.cpp | 99 | ||||
-rw-r--r-- | esed/tests/weaver_integration_tests.cpp | 115 |
4 files changed, 0 insertions, 250 deletions
diff --git a/esed/Android.bp b/esed/Android.bp index 997329f..f746f38 100644 --- a/esed/Android.bp +++ b/esed/Android.bp @@ -14,8 +14,6 @@ // limitations under the License. // -subdirs = ["tests"] - cc_defaults { name: "esed_defaults", proprietary: true, diff --git a/esed/tests/Android.bp b/esed/tests/Android.bp deleted file mode 100644 index b5f504e..0000000 --- a/esed/tests/Android.bp +++ /dev/null @@ -1,34 +0,0 @@ -// -// Copyright (C) 2017 The Android Open Source Project -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -// TODO: move to a VTS test -cc_test { - name: "esed_integration_tests", - proprietary: true, - srcs: [ - "weaver_integration_tests.cpp", - ], - host_supported: false, - shared_libs: [ - "android.hardware.weaver@1.0", - "libbase", - "libhidlbase", - "libhidltransport", - "libhwbinder", - "liblog", - "libutils", - ], -} diff --git a/esed/tests/oemlock_integration_tests.cpp b/esed/tests/oemlock_integration_tests.cpp deleted file mode 100644 index 9f1b148..0000000 --- a/esed/tests/oemlock_integration_tests.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <string> - -#include <android-base/logging.h> -#include <android/hardware/oemlock/1.0/IOemLock.h> -#include <hidl/Status.h> - -#include <gtest/gtest.h> - -using ::android::OK; -using ::android::sp; -using ::android::status_t; -using ::android::hardware::oemlock::V1_0::IOemLock; -using ::android::hardware::oemlock::V1_0::OemLockSecureStatus; -using ::android::hardware::oemlock::V1_0::OemLockStatus; -using ::android::hardware::hidl_string; -using ::android::hardware::hidl_vec; -using ::android::hardware::Return; -using ::android::hardware::Void; - -using ::testing::Test; - -class OemLockClientTest : public virtual Test { - public: - OemLockClientTest() { - } - virtual ~OemLockClientTest() { } - virtual void SetUp() { - service_ = IOemLock::getService(); - ASSERT_NE(service_, nullptr); - } - virtual void TearDown() { } - sp<IOemLock> service_; -}; - -TEST_F(OemLockClientTest, GetName) { - std::string name; - OemLockStatus status; - auto get_name_cb = [&status, &name](OemLockStatus cb_status, hidl_string cb_name) { - status = cb_status; - name = cb_name.c_str(); - }; - Return<void> ret = service_->getName(get_name_cb); - - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(status, OemLockStatus::OK); - EXPECT_STREQ(name.c_str(), "01"); -}; - -TEST_F(OemLockClientTest, AllowedByDeviceToggle) { - // Should always work as it is independent of carrier and boot lock states. - bool allowed = true; - OemLockStatus status; - auto get_allowed_cb = [&status, &allowed](OemLockStatus cb_status, bool cb_allowed) { - status = cb_status; - allowed = cb_allowed; - }; - - Return<OemLockStatus> set_ret = service_->setOemUnlockAllowedByDevice(allowed); - EXPECT_EQ(set_ret, OemLockStatus::OK); - Return<void> get_ret = service_->isOemUnlockAllowedByDevice(get_allowed_cb); - EXPECT_EQ(status, OemLockStatus::OK); - EXPECT_EQ(true, allowed); - - allowed = false; - set_ret = service_->setOemUnlockAllowedByDevice(allowed); - EXPECT_EQ(set_ret, OemLockStatus::OK); - get_ret = service_->isOemUnlockAllowedByDevice(get_allowed_cb); - EXPECT_EQ(status, OemLockStatus::OK); - EXPECT_EQ(false, allowed); -}; - -TEST_F(OemLockClientTest, GetAllowedByCarrierIsFalse) { - bool allowed = true; - OemLockStatus status; - auto get_allowed_cb = [&status, &allowed](OemLockStatus cb_status, bool cb_allowed) { - status = cb_status; - allowed = cb_allowed; - }; - - Return<void> ret = service_->isOemUnlockAllowedByCarrier(get_allowed_cb); - EXPECT_EQ(status, OemLockStatus::OK); - EXPECT_EQ(false, allowed); -}; diff --git a/esed/tests/weaver_integration_tests.cpp b/esed/tests/weaver_integration_tests.cpp deleted file mode 100644 index 747955c..0000000 --- a/esed/tests/weaver_integration_tests.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <string> - -#include <android-base/logging.h> -#include <android/hardware/weaver/1.0/IWeaver.h> -#include <hidl/Status.h> - -#include <gtest/gtest.h> - -using ::android::OK; -using ::android::sp; -using ::android::status_t; -using ::android::hardware::weaver::V1_0::IWeaver; -using ::android::hardware::weaver::V1_0::WeaverConfig; -using ::android::hardware::weaver::V1_0::WeaverReadResponse; -using ::android::hardware::weaver::V1_0::WeaverReadStatus; -using ::android::hardware::weaver::V1_0::WeaverStatus; -using ::android::hardware::hidl_string; -using ::android::hardware::hidl_vec; -using ::android::hardware::Return; -using ::android::hardware::Void; - -using ::testing::Test; - -const std::vector<uint8_t> KEY{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; -const std::vector<uint8_t> WRONG_KEY{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -const std::vector<uint8_t> VALUE{16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; - -struct WeaverClientTest : public Test { - sp<IWeaver> service; - - WeaverClientTest() = default; - virtual ~WeaverClientTest() = default; - void SetUp() override { - service = IWeaver::getService(); - ASSERT_NE(service, nullptr); - } - void TearDown() override {} -}; - -TEST_F(WeaverClientTest, getConfig) { - bool cbkCalled = false; - WeaverStatus status; - WeaverConfig config; - auto ret = service->getConfig([&](WeaverStatus s, WeaverConfig c) { - cbkCalled = true; - status = s; - config = c; - }); - - EXPECT_TRUE(cbkCalled); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(status, WeaverStatus::OK); - const WeaverConfig expectedConfig{64, 16, 16}; - EXPECT_EQ(config, expectedConfig); -} - -TEST_F(WeaverClientTest, writeAndReadBack) { - const uint32_t slotId = 3; - auto ret = service->write(slotId, KEY, VALUE); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(ret, WeaverStatus::OK); - - bool cbkCalled = false; - WeaverReadStatus status; - std::vector<uint8_t> readValue; - uint32_t timeout; - auto readRet = service->read(slotId, KEY, [&](WeaverReadStatus s, WeaverReadResponse r) { - cbkCalled = true; - status = s; - readValue = r.value; - timeout = r.timeout; - }); - EXPECT_TRUE(cbkCalled); - EXPECT_TRUE(readRet.isOk()); - EXPECT_EQ(status, WeaverReadStatus::OK); - EXPECT_EQ(readValue, VALUE); -} - -TEST_F(WeaverClientTest, writeAndReadWithWrongKey) { - const uint32_t slotId = 3; - auto ret = service->write(slotId, KEY, VALUE); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(ret, WeaverStatus::OK); - - bool cbkCalled = false; - WeaverReadStatus status; - std::vector<uint8_t> readValue; - uint32_t timeout; - auto readRet = service->read(slotId, WRONG_KEY, [&](WeaverReadStatus s, WeaverReadResponse r) { - cbkCalled = true; - status = s; - readValue = r.value; - timeout = r.timeout; - }); - EXPECT_TRUE(cbkCalled); - EXPECT_TRUE(readRet.isOk()); - EXPECT_EQ(status, WeaverReadStatus::INCORRECT_KEY); - EXPECT_EQ(timeout, uint32_t{0}); // first timeout is 0 -} |