Dump debug information for apply_patch unit tests
The apply patch test should have a deterministic way to append patch data. Add debug logs to dump the length and SHA1 of each step to further track down the flakiness. Also redirect the debug logging to stdout in case the logcat becomes too chatty. Bug: 67849209 Test: Run recovery_component_test Change-Id: I42bafef2d9dee599719ae57840b3d8c00d243ebd
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <android-base/stringprintf.h>
|
||||
#include <android-base/test_utils.h>
|
||||
#include <android-base/unique_fd.h>
|
||||
@@ -46,7 +47,7 @@
|
||||
using namespace std::string_literals;
|
||||
|
||||
static void sha1sum(const std::string& fname, std::string* sha1, size_t* fsize = nullptr) {
|
||||
ASSERT_NE(nullptr, sha1);
|
||||
ASSERT_TRUE(sha1 != nullptr);
|
||||
|
||||
std::string data;
|
||||
ASSERT_TRUE(android::base::ReadFileToString(fname, &data));
|
||||
@@ -68,6 +69,14 @@ static void mangle_file(const std::string& fname) {
|
||||
ASSERT_TRUE(android::base::WriteStringToFile(content, fname));
|
||||
}
|
||||
|
||||
static void test_logger(android::base::LogId /* id */, android::base::LogSeverity severity,
|
||||
const char* /* tag */, const char* /* file */, unsigned int /* line */,
|
||||
const char* message) {
|
||||
if (severity >= android::base::GetMinimumLogSeverity()) {
|
||||
fprintf(stdout, "%s\n", message);
|
||||
}
|
||||
}
|
||||
|
||||
class ApplyPatchTest : public ::testing::Test {
|
||||
public:
|
||||
virtual void SetUp() override {
|
||||
@@ -109,6 +118,8 @@ class ApplyPatchModesTest : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
CacheLocation::location().set_cache_temp_source(cache_source.path);
|
||||
android::base::InitLogging(nullptr, &test_logger);
|
||||
android::base::SetMinimumLogSeverity(android::base::LogSeverity::DEBUG);
|
||||
}
|
||||
|
||||
TemporaryFile cache_source;
|
||||
|
||||
Reference in New Issue
Block a user