From ffed57a7a3e5e82969b5998f759d09fbb6edd4e2 Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Mon, 23 Apr 2018 17:51:45 -0700 Subject: 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 --- applypatch/applypatch.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'applypatch/applypatch.cpp') diff --git a/applypatch/applypatch.cpp b/applypatch/applypatch.cpp index 7104abd67..db7530be9 100644 --- a/applypatch/applypatch.cpp +++ b/applypatch/applypatch.cpp @@ -630,6 +630,11 @@ static int GenerateTarget(const FileContents& source_file, const std::unique_ptr SHA_CTX ctx; SHA1_Init(&ctx); SinkFn sink = [&memory_sink_str, &ctx](const unsigned char* data, size_t len) { + if (len != 0) { + uint8_t digest[SHA_DIGEST_LENGTH]; + SHA1(data, len, digest); + LOG(DEBUG) << "Appending " << len << " bytes data, sha1: " << short_sha1(digest); + } SHA1_Update(&ctx, data, len); memory_sink_str.append(reinterpret_cast(data), len); return len; -- cgit v1.2.3