From 9dff85f0dc84c8da541f0cf3c3a92d40940435d1 Mon Sep 17 00:00:00 2001 From: John Beard Date: Wed, 1 Mar 2017 19:05:40 +0800 Subject: [PATCH] Add developer docs about testing --- Documentation/development/testing.md | 41 ++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Documentation/development/testing.md diff --git a/Documentation/development/testing.md b/Documentation/development/testing.md new file mode 100644 index 0000000000..8a80fd3f48 --- /dev/null +++ b/Documentation/development/testing.md @@ -0,0 +1,41 @@ +# Testing KiCad # + +# Unit tests # + +KiCad has a limited number of unit tests, which can be used to +check that certain functionality works. + +## Python modules ## + +The Pcbnew Python modules have some test programs in the `qa` directory. +You must have the `KICAD_SCRIPTING_MODULES` option on in CMake to +build the modules and enable this target. + +The main test script is `qa/test.py` and the test units are in +`qa/testcases`. All the test units can by run using `make qa`, which +runs `test.py`. + +You can also run an individual case manually, by making sure the +modules are built, adding them to `PYTHONPATH` and running the test +from the source tree: + + make pcbnew_python_module + export PYTHONPATH=/path/to/kicad/build/pcbnew + cd /path/to/kicad/source/qa + python2 testcase/test_001_pcb_load.py + +### Diagnosing segfaults ### + +Although the module is Python, it links against a C++ library +(the same one used by KiCad Pcbnew), so it can segfault if the library +has a defect. + +You can run the tests in GDB to trace this: + + $ gdb + + (gdb) file python2 + (gdb) run testcases/test_001_pcb_load.py + +If the test segfaults, you will get a familiar backtrace, just like +if you were running pcbnew under GDB.