[llvm-dev] Support for deferred execution in lit
Petr Hosek via llvm-dev
llvm-dev at lists.llvm.org
Fri Jul 16 11:08:53 PDT 2021
On Thu, Jul 15, 2021 at 1:04 PM Stephen Neuendorffer <
stephen.neuendorffer at gmail.com> wrote:
> We've been looking at some related questions and have some other options
> that you might be interested in. First of all a comment: The idea of
> 'deferred execution' seems problematic since it fundamentally changes the
> semantics of the report from lit. I'm curious how you are able to use this
> in practice to, for instance, check that tests were eventually run
> somewhere?
>
I think that's one of the open questions and I can see several potential
solutions. We could leave it entirely up to the user to ensure that the
tests were executed eventually. We could extend lit so it's still
responsible for executing the tests but it does so via a user provided
(remote) executor.
> We have an embedded environment where building LLVM itself is barely
> feasible due to resource constraints. As a result we cross-compile LLVM and
> generate an installed tarball copied to the embedded system. However, this
> means that we can't test the cross-compiled LLVM executables until we get
> to the embedded system.
> Our approach has been to factor the test directory into a hierarchical
> cmake project. This project then uses the standard LLVM cmake export
> mechanisms (i.e. find_project) to find LLVM. This refactoring has no
> effect on a regular in-tree toplevel build. However, we can checkout the
> LLVM tree on the embedded system and build *just the test area* using the
> installed tarball of LLVM. I think this refactoring of cmake is something
> that would be relatively easy to carry out on the LLVM tree. Relative to
> your current approach, this moves the problem of tarballing and remote code
> execution out of lit's responsibility and into a more devops/release
> responsibility, which makes more sense to me.
>
I agree with that distinction but it's not an approach that would be
feasible for us since we cannot even run CMake or Python on the target at
the moment. In our case, we want to package and execute individual test
binaries (with their data dependencies).
> Perhaps you also have other goals, such as partitioning tests to run on
> multiple target nodes? I haven't thought too much about how this would
> interact.
>
It's not something we're actively looking into right now but if that option
existed we would take advantage of it.
> Separately, we also have the problem of tests that need to behave
> differently in different contexts. e.g.:
> RUN: clang --target=my_cross_target ... -o test.elf
> RUN: %run% test.elf
>
> In this case, we'd like to be able to test the compilation part outside of
> the target, but when we run the same test on the target machine, we can
> compile and run. In this case we do something similar (as you see above)
> using a lit subsitution that varies depending on the cmake environment.
> Doing this is somewhat clumsy and I've thought it would be nicer to move
> this into lit, allowing the test to be:
>
> RUN: clang --target=my_cross_target ... -o test.elf
> RUN_ON_TARGET: %run% test.elf
>
> In this case the behavior of RUN*: lines would be configurable in the
> lit.cfg.py. This could implement part of your current use case (although
> maybe there would be impacts on how the reporting is done?)
>
That idea was also suggested in https://reviews.llvm.org/D77657 and I think
of it as a superset of the deferred execution in that the execution of the
command is deferred if the host doesn't match the target. It would require
for lit to become cross-compilation aware, that is to have a notion of host
and target, which would require more changes but is likely going to be more
useful than just deferred execution alone.
> Steve
>
> On Thu, Jul 15, 2021 at 11:54 AM Petr Hosek via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
>
>> This is a topic that came out in our recent discussions about remote test
>> execution in libc++ and other runtimes.
>>
>> libc++ lit test suite has support for running tests remotely using a
>> custom executor. compiler-rt has a similar support. The problem is that
>> this is done in a very ad-hoc way on a per-command basis.
>>
>> The most basic example looks as follows:
>>
>> RUN: %{exec} %t.exe
>>
>> When executing tests locally, %{exec} would be empty (or it could be a
>> binary like env). When executing tests remotely, for example over SSH which
>> is the most common case, %{exec} is expanded into a script
>> <https://github.com/llvm/llvm-project/blob/b8b23aa/libcxx/utils/ssh.py> that
>> uses SCP to copy the binary to the remote target and SSH to execute it.
>> While we're waiting for the command to finish, the test execution is
>> blocked.
>>
>> When you only have a handful of tests, it's a reasonable approach, but it
>> becomes a problem with a large number of tests (as in the case of libc++)
>> because the overhead of copying and executing tests one-by-one can be
>> significant. It gets worse if setting up the target test environment is
>> expensive, which can be the case for some embedded environments.
>>
>> It would be more efficient to bundle up all binaries (with their
>> dependencies), copy them over to the target and run them all but that
>> pattern is difficult to express in lit right now.
>>
>> https://reviews.llvm.org/D77657 is one possible implementation but there
>> are some unresolved issues described in the details of that change.
>>
>> While we could try and workaround some of these issues, we think that a
>> better solution would be to introduce a notion of "deferred execution" into
>> lit, so any RUN lines marked as deferred wouldn't be run immediately and
>> the test would be reported as having a new status DEFERRED. We would then
>> ideally have some way of collecting all deferred commands and providing a
>> custom handler (for example via TestingConfig) that could do things like
>> packaging up all binaries and executing them on the target device.
>>
>> We think that such a feature would be generally useful but I'd like to
>> collect more feedback before we go ahead with the implementation. Do you
>> think such a feature would be useful? Is there another way of supporting
>> batched/deferred execution of test binaries with lit?
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210716/dc15c704/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3996 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210716/dc15c704/attachment.bin>
More information about the llvm-dev
mailing list