Filter out ddms error message in 1940 better
Since the ddms error message in test 1940 is printed from within the
runtime it lacks the synchronization with System.out that other prints
have. This could cause the output to get mixed slightly with other
messages from the test. In order to fix this we filter it out using
python code that is able to understand the interleaving.
Test: ./test.py --host -j50
Change-Id: Ic42816beeea2f04046b5bb88e17a1f6bde19a58e
diff --git a/test/1940-ddms-ext/check b/test/1940-ddms-ext/check
index d2c0384..91966b4 100755
--- a/test/1940-ddms-ext/check
+++ b/test/1940-ddms-ext/check
@@ -16,6 +16,6 @@
# Need to pull out the describeException ouput since that won't be there on
# device.
-sed -e '/\t.*$/d' "$2" | sed -e '/java.lang.ArrayIndexOutOfBoundsException:.*$/d' > "$2.tmp"
+./remove_error.py "$2" "./expected_error.txt" > "$2.tmp"
./default-check "$1" "$2.tmp"
diff --git a/test/1940-ddms-ext/expected_error.txt b/test/1940-ddms-ext/expected_error.txt
new file mode 100644
index 0000000..73883b4
--- /dev/null
+++ b/test/1940-ddms-ext/expected_error.txt
@@ -0,0 +1,4 @@
+java.lang.ArrayIndexOutOfBoundsException: byte[] offset=12 length=55 src.length=1
+ at art.Test1940.processChunk(Native Method)
+ at art.Test1940.run(Test1940.java:156)
+ at Main.main(Main.java:19)
diff --git a/test/1940-ddms-ext/remove_error.py b/test/1940-ddms-ext/remove_error.py
new file mode 100755
index 0000000..638c479
--- /dev/null
+++ b/test/1940-ddms-ext/remove_error.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python3
+#
+# Copyright (C) 2018 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import argparse
+
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument('input_data', type=open)
+ parser.add_argument('expected_error', type=str)
+ args = parser.parse_args()
+
+ for line in map(str.rstrip, args.input_data.readlines()):
+ print_full = True
+ with open(args.expected_error) as err_file:
+ for err_line in map(str.rstrip, err_file):
+ if line.startswith(err_line):
+ print_full = False
+ if line != err_line:
+ print(line[len(err_line):])
+ break
+ if print_full and line != '':
+ print(line)
+
+if __name__ == '__main__':
+ main()