https://github.com/elektrobit/cmocka_mocks
Library to mock common C functions, including libc and jsonc, for testing purposes.
https://github.com/elektrobit/cmocka_mocks
cmocka libc mocks unittest
Last synced: 8 months ago
JSON representation
Library to mock common C functions, including libc and jsonc, for testing purposes.
- Host: GitHub
- URL: https://github.com/elektrobit/cmocka_mocks
- Owner: Elektrobit
- License: mit
- Created: 2023-08-29T11:20:38.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-09-09T12:41:55.000Z (9 months ago)
- Last Synced: 2025-09-09T14:38:02.727Z (9 months ago)
- Topics: cmocka, libc, mocks, unittest
- Language: C
- Homepage: https://github.com/Elektrobit/elos/
- Size: 221 KB
- Stars: 0
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cmocka_mocks
Library to mock common C functions, like libc and jsonc,
for testing purposes. This collection of ready to use mocks is based on
[cmocka_extensions](https://github.com/Elektrobit/cmocka_extensions)
## Building
Make sure to install all dependencies
* cmocka
* cmocka_extensions
* libmnl
* jsonc
* openssl
cmocka_mocks uses CMake for building:
```bash
cmake -B ./build/
make -C ./build/ all
make -C ./build/ install
```
or use the CI hooks for developer setup
```bash
./ci/install_deps.py
./ci/build.sh [Release|Debug]
```
### Workspace setup
1. Please run the following git commands after cloning the repository:
```bash
git config core.hooksPath .githooks
```
to set the commit message template and to setup the project specific git hooks.
2. Usually it is a good idea to create a symlink to the compilation database
created by cmake in the build directory. Run therefore:
```
ln -s build/compile_commands.json
```
### Building with custom cmocka_extensions
If you want to build using a custom location or another remote repository for
cmocka_extensions or build another tag or branch then integration,
then the use of variables is required.
If build using cmake, simply adjust the values of ```CMOCKA_EXTENSIONS_URI```
and ```CMOCKA_EXTENSIONS_REF``` to the wanted values. URI can be a local or
remote path.
If building using the CI Hook, refer to the configuration file CONFIG.ini
```SOURCES_URI``` configures the location of the project directory while
```CMOCKA_EXTENSIONS_REPO_NAME``` configures the directory name that contains
the project directory.
Additionally ```CMOCKA_EXTENSIONS_REPO_PATH``` can be set, invalidating both
previous variables. This corresponds to setting ```CMOCKA_EXTENSIONS_URI``` in
the cmake example. In the same way setting ```CMOCKA_EXTENSIONS_REPO_REF```
does the same as in the cmake variant.
## Folders
### ci
Scripts to be used by CI pipelines to build , run various tests and checks.
### debian.native
Contains Debian packaging scripts for building the current source tree as .deb
packages. This is primarily for CI pipelines to automatically verify if the
packages are buildable or if anything needs to be changed.
See `debian.native/README.md` for more information.
### documentation
A more detailed description of the mocked functions can be found in the documentation.
```
./documentation/documentation.md
```
### src
Contains the actual productive sources.
#### src/cmocka_mocks
Contains code.
# License
MIT License
Copyright (c) [2023] [emlix GmbH, Elektrobit Automotive GmbH]
The full text of the license can be found in the [LICENSE](LICENSE) file in the repository root directory.
## Powered by EB
elos is powered by elektrobit automotive gmbh.
Elektrobit is an automotive software company and developer of embedded software products for ECU, AUTOSAR, automated driving, connected vehicles and UX.
elos isan integrated part of EB corbos Linux – built on Ubuntu is an open-source operating system for high-performance computing, leveraging the rich functionality of Linux while meeting security and industry regulations.
## Maintainers
* Wolfgang Gehrhardt wolfgang.gehrhardt@emlix.com [@gehwolf](https://github.com/gehwolf)
* Thomas Brinker thomas.brinker@emlix.com [@ThomasBrinker](https://github.com/ThomasBrinker)
## Credits
* Andreas Schickedanz
* Andreas Zdziarstek
* Anja Lehwess-Litzmann
* Annika Schmitt
* Anton Hillerband
* Benedikt Braunger
* Christian Steiger
* Daniel Glöckner
* Fabian Godehardt
* Friedrich Schwedler
* Isaac True
* Joerg Vehlow
* Maryniuk Bogdan
* Rainer Müller
* Sabrina Otto
* Thomas Brinker
* Vignesh Jayaraman
* Wolfgang Gehrhardt