This is an archive of the discontinued LLVM Phabricator instance.

[lit] Add knob --run-prefix to allow developers to run LIT on a simulator when real machine is not available
AbandonedPublic

Authored by skan on May 12 2023, 1:12 AM.

Details

Summary

https://llvm.org/docs/TestSuiteGuide.html

LLVM test-suite leverages the LIT infrastructure for testing. It's a run-time test suite but sometimes we do
not have a real machine for the test. So, I'd like to introduce a mechanism to run it on a simulator by this
patch.

According to the documentations:

Intel SDE:
https://www.intel.com/content/www/us/en/developer/articles/tool/software-development-emulator.html

QEMU:
https://www.qemu.org/docs/master/user/main.html

Here are some usage examples:

llvm-lit ./llvm/test/MC/X86/abs8.s --run-prefix "sde --"
llvm-lit ./llvm/test/MC/X86/abs8.s --run-prefix "qemu-x86_64"

Although LLVM test suites supports CMAKE variable TEST_SUITE_RUN_UNDER, it does not work for me.

When I built llvm-test-suite with command like cmake -DTEST_SUITE_RUN_UNDER="sde --", and then ran llvm-lit, the result looked like

bash$ llvm-lit -v llvm-test-suite/build/SingleSource/Regression/C++/Regression-C++-2011-03-28-Bitfield.test -a 

llvm-test-suite/build/tools/timeit-target --limit-core 0 --limit-cpu 7200 --timeout 7200 --limit-file-size 104857600 --limit-rss-size 838860800 --append-exitstatus 
--redirect-output llvm-test-suite/build/SingleSource/Regression/C++/Output/Regression-C++-2011-03-28-Bitfield.test.out 
--redirect-input /dev/null --chdir llvm-test-suite/build/SingleSource/Regression/C++ --summary 
llvm-test-suite/build/SingleSource/Regression/C++/Output/Regression-C++-2011-03-28-Bitfield.test.time sde -- 
llvm-test-suite/build/SingleSource/Regression/C++/Regression-C++-2011-03-28-Bitfield

It tried to run Regression-C++-2011-03-28-Bitfield on the simulator, however the tool timeit-target was built with same flags, which has illegal instructions too. So the LIT ran fail.

In addition, it looks more reasonable to add the prefix during the run process than build process.

Discussion: https://discourse.llvm.org/t/rfc-prefix-test-invocations-with-the-given-tool-for-llvm-lit/70611

Diff Detail

Unit TestsFailed

Event Timeline

skan created this revision.May 12 2023, 1:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 12 2023, 1:12 AM
skan requested review of this revision.May 12 2023, 1:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 12 2023, 1:12 AM
skan updated this revision to Diff 521859.May 12 2023, 7:44 PM

Fix LIT test fail by setting default=''

skan abandoned this revision.May 12 2023, 11:27 PM

Abandoned this b/c I found we can utilize the CMAKE variable TEST_SUITE_RUN_UNDER to achieve this.

skan reclaimed this revision.May 13 2023, 4:22 AM

Reopen this revision b/c TEST_SUITE_RUN_UNDER does not work for me.

When I build llvm-test-suite with command like cmake -DTEST_SUITE_RUN_UNDER="sde --", and then run llvm-lit, the result looks like

bash$ llvm-lit -v llvm-test-suite/build/SingleSource/Regression/C++/Regression-C++-2011-03-28-Bitfield.test -a 

llvm-test-suite/build/tools/timeit-target --limit-core 0 --limit-cpu 7200 --timeout 7200 --limit-file-size 104857600 --limit-rss-size 838860800 --append-exitstatus 
--redirect-output llvm-test-suite/build/SingleSource/Regression/C++/Output/Regression-C++-2011-03-28-Bitfield.test.out 
--redirect-input /dev/null --chdir llvm-test-suite/build/SingleSource/Regression/C++ --summary 
llvm-test-suite/build/SingleSource/Regression/C++/Output/Regression-C++-2011-03-28-Bitfield.test.time sde -- 
llvm-test-suite/build/SingleSource/Regression/C++/Regression-C++-2011-03-28-Bitfield

It tries to run Regression-C++-2011-03-28-Bitfield on the simulator, however the tool timeit-target is built with same flags, which has illegal instructions too. So the LIT run fail.

And with the knob --simulator-cmd, the test can pass.

skan updated this revision to Diff 521901.May 13 2023, 6:11 AM

Rename the knob to --run-prefix to make it more generic

skan retitled this revision from [lit] Add knob --simulator-cmd to allow developers to run LIT on a simulator when real machine is not available to [lit] Add knob --run-prefix to allow developers to run LIT on a simulator when real machine is not available.May 13 2023, 6:12 AM
skan edited the summary of this revision. (Show Details)
skan edited the summary of this revision. (Show Details)May 13 2023, 6:18 AM

We had a buildbot that run with sde before, though it was removed by D143552. I think current LLVM test-suite infrastructure should have supported sde already. Maybe @yinyangsx can help with your problem?

skan edited the summary of this revision. (Show Details)May 13 2023, 6:50 AM
skan added a comment.May 13 2023, 7:35 AM

We had a buildbot that run with sde before, though it was removed by D143552. I think current LLVM test-suite infrastructure should have supported sde already. Maybe @yinyangsx can help with your problem?

Great link! It seems the variable USER_MODE_EMULATION=1 may help. Let me try.

# litsupport/modules/timeit.py

def _mutateCommandLine(context, commandline):
    timefile = context.tmpBase + ".time"
    config = context.config
    cmd = shellcommand.parse(commandline)

 

    if config.user_mode_emulation:
        # user_mode_emulation should be true if tests are being run via
        # user-mode emulation (e.g. Qemu) and thus the host version of timeit
        # should be used.
        timeit_name = "timeit"
    else:
        timeit_name = "timeit-target"
myhsu added a subscriber: myhsu.May 13 2023, 9:53 AM
skan added a comment.May 16 2023, 6:16 PM

USER_MODE_EMULATION=1 did resolve the problem. I will keep this revision open for a while in case someone expects this functionality in LIT.

skan abandoned this revision.May 26 2023, 3:56 AM