summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-09-15 23:58:22 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-09-16 00:06:45 +0000
commit815ffcf492bbaa530639865f35694c319dc83bd3 (patch)
tree82fb476f05899b7e3f8453e3d3ff4a3a701a6fc6
parent042c2df093a7df8146dcd166773501fae77087fc (diff)
parentd26f8c98aa84016df1b8a482cd99cacd6e6380db (diff)
downloadcore-815ffcf492bbaa530639865f35694c319dc83bd3.tar.gz
Make change and version bump to r_aml_301100000 for mainline module file: adb/apex/apex_manifest.json
Change-Id: I74c3e56e06352ad19d87fe8b2ed21addc0447dbe
-rw-r--r--adb/apex/apex_manifest.json2
-rw-r--r--adb/daemon/main.cpp5
-rw-r--r--fastboot/fuzzy_fastboot/fixtures.cpp25
-rw-r--r--fs_mgr/libsnapshot/include_test/libsnapshot/test_helpers.h17
-rw-r--r--fs_mgr/libsnapshot/partition_cow_creator_test.cpp16
-rw-r--r--fs_mgr/libsnapshot/snapshot_metadata_updater_test.cpp13
-rw-r--r--fs_mgr/libsnapshot/snapshot_test.cpp98
-rw-r--r--fs_mgr/libsnapshot/test_helpers.cpp5
-rw-r--r--init/AndroidTest.xml3
-rw-r--r--libnetutils/Android.bp15
-rw-r--r--libutils/String8.cpp8
11 files changed, 135 insertions, 72 deletions
diff --git a/adb/apex/apex_manifest.json b/adb/apex/apex_manifest.json
index 1dae854d9..2c2b40f3a 100644
--- a/adb/apex/apex_manifest.json
+++ b/adb/apex/apex_manifest.json
@@ -1,4 +1,4 @@
{
"name": "com.android.adbd",
- "version": 300901700
+ "version": 301100000
}
diff --git a/adb/daemon/main.cpp b/adb/daemon/main.cpp
index 658e24456..7a0f7ffcd 100644
--- a/adb/daemon/main.cpp
+++ b/adb/daemon/main.cpp
@@ -108,9 +108,12 @@ static void drop_privileges(int server_port) {
// AID_NET_BW_STATS to read out qtaguid statistics
// AID_READPROC for reading /proc entries across UID boundaries
// AID_UHID for using 'hid' command to read/write to /dev/uhid
+ // AID_EXT_DATA_RW for writing to /sdcard/Android/data (devices without sdcardfs)
+ // AID_EXT_OBB_RW for writing to /sdcard/Android/obb (devices without sdcardfs)
gid_t groups[] = {AID_ADB, AID_LOG, AID_INPUT, AID_INET,
AID_NET_BT, AID_NET_BT_ADMIN, AID_SDCARD_R, AID_SDCARD_RW,
- AID_NET_BW_STATS, AID_READPROC, AID_UHID};
+ AID_NET_BW_STATS, AID_READPROC, AID_UHID, AID_EXT_DATA_RW,
+ AID_EXT_OBB_RW};
minijail_set_supplementary_gids(jail.get(), arraysize(groups), groups);
// Don't listen on a port (default 5037) if running in secure mode.
diff --git a/fastboot/fuzzy_fastboot/fixtures.cpp b/fastboot/fuzzy_fastboot/fixtures.cpp
index bd76ff4ee..9b5e5f7bd 100644
--- a/fastboot/fuzzy_fastboot/fixtures.cpp
+++ b/fastboot/fuzzy_fastboot/fixtures.cpp
@@ -45,6 +45,7 @@
#include <vector>
#include <android-base/stringprintf.h>
+#include <android-base/strings.h>
#include <gtest/gtest.h>
#include "fastboot_driver.h"
@@ -76,8 +77,7 @@ int FastBootTest::MatchFastboot(usb_ifc_info* info, const std::string& local_ser
}
bool FastBootTest::IsFastbootOverTcp() {
- // serial contains ":" is treated as host ip and port number
- return (device_serial.find(":") != std::string::npos);
+ return android::base::StartsWith(device_serial, "tcp:");
}
bool FastBootTest::UsbStillAvailible() {
@@ -182,19 +182,14 @@ void FastBootTest::TearDownSerial() {
}
void FastBootTest::ConnectTcpFastbootDevice() {
- std::size_t found = device_serial.find(":");
- if (found != std::string::npos) {
- for (int i = 0; i < MAX_TCP_TRIES && !transport; i++) {
- std::string error;
- std::unique_ptr<Transport> tcp(
- tcp::Connect(device_serial.substr(0, found), tcp::kDefaultPort, &error)
- .release());
- if (tcp)
- transport =
- std::unique_ptr<TransportSniffer>(new TransportSniffer(std::move(tcp), 0));
- if (transport != nullptr) break;
- std::this_thread::sleep_for(std::chrono::milliseconds(10));
- }
+ for (int i = 0; i < MAX_TCP_TRIES && !transport; i++) {
+ std::string error;
+ std::unique_ptr<Transport> tcp(
+ tcp::Connect(device_serial.substr(4), tcp::kDefaultPort, &error).release());
+ if (tcp)
+ transport = std::unique_ptr<TransportSniffer>(new TransportSniffer(std::move(tcp), 0));
+ if (transport != nullptr) break;
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
diff --git a/fs_mgr/libsnapshot/include_test/libsnapshot/test_helpers.h b/fs_mgr/libsnapshot/include_test/libsnapshot/test_helpers.h
index 98bf56af6..8e369b052 100644
--- a/fs_mgr/libsnapshot/include_test/libsnapshot/test_helpers.h
+++ b/fs_mgr/libsnapshot/include_test/libsnapshot/test_helpers.h
@@ -180,5 +180,22 @@ class LowSpaceUserdata {
uint64_t bsize_ = 0;
};
+bool IsVirtualAbEnabled();
+
+#define SKIP_IF_NON_VIRTUAL_AB() \
+ do { \
+ if (!IsVirtualAbEnabled()) GTEST_SKIP() << "Test for Virtual A/B devices only"; \
+ } while (0)
+
+#define RETURN_IF_NON_VIRTUAL_AB_MSG(msg) \
+ do { \
+ if (!IsVirtualAbEnabled()) { \
+ std::cerr << (msg); \
+ return; \
+ } \
+ } while (0)
+
+#define RETURN_IF_NON_VIRTUAL_AB() RETURN_IF_NON_VIRTUAL_AB_MSG("")
+
} // namespace snapshot
} // namespace android
diff --git a/fs_mgr/libsnapshot/partition_cow_creator_test.cpp b/fs_mgr/libsnapshot/partition_cow_creator_test.cpp
index 526f8749a..aca55b479 100644
--- a/fs_mgr/libsnapshot/partition_cow_creator_test.cpp
+++ b/fs_mgr/libsnapshot/partition_cow_creator_test.cpp
@@ -41,8 +41,14 @@ namespace snapshot {
class PartitionCowCreatorTest : public ::testing::Test {
public:
- void SetUp() override { SnapshotTestPropertyFetcher::SetUp(); }
- void TearDown() override { SnapshotTestPropertyFetcher::TearDown(); }
+ void SetUp() override {
+ SKIP_IF_NON_VIRTUAL_AB();
+ SnapshotTestPropertyFetcher::SetUp();
+ }
+ void TearDown() override {
+ RETURN_IF_NON_VIRTUAL_AB();
+ SnapshotTestPropertyFetcher::TearDown();
+ }
};
TEST_F(PartitionCowCreatorTest, IntersectSelf) {
@@ -198,6 +204,8 @@ TEST_F(PartitionCowCreatorTest, CowSize) {
}
TEST(DmSnapshotInternals, CowSizeCalculator) {
+ SKIP_IF_NON_VIRTUAL_AB();
+
DmSnapCowSizeCalculator cc(512, 8);
unsigned long int b;
@@ -261,7 +269,9 @@ struct OptimizeOperationTestParam {
std::optional<InstallOperation> expected_output;
};
-class OptimizeOperationTest : public ::testing::TestWithParam<OptimizeOperationTestParam> {};
+class OptimizeOperationTest : public ::testing::TestWithParam<OptimizeOperationTestParam> {
+ void SetUp() override { SKIP_IF_NON_VIRTUAL_AB(); }
+};
TEST_P(OptimizeOperationTest, Test) {
InstallOperation actual_output;
EXPECT_EQ(GetParam().expected_output.has_value(),
diff --git a/fs_mgr/libsnapshot/snapshot_metadata_updater_test.cpp b/fs_mgr/libsnapshot/snapshot_metadata_updater_test.cpp
index 5530e59f0..0a16c03ce 100644
--- a/fs_mgr/libsnapshot/snapshot_metadata_updater_test.cpp
+++ b/fs_mgr/libsnapshot/snapshot_metadata_updater_test.cpp
@@ -43,11 +43,11 @@ namespace snapshot {
class SnapshotMetadataUpdaterTest : public ::testing::TestWithParam<uint32_t> {
public:
- SnapshotMetadataUpdaterTest() {
- is_virtual_ab_ = android::base::GetBoolProperty("ro.virtual_ab.enabled", false);
- }
+ SnapshotMetadataUpdaterTest() = default;
void SetUp() override {
+ SKIP_IF_NON_VIRTUAL_AB();
+
target_slot_ = GetParam();
target_suffix_ = SlotSuffixForSlotNumber(target_slot_);
SnapshotTestPropertyFetcher::SetUp(SlotSuffixForSlotNumber(1 - target_slot_));
@@ -68,7 +68,11 @@ class SnapshotMetadataUpdaterTest : public ::testing::TestWithParam<uint32_t> {
ASSERT_TRUE(FillFakeMetadata(builder_.get(), manifest_, target_suffix_));
}
- void TearDown() override { SnapshotTestPropertyFetcher::TearDown(); }
+ void TearDown() override {
+ RETURN_IF_NON_VIRTUAL_AB();
+
+ SnapshotTestPropertyFetcher::TearDown();
+ }
// Append suffix to name.
std::string T(std::string_view name) { return std::string(name) + target_suffix_; }
@@ -127,7 +131,6 @@ class SnapshotMetadataUpdaterTest : public ::testing::TestWithParam<uint32_t> {
<< ".";
}
- bool is_virtual_ab_;
std::unique_ptr<MetadataBuilder> builder_;
uint32_t target_slot_;
std::string target_suffix_;
diff --git a/fs_mgr/libsnapshot/snapshot_test.cpp b/fs_mgr/libsnapshot/snapshot_test.cpp
index 9ca2412df..dce2c41f7 100644
--- a/fs_mgr/libsnapshot/snapshot_test.cpp
+++ b/fs_mgr/libsnapshot/snapshot_test.cpp
@@ -78,9 +78,7 @@ void MountMetadata();
class SnapshotTest : public ::testing::Test {
public:
- SnapshotTest() : dm_(DeviceMapper::Instance()) {
- is_virtual_ab_ = android::base::GetBoolProperty("ro.virtual_ab.enabled", false);
- }
+ SnapshotTest() : dm_(DeviceMapper::Instance()) {}
// This is exposed for main.
void Cleanup() {
@@ -90,7 +88,7 @@ class SnapshotTest : public ::testing::Test {
protected:
void SetUp() override {
- if (!is_virtual_ab_) GTEST_SKIP() << "Test for Virtual A/B devices only";
+ SKIP_IF_NON_VIRTUAL_AB();
SnapshotTestPropertyFetcher::SetUp();
InitializeState();
@@ -101,7 +99,7 @@ class SnapshotTest : public ::testing::Test {
}
void TearDown() override {
- if (!is_virtual_ab_) return;
+ RETURN_IF_NON_VIRTUAL_AB();
lock_ = nullptr;
@@ -336,7 +334,6 @@ class SnapshotTest : public ::testing::Test {
}
static constexpr std::chrono::milliseconds snapshot_timeout_ = 5s;
- bool is_virtual_ab_;
DeviceMapper& dm_;
std::unique_ptr<SnapshotManager::LockedFile> lock_;
android::fiemap::IImageManager* image_manager_ = nullptr;
@@ -717,11 +714,13 @@ class LockTestConsumer {
class LockTest : public ::testing::Test {
public:
void SetUp() {
+ SKIP_IF_NON_VIRTUAL_AB();
first_consumer.StartHandleRequestsInBackground();
second_consumer.StartHandleRequestsInBackground();
}
void TearDown() {
+ RETURN_IF_NON_VIRTUAL_AB();
EXPECT_TRUE(first_consumer.MakeRequest(Request::EXIT));
EXPECT_TRUE(second_consumer.MakeRequest(Request::EXIT));
}
@@ -765,7 +764,7 @@ INSTANTIATE_TEST_SUITE_P(
class SnapshotUpdateTest : public SnapshotTest {
public:
void SetUp() override {
- if (!is_virtual_ab_) GTEST_SKIP() << "Test for Virtual A/B devices only";
+ SKIP_IF_NON_VIRTUAL_AB();
SnapshotTest::SetUp();
Cleanup();
@@ -827,7 +826,7 @@ class SnapshotUpdateTest : public SnapshotTest {
}
}
void TearDown() override {
- if (!is_virtual_ab_) return;
+ RETURN_IF_NON_VIRTUAL_AB();
Cleanup();
SnapshotTest::TearDown();
@@ -1360,13 +1359,17 @@ TEST_F(SnapshotUpdateTest, MergeCannotRemoveCow) {
ASSERT_EQ(UpdateState::MergeCompleted, init->ProcessUpdateState());
}
-class MetadataMountedTest : public SnapshotUpdateTest {
+class MetadataMountedTest : public ::testing::Test {
public:
+ // This is so main() can instantiate this to invoke Cleanup.
+ virtual void TestBody() override {}
void SetUp() override {
+ SKIP_IF_NON_VIRTUAL_AB();
metadata_dir_ = test_device->GetMetadataDir();
ASSERT_TRUE(ReadDefaultFstab(&fstab_));
}
void TearDown() override {
+ RETURN_IF_NON_VIRTUAL_AB();
SetUp();
// Remount /metadata
test_device->set_recovery(false);
@@ -1697,8 +1700,6 @@ class FlashAfterUpdateTest : public SnapshotUpdateTest,
};
TEST_P(FlashAfterUpdateTest, FlashSlotAfterUpdate) {
- if (!is_virtual_ab_) GTEST_SKIP() << "Test for Virtual A/B devices only";
-
// OTA client blindly unmaps all partitions that are possibly mapped.
for (const auto& name : {"sys_b", "vnd_b", "prd_b"}) {
ASSERT_TRUE(sm->UnmapUpdateSnapshot(name));
@@ -1798,15 +1799,13 @@ INSTANTIATE_TEST_SUITE_P(Snapshot, FlashAfterUpdateTest, Combine(Values(0, 1), B
class ImageManagerTest : public SnapshotTest, public WithParamInterface<uint64_t> {
protected:
void SetUp() override {
- if (!is_virtual_ab_) GTEST_SKIP() << "Test for Virtual A/B devices only";
- GTEST_SKIP() << "WIP failure b/149738928";
-
+ SKIP_IF_NON_VIRTUAL_AB();
SnapshotTest::SetUp();
userdata_ = std::make_unique<LowSpaceUserdata>();
ASSERT_TRUE(userdata_->Init(GetParam()));
}
void TearDown() override {
- if (!is_virtual_ab_) return;
+ RETURN_IF_NON_VIRTUAL_AB();
return; // BUG(149738928)
EXPECT_TRUE(!image_manager_->BackingImageExists(kImageName) ||
@@ -1848,11 +1847,6 @@ std::vector<uint64_t> ImageManagerTestParams() {
INSTANTIATE_TEST_SUITE_P(ImageManagerTest, ImageManagerTest, ValuesIn(ImageManagerTestParams()));
-} // namespace snapshot
-} // namespace android
-
-using namespace android::snapshot;
-
bool Mkdir(const std::string& path) {
if (mkdir(path.c_str(), 0700) && errno != EEXIST) {
std::cerr << "Could not mkdir " << path << ": " << strerror(errno) << std::endl;
@@ -1861,8 +1855,21 @@ bool Mkdir(const std::string& path) {
return true;
}
-int main(int argc, char** argv) {
- ::testing::InitGoogleTest(&argc, argv);
+class SnapshotTestEnvironment : public ::testing::Environment {
+ public:
+ ~SnapshotTestEnvironment() override {}
+ void SetUp() override;
+ void TearDown() override;
+
+ private:
+ std::unique_ptr<IImageManager> super_images_;
+};
+
+void SnapshotTestEnvironment::SetUp() {
+ // b/163082876: GTEST_SKIP in Environment will make atest report incorrect results. Until
+ // that is fixed, don't call GTEST_SKIP here, but instead call GTEST_SKIP in individual test
+ // suites.
+ RETURN_IF_NON_VIRTUAL_AB_MSG("Virtual A/B is not enabled, skipping global setup.\n");
std::vector<std::string> paths = {
// clang-format off
@@ -1875,18 +1882,13 @@ int main(int argc, char** argv) {
// clang-format on
};
for (const auto& path : paths) {
- if (!Mkdir(path)) {
- return 1;
- }
+ ASSERT_TRUE(Mkdir(path));
}
// Create this once, otherwise, gsid will start/stop between each test.
test_device = new TestDeviceInfo();
sm = SnapshotManager::New(test_device);
- if (!sm) {
- std::cerr << "Could not create snapshot manager\n";
- return 1;
- }
+ ASSERT_NE(nullptr, sm) << "Could not create snapshot manager";
// Clean up previous run.
MetadataMountedTest().TearDown();
@@ -1894,31 +1896,35 @@ int main(int argc, char** argv) {
SnapshotTest().Cleanup();
// Use a separate image manager for our fake super partition.
- auto super_images = IImageManager::Open("ota/test/super", 10s);
- if (!super_images) {
- std::cerr << "Could not create image manager\n";
- return 1;
- }
+ super_images_ = IImageManager::Open("ota/test/super", 10s);
+ ASSERT_NE(nullptr, super_images_) << "Could not create image manager";
// Clean up any old copy.
- DeleteBackingImage(super_images.get(), "fake-super");
+ DeleteBackingImage(super_images_.get(), "fake-super");
// Create and map the fake super partition.
static constexpr int kImageFlags =
IImageManager::CREATE_IMAGE_DEFAULT | IImageManager::CREATE_IMAGE_ZERO_FILL;
- if (!super_images->CreateBackingImage("fake-super", kSuperSize, kImageFlags)) {
- std::cerr << "Could not create fake super partition\n";
- return 1;
- }
- if (!super_images->MapImageDevice("fake-super", 10s, &fake_super)) {
- std::cerr << "Could not map fake super partition\n";
- return 1;
- }
+ ASSERT_TRUE(super_images_->CreateBackingImage("fake-super", kSuperSize, kImageFlags))
+ << "Could not create fake super partition";
+
+ ASSERT_TRUE(super_images_->MapImageDevice("fake-super", 10s, &fake_super))
+ << "Could not map fake super partition";
test_device->set_fake_super(fake_super);
+}
- auto result = RUN_ALL_TESTS();
+void SnapshotTestEnvironment::TearDown() {
+ RETURN_IF_NON_VIRTUAL_AB();
+ if (super_images_ != nullptr) {
+ DeleteBackingImage(super_images_.get(), "fake-super");
+ }
+}
- DeleteBackingImage(super_images.get(), "fake-super");
+} // namespace snapshot
+} // namespace android
- return result;
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ ::testing::AddGlobalTestEnvironment(new ::android::snapshot::SnapshotTestEnvironment());
+ return RUN_ALL_TESTS();
}
diff --git a/fs_mgr/libsnapshot/test_helpers.cpp b/fs_mgr/libsnapshot/test_helpers.cpp
index de3d91246..b07bf9182 100644
--- a/fs_mgr/libsnapshot/test_helpers.cpp
+++ b/fs_mgr/libsnapshot/test_helpers.cpp
@@ -18,6 +18,7 @@
#include <android-base/file.h>
#include <android-base/logging.h>
+#include <android-base/properties.h>
#include <android-base/strings.h>
#include <android-base/unique_fd.h>
#include <gtest/gtest.h>
@@ -241,5 +242,9 @@ uint64_t LowSpaceUserdata::bsize() const {
return bsize_;
}
+bool IsVirtualAbEnabled() {
+ return android::base::GetBoolProperty("ro.virtual_ab.enabled", false);
+}
+
} // namespace snapshot
} // namespace android
diff --git a/init/AndroidTest.xml b/init/AndroidTest.xml
index 920dc6c58..95f97e3fd 100644
--- a/init/AndroidTest.xml
+++ b/init/AndroidTest.xml
@@ -29,4 +29,7 @@
<option name="module-name" value="CtsInitTestCases" />
<option name="runtime-hint" value="65s" />
</test>
+ <!-- Controller that will skip the module if a native bridge situation is detected -->
+ <!-- For example: module wants to run arm32 and device is x86 -->
+ <object type="module_controller" class="com.android.tradefed.testtype.suite.module.NativeBridgeModuleController" />
</configuration>
diff --git a/libnetutils/Android.bp b/libnetutils/Android.bp
index 268496f7c..65371fa63 100644
--- a/libnetutils/Android.bp
+++ b/libnetutils/Android.bp
@@ -23,6 +23,21 @@ cc_library_shared {
export_include_dirs: ["include"],
}
+cc_library_static {
+ name: "libipchecksum",
+
+ srcs: [
+ "checksum.c",
+ ],
+
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+
+ export_include_dirs: ["include"],
+}
+
cc_binary {
name: "dhcpdbg",
diff --git a/libutils/String8.cpp b/libutils/String8.cpp
index d13548e4c..9d50e0bc5 100644
--- a/libutils/String8.cpp
+++ b/libutils/String8.cpp
@@ -322,8 +322,14 @@ status_t String8::appendFormatV(const char* fmt, va_list args)
n = vsnprintf(nullptr, 0, fmt, tmp_args);
va_end(tmp_args);
- if (n != 0) {
+ if (n < 0) return UNKNOWN_ERROR;
+
+ if (n > 0) {
size_t oldLength = length();
+ if ((size_t)n > SIZE_MAX - 1 ||
+ oldLength > SIZE_MAX - (size_t)n - 1) {
+ return NO_MEMORY;
+ }
char* buf = lockBuffer(oldLength + n);
if (buf) {
vsnprintf(buf + oldLength, n + 1, fmt, args);