api-sanity-checker icon indicating copy to clipboard operation
api-sanity-checker copied to clipboard

C++ Exceptions always reported as ABRT warnings?

Open cdeil opened this issue 11 years ago • 4 comments

I have a C++ library that makes extensive use of C++ exceptions.

Running it through the api-sanity-checker results in over 1000 warnings. I looked at a dozen, and they were all cases where an exception was supposed to be thrown and wasn't catched in the generated test case.

The API sanity checker documentation doesn't mention C++ exceptions at all (or I overlooked it). Can you please add some information if generating tons of ABRT signals is the expected behaviour and if there is a way to suppress these warnings to maybe find real issues?

Thanks!

cdeil avatar Nov 02 '12 16:11 cdeil

Thanks for the idea!

The tool should be definitely improved to support generation of try/catch pairs in the test case for functions that can throw exceptions. I will add an option like "-catch" to the tool on the next week or so. This should allow to separate cases with incorrect functions usage from other issues.

But why your functions have thrown exceptions? Are the generated input parameters so incorrect? May be test cases should be improved?

Use specialized types to improve generated tests: http://ispras.linuxbase.org/index.php/Specialized_Type

aponomarenko avatar Nov 02 '12 19:11 aponomarenko

I am working on gammalib ( http://gammalib.sourceforge.net ), in case you want to have a look at the exceptions. I don't think there is anything the api-sanity-checker can do to generate better in put parameters, gammalib simply uses exceptions to signal things to API users. Isn't this normal for many C++ libraries?

cdeil avatar Nov 02 '12 19:11 cdeil

I don't think there is anything the api-sanity-checker can do to generate better in put parameters

Some additional heuristics or additional spec-types can improve input parameters. I will try to adapt the tool to the gammalib if possible this Tuesday when I access my workstation. But for now you can correct the generation process by writing some spec-types by yourself. May be some pre-condition is needed for all tests or some commonly used class needs a special initialization. All of this can be described in the spec-types that can be provided to the tool in order to generate better tests.

gammalib simply uses exceptions to signal things to API users. Isn't this normal for many C++ libraries?

Actually, the tool was initially created in 2008 to generate "shallow"-quality tests for Qt 3 and Qt 4 libraries (about 20.000 functions) under the LSB Infrastructure project. Qt is not using exceptions for errors.

aponomarenko avatar Nov 02 '12 20:11 aponomarenko

That is good to know that ABRT warnings are normal when running the api-sanity-checker on a library with exceptions and I'm not doing something wrong. If there is a way to separate those warnings from possible real issues that show up as ABRT warnings in the report that might be useful. I don't know though what other issues might generate ABRT signals and if it is technically possible for the api-sanity-checker to distinguish the exceptions from the other cases. Otherwise I think simply adding a few sentences to the api-sanity-checker documentation on C++ exceptions would be nice.

cdeil avatar Nov 05 '12 16:11 cdeil