aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2017-12-06 11:51:53 -0800
committerXin Li <delphij@google.com>2017-12-06 14:24:47 -0800
commitece867c88c6d98edfee26b7ef99e17e4847eeb48 (patch)
tree9ec3b7d9c312c063f4c09b9723564e8751791e11
parentef2187d2120896e7351eb2cf95b8d0e7a2f8b321 (diff)
parent83bf2811204f17eb0771cf25750f4729d280d516 (diff)
downloadlibese-ece867c88c6d98edfee26b7ef99e17e4847eeb48.tar.gz
DO NOT MERGE: Merge Oreo MR1 into master
Exempt-From-Owner-Approval: Changes already landed internally Change-Id: I143cfb6a0bf67660e9c875bc3231911812beeec8
-rw-r--r--esed/Android.bp2
-rw-r--r--esed/tests/Android.bp35
-rw-r--r--esed/tests/oemlock_integration_tests.cpp99
-rw-r--r--esed/tests/weaver_integration_tests.cpp115
-rw-r--r--libese/Android.bp3
5 files changed, 3 insertions, 251 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 b759f6f..0000000
--- a/esed/tests/Android.bp
+++ /dev/null
@@ -1,35 +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",
- ],
- cflags: ["-Wall", "-Werror"],
- 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
-}
diff --git a/libese/Android.bp b/libese/Android.bp
index 6993604..38f0a7c 100644
--- a/libese/Android.bp
+++ b/libese/Android.bp
@@ -52,7 +52,10 @@ cc_library {
"ese_sg.c",
],
+ export_include_dirs: ["include"],
+
shared_libs: ["libese-sysdeps", "liblog"],
+ export_shared_lib_headers: ["liblog"],
}
subdirs = ["tests"]