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
- Host: GitHub
- URL: https://github.com/pseudoincorrect/cpython_testing_framework
- Owner: pseudoincorrect
- Created: 2019-03-19T18:44:22.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-20T09:12:35.000Z (over 6 years ago)
- Last Synced: 2025-02-09T09:09:59.770Z (4 months ago)
- Topics: c, cpython, python, template
- Language: C
- Homepage:
- Size: 112 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme
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 pythonExample 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