[llvm-lit] Is it possible to write a test for Linux only?

Hello,

I wonder if I can write a test that runs only on Linux. I was thinking of adding “REQUIRES” to the test, but couldn’t find a feature name for Linux (if one exists). Thanks!

Best,

Taewook

Hello,

I wonder if I can write a test that runs only on Linux. I was thinking
of adding “REQUIRES” to the test, but couldn’t find a feature name for
Linux (if one exists). Thanks!

$ grep -r REQUIRES ../llvm/test/ | grep linux

The feature name you want is: "x86_64-linux"

Jon

Thanks Jon. Actually I tried “x86_64-linux”, but it makes the test “Unsupported” from my linux machine, and it was because my test is under clang, not llvm. It seems that clang doesn’t support “x86_64-linux” yet. Thanks again!

Best,
Taewook

    > Hello,
    >
    >
    >
    > I wonder if I can write a test that runs only on Linux. I was thinking
    > of adding “REQUIRES” to the test, but couldn’t find a feature name for
    > Linux (if one exists). Thanks!
    
    $ grep -r REQUIRES ../llvm/test/ | grep linux
    
    The feature name you want is: "x86_64-linux"
    
    Jon

Thanks Jon. Actually I tried “x86_64-linux”, but it makes the test “Unsupported” from my linux machine, and it was because my test is under clang, not llvm. It seems that clang doesn’t support “x86_64-linux” yet. Thanks again!

Oh, ok. Follow-up question: why is your clang test $host platform dependent (instead of $target dependent)?

Jon

It is $target dependent. I’m curious what makes you think it is $host dependent.

Thanks,
Taewook

    > Thanks Jon. Actually I tried “x86_64-linux”, but it makes the test “Unsupported” from my linux machine, and it was because my test is under clang, not llvm. It seems that clang doesn’t support “x86_64-linux” yet. Thanks again!
    
    Oh, ok. Follow-up question: why is your clang test $host platform
    dependent (instead of $target dependent)?
    
    Jon

It is $target dependent. I’m curious what makes you think it is $host dependent.

Because you're asking about REQUIRES, which refers to features of the $host. If you just want to write a target dependent test, use -target / -triple.

Jon

Maybe I was totally confused. When I see /test/lit.cfg (https://github.com/llvm-mirror/clang/blob/master/test/lit.cfg), some available_features are based on config.target_triple (e.g. https://github.com/llvm-mirror/clang/blob/master/test/lit.cfg#L420), so I though REQUIRES is not necessarily about $host.

    > It is $target dependent. I’m curious what makes you think it is $host dependent.
    
    Because you're asking about REQUIRES, which refers to features of the
    $host. If you just want to write a target dependent test, use -target /
    -triple.
    
    Jon

From: llvm-dev [mailto:llvm-dev-bounces@lists.llvm.org] On Behalf Of
Taewook Oh via llvm-dev
Sent: Friday, March 03, 2017 7:56 PM
To: Jonathan Roelofs; llvm-dev@lists.llvm.org
Subject: Re: [llvm-dev] [llvm-lit] Is it possible to write a test for
Linux only?

Maybe I was totally confused. When I see /test/lit.cfg
(https://github.com/llvm-mirror/clang/blob/master/test/lit.cfg), some
available_features are based on config.target_triple (e.g.
https://github.com/llvm-mirror/clang/blob/master/test/lit.cfg#L420), so I
though REQUIRES is not necessarily about $host.

REQUIRES is something of a grab bag. Some of its features are based on
host, I think some are based on other configuration things, and you can
also put elements of the target triple in there.

You could specify a target triple in your test, but that generally means
restricting it to both a particular architecture and a particular OS
(for example, x86_64-unknown-linux). If you want a test that runs on
any architecture but only for linux, I would expect `REQUIRES: linux` to
work, as it would look for `linux` as a target triple component.

There are some differences between the feature sets supported in the
LLVM suite versus the Clang suite, and without a bit more research
(which unfortunately I cannot do at the moment, I am away this weekend)
I can't be sure whether my suggestion actually works. :slight_smile: But you could
try some experiments in this direction and see if you can get it to work.

Good luck,
--paulr