add support for running binaries with remote-test-client on run-make

This commit is contained in:
Pietro Albini 2022-09-26 12:59:22 +02:00
parent 9340e5c1b9
commit b2c74ab82b
No known key found for this signature in database
GPG Key ID: CD76B35F7734769E
2 changed files with 21 additions and 6 deletions

View File

@ -40,6 +40,17 @@ endif
# e.g. for `$(CC) -o $(RUN_BINFILE)`.
RUN_BINFILE = $(TMPDIR)/$(1)
# Invoke the generated binary on the remote machine if a test address is
# provided, otherwise run it on the current host.
ifdef TEST_DEVICE_ADDR
# FIXME: if a test requires additional files, this will need to be changed to
# also push them (by changing the 0 to the number of additional files, and
# providing the path of the additional files as the last arguments).
EXECUTE = $(REMOTE_TEST_CLIENT) run 0 $(RUN_BINFILE)
else
EXECUTE = $(RUN_BINFILE)
endif
# RUN and FAIL are basic way we will invoke the generated binary. On
# non-windows platforms, they set the LD_LIBRARY_PATH environment
# variable before running the binary.
@ -50,16 +61,16 @@ BIN = $(1)
UNAME = $(shell uname)
ifeq ($(UNAME),Darwin)
RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE)
FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0
RUN = $(TARGET_RPATH_ENV) $(EXECUTE)
FAIL = $(TARGET_RPATH_ENV) $(EXECUTE) && exit 1 || exit 0
DYLIB_GLOB = lib$(1)*.dylib
DYLIB = $(TMPDIR)/lib$(1).dylib
STATICLIB = $(TMPDIR)/lib$(1).a
STATICLIB_GLOB = lib$(1)*.a
else
ifdef IS_WINDOWS
RUN = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE)
FAIL = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE) && exit 1 || exit 0
RUN = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(EXECUTE)
FAIL = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(EXECUTE) && exit 1 || exit 0
DYLIB_GLOB = $(1)*.dll
DYLIB = $(TMPDIR)/$(1).dll
ifdef IS_MSVC
@ -73,8 +84,8 @@ endif
BIN = $(1).exe
LLVM_FILECHECK := $(shell cygpath -u "$(LLVM_FILECHECK)")
else
RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE)
FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0
RUN = $(TARGET_RPATH_ENV) $(EXECUTE)
FAIL = $(TARGET_RPATH_ENV) $(EXECUTE) && exit 1 || exit 0
DYLIB_GLOB = lib$(1)*.so
DYLIB = $(TMPDIR)/lib$(1).so
STATICLIB = $(TMPDIR)/lib$(1).a

View File

@ -2987,6 +2987,10 @@ impl<'test> TestCx<'test> {
cmd.env("LLVM_BIN_DIR", llvm_bin_dir);
}
if let Some(ref remote_test_client) = self.config.remote_test_client {
cmd.env("REMOTE_TEST_CLIENT", remote_test_client);
}
// We don't want RUSTFLAGS set from the outside to interfere with
// compiler flags set in the test cases:
cmd.env_remove("RUSTFLAGS");