ART: Add workaround of 4.14 kernel bug to 137-cfi
4.14 kernel has a bug: missing final null byte in /proc/$pid/cmdline.
This causes 137-cfi to fail on Pixel 4. The test creates a command based
on /proc/self/cmdline. Because of the bug the created command is
invalid.
The CL adds a workaround of the bug by adding the final null byte if it
misses.
Bug: https://issuetracker.google.com/issues/150189787
Test: Pixel 2/3/4
Test: 137-cfi
Change-Id: If161b0b37df4a691a502e95eda7697c81334a7f1
diff --git a/test/137-cfi/cfi.cc b/test/137-cfi/cfi.cc
index aeb996c..7f27145 100644
--- a/test/137-cfi/cfi.cc
+++ b/test/137-cfi/cfi.cc
@@ -63,7 +63,16 @@
#if __linux__
// Get our command line so that we can use it to start identical process.
std::string cmdline; // null-separated and null-terminated arguments.
- android::base::ReadFileToString("/proc/self/cmdline", &cmdline);
+ if (!android::base::ReadFileToString("/proc/self/cmdline", &cmdline)) {
+ LOG(FATAL) << "Failed to read /proc/self/cmdline.";
+ }
+ if (cmdline.empty()) {
+ LOG(FATAL) << "No data was read from /proc/self/cmdline.";
+ }
+ // Workaround for b/150189787.
+ if (cmdline.back() != '\0') {
+ cmdline += '\0';
+ }
cmdline = cmdline + "--secondary" + '\0'; // Let the child know it is a helper.
// Split the string into individual arguments suitable for execv.