From e1ac18930c68b2c129caf2a83c58aa5fa50361f0 Mon Sep 17 00:00:00 2001 From: Evgeny Astigeevich Date: Thu, 28 Feb 2019 12:38:03 +0000 Subject: Fix MaskAddresses for toybox sed In MaskAddresses sed is used to preprocess traces. In I575ae9db8d94cbec811d0029691df98373f8fe35 switching to use toybox sed instead of sed(1) for build tools was done. Command line options and regular expressions for GNU sed don't work for toybox sed causing test failures: 1. Toybox sed does not support '--in-place --regexp-extended'. 2. Toybox sed does not support hexadecimal expressions. The CL changes MaskAddresses to work with toybox sed: 1. Use '-i -E' instead of '--in-place --regexp-extended' because they have the same meaning. GNU sed also supports '-i -E' instead of '--in-place --regexp-extended'. 2. Use '.' instead of a hexadecimal expression '\x1b' because regular expressions have enough information for an exact match. As the CL makes some macros redundant the macros are removed. Test: mma test-art-host-vixl Change-Id: I03701adfe5c62ff98d88125ed6208dc162ab7668 --- test/aarch64/test-trace-aarch64.cc | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/test/aarch64/test-trace-aarch64.cc b/test/aarch64/test-trace-aarch64.cc index eac16c6b..e061e0cf 100644 --- a/test/aarch64/test-trace-aarch64.cc +++ b/test/aarch64/test-trace-aarch64.cc @@ -2739,21 +2739,14 @@ static void GenerateTestSequenceNEONFP(MacroAssembler* masm) { static void MaskAddresses(const char* trace) { -// Hexadecimal expressions of the form `\xab` do not work out-of-the box with -// BSD `sed`. So we use ANSI-C quoting to have the regular expressions below -// work both on Linux and BSD (and macOS). #ifdef __APPLE__ -#define MAYBE_ANSI_C_QUOTE "$" -#define HEX(val) "\\x" #val #define ESCAPE(c) "\\\\" #c const char* sed_options = "-i \"\" -E"; #else -#define MAYBE_ANSI_C_QUOTE -#define HEX(val) "\\x" #val #define ESCAPE(c) "\\" #c - const char* sed_options = "--in-place --regexp-extended"; + const char* sed_options = "-i -E"; #endif -#define COLOUR "(" HEX(1b) ESCAPE([) "[01];([0-9][0-9])?m)?" +#define COLOUR "(." ESCAPE([) "[01];([0-9][0-9])?m)?" struct { const char* search; const char* replace; @@ -2775,7 +2768,7 @@ static void MaskAddresses(const char* trace) { for (size_t i = 0; i < patterns_length; i++) { size_t length = snprintf(command, sizeof(command), - "sed %s " MAYBE_ANSI_C_QUOTE "'s/%s/%s/' '%s'", + "sed %s 's/%s/%s/' '%s'", sed_options, patterns[i].search, patterns[i].replace, -- cgit v1.2.3