run integration tests for single file

Hi everyone,

I'm trying to run some integration tests, defined in a single
file, for a static analysis check I wrote.

https://github.com/0ax1/MPI-Checker/blob/master/tests/integration_tests/MPICheckerTest.c

When I run the complete Clang test-suite (calling "ninja clang-test") for
integration tests, the tests I defined get executed and work as expected but
calling "llvm-lit MPICheckerTest.c" yields:

"llvm-lit: discovery.py:113: warning: unable to find test suite for
'MPICheckerTest.c' llvm-lit: discovery.py:224: warning: input 'MPICheckerTest.c'
contained no tests.."

In the docs (http://llvm.org/docs/TestingGuide.html) it is stated that in order
to add a test, configure/make should be called.
But in the llvm/test folder I do not have a configure script (I used ninja to
build LLVM) and simply calling make does not work ("../Makefile.config: No such
file ...").

Can anybody help out?

Best regards,
Alex

Hi everyone,

I'm trying to run some integration tests, defined in a single
file, for a static analysis check I wrote.

https://github.com/0ax1/MPI-Checker/blob/master/tests/integration_tests/MPICheckerTest.c

When I run the complete Clang test-suite (calling "ninja clang-test") for
integration tests, the tests I defined get executed and work as expected
but
calling "llvm-lit MPICheckerTest.c" yields:

"llvm-lit: discovery.py:113: warning: unable to find test suite for
'MPICheckerTest.c' llvm-lit: discovery.py:224: warning: input
'MPICheckerTest.c'
contained no tests.."

In the docs (http://llvm.org/docs/TestingGuide.html) it is stated that in
order
to add a test, configure/make should be called.
But in the llvm/test folder I do not have a configure script (I used ninja
to
build LLVM) and simply calling make does not work ("../Makefile.config: No
such
file ...").

Can anybody help out?

I'm not sure what ways work/are meant to work, but the way that works for
me is this:

From the build directory you run ninja in, run "./bin/llvm-lit -v

test/CodeGen/foo.ll" etc. (ie: the source relative path in LLVM)

Oh, you're running tests that aren't part of Clang or LLVM's test suite?
That I'm less (not at all) familiar with, but you might need a lit config
file in the directory parent chain of the test file you're running (check
the ones in LLVM's suite for example)

- Dave

Hi,

thanks for your reply.
I have positioned the test file in llvm/tools/clang/test/Analysis
which includes a lot of other regression test files.
For each other file I tried, the llvm-lit command works.
A lit config file is contained in that folder.
I think the question is how the lit configuration can be
regenerated/configured to fix the issue.

Best regards,
Alex

Solved. There were two problems:

The integration test I added, was symlinked into the test folder.
llvm-lit seems to follow symlinks why it looked in the wrong place for
the config files. In contrast the symlinks are not followed if
"ninja clang-test" is called why I didn't consider this to be a
problem at first.

The second problem was that I didn't use the llvm-lit from
the debug repository I added the test to. I used the llvm-lit
from a seperate repo folder which contains the stable branch, release
executables I use as my system defaults which are front in the PATH.

--Alex

Hi everyone,

is it possible to get the type of a clang::Expr instance
the expression evaluates to? I would like to use this, to find out
what kind of types arguments passed to a clang::CallExpr have.

Sth. like this:

int n;
function(&n);
..
// getArg() returns Expr
callExpr()->getArg(idx)--->getTypeExprEvaluatesTo(); // -> *int

or with multiple operands:
int n;
function(1 + n);
..
callExpr()->getArg(idx)--->getTypeExprEvaluatesTo(); // -> int

-Alex

Hi everyone,

is it possible to get the type of a clang::Expr instance
the expression evaluates to?

You should be able to use clang::Expr::getType().

~Aaron

Thanks for your reply!

clang::Expr::getType() seems to return
the arg type it is casted to (if possible)
when passed to function and not the original arg type.

If I have a function like func(int)
and I pass a float func(1.1)
callExpr()->getArg(1)->getType()->dump()
gives me: BuiltinType 0x7f833183b1b0 'int'

-Alex

Works, thanks a lot for pointing this out!