Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to add compiler include path to --generate phase #1

Closed
cdeil opened this issue Nov 2, 2012 · 11 comments
Closed

Add possibility to add compiler include path to --generate phase #1

cdeil opened this issue Nov 2, 2012 · 11 comments

Comments

@cdeil
Copy link

cdeil commented Nov 2, 2012

First of all: the API Sanity Checker is a very cool project! Thanks!

I want to run the api-sanity-checker on a library B which depends on another library A.
The problem I've run into is that the call

api-sanity-checker -lib libB -d VERSION.xml -gen

makes a call like this

gcc -fdump-translation-unit -fkeep-inline-functions -c -x c++-header /tmp/something/dump.h -I/my/working/dir

and this fails because the B header files included in /tmp/something/dump.h include headers from library A.
So what I need is a way to tell the api-sanity-checker to pass a flag -I/path/to/library/A/headers/ along to gcc.

Is there an option or workaround to do this?
(Sorry if I didn't explain my problem well.)

@aponomarenko
Copy link
Collaborator

Hi,

Thanks for the detailed feedback!

Try to add this option to your VERSION.xml descriptor:

<add_include_paths>
    /path/to/library/A/headers/
</add_include_paths>

All available options are described here: http://ispras.linuxbase.org/index.php/Library_Descriptor

@cdeil
Copy link
Author

cdeil commented Nov 2, 2012

The problem is that then ~ 4000 tests for library A are generated, but I only want the ~ 100 tests for library B.
For now I am using the -header option, but I have to process one library B header at a time, which is annoying.

@aponomarenko
Copy link
Collaborator

Generally, the tool should generate test cases for those symbols that are exported by the input shared library (B). Do you use libs option in the XML descriptor (VERSION.xml)?

<libs>
    /path/to/library/B/shared/object(s)/
</libs>

@cdeil
Copy link
Author

cdeil commented Nov 5, 2012

The problem in my case is that shared library B contains many of the symbols from shared library A as undefined references and the api-sanity-checker generates tests for all of those, which I don't want since we run the api-sanity-checker on library A in a separate continous integration job.

Unfortunately at the moment for my case library B is not publicly available, which makes this discussion unnecessarily abstract. Do you know another similar example where both libraries are public that we can both run through the api-sanity-checker?

@pkgdiff
Copy link

pkgdiff commented Nov 7, 2012

The tool should not generate tests for undefined symbols in the library. Do you use any additional options (like --headers-only)?

@cdeil
Copy link
Author

cdeil commented Nov 7, 2012

I don't use any additional options, I run this command:

api-sanity-checker -d VERSION.xml -l libctools -gen

Here's my VERSION.xml (with the library A = gammalib headers added in addition to the library B = ctools headers as you suggested):

<version>0.0</version>
<headers>
/home/deil/software/code/ctools/src
/usr/local/gamma/include
</headers>
<libs>/usr/local/gamma/lib</libs>

Here's an example of a test generated for a symbol in A which is undefined in B:

$ nm /usr/local/gamma/lib/libctools.so | grep GSkyDir
...
                 U _ZN7GSkyDirC1Ev
...

$ cat ./tests/libctools/0.0/groups/GSkyDir/classes/GSkyDir/_ZN7GSkyDirC1Ev/test.cpp 
#include <gammalib/GammaLib.hpp>
int main(int argc, char *argv[])
{
    GSkyDir* skydir = new GSkyDir(); //target call
    return 0;
}

Here's the log:
https://gist.github.com/4030446

Am I doing something wrong?
I want to not generate tests that only involve library A.

@aponomarenko
Copy link
Collaborator

Try this XML descriptor:

<version>
    0.0
</version>

<headers>
    /home/deil/software/code/ctools/src
</headers>

<libs>
    /usr/local/gamma/lib/libctools.so
</libs>

<add_include_paths>
    /usr/local/gamma/include/gammalib
</add_include_paths>

@cdeil
Copy link
Author

cdeil commented Nov 7, 2012

Ah, something like an add_include_paths option is what I was looking for.

I now have the problem that some tests fail to generate and most fail to build:

deil@ubuntu:~/software/code/ctools-sanity-full$ api-sanity-checker -lib libctools -d VERSION.xml -gen -build -run
library(ies) analysis: [100.00%]
header(s) analysis: [100.00%]
generating tests: 134/134 [100.00%], success/fail: 129/5    
1. see generated test suite in the directory 'tests/libctools/0.0/'
2. for viewing the tests use 'tests/libctools/0.0/view_tests.html'
3. use -build option for building tests
building tests: 129/129 [100.00%], success/fail: 10/119    
running tests: 10/10 [100.00%], success/fail: 10/0    
creating report ...
see test results in the file:
  test_results/libctools/0.0/test_results.html

The build failures occur because the linker flag for library A -libgamma is missing:

deil@ubuntu:~/software/code/ctools-sanity-full/tests/libctools/0.0/groups/ctbin/classes/ctbin/_ZN5ctbin4saveEv$ cat build_log 
/usr/bin/ld: /tmp/cczm35et.o: undefined reference to symbol 'GObservations::GObservations(GObservations const&)'
/usr/bin/ld: note: 'GObservations::GObservations(GObservations const&)' is defined in DSO /usr/local/gamma/lib/libgamma.so.0 so try adding it to the linker command line
/usr/local/gamma/lib/libgamma.so.0: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make: *** [test] Error 1

How can I make the api-sanity-checker add it?

@aponomarenko
Copy link
Collaborator

Try to add this option to the descriptor:

<libs_depend>
    /usr/local/gamma/lib/libgamma.so.0
</libs_depend>

Actually, this is a bug in the tool if it cannot find this library automatically.

@cdeil
Copy link
Author

cdeil commented Nov 7, 2012

If I add <libs_depend> it works:

$ cat VERSION.xml 
<version>
    0.0
</version>

<headers>
    /home/deil/software/code/ctools/src
</headers>

<libs>
    /usr/local/gamma/lib/libctools.so
</libs>

<add_include_paths>
    /usr/local/gamma/include/gammalib
</add_include_paths>

<libs_depend>
    /usr/local/gamma/lib/libgamma.so.0
</libs_depend>

$ api-sanity-checker -lib libctools -d VERSION.xml -gen -build -run
library(ies) analysis: [100.00%]
header(s) analysis: [100.00%]
generating tests: 134/134 [100.00%], success/fail: 129/5    
1. see generated test suite in the directory 'tests/libctools/0.0/'
2. for viewing the tests use 'tests/libctools/0.0/view_tests.html'
3. use -build option for building tests
building tests: 129/129 [100.00%], success/fail: 129/0    
running tests: 129/129 [100.00%], success/fail: 125/4    
creating report ...
see test results in the file:
  test_results/libctools/0.0/test_results.html

So I now have what I wanted, so as far as I'm concerned feel free to close this ticket.

You mentioned it might be a bug that it is necessary to add the <libs_depend>, if you can't reproduce this issue let me know how I can help track it down.

@aponomarenko
Copy link
Collaborator

Cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants