From c4234b2b62fa5d2547b35e8945c90014c9722618 Mon Sep 17 00:00:00 2001 From: James Farrell Date: Thu, 13 Oct 2022 19:40:00 +0000 Subject: [PATCH] Revert "Remove comment and hack for binary verification." This reverts commit 124ad2d8c15dc42c230d3394a3c18c639600f229. Reason for revert: Breaks tests Change-Id: I02e8a9fee0a1cea1cb0f70c4116719117492c0b6 --- ndk/test/devicetest/case.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/ndk/test/devicetest/case.py b/ndk/test/devicetest/case.py index 7d7c27d7..ab91ce1d 100644 --- a/ndk/test/devicetest/case.py +++ b/ndk/test/devicetest/case.py @@ -84,6 +84,14 @@ def run(self, device: Device) -> AdbResult: logger().info('%s: shell_nocheck "%s"', device.name, self.cmd) return shell_nocheck_wrap_errors(device, self.cmd) + # Note that TradeFed will split this command on whitespace, and verify + # that one of the tokens is an executable file on the device. Therefore, you + # must ensure that TestCase.cmd contains, somewhere, the full path + # to the executable, surrounded by whitespace. + # + # For example, neither of the following will work: + # cd /path && ./cmd # relative path + # /path/cmd||echo "foo" # no whitespace @property def cmd(self) -> str: """The shell command to run on the device to execute the test case.""" @@ -92,6 +100,10 @@ def cmd(self) -> str: @property def negated_cmd(self) -> str: """The command to execute the test case, but with the exit code flipped.""" + # Note that TradeFed will split this command on whitespace, and verify + # that one of the tokens is an executable file on the device. + # So the whitespace around the parens is intentional, because + # ! (/path/to/some/cmd) won't work. return f"! ( {self.cmd} )" def __str__(self) -> str: @@ -139,7 +151,8 @@ def check_broken( @property def cmd(self) -> str: - return "cd {} && LD_LIBRARY_PATH={} ./{} 2>&1".format( + # See note in the base class above about parsing by TradeFed. + return "cd {} && LD_LIBRARY_PATH={} {}/{} 2>&1".format( self.device_dir, self.device_dir, self.device_dir, self.executable ) @@ -204,6 +217,7 @@ def check_broken( @property def cmd(self) -> str: + # See note in the base class above about parsing by TradeFed. libcxx_so_dir = self.device_base_dir / str(self.config) / "libcxx" / "libc++" return "cd {} && LD_LIBRARY_PATH={} ./{} 2>&1".format( self.device_dir, libcxx_so_dir, self.executable