Difference between revisions of "Developer:Testing"

From Open Babel
Jump to: navigation, search
Line 38: Line 38:
[http://www.gnu.org/software/binutils/manual/html_chapter/binutils_9.html c++filt]
[http://www.gnu.org/software/binutils/manual/html_chapter/binutils_9.html c++filt]
Using the Visual C++ project files for Open Babel, the Microsoft tools offer debugging and profiling options.

Revision as of 16:42, 16 February 2006

Testing (and documenting) Open Babel is an important, and never-ending task. The following documentation is intended to give some idea as to the types of tests used by Open Babel and various tools available for debugging and testing.

Types of Tests

  • Unit tests - These are run under the UNIX build environment by calling make check and include a variety of tests
    • Ideally these tests should cover every public function in the Open Babel API.
    • The tests attempt to show that functions work as indicated (i.e. pass) and fail properly on unacceptable input.
  • Roundtrip tests - These are run from the test file repository and test file translation to/from all file formats.
  • Scripting "wrapper" tests -- Both the PerlWrapper and PythonWrapper have additional tests to ensure that these scripting language modules work.
    • These tests not only stress the "wrapper" module, but also the underlying library.

UNIX/Linux/Mac OS X

A variety of tools can be used to help diagnose problems and debug errors:


  • gdb - the GNU project debugger is a basic debugger on UNIX systems.
    • GDB can be run on the babel program like so: ./libtool gdb src/babel
    • Several GDB commands are highly useful, including bt which gives a full backtrace of program execution upon error.

Memory Checkers

Unlike languages like Java, which handle memory allocation and deletion, C++ requires that all code handle memory. In particular, this means if you use new or malloc or similar calls, you must be sure the memory will be properly freed when no longer needed. So-called "memory leaks" are cases where memory has been allocated, but never properly freed and are significant bugs in Open Babel.

Several tools can help find such errors:

  • Valgrind - Works on several platforms by carefully monitoring each memory access and allocation.
  • LeakTracer - Works on a range of platforms by using C++ operator overloading.

Code Profiling

To improve the speed of execution, it is often helpful to rely on tools which can

  • gprof - Used with the GCC compilers to produce profiling data including the number of calls to routines and the amount of time spent executing.
  • Shark / Saturn (Mac OS X only) - Graphical front-ends to gprof and can sample programs while running.

C++ Unscrambler

The symbols used by C++ compilers and exposed by debugging, profiling, and memory tools are "scrambled." The c++filt program can be used to decode the symbol to a human-readable form:



Using the Visual C++ project files for Open Babel, the Microsoft tools offer debugging and profiling options.