summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2024-07-15doc: Fix pre-defined macro definitionstable-1.1Andreas Schneider1-1/+1
We need to escape the braces or cmake will break it up. Fixes #101
2024-02-04cmocka: Fix assert_memory_equal() displayJoseph Sutton1-3/+3
The %x specifier expects an unsigned argument. If char is signed, cmocka_print_error() may incorrectly display values sign-extended. To fix this, use an unsigned char and the corresponding format specifier (%hhx). Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> (backported from commit 2206c22515e788f7a43cde2162408081b3e8f6ae)
2024-02-03cmake: disable `-Wdeclaration-after-statement`Alois Klink1-2/+0
Disable `-Wdeclaration-after-statement`. Before ISO C99, declaring variables after statements was not allowed by the C standard, but was allowed by GCC as an extension. CMocka now requires a minimum version of C99, since commit 5a4b15870efa2225e6586fbb4c3af05ff0659434, so this behaviour is valid on all compilers. on-behalf-of: @nqminds <info@nqminds.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> (cherry picked from commit bfdf78c4e6f870977ff8996abecd84ba7086a331)
2024-02-03Sanitize XML strings.Jakub Czapiga3-5/+26
Replace characters with their XML string equivalents to allow for them in the tests and groups names. Reviewed-by: Andreas Schneider <asn@cryptomilk.org> (cherry picked from commit 90315882d6de183ab31b66b5008d4ca3d1fea140)
2024-02-03Improve c_strreplace implementationJakub Czapiga3-9/+147
Return successfuly if there is nothing to replace. Allow for replacement with superset pattern. Simplified example without fix: c_strreplace("ABCD", "A", "AX") -> "AAAAAA...AAAXBCD" Simplified example with fix: c_strreplace("ABCD", "A", "AX") -> "AXBCD" Reviewed-by: Andreas Schneider <asn@cryptomilk.org> (cherry picked from commit 54b3af4631e19bdf64ebfc3985c3dd9abf775321)
2024-02-02cmake: Set CMOCKA_LIBRARIES in package config for backwards compatibilityAlexander Dahl3-3/+21
Projects using cmocka could have done this successfully from version 1.0 to 1.1.5 to build against cmocka: ``` find_package(cmocka 1.0 REQUIRED CONFIG) ``` and later ``` target_link_libraries(myapp ${CMOCKA_LIBRARIES} ) ``` Modern apps should just "link" against 'cmocka::cmocka' instead like it's done in examples already. To not break old builds (as it is the case with cmocka release 1.1.7) we can put that modern target string into the variable CMOCKA_LIBRARIES and thus trick old projects to just use that, keeping compatibility until those projects explicitly use the modern version. Link: https://cmake.org/cmake/help/latest/command/install.html#install-export Link: https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#package-configuration-file Link: https://cmake.org/cmake/help/latest/module/CMakePackageConfigHelpers.html#module:CMakePackageConfigHelpers Fixes: #87 Signed-off-by: Alexander Dahl <ada@thorsis.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> (cherry picked from commit de67675842e549008f3e1aeb03ae7995afa3dd26)
2024-02-02cmocka: Add overflow check for test_calloc()Alexander Dahl1-1/+10
Makes the implementation behave the same like libc calloc() and not fail with unpredictable errors in test_malloc() anymore. Signed-off-by: Alexander Dahl <ada@thorsis.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> (cherry picked from commit 6ff1378b6f4e82af7bb53868f8526cf8e0a0cf98)
2024-02-02tests: Add test for test_calloc()Alexander Dahl1-0/+20
calloc() is prone to integer overflow on multiplication of its arguments. glibc, musl, and uclibc test for that in its implementations and return NULL in that case with errno set to ENOMEM. cmocka lacks such a check and passes all kinds of overflown values to test_malloc() with different ways to fail. Signed-off-by: Alexander Dahl <ada@thorsis.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> (cherry picked from commit d87c470017e095a01d9e9233f35c0b5254431648)
2023-02-23Bump version to 1.1.7cmocka-1.1.7Andreas Schneider2-1/+5
2023-02-19cpack: Update ignore files for source package generationAndreas Schneider1-1/+5
Fixes #86
2023-02-17Bump version 1.1.6cmocka-1.1.6Andreas Schneider2-2/+13
2023-02-16tests: The exception handler doesn't work on WindowsAndreas Schneider1-11/+8
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2023-02-16tests: Raise segmantation faultAndreas Schneider1-10/+4
This way compilers should not mark it as unreachable.
2023-02-16tests: Rename exceptions tests arrayAndreas Schneider1-2/+2
2023-02-16tests: Better match for test_exception_handlerAndreas Schneider1-1/+1
2023-02-16cmake: Fix path relocation in pkgconfig file for mingwBiswapriyo Nath2-5/+11
This fixes path relocation in mingw environment by using predefined Libs and Cflags variable in pkgconfig file. Otherwise, libdir and includedir are not shown in pkgconf output. e.g. * Without predefined variables: - pkgconf -cflags cmocka: No output - pkgconf -libs cmocka: -lcmocka * With predefined variables: - pkgconf -cflags cmocka: -IC:/msys64/mingw64/include - pkgconf -libs cmocka: -LC:/msys64/mingw64/lib -lcmocka Also official documentation suggests to use predefiend keywords here https://people.freedesktop.org/~dbn/pkg-config-guide.html Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2023-02-16cmake: Do not use CMAKE_(BINARY|SOURCE)_DIR for compile_commands.jsonAndreas Schneider1-2/+2
This should fix being imported by other projects. Fixes #85
2023-02-16Improve INSTALL.mdAndreas Schneider2-12/+30
Fixes #63
2023-02-16doc: Link to the examples for mockingAndreas Schneider1-1/+1
Fixes #65
2023-02-16include: Update copyright year infoAndreas Schneider1-1/+1
2023-02-16include: Define strtok_r with Visual StudioAndreas Schneider1-0/+2
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2023-02-16gitlab-ci: Move memory and ub sanitizer to analysis stageAndreas Schneider1-2/+2
2023-02-16gitlab-ci: Move freebsd to test stageAndreas Schneider1-1/+1
2023-02-16examples: Add missing compile and link optionsAndreas Schneider1-0/+7
2023-02-16gitlab-ci: Introduce stagesAndreas Schneider1-0/+23
2023-02-16gitlab-ci: Fix typo in fedora/mingw32 buildAndreas Schneider1-1/+1
2023-02-16gitlab-ci: Use gitlab windows runnersAndreas Schneider1-39/+32
2023-02-16gitlab-ci: Reformat yamlAndreas Schneider1-178/+180
2023-02-16tests: Initialize 'struct stat' in test_assert_macros.cAndreas Schneider1-1/+1
2023-02-16cmake: Fix path where to find cmocka.dllAndreas Schneider1-1/+1
2023-02-16include: Improved call ordering documentationFrédéric Jouault1-1/+4
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2023-02-16doc: Remove redundant wordsAlexander Dahl1-1/+1
Fixes: 400038f6cac9 ("include: Add a group for mock objects.") Signed-off-by: Alexander Dahl <ada@thorsis.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2023-02-16Fix issue with fail_msgAmmar Ratnani2-3/+2
2020-10-12cmocka: Fix cm_print_error() in check_for_leftover_values(_list)Andreas Schneider1-2/+2
Fixes #26 (cherry picked from commit fe9663b80e1e505e93522ef75a660bedc32d7775)
2020-10-06include: Improve documentation for expect_value()Andreas Schneider1-3/+9
2020-10-06doc: Add stdint.h to headersAndreas Schneider2-0/+2
Will be required in future.
2020-10-06doc: Remove old and obsolete index.htmlAndreas Schneider1-706/+0
The documentation is doxygen generated in the meantime!
2020-10-06cmocka: Remove cast in assert_string_(not_)equal macrosAndreas Schneider3-4/+43
Also add basic tests Fixes #48
2020-10-06cmocka: Increase the vprint buffersAndreas Schneider1-4/+8
Fixes #51
2020-10-05cmocka: add header with version to TAP13 outputSergey Bronnikov2-3/+13
Version must be specified in a first line of TAP13 output. See TAP13 specification - https://testanything.org/tap-version-13-specification.html Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-10-04remove union ValuePointerPascal Cuoq1-31/+11
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-10-04Better integration of cmocka as meson-build git subprojectsEmmanuel Fleury1-23/+36
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-10-04cmocka: Add compiler attributes to non-returning functionsAnderson Toshiyuki Sasaki2-3/+20
This introduces the CMOCKA_NORETURN macro which adds the __attribute__((noreturn)) attribute to non-returning functions. In Windows, __declspec(noreturn) is added instead. Functions that don't return but are not marked with the attribute can confuse static analysers, making them to report false positives. Add CMOCKA_NORETURN attribute to _fail(), _skip(), and to the internal exception_handler(). Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-10-04mainpage.dox: fix typoSirio Balmelli1-1/+1
Signed-off-by: Sirio Balmelli <sirio@b-ad.ch>
2020-10-04cmake: Remove obsolete cmocka-config.cmake.inAndreas Schneider1-15/+0
2020-10-04Fix TAP output for skipped testsMatthias Schiffer2-2/+2
According to [1], a skipped test should print "ok" and not "not ok" before "# SKIP". This breaks tests harnesses like the one built into Meson [2]. [1] http://testanything.org/tap-specification.html [2] https://mesonbuild.com/Unit-tests.html
2020-08-25gitlab-ci: Add Unbuntu runnerAndreas Schneider1-0/+19
2020-02-13Refactor symbol map freeing to avoid UBSamuel Vasko1-3/+10
Removes a undefined behaviour (uint underflow) happening when freeing a value. Fortunately this undefined behaviour has no effect on the program. It only manifests itself when cmocka is compiled using clangs undefined behaviour sanitizer. Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-02-06src: Add group_name in cmprintf_group_start_standardAndreas Schneider1-6/+9
2020-02-06Add group_name in cmprintf_group_finish_standard.Arnaud Gelas2-17/+28
When using cmocka_run_group_tests_name, group_name was not printed; which made it complicated to know when one failure occurs.