Commit Graph

770 Commits

Author SHA1 Message Date
Sergey Bronnikov 0df9d23bab cmocka: add header with version to TAP13 output
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-04 11:05:33 +02:00
Pascal Cuoq 1206b4ac0e remove union ValuePointer
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-10-04 09:58:16 +02:00
Emmanuel Fleury 071a3a187f Better integration of cmocka as meson-build git subprojects
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-10-04 09:54:24 +02:00
Anderson Toshiyuki Sasaki a731966c62 cmocka: Add compiler attributes to non-returning functions
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-04 09:45:39 +02:00
Sirio Balmelli 9c114ac31a mainpage.dox: fix typo
Signed-off-by: Sirio Balmelli <sirio@b-ad.ch>
2020-10-04 09:44:22 +02:00
Andreas Schneider f24ef3ce57 cmake: Remove obsolete cmocka-config.cmake.in 2020-10-04 09:42:29 +02:00
Matthias Schiffer f49d5c476a Fix TAP output for skipped tests
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-10-04 09:36:47 +02:00
Andreas Schneider f615c3f3e7 gitlab-ci: Add Unbuntu runner 2020-08-25 17:51:24 +02:00
Samuel Vasko 672c5cee79 Refactor symbol map freeing to avoid UB
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-13 11:36:50 +01:00
Andreas Schneider 13c1c7afb4 src: Add group_name in cmprintf_group_start_standard 2020-02-06 08:44:02 +01:00
Arnaud Gelas 946c151269 Add group_name in cmprintf_group_finish_standard.
When using cmocka_run_group_tests_name, group_name was not printed; which made
it complicated to know when one failure occurs.
2020-02-06 08:41:55 +01:00
Alexander Dahl 1cc9cde344 build: Export CMake config with namespace 'cmocka::'
The internal targets use 'target_link_libraries' with cmocka::cmocka and
so should external users of the lib.

Fixes: e4c51ce ("cmake: Export cmake config for cmocka")
Signed-off-by: Alexander Dahl <post@lespocky.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-05 11:56:39 +01:00
Andreas Schneider 22264569de cmake: Add options for BUILD_SHARED_LIBS 2019-11-19 15:57:27 +01:00
Andreas Schneider e4c51ce9a4 cmake: Export cmake config for cmocka
For backwards compatibility use:

    find_package(cmocka REQUIRED)
    if (NOT TARGET cmocka)
         add_library(cmocka SHARED IMPORTED)
         set_target_properties(cmocka
                               PROPERTIES
                               IMPORTED_LOCATION "${CMOCKA_LIBRARIES}"
                               INTERFACE_INCLUDE_DIRECTORIES "${CMOCKA_INCLUDE_DIR}")
    endif()

    target_link_libraries(mylib cmocka)
2019-11-19 15:55:15 +01:00
Fabrice Fontaine 28ce16b299 Don't redefine uintptr_t
Add a call to check_type_size in ConfigureChecks.cmake and use it in
include/cmocka.h to avoid the following redefinition error on riscv64:

In file included from /data/buildroot/buildroot-test/instance-0/output/build/cmocka-1.1.5/src/cmocka.c:62:
/data/buildroot/buildroot-test/instance-0/output/build/cmocka-1.1.5/include/cmocka.h:132:28: error: conflicting types for 'uintptr_t'
       typedef unsigned int uintptr_t;
                            ^~~~~~~~~
In file included from /data/buildroot/buildroot-test/instance-0/output/host/riscv64-buildroot-linux-musl/sysroot/usr/include/stdint.h:20,
                 from /data/buildroot/buildroot-test/instance-0/output/host/riscv64-buildroot-linux-musl/sysroot/usr/include/inttypes.h:9,
                 from /data/buildroot/buildroot-test/instance-0/output/build/cmocka-1.1.5/src/cmocka.c:27:
/data/buildroot/buildroot-test/instance-0/output/host/riscv64-buildroot-linux-musl/sysroot/usr/include/bits/alltypes.h:104:24: note: previous declaration of 'uintptr_t' was here
 typedef unsigned _Addr uintptr_t;
                        ^~~~~~~~~

Fixes:
 - http://autobuild.buildroot.org/results/30922c18150ea62aefe123d1b7cd1444efab963f

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-11-19 15:41:58 +01:00
Pablo Oliveira 7cc94638ef Fix comparison between pointer and integer in Doxigen example
cmocka_run_group_tests Doxigen example should not dereference answer when checking the malloc result.
2019-11-19 15:41:23 +01:00
Andreas Schneider 61ab1b9207 gitlab-ci: Remove Debian MIPS as they dropped support for it 2019-11-19 15:38:42 +01:00
Arnaud Gelas 226a89cc43 cmocka: Add new assert macros to compare 2 double given an epsilon.
assert_double_equal and assert_double_not_equal

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-11-19 15:38:34 +01:00
Arnaud Gelas 1e21400a79 cmocka: Fix indentation
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-11-19 15:25:39 +01:00
Andreas Schneider ff70e53b65 cmake: Link compile database to source dir for clangd
See
https://github.com/ycm-core/YouCompleteMe
https://github.com/abingham/emacs-ycmd

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-10-25 10:15:34 +02:00
Arnaud Gelas 1a41f98a6b cmake: Fix usage of cmocka with build tree
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-10-22 09:09:06 +02:00
Andreas Schneider 8e60ec80b6 cmocka: Cast return to int in _cmocka_run_group_tests()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-10-22 08:51:32 +02:00
Paolo Teti 3f82b50d57 Fix MSVC warning on conversion from 'time_t' to 'double'
Fixes the following MSVC warning:

