Skip to content

Commit

Permalink
Merge "Revert "Remove comment and hack for binary verification.""
Browse files Browse the repository at this point in the history
  • Loading branch information
Treehugger Robot authored and Gerrit Code Review committed Oct 13, 2022
2 parents 3b3f067 + c4234b2 commit e556869
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion ndk/test/devicetest/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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:
Expand Down Expand Up @@ -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
)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e556869

Please sign in to comment.