Merge "Move CF only tests to CF test mapping suite" into main
diff --git a/fs_mgr/libsnapshot/include/libsnapshot/cow_format.h b/fs_mgr/libsnapshot/include/libsnapshot/cow_format.h
index c9a4dee..9359b9e 100644
--- a/fs_mgr/libsnapshot/include/libsnapshot/cow_format.h
+++ b/fs_mgr/libsnapshot/include/libsnapshot/cow_format.h
@@ -49,7 +49,9 @@
// | Footer (fixed) |
// +-----------------------+
//
-// The operations begin immediately after the header, and the "raw data"
+// After the header is a 2mb scratch space that is used to read ahead data during merge operations
+//
+// The operations begin immediately after the scratch space, and the "raw data"
// immediately follows the operation which refers to it. While streaming
// an OTA, we can immediately write the op and data, syncing after each pair,
// while storing operation metadata in memory. At the end, we compute data and
@@ -143,6 +145,42 @@
uint64_t source;
} __attribute__((packed));
+// The on disk format of cow (currently == CowOperation)
+struct CowOperationV2 {
+ // The operation code (see the constants and structures below).
+ uint8_t type;
+
+ // If this operation reads from the data section of the COW, this contains
+ // the compression type of that data (see constants below).
+ uint8_t compression;
+
+ // If this operation reads from the data section of the COW, this contains
+ // the length.
+ uint16_t data_length;
+
+ // The block of data in the new image that this operation modifies.
+ uint64_t new_block;
+
+ // The value of |source| depends on the operation code.
+ //
+ // For copy operations, this is a block location in the source image.
+ //
+ // For replace operations, this is a byte offset within the COW's data
+ // sections (eg, not landing within the header or metadata). It is an
+ // absolute position within the image.
+ //
+ // For zero operations (replace with all zeroes), this is unused and must
+ // be zero.
+ //
+ // For Label operations, this is the value of the applied label.
+ //
+ // For Cluster operations, this is the length of the following data region
+ //
+ // For Xor operations, this is the byte location in the source image.
+ uint64_t source;
+} __attribute__((packed));
+
+static_assert(sizeof(CowOperationV2) == sizeof(CowOperation));
static_assert(sizeof(CowOperation) == sizeof(CowFooterOperation));
static constexpr uint8_t kCowCopyOp = 1;
diff --git a/fs_mgr/libsnapshot/include/libsnapshot/cow_reader.h b/fs_mgr/libsnapshot/include/libsnapshot/cow_reader.h
index f4ce52f..67d301d 100644
--- a/fs_mgr/libsnapshot/include/libsnapshot/cow_reader.h
+++ b/fs_mgr/libsnapshot/include/libsnapshot/cow_reader.h
@@ -165,7 +165,6 @@
void UpdateMergeOpsCompleted(int num_merge_ops) { header_.num_merge_ops += num_merge_ops; }
private:
- bool ParseOps(std::optional<uint64_t> label);
bool PrepMergeOps();
uint64_t FindNumCopyops();
uint8_t GetCompressionType(const CowOperation* op);
diff --git a/fs_mgr/libsnapshot/snapuserd/Android.bp b/fs_mgr/libsnapshot/snapuserd/Android.bp
index 7aac4be..47a8685 100644
--- a/fs_mgr/libsnapshot/snapuserd/Android.bp
+++ b/fs_mgr/libsnapshot/snapuserd/Android.bp
@@ -74,6 +74,11 @@
"user-space-merge/worker.cpp",
"utility.cpp",
],
+ cflags: [
+ "-D_FILE_OFFSET_BITS=64",
+ "-Wall",
+ "-Werror",
+ ],
static_libs: [
"libbase",
"libdm",
@@ -106,6 +111,8 @@
cflags: [
"-D_FILE_OFFSET_BITS=64",
+ "-Wall",
+ "-Werror",
],
static_libs: [
@@ -230,6 +237,11 @@
"testing/host_harness.cpp",
"user-space-merge/snapuserd_test.cpp",
],
+ cflags: [
+ "-D_FILE_OFFSET_BITS=64",
+ "-Wall",
+ "-Werror",
+ ],
shared_libs: [
"libbase",
"liblog",
diff --git a/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_core.h b/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_core.h
index 622fc50..e401c11 100644
--- a/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_core.h
+++ b/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_core.h
@@ -249,6 +249,7 @@
};
std::ostream& operator<<(std::ostream& os, MERGE_IO_TRANSITION value);
+static_assert(sizeof(off_t) == sizeof(uint64_t));
} // namespace snapshot
} // namespace android
diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp
index e4cf582..0c97632 100644
--- a/healthd/BatteryMonitor.cpp
+++ b/healthd/BatteryMonitor.cpp
@@ -432,7 +432,7 @@
}
if (readFromFile(mHealthdConfig->batteryTechnologyPath, &buf) > 0)
- mHealthInfo->batteryTechnology = String8(buf.c_str());
+ mHealthInfo->batteryTechnology = buf;
if (readFromFile(mHealthdConfig->chargingPolicyPath, &buf) > 0)
mHealthInfo->chargingPolicy = getBatteryChargingPolicy(buf.c_str());
@@ -786,39 +786,35 @@
path.clear();
path.appendFormat("%s/%s/status", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0)
- mHealthdConfig->batteryStatusPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->batteryStatusPath = path;
}
if (mHealthdConfig->batteryHealthPath.empty()) {
path.clear();
path.appendFormat("%s/%s/health", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0)
- mHealthdConfig->batteryHealthPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->batteryHealthPath = path;
}
if (mHealthdConfig->batteryPresentPath.empty()) {
path.clear();
path.appendFormat("%s/%s/present", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0)
- mHealthdConfig->batteryPresentPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->batteryPresentPath = path;
}
if (mHealthdConfig->batteryCapacityPath.empty()) {
path.clear();
path.appendFormat("%s/%s/capacity", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0)
- mHealthdConfig->batteryCapacityPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->batteryCapacityPath = path;
}
if (mHealthdConfig->batteryVoltagePath.empty()) {
path.clear();
path.appendFormat("%s/%s/voltage_now",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) {
+ if (access(path.c_str(), R_OK) == 0) {
mHealthdConfig->batteryVoltagePath = path;
}
}
@@ -827,7 +823,7 @@
path.clear();
path.appendFormat("%s/%s/charge_full",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryFullChargePath = path;
}
@@ -835,7 +831,7 @@
path.clear();
path.appendFormat("%s/%s/current_now",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryCurrentNowPath = path;
}
@@ -843,27 +839,29 @@
path.clear();
path.appendFormat("%s/%s/cycle_count",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryCycleCountPath = path;
}
if (mHealthdConfig->batteryCapacityLevelPath.empty()) {
path.clear();
path.appendFormat("%s/%s/capacity_level", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) mHealthdConfig->batteryCapacityLevelPath = path;
+ if (access(path.c_str(), R_OK) == 0) {
+ mHealthdConfig->batteryCapacityLevelPath = path;
+ }
}
if (mHealthdConfig->batteryChargeTimeToFullNowPath.empty()) {
path.clear();
path.appendFormat("%s/%s/time_to_full_now", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryChargeTimeToFullNowPath = path;
}
if (mHealthdConfig->batteryFullChargeDesignCapacityUahPath.empty()) {
path.clear();
path.appendFormat("%s/%s/charge_full_design", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryFullChargeDesignCapacityUahPath = path;
}
@@ -871,7 +869,7 @@
path.clear();
path.appendFormat("%s/%s/current_avg",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryCurrentAvgPath = path;
}
@@ -879,7 +877,7 @@
path.clear();
path.appendFormat("%s/%s/charge_counter",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryChargeCounterPath = path;
}
@@ -887,7 +885,7 @@
path.clear();
path.appendFormat("%s/%s/temp", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0) {
+ if (access(path.c_str(), R_OK) == 0) {
mHealthdConfig->batteryTemperaturePath = path;
}
}
@@ -896,19 +894,19 @@
path.clear();
path.appendFormat("%s/%s/technology",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryTechnologyPath = path;
}
if (mHealthdConfig->batteryStateOfHealthPath.empty()) {
path.clear();
path.appendFormat("%s/%s/state_of_health", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) {
+ if (access(path.c_str(), R_OK) == 0) {
mHealthdConfig->batteryStateOfHealthPath = path;
} else {
path.clear();
path.appendFormat("%s/%s/health_index", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryStateOfHealthPath = path;
}
}
@@ -916,32 +914,36 @@
if (mHealthdConfig->batteryHealthStatusPath.empty()) {
path.clear();
path.appendFormat("%s/%s/health_status", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) mHealthdConfig->batteryHealthStatusPath = path;
+ if (access(path.c_str(), R_OK) == 0) {
+ mHealthdConfig->batteryHealthStatusPath = path;
+ }
}
if (mHealthdConfig->batteryManufacturingDatePath.empty()) {
path.clear();
path.appendFormat("%s/%s/manufacturing_date", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryManufacturingDatePath = path;
}
if (mHealthdConfig->batteryFirstUsageDatePath.empty()) {
path.clear();
path.appendFormat("%s/%s/first_usage_date", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) mHealthdConfig->batteryFirstUsageDatePath = path;
+ if (access(path.c_str(), R_OK) == 0) {
+ mHealthdConfig->batteryFirstUsageDatePath = path;
+ }
}
if (mHealthdConfig->chargingStatePath.empty()) {
path.clear();
path.appendFormat("%s/%s/charging_state", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) mHealthdConfig->chargingStatePath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->chargingStatePath = path;
}
if (mHealthdConfig->chargingPolicyPath.empty()) {
path.clear();
path.appendFormat("%s/%s/charging_policy", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) mHealthdConfig->chargingPolicyPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->chargingPolicyPath = path;
}
break;
diff --git a/healthd/BatteryMonitor_v1.cpp b/healthd/BatteryMonitor_v1.cpp
index 686c338..2e0cfc9 100644
--- a/healthd/BatteryMonitor_v1.cpp
+++ b/healthd/BatteryMonitor_v1.cpp
@@ -352,7 +352,7 @@
mHealthInfo->batteryHealth = getBatteryHealth(buf.c_str());
if (readFromFile(mHealthdConfig->batteryTechnologyPath, &buf) > 0)
- mHealthInfo->batteryTechnology = String8(buf.c_str());
+ mHealthInfo->batteryTechnology = buf;
double MaxPower = 0;
@@ -639,39 +639,35 @@
path.clear();
path.appendFormat("%s/%s/status", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0)
- mHealthdConfig->batteryStatusPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->batteryStatusPath = path;
}
if (mHealthdConfig->batteryHealthPath.empty()) {
path.clear();
path.appendFormat("%s/%s/health", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0)
- mHealthdConfig->batteryHealthPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->batteryHealthPath = path;
}
if (mHealthdConfig->batteryPresentPath.empty()) {
path.clear();
path.appendFormat("%s/%s/present", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0)
- mHealthdConfig->batteryPresentPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->batteryPresentPath = path;
}
if (mHealthdConfig->batteryCapacityPath.empty()) {
path.clear();
path.appendFormat("%s/%s/capacity", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0)
- mHealthdConfig->batteryCapacityPath = path;
+ if (access(path.c_str(), R_OK) == 0) mHealthdConfig->batteryCapacityPath = path;
}
if (mHealthdConfig->batteryVoltagePath.empty()) {
path.clear();
path.appendFormat("%s/%s/voltage_now",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) {
+ if (access(path.c_str(), R_OK) == 0) {
mHealthdConfig->batteryVoltagePath = path;
}
}
@@ -680,7 +676,7 @@
path.clear();
path.appendFormat("%s/%s/charge_full",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryFullChargePath = path;
}
@@ -688,7 +684,7 @@
path.clear();
path.appendFormat("%s/%s/current_now",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryCurrentNowPath = path;
}
@@ -696,27 +692,29 @@
path.clear();
path.appendFormat("%s/%s/cycle_count",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryCycleCountPath = path;
}
if (mHealthdConfig->batteryCapacityLevelPath.empty()) {
path.clear();
path.appendFormat("%s/%s/capacity_level", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0) mHealthdConfig->batteryCapacityLevelPath = path;
+ if (access(path.c_str(), R_OK) == 0) {
+ mHealthdConfig->batteryCapacityLevelPath = path;
+ }
}
if (mHealthdConfig->batteryChargeTimeToFullNowPath.empty()) {
path.clear();
path.appendFormat("%s/%s/time_to_full_now", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryChargeTimeToFullNowPath = path;
}
if (mHealthdConfig->batteryFullChargeDesignCapacityUahPath.empty()) {
path.clear();
path.appendFormat("%s/%s/charge_full_design", POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryFullChargeDesignCapacityUahPath = path;
}
@@ -724,7 +722,7 @@
path.clear();
path.appendFormat("%s/%s/current_avg",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryCurrentAvgPath = path;
}
@@ -732,7 +730,7 @@
path.clear();
path.appendFormat("%s/%s/charge_counter",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryChargeCounterPath = path;
}
@@ -740,7 +738,7 @@
path.clear();
path.appendFormat("%s/%s/temp", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0) {
+ if (access(path.c_str(), R_OK) == 0) {
mHealthdConfig->batteryTemperaturePath = path;
}
}
@@ -749,7 +747,7 @@
path.clear();
path.appendFormat("%s/%s/technology",
POWER_SUPPLY_SYSFS_PATH, name);
- if (access(path, R_OK) == 0)
+ if (access(path.c_str(), R_OK) == 0)
mHealthdConfig->batteryTechnologyPath = path;
}
diff --git a/init/security.cpp b/init/security.cpp
index 6e616be..0c73fae 100644
--- a/init/security.cpp
+++ b/init/security.cpp
@@ -106,21 +106,17 @@
// uml does not support mmap_rnd_bits
return {};
#elif defined(__aarch64__)
- // arm64 architecture supports 18 - 33 rnd bits depending on pagesize and
- // VA_SIZE. However the kernel might have been compiled with a narrower
- // range using CONFIG_ARCH_MMAP_RND_BITS_MIN/MAX. To use the maximum
- // supported number of bits, we start from the theoretical maximum of 33
- // bits and try smaller values until we reach 24 bits which is the
- // Android-specific minimum. Don't go lower even if the configured maximum
- // is smaller than 24.
+ // arm64 supports 14 - 33 rnd bits depending on page size and ARM64_VA_BITS.
+ // The kernel (6.5) still defaults to 39 va bits for 4KiB pages, so shipping
+ // devices are only getting 24 bits of randomness in practice.
if (SetMmapRndBitsMin(33, 24, false) && (!Has32BitAbi() || SetMmapRndBitsMin(16, 16, true))) {
return {};
}
#elif defined(__riscv)
- // TODO: sv48 and sv57 were both added to the kernel this year, so we
- // probably just need some kernel fixes to enable higher ASLR randomization,
- // but for now 24 is the maximum that the kernel supports.
- if (SetMmapRndBitsMin(24, 18, false)) {
+ // TODO: sv48 and sv57 have both been added to the kernel, but the kernel
+ // still doesn't support more than 24 bits.
+ // https://github.com/google/android-riscv64/issues/1
+ if (SetMmapRndBitsMin(24, 24, false)) {
return {};
}
#elif defined(__x86_64__)
diff --git a/libutils/CallStack.cpp b/libutils/CallStack.cpp
index 4dcb35b..11f2c92 100644
--- a/libutils/CallStack.cpp
+++ b/libutils/CallStack.cpp
@@ -82,7 +82,7 @@
void CallStack::print(Printer& printer) const {
for (size_t i = 0; i < mFrameLines.size(); i++) {
- printer.printLine(mFrameLines[i]);
+ printer.printLine(mFrameLines[i].c_str());
}
}
diff --git a/libutils/String16_test.cpp b/libutils/String16_test.cpp
index c6e6f74..6f4642e 100644
--- a/libutils/String16_test.cpp
+++ b/libutils/String16_test.cpp
@@ -33,50 +33,50 @@
TEST(String16Test, FromChar16_t) {
String16 tmp(u"Verify me");
- EXPECT_STR16EQ(u"Verify me", tmp);
+ EXPECT_STR16EQ(u"Verify me", tmp.c_str());
}
TEST(String16Test, FromChar16_tSized) {
String16 tmp(u"Verify me", 7);
- EXPECT_STR16EQ(u"Verify ", tmp);
+ EXPECT_STR16EQ(u"Verify ", tmp.c_str());
}
TEST(String16Test, FromChar) {
String16 tmp("Verify me");
- EXPECT_STR16EQ(u"Verify me", tmp);
+ EXPECT_STR16EQ(u"Verify me", tmp.c_str());
}
TEST(String16Test, FromCharSized) {
String16 tmp("Verify me", 7);
- EXPECT_STR16EQ(u"Verify ", tmp);
+ EXPECT_STR16EQ(u"Verify ", tmp.c_str());
}
TEST(String16Test, Copy) {
String16 tmp("Verify me");
String16 another = tmp;
- EXPECT_STR16EQ(u"Verify me", tmp);
- EXPECT_STR16EQ(u"Verify me", another);
+ EXPECT_STR16EQ(u"Verify me", tmp.c_str());
+ EXPECT_STR16EQ(u"Verify me", another.c_str());
}
TEST(String16Test, CopyAssign) {
String16 tmp("Verify me");
String16 another;
another = tmp;
- EXPECT_STR16EQ(u"Verify me", tmp);
- EXPECT_STR16EQ(u"Verify me", another);
+ EXPECT_STR16EQ(u"Verify me", tmp.c_str());
+ EXPECT_STR16EQ(u"Verify me", another.c_str());
}
TEST(String16Test, Move) {
String16 tmp("Verify me");
String16 another(std::move(tmp));
- EXPECT_STR16EQ(u"Verify me", another);
+ EXPECT_STR16EQ(u"Verify me", another.c_str());
}
TEST(String16Test, MoveAssign) {
String16 tmp("Verify me");
String16 another;
another = std::move(tmp);
- EXPECT_STR16EQ(u"Verify me", another);
+ EXPECT_STR16EQ(u"Verify me", another.c_str());
}
TEST(String16Test, Size) {
@@ -88,27 +88,27 @@
String16 tmp("Verify me");
tmp.setTo(u"New content");
EXPECT_EQ(11U, tmp.size());
- EXPECT_STR16EQ(u"New content", tmp);
+ EXPECT_STR16EQ(u"New content", tmp.c_str());
}
TEST(String16Test, Append) {
String16 tmp("Verify me");
tmp.append(String16("Hello"));
EXPECT_EQ(14U, tmp.size());
- EXPECT_STR16EQ(u"Verify meHello", tmp);
+ EXPECT_STR16EQ(u"Verify meHello", tmp.c_str());
}
TEST(String16Test, Insert) {
String16 tmp("Verify me");
tmp.insert(6, u"Insert");
EXPECT_EQ(15U, tmp.size());
- EXPECT_STR16EQ(u"VerifyInsert me", tmp);
+ EXPECT_STR16EQ(u"VerifyInsert me", tmp.c_str());
}
TEST(String16Test, ReplaceAll) {
String16 tmp("Verify verify Verify");
tmp.replaceAll(u'r', u'!');
- EXPECT_STR16EQ(u"Ve!ify ve!ify Ve!ify", tmp);
+ EXPECT_STR16EQ(u"Ve!ify ve!ify Ve!ify", tmp.c_str());
}
TEST(String16Test, Compare) {
@@ -127,8 +127,8 @@
TEST(String16Test, StaticStringCopy) {
StaticString16 tmp(u"Verify me");
String16 another = tmp;
- EXPECT_STR16EQ(u"Verify me", tmp);
- EXPECT_STR16EQ(u"Verify me", another);
+ EXPECT_STR16EQ(u"Verify me", tmp.c_str());
+ EXPECT_STR16EQ(u"Verify me", another.c_str());
EXPECT_TRUE(tmp.isStaticString());
EXPECT_TRUE(another.isStaticString());
}
@@ -136,7 +136,7 @@
TEST(String16Test, StaticStringMove) {
StaticString16 tmp(u"Verify me");
String16 another(std::move(tmp));
- EXPECT_STR16EQ(u"Verify me", another);
+ EXPECT_STR16EQ(u"Verify me", another.c_str());
EXPECT_TRUE(another.isStaticString());
}
@@ -157,7 +157,7 @@
StaticString16 tmp(u"Verify me");
tmp.append(String16("Hello"));
EXPECT_EQ(14U, tmp.size());
- EXPECT_STR16EQ(u"Verify meHello", tmp);
+ EXPECT_STR16EQ(u"Verify meHello", tmp.c_str());
EXPECT_FALSE(tmp.isStaticString());
}
@@ -165,14 +165,14 @@
StaticString16 tmp(u"Verify me");
tmp.insert(6, u"Insert");
EXPECT_EQ(15U, tmp.size());
- EXPECT_STR16EQ(u"VerifyInsert me", tmp);
+ EXPECT_STR16EQ(u"VerifyInsert me", tmp.c_str());
EXPECT_FALSE(tmp.isStaticString());
}
TEST(String16Test, StaticStringReplaceAll) {
StaticString16 tmp(u"Verify verify Verify");
tmp.replaceAll(u'r', u'!');
- EXPECT_STR16EQ(u"Ve!ify ve!ify Ve!ify", tmp);
+ EXPECT_STR16EQ(u"Ve!ify ve!ify Ve!ify", tmp.c_str());
EXPECT_FALSE(tmp.isStaticString());
}
@@ -185,17 +185,17 @@
StaticString16 tmp(u"Verify me");
String16 another(u"nonstatic");
another = tmp;
- EXPECT_STR16EQ(u"Verify me", tmp);
- EXPECT_STR16EQ(u"Verify me", another);
+ EXPECT_STR16EQ(u"Verify me", tmp.c_str());
+ EXPECT_STR16EQ(u"Verify me", another.c_str());
}
TEST(String16Test, StringCopyAssignFromStaticString) {
StaticString16 tmp(u"Verify me");
String16 another(u"nonstatic");
another = tmp;
- EXPECT_STR16EQ(u"Verify me", another);
+ EXPECT_STR16EQ(u"Verify me", another.c_str());
EXPECT_TRUE(another.isStaticString());
- EXPECT_STR16EQ(u"Verify me", tmp);
+ EXPECT_STR16EQ(u"Verify me", tmp.c_str());
EXPECT_TRUE(tmp.isStaticString());
}
@@ -203,7 +203,7 @@
StaticString16 tmp(u"Verify me");
String16 another(u"nonstatic");
another = std::move(tmp);
- EXPECT_STR16EQ(u"Verify me", another);
+ EXPECT_STR16EQ(u"Verify me", another.c_str());
EXPECT_TRUE(another.isStaticString());
}
@@ -221,19 +221,19 @@
TEST(String16Test, ValidUtf8Conversion) {
String16 another("abcdef");
EXPECT_EQ(6U, another.size());
- EXPECT_STR16EQ(another, u"abcdef");
+ EXPECT_STR16EQ(another.c_str(), u"abcdef");
}
TEST(String16Test, append) {
String16 s;
EXPECT_EQ(OK, s.append(String16(u"foo")));
- EXPECT_STR16EQ(u"foo", s);
+ EXPECT_STR16EQ(u"foo", s.c_str());
EXPECT_EQ(OK, s.append(String16(u"bar")));
- EXPECT_STR16EQ(u"foobar", s);
+ EXPECT_STR16EQ(u"foobar", s.c_str());
EXPECT_EQ(OK, s.append(u"baz", 0));
- EXPECT_STR16EQ(u"foobar", s);
+ EXPECT_STR16EQ(u"foobar", s.c_str());
EXPECT_EQ(NO_MEMORY, s.append(u"baz", SIZE_MAX));
- EXPECT_STR16EQ(u"foobar", s);
+ EXPECT_STR16EQ(u"foobar", s.c_str());
}
TEST(String16Test, insert) {
@@ -241,19 +241,19 @@
// Inserting into the empty string inserts at the start.
EXPECT_EQ(OK, s.insert(123, u"foo"));
- EXPECT_STR16EQ(u"foo", s);
+ EXPECT_STR16EQ(u"foo", s.c_str());
// Inserting zero characters at any position is okay, but won't expand the string.
EXPECT_EQ(OK, s.insert(123, u"foo", 0));
- EXPECT_STR16EQ(u"foo", s);
+ EXPECT_STR16EQ(u"foo", s.c_str());
// Inserting past the end of a non-empty string appends.
EXPECT_EQ(OK, s.insert(123, u"bar"));
- EXPECT_STR16EQ(u"foobar", s);
+ EXPECT_STR16EQ(u"foobar", s.c_str());
EXPECT_EQ(OK, s.insert(3, u"!"));
- EXPECT_STR16EQ(u"foo!bar", s);
+ EXPECT_STR16EQ(u"foo!bar", s.c_str());
EXPECT_EQ(NO_MEMORY, s.insert(3, u"", SIZE_MAX));
- EXPECT_STR16EQ(u"foo!bar", s);
+ EXPECT_STR16EQ(u"foo!bar", s.c_str());
}
diff --git a/libutils/String8_test.cpp b/libutils/String8_test.cpp
index 9c12cb1..e1fd13a 100644
--- a/libutils/String8_test.cpp
+++ b/libutils/String8_test.cpp
@@ -100,19 +100,19 @@
TEST_F(String8Test, ValidUtf16Conversion) {
char16_t tmp[] = u"abcdef";
String8 valid = String8(String16(tmp));
- EXPECT_STREQ(valid, "abcdef");
+ EXPECT_STREQ(valid.c_str(), "abcdef");
}
TEST_F(String8Test, append) {
String8 s;
EXPECT_EQ(OK, s.append("foo"));
- EXPECT_STREQ("foo", s);
+ EXPECT_STREQ("foo", s.c_str());
EXPECT_EQ(OK, s.append("bar"));
- EXPECT_STREQ("foobar", s);
+ EXPECT_STREQ("foobar", s.c_str());
EXPECT_EQ(OK, s.append("baz", 0));
- EXPECT_STREQ("foobar", s);
+ EXPECT_STREQ("foobar", s.c_str());
EXPECT_EQ(NO_MEMORY, s.append("baz", SIZE_MAX));
- EXPECT_STREQ("foobar", s);
+ EXPECT_STREQ("foobar", s.c_str());
}
TEST_F(String8Test, removeAll) {
@@ -123,12 +123,12 @@
// expect to return true and string content should remain unchanged
EXPECT_TRUE(s.removeAll(""));
- EXPECT_STREQ("Hello, world!", s);
+ EXPECT_STREQ("Hello, world!", s.c_str());
// expect to return false
EXPECT_FALSE(s.removeAll("x"));
- EXPECT_STREQ("Hello, world!", s);
+ EXPECT_STREQ("Hello, world!", s.c_str());
EXPECT_TRUE(s.removeAll("o"));
- EXPECT_STREQ("Hell, wrld!", s);
+ EXPECT_STREQ("Hell, wrld!", s.c_str());
}
diff --git a/trusty/stats/test/stats_test.cpp b/trusty/stats/test/stats_test.cpp
index 1edddeb..1d6eb34 100644
--- a/trusty/stats/test/stats_test.cpp
+++ b/trusty/stats/test/stats_test.cpp
@@ -252,20 +252,20 @@
::testing::AnyOf(::testing::Eq(TrustyAtoms::TrustyAppCrashed),
::testing::Eq(TrustyAtoms::TrustyError),
::testing::Eq(TrustyAtoms::TrustyStorageError)));
- ASSERT_STREQ(String8(vendorAtom.reverseDomainName), "google.android.trusty");
+ ASSERT_EQ(String8(vendorAtom.reverseDomainName), "google.android.trusty");
switch (vendorAtom.atomId) {
case TrustyAtoms::TrustyAppCrashed:
++atomAppCrashedCnt;
- ASSERT_STREQ(String8(vendorAtom.values[0].get<VendorAtomValue::stringValue>()),
- "5247d19b-cf09-4272-a450-3ef20dbefc14");
+ ASSERT_EQ(String8(vendorAtom.values[0].get<VendorAtomValue::stringValue>()),
+ "5247d19b-cf09-4272-a450-3ef20dbefc14");
break;
case TrustyAtoms::TrustyStorageError:
++atomStorageErrorCnt;
ASSERT_EQ(vendorAtom.values[0].get<VendorAtomValue::intValue>(), 5);
- ASSERT_STREQ(String8(vendorAtom.values[1].get<VendorAtomValue::stringValue>()),
- "5247d19b-cf09-4272-a450-3ef20dbefc14");
- ASSERT_STREQ(String8(vendorAtom.values[2].get<VendorAtomValue::stringValue>()),
- "5247d19b-cf09-4272-a450-3ef20dbefc14");
+ ASSERT_EQ(String8(vendorAtom.values[1].get<VendorAtomValue::stringValue>()),
+ "5247d19b-cf09-4272-a450-3ef20dbefc14");
+ ASSERT_EQ(String8(vendorAtom.values[2].get<VendorAtomValue::stringValue>()),
+ "5247d19b-cf09-4272-a450-3ef20dbefc14");
ASSERT_EQ(vendorAtom.values[3].get<VendorAtomValue::intValue>(), 1);
ASSERT_EQ(vendorAtom.values[4].get<VendorAtomValue::intValue>(), 3);
ASSERT_EQ(vendorAtom.values[5].get<VendorAtomValue::longValue>(),
@@ -330,13 +330,13 @@
::testing::AnyOf(::testing::Eq(TrustyAtoms::TrustyAppCrashed),
::testing::Eq(TrustyAtoms::TrustyError),
::testing::Eq(TrustyAtoms::TrustyStorageError)));
- ASSERT_STREQ(String8(vendorAtom.reverseDomainName), "google.android.trusty");
+ ASSERT_EQ(String8(vendorAtom.reverseDomainName), "google.android.trusty");
switch (vendorAtom.atomId) {
case TrustyAtoms::TrustyAppCrashed:
++atomAppCrashedCnt;
- ASSERT_STREQ(String8(vendorAtom.values[0].get<VendorAtomValue::stringValue>()),
- kTrustyCrasherUuid);
+ ASSERT_EQ(String8(vendorAtom.values[0].get<VendorAtomValue::stringValue>()),
+ kTrustyCrasherUuid);
atomCrashReasons.push_back(vendorAtom.values[1].get<VendorAtomValue::intValue>());
break;
case TrustyAtoms::TrustyStorageError:
@@ -344,7 +344,7 @@
break;
case TrustyAtoms::TrustyError:
++atomTrustyErrorCnt;
- ASSERT_STREQ(String8(vendorAtom.values[1].get<VendorAtomValue::stringValue>()), "");
+ ASSERT_EQ(String8(vendorAtom.values[1].get<VendorAtomValue::stringValue>()), "");
break;
default:
FAIL() << "Unknown vendor atom ID: " << vendorAtom.atomId;