warning C4244: '=': conversion from 'time_t' to 'double',
possible loss of data

Signed-off-by: Paolo Teti <paolo.teti@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-10-22 08:30:13 +02:00
Paolo Teti 5f0c2fe370 Fix possible loss of data reported by MSVC
Fixes the following warning:

warning C4267: 'return': conversion from 'size_t' to 'int',
possible loss of data

Signed-off-by: Paolo Teti <paolo.teti@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-10-22 08:30:13 +02:00
Andreas Schneider 0be5fb3c9c cmake: Create a static cmocka library for testing
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-10-22 08:28:24 +02:00
Andreas Schneider f90eb49488 gitlab-ci: Set the build type to Debug
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-10-22 07:38:07 +02:00
Paolo Teti ea10b51375 CI: Attemp to fix MSVC pipeline
Attemp to fix 'Exit code 0xc0000139' (DLL not found) when running tests.

Signed-off-by: Paolo Teti <paolo.teti@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-10-21 10:41:30 +02:00
Arnaud Gelas 86681906ba cmake: Make shared lib optional
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-10-16 09:05:18 +02:00
Arnaud Gelas c151f45ed0 Fix in INSTALL.md cmake required version (i.e. >= 3.5.0)
https://gitlab.com/cmocka/cmocka/issues/33
2019-10-16 08:45:12 +02:00
Dima Krasner 2f9c815def gitlab-ci: Add a Meson runner 2019-08-22 11:42:02 +02:00
Dima Krasner 33d48bfaa7 meson: Build and run unit tests 2019-08-22 11:41:49 +02:00
Dima Krasner aed0d9dd55 meson: Initial Meson build system support
Signed-off-by: Dima Krasner <dima@dimakrasner.com>
2019-08-22 11:41:44 +02:00
myd7349 9aa64bb7f8 cmocka: Fix C4703 build error on UWP 2019-08-21 09:40:01 +02:00
Janusz Jankowski 546bd50924 cmocka: check MALLOC_ALIGNMENT macro
Some compilers already define this macro in standard
libary headers, for example GCC for Xtensa

Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-29 11:56:23 +01:00
Andreas Schneider f5e2cd77c8 Bump version to 1.1.5
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-28 13:33:38 +01:00
Anderson Toshiyuki Sasaki 4b6a9ed43b tests: Add tests for skip filter
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-28 13:32:07 +01:00
Anderson Toshiyuki Sasaki 262e7d00d0 cmocka: Add cmocka_set_skip_filter() to skip tests
The introduced cmocka_set_skip_filter() allows setting a filter for
tests to be skipped.  It supports the same wildcards allowed for
cmocka_set_test_filter() (i.e. '*' or '?').

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-28 13:32:02 +01:00
Anderson Toshiyuki Sasaki 4c5639246c include: Fixed typo in documentation
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-28 13:31:58 +01:00
Andreas Schneider f33b5cee61 def: Add missing exports for _assert_float_(not_)equal
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-28 13:30:25 +01:00
Andreas Schneider ad4f670e73 Bump version to 1.1.4 2019-03-28 13:26:33 +01:00
Andreas Schneider a5655944b6 include: Add missing semicolon
Fixes #22

Reported-by: Stef van Os
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-27 15:47:56 +01:00
Andreas Schneider c4cdb7435b cmake: Fix lib name on Windows
Fixes #19

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-12 22:11:24 +01:00
Andreas Schneider 453306b671 cmake: Do not link to librt on Android
Fixes #16

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-12 22:11:19 +01:00
Andreas Schneider 18726b3aa0 cmake: Disable in source builds the cmake way
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-12 22:11:19 +01:00
Andreas Schneider 6827e25d5a include: Fix documentation links
Fixes #17

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-12 22:11:19 +01:00
Richard Bayerle 765c1d1a82 XML output is JUnit XML, not xUnit XML.
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-25 16:24:29 +01:00
Andreas Schneider d2010dfafb examples: Include stdint.h in simple example
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-19 16:13:07 +01:00
Andreas Schneider 98bdcfe56f gitlab-ci: Add target for MemorySanitizer
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-25 13:32:08 +01:00
Andreas Schneider 700ebf3324 cmake: Add MemorySanitizer build type
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-25 13:32:08 +01:00
Andreas Schneider b242604489 cmocka: Use calloc for allocating memory
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-25 13:32:08 +01:00