An open API service indexing awesome lists of open source software.

https://github.com/pseudoincorrect/cpython_testing_framework

Template for testing (integration test) C code with cpython
https://github.com/pseudoincorrect/cpython_testing_framework

c cpython python template

Last synced: 3 months ago
JSON representation

Template for testing (integration test) C code with cpython

Awesome Lists containing this project

README

        

Cpython Testing framework

Simple framework made to either test (integration) C code with python or to start a new Cpython project.

File Architecture:
main.py:
Python script that will:
Compile the C code in c_src/ folder
Import the compiled .so C library
Import data from data/ folder
Run the test (c function thanks to cpython)
Display with matplot lib
c_src/:
src/:
.c and .h C files to be compiled
makefile:
Gnu make build automation file
data/:
Timeseries data to be inputed in python

Example chosen:
The ./data/ folder contains the data of an optical heart rate sensor
The C sources contains the algorith need to filter the above date and extrac the heart rate within the python code, we will input those data one by one to the .so library.
For each data inputed, the .so library's function will output a filtered one.
We will then display both input and output signals.

Debugging python is straight forward (especially with vscode or other "IDE/text editors")

However to debug the C code in ./src/ folder they are two ways:
Simpler one:
Use printf with the c code and run the main.py to compile it, and display the print statements
More advanced one:
Use vscode and GDB (or LLVM on mac)
Go to ./c_src/ $> make executable
Use gdb with the binary file created in ./c_src/bin
Optional, setup VScode to debug with GDB:
https://code.visualstudio.com/docs/languages/cpp (debugging section)

Instructions:
$> python main.py