Projects
openEuler:Mainline
cmocka
Sign Up
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 5
View file
_service:tar_scm:cmocka.spec
Changed
@@ -1,6 +1,6 @@ Name: cmocka -Version: 1.1.5 -Release: 3 +Version: 1.1.7 +Release: 1 License: ASL 2.0 Summary: An elegant unit testing framework for C with support for mock objects @@ -87,9 +87,12 @@ %{_libdir}/pkgconfig/cmocka.pc %{_libdir}/cmake/cmocka/cmocka-config-version.cmake %{_libdir}/cmake/cmocka/cmocka-config.cmake -%{_libdir}/libcmocka-static.a +%{_libdir}/cmake/cmocka/cmocka-config-noconfig.cmake %changelog +* Wed Jun 21 2023 yaoxin <yao_xin001@hoperun.com> - 1.1.7-1 +- Update to 1.1.7 + * Mon May 31 2021 baizhonggui <baizhonggui@huawei.com> - 1.1.5-3 - Add gcc in BuildRequires
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/.gitlab-ci.yml
Deleted
@@ -1,400 +0,0 @@ -variables: - BUILD_IMAGES_PROJECT: cmocka/gitlab-build-images - FEDORA_BUILD: buildenv-fedora - CENTOS7_BUILD: buildenv-centos7 - TUMBLEWEED_BUILD: buildenv-tumbleweed - MINGW_BUILD: buildenv-mingw - DEBIAN_CROSS_BUILD: buildenv-debian-cross - -centos7/x86_64: - image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$CENTOS7_BUILD - script: - - mkdir -p obj && cd obj && cmake3 - -DCMAKE_BUILD_TYPE=RelWithDebInfo - -DPICKY_DEVELOPER=ON - -DUNIT_TESTING=ON .. && - make -j$(nproc) && ctest --output-on-failure - tags: - - shared - except: - - tags - artifacts: - expire_in: 1 week - when: on_failure - paths: - - obj/ - -fedora/x86_64: - image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD - script: - - mkdir -p obj && cd obj && cmake - -DCMAKE_BUILD_TYPE=RelWithDebInfo - -DPICKY_DEVELOPER=ON - -DUNIT_TESTING=ON .. && - make -j$(nproc) && ctest --output-on-failure - tags: - - shared - except: - - tags - artifacts: - expire_in: 1 week - when: on_failure - paths: - - obj/ - -fedora/address-sanitizer: - image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD - script: - - mkdir -p obj && cd obj && cmake - -DCMAKE_BUILD_TYPE=AddressSanitizer - -DPICKY_DEVELOPER=ON - -DUNIT_TESTING=ON .. && - make -j$(nproc) && ctest --output-on-failure - tags: - - shared - except: - - tags - artifacts: - expire_in: 1 week - when: on_failure - paths: - - obj/ - -fedora/memory-sanitizer: - image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD - script: - - mkdir -p obj && cd obj && cmake - -DCMAKE_BUILD_TYPE=MemorySanitizer - -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ - -DUNIT_TESTING=ON .. - && make -j$(nproc) && ctest --output-on-failure - tags: - - shared - except: - - tags - artifacts: - expire_in: 1 week - when: on_failure - paths: - - obj/ - -fedora/undefined-sanitizer: - image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD - script: - - mkdir -p obj && cd obj && cmake - -DCMAKE_BUILD_TYPE=UndefinedSanitizer - -DUNIT_TESTING=ON .. - && make -j$(nproc) && ctest --output-on-failure - tags: - - shared - except: - - tags - artifacts: - expire_in: 1 week - when: on_failure - paths: - - obj/ - -fedora/csbuild: - image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD - script: - - | - if -z "$CI_COMMIT_BEFORE_SHA" ; then - export CI_COMMIT_BEFORE_SHA=$(git rev-parse "${CI_COMMIT_SHA}~20") - fi - - # Check if the commit exists in this branch - # This is not the case for a force push - git branch --contains $CI_COMMIT_BEFORE_SHA 2>/dev/null || export CI_COMMIT_BEFORE_SHA=$(git rev-parse "${CI_COMMIT_SHA}~20") - - export CI_COMMIT_RANGE="$CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA" - - - csbuild - --build-dir=obj-csbuild - --prep-cmd="cmake -DCMAKE_BUILD_TYPE=Debug -DPICKY_DEVELOPER=ON -DUNIT_TESTING=ON @SRCDIR@" - --build-cmd "make clean && make -j$(nproc)" - --git-commit-range $CI_COMMIT_RANGE - --color - --print-current --print-fixed - tags: - - shared - except: - - tags - artifacts: - expire_in: 1 week - when: on_failure - paths: - - obj-csbuild/ - -freebsd/x86_64: - image: - script: - - mkdir -p obj && cd obj && cmake - -DCMAKE_BUILD_TYPE=RelWithDebInfo - -DPICKY_DEVELOPER=ON - -DUNIT_TESTING=ON .. && - make && ctest --output-on-failure - tags: - - freebsd - except: - - tags - only: - - branches@cmocka/cmocka - - branches@cryptomilk/cmocka - artifacts: - expire_in: 1 week - when: on_failure - paths: - - obj/ - -fedora/mingw64: - image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$MINGW_BUILD - script: - - export WINEPATH=/usr/x86_64-w64-mingw32/sys-root/mingw/bin - - export WINEDEBUG=-all - - mkdir -p obj && cd obj && mingw64-cmake - -DCMAKE_BUILD_TYPE=RelWithDebInfo - -DPICKY_DEVELOPER=ON - -DUNIT_TESTING=ON .. && - make -j$(nproc) && - ctest --output-on-failure - tags: - - shared - except: - - tags - artifacts: - expire_in: 1 week - when: on_failure - paths: - - obj/ - -fedora/mingw32: - image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$MINGW_BUILD - script: - - export WINEPATH=/usr/i686-w64-mingw32/sys-root/mingw/bin - - export WINEDEBUG=-all - - mkdir -p obj && cd obj && mingw32-cmake - -DCMAKE_BUILD_TYPE=RelWithDebInfo - -DPICKY_DEVELOPER=ON - -DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON --DWITH_PCAP=ON - -DUNIT_TESTING=ON .. && - make -j$(nproc) && - ctest --output-on-failure - tags: - - shared - except: - - tags - artifacts: - expire_in: 1 week - when: on_failure - paths: - - obj/ - -.Debian.cross.template: &Debian_cross_template - stage: test - image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$DEBIAN_CROSS_BUILD - script: - - build=$(dpkg-architecture -qDEB_HOST_GNU_TYPE) - - host="${CI_JOB_NAME#*.cross.}" - - mkdir -p obj && cd obj && cmake
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/5.patch
Deleted
@@ -1,34 +0,0 @@ -From addb1927eb979310a01abc65f29a5408a970da11 Mon Sep 17 00:00:00 2001 -From: Richard Bayerle <richi.bayerle@gmail.com> -Date: Sun, 24 Feb 2019 16:38:05 +0000 -Subject: PATCH XML output is JUnit XML, not xUnit XML. - ---- - doc/mainpage.dox | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/doc/mainpage.dox b/doc/mainpage.dox -index 4c26d96..c378bb1 100644 ---- a/doc/mainpage.dox -+++ b/doc/mainpage.dox -@@ -33,7 +33,7 @@ The CMocka library provides: - - Very well tested - - Testing of memory leaks, buffer overflows and underflows. - - A set of assert macros. -- - Several supported output formats (stdout, TAP, xUnit XML, Subunit) -+ - Several supported output formats (stdout, TAP, JUnit XML, Subunit) - - License: Apache License 2.0 - - @section main-test A cmocka test -@@ -119,7 +119,7 @@ supported values are: - - <tt>STDOUT</tt> for the default standard output printer - - <tt>SUBUNIT</tt> for subunit output - - <tt>TAP</tt> for Test Anything Protocol (TAP) output -- - <tt>XML</tt> for xUnit XML format -+ - <tt>XML</tt> for JUnit XML format - The case doesn't matter. - - The XML output goes to stderr by default. If the environment variable --- -2.18.1 -
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/cmocka-config.cmake.in
Deleted
@@ -1,15 +0,0 @@ -@PACKAGE_INIT@ - -get_filename_component(CMOCKA_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) - -if (EXISTS "${CMOCKA_CMAKE_DIR}/CMakeCache.txt") - # In build tree - include(${CMOCKA_CMAKE_DIR}/cmocka-build-tree-settings.cmake) -else() - set(CMOCKA_INCLUDE_DIR @PACKAGE_INCLUDE_INSTALL_DIR@) -endif() - -set(CMOCKA_LIBRARY @PACKAGE_LIB_INSTALL_DIR@/@CMOCKA_LIBRARY_NAME@) -set(CMOCKA_LIBRARIES @PACKAGE_LIB_INSTALL_DIR@/@CMOCKA_LIBRARY_NAME@) - -mark_as_advanced(CMOCKA_LIBRARY CMOCKA_INCLUDE_DIR)
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/doc/index.html
Deleted
@@ -1,706 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> -<html><head> -<title>cmocka</title> -</head> -<body> -<h1>cmocka Unit Testing Framework</h1> -<p>cmocka is a lightweight library that is used to author C unit tests.</p> - -<ul>Contents - <li><a href="#Motivation">Motivation</a></li> - <li><a href="#Overview">Overview</a></li> - <li><a href="#Test_Execution">Test Execution</a> - <li><a href="#Exception_Handling">Exception Handling</a></li> - <li><a href="#Failure_Conditions">Failure Conditions</a></li> - <li><a href="#Assertions">Assertions</a></li> - <ul> - <li><a href="#Assert_Macros">Assert Macros</a></li> - </ul> - <li><a href="#Dynamic_Memory_Allocation">Dynamic Memory Allocation</a></li> - <li><a href="#Mock_Functions">Mock functions</a></li> - <ul> - <li><a href="#Return_Values">Return Values</a></li> - <li><a href="#Checking_Parameters">Checking Parameters</a></li> - </ul> - <li><a href="#Test_State">Test State</a></li> - <li><a href="#Example">Example</a></li> -</ul> - -<a name="Motivation"><h2>Motivation</h2></a> -<p>There are a variety of C unit testing frameworks available however many of -them are fairly complex and require the latest compiler technology. Some -development requires the use of old compilers which makes it difficult to -use some unit testing frameworks. In addition many unit testing frameworks -assume the code being tested is an application or module that is targeted to -the same platform that will ultimately execute the test. Because of this -assumption many frameworks require the inclusion of standard C library headers -in the code module being tested which may collide with the custom or -incomplete implementation of the C library utilized by the code under test.</p> - -<p>cmocka only requires a test application is linked with the standard C -library which minimizes conflicts with standard C library headers. Also, -cmocka tries avoid the use of some of the newer features of C compilers.</p> - -<p>This results in cmocka being a relatively small library that can be used -to test a variety of exotic code. If a developer wishes to simply test an -application with the latest compiler then other unit testing frameworks maybe -preferable.</p> - -<a name="Overview"><h2>Overview</h2></a> -<p>cmocka tests are compiled into stand-alone executables and linked with -the cmocka library, the standard C library and module being tested. Any -symbols external to the module being tested should be mocked - replaced with -functions that return values determined by the test - within the test -application. Even though significant differences may exist between the target -execution environment of a code module and the environment used to test the -code the unit testing is still valid since its goal is to test the logic of a -code modules at a functional level and not necessarily all of its interactions -with the target execution environment.</p> - -<p>It may not be possible to compile a module into a test application without -some modification, therefore the preprocessor symbol <b>UNIT_TESTING</b> should -be defined when cmocka unit test applications are compiled so code within the -module can be conditionally compiled for tests.</p> - -<a name="Test_Execution"><h2>Test Execution</h2></a> -<p>cmocka unit test cases are functions with the signature -<b>void function(void **state)</b>. cmocka test applications initialize a -table with test case function pointers using <b>unit_test*()</b> macros. This -table is then passed to the <b>run_tests()</b> macro to execute the tests. - -<b>run_tests()</b> sets up the appropriate exception / signal handlers and -other data structures prior to running each test function. When a unit test -is complete <b>run_tests()</b> performs various checks to determine whether -the test succeeded.</p> - -<h4>Using run_tests()</h4> -<a href="../example/run_tests.c">run_tests.c</a> -<listing> -#include <stdarg.h> -#include <stddef.h> -#include <setjmp.h> -#include <cmocka.h> - -// A test case that does nothing and succeeds. -void null_test_success(void **state) { -} - -int main(int argc, char* argv) { - const UnitTest tests = { - unit_test(null_test_success), - }; - return run_tests(tests); -} -</listing> - -<a name="Exception_Handling"><h2>Exception Handling</h2></a> -<p>Before a test function is executed by <b>run_tests()</b>, -exception / signal handlers are overridden with a handler that simply -displays an error and exits a test function if an exception occurs. If an -exception occurs outside of a test function, for example in cmocka itself, -the application aborts execution and returns an error code.</p> - -<a name="Failure_Conditions"><h2>Failure Conditions</h2></a> -<p>If a failure occurs during a test function that's executed via -<b>run_tests()</b>, the test function is aborted and the application's -execution resumes with the next test function. - -Test failures are ultimately signalled via the cmocka function <b>fail()</b>. -The following events will result in the cmocka library signalling a test -failure... - -<ul> - <li><a href="#Assertions">Assertions</a></li> - <li><a href="#Exception_Handling">Exceptions</a></li> - <li><a href="#Dynamic_Memory_Allocation">Memory leaks</a></li> - <li><a href="#Test_State">Mismatched setup and tear down functions</a></li> - <li><a href="#Return_Values">Missing mock return values</a></li> - <li><a href="#Return_Values">Unused mock return values</a></li> - <li><a href="#Checking_Parameters">Missing expected parameter values</a></li> - <li><a href="#Checking_Parameters">Unused expected parameter values</a></li> -</ul> -</p> - -<a name="Assertions"><h2>Assertions</h2></a> -<p>Runtime assert macros like the standard C library's <b>assert()</b> should -be redefined in modules being tested to use cmocka's <b>mock_assert()</b> -function. Normally <b>mock_assert()</b> signals a -<a href="#Failure_Conditions">test failure</a>. If a function is called using -the <b>expect_assert_failure()</b> macro, any calls to <b>mock_assert()</b> -within the function will result in the execution of the test. If no -calls to <b>mock_assert()</b> occur during the function called via -<b>expect_assert_failure()</b> a test failure is signalled.</p> - -<h4>Using mock_assert()</h4> -<a href="../example/assert_module.c">assert_module.c</a> -<listing> -#include <assert.h> - -// If unit testing is enabled override assert with mock_assert(). -#ifdef UNIT_TESTING -extern void mock_assert(const int result, const char* const expression, - const char * const file, const int line); -#undef assert -#define assert(expression) \ - mock_assert((int)(expression), #expression, __FILE__, __LINE__); -#endif // UNIT_TESTING - -void increment_value(int * const value) { - assert(value); - (*value) ++; -} - -void decrement_value(int * const value) { - if (value) { - *value --; - } -} -</listing> -<a href="../example/assert_module_test.c">assert_module_test.c</a> -<listing> -#include <stdarg.h> -#include <stddef.h> -#include <setjmp.h> -#include <cmocka.h> - -extern void increment_value(int * const value); - -/* This test case will fail but the assert is caught by run_tests() and the - * next test is executed. */ -void increment_value_fail(void **state) { - increment_value(NULL); -} - -// This test case succeeds since increment_value() asserts on the NULL pointer. -void increment_value_assert(void **state) { - expect_assert_failure(increment_value(NULL)); -} - -/* This test case fails since decrement_value() doesn't assert on a NULL - * pointer. */ -void decrement_value_fail(void **state) { - expect_assert_failure(decrement_value(NULL)); -} - -int main(int argc, char *argv) { - const UnitTest tests = { - unit_test(increment_value_fail), - unit_test(increment_value_assert), - unit_test(decrement_value_fail), - }; - return run_tests(tests); -} -</listing> - -<h3><a name="Assert_Macros">Assert Macros</a></h3> - -<p>cmocka provides an assortment of assert macros that tests applications -should use use in preference to the C standard library's assert macro. On an -assertion failure a cmocka assert macro will write the failure to the
View file
_service:tar_scm:cmocka-1.1.7.tar.xz/49.patch
Added
@@ -0,0 +1,1628 @@ +From 6a99bd773e986a615272ed0611d4fc7636b01a03 Mon Sep 17 00:00:00 2001 +From: maxime <maximeandrighetto@gmail.com> +Date: Tue, 9 Aug 2022 16:37:34 +0900 +Subject: PATCH 1/8 Fixed warning when compiling on Windows: warning C4996: + 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO + C++ conformant name: _strdup. See online help for details. + +--- + include/cmocka_private.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/include/cmocka_private.h b/include/cmocka_private.h +index 4d3ff30..7ee4a76 100644 +--- a/include/cmocka_private.h ++++ b/include/cmocka_private.h +@@ -40,6 +40,7 @@ + # define strcasecmp _stricmp + # define strncasecmp _strnicmp + # define strtok_r strtok_s ++# define strdup _strdup + + # if defined(HAVE__SNPRINTF_S) + # undef snprintf +-- +GitLab + + +From 7f2705e48bcde685189764303246601c13d66718 Mon Sep 17 00:00:00 2001 +From: maxime <maximeandrighetto@gmail.com> +Date: Tue, 9 Aug 2022 16:40:08 +0900 +Subject: PATCH 2/8 Improve the implementation of the TAP output by printing + the message, severity, data, etc. in a YAML diagnostics section, as specified + by the TAP14 specification. + +--- + src/cmocka.c | 66 +++++++++++++++++++++++++++++----------------------- + 1 file changed, 37 insertions(+), 29 deletions(-) + +diff --git a/src/cmocka.c b/src/cmocka.c +index 2518590..1ab88fe 100644 +--- a/src/cmocka.c ++++ b/src/cmocka.c +@@ -2725,7 +2725,7 @@ static void cmprintf_group_start_tap(const size_t num_tests) + { + static bool version_printed = false; + if (!version_printed) { +- print_message("TAP version 13\n"); ++ print_message("TAP version 14\n"); + version_printed = true; + } + +@@ -2749,6 +2749,8 @@ static void cmprintf_tap(enum cm_printf_type type, + const char *test_name, + const char *error_message) + { ++ int print_error_message = 0; ++ + switch (type) { + case PRINTF_TEST_START: + break; +@@ -2756,42 +2758,48 @@ static void cmprintf_tap(enum cm_printf_type type, + print_message("ok %u - %s\n", (unsigned)test_number, test_name); + break; + case PRINTF_TEST_FAILURE: ++ case PRINTF_TEST_ERROR: + print_message("not ok %u - %s\n", (unsigned)test_number, test_name); +- if (error_message != NULL) { +- char *msg; +- char *p; ++ print_error_message = 1; ++ break; ++ case PRINTF_TEST_SKIPPED: ++ print_message("ok %u - %s # SKIP\n", (unsigned)test_number, test_name); ++ break; ++ } + +- msg = strdup(error_message); +- if (msg == NULL) { +- return; +- } +- p = msg; ++ if ((print_error_message == 1) && (error_message != NULL)) { ++ char *msg; ++ char *p; ++ const char *indent = ""; + +- while (p0 != '\0') { +- char *q = p; ++ msg = strdup(error_message); ++ if (msg == NULL) { ++ return; ++ } ++ p = msg; + +- p = strchr(q, '\n'); +- if (p != NULL) { +- p0 = '\0'; +- } ++ print_message(" ---\n"); + +- print_message("# %s\n", q); ++ print_message(" message: \""); ++ while (p0 != '\0') { ++ char *q = p; + +- if (p == NULL) { +- break; +- } +- p++; ++ p = strchr(q, '\n'); ++ if (p != NULL) { ++ p0 = '\0'; ++ print_message("%s%s\\n\\\n", indent, q); ++ } else { ++ print_message("%s%s\"\n", indent, q); ++ break; + } +- libc_free(msg); ++ p++; ++ indent = " "; + } +- break; +- case PRINTF_TEST_SKIPPED: +- print_message("ok %u # SKIP %s\n", (unsigned)test_number, test_name); +- break; +- case PRINTF_TEST_ERROR: +- print_message("not ok %u - %s %s\n", +- (unsigned)test_number, test_name, error_message); +- break; ++ libc_free(msg); ++ ++ print_message(" severity: %s\n", (type == PRINTF_TEST_FAILURE) ? "fail" : "error"); ++ ++ print_message(" ...\n"); + } + } + +-- +GitLab + + +From 9874464dc7858475ace081dc748b0f399213b473 Mon Sep 17 00:00:00 2001 +From: maxime <maximeandrighetto@gmail.com> +Date: Tue, 9 Aug 2022 16:44:18 +0900 +Subject: PATCH 3/8 Added functions so that custom data can be attached to + the current test. I'm open to a different implementation, but I basically + needed a mechanism that is flexible enough to print any kind of data whether + a test passes or fails. For example, on the app using cmocka, I wanted to be + able to redefine the assert_* macros to automatically include data such as + 'expected', 'got' when a test fails. Currently the data are only used by the + TAP output. + +--- + include/cmocka.h | 51 +++++++++++++ + src/cmocka.c | 185 ++++++++++++++++++++++++++++++++++++++++++++--- + src/cmocka.def | 6 ++ + 3 files changed, 231 insertions(+), 11 deletions(-) + +diff --git a/include/cmocka.h b/include/cmocka.h +index 1897240..18f0da3 100644 +--- a/include/cmocka.h ++++ b/include/cmocka.h +@@ -1742,6 +1742,45 @@ void stop(void); + #define stop() _stop() + #endif + ++#ifdef DOXYGEN ++/** ++ * @brief Initialize a list of data for the current test. ++ */ ++int attach_test_data(size_t size); ++ ++/** ++ * @brief Expand the list of data for the current test. ++ */ ++int extend_test_data(size_t size); ++ ++/** ++ * @brief Append Boolean data for the current test. ++ */ ++void append_test_data_boolean(const char * const name, int value); ++ ++/** ++ * @brief Append Integer data for the current test. ++ */ ++void append_test_data_integer(const char * const name, uintmax_t value); ++ ++/** ++ * @brief Append Pointer data for the current test. ++ */ ++void append_test_data_pointer(const char * const name, void * const value); ++ ++/** ++ * @brief Append String data for the current test. ++ */ ++void append_test_data_string(const char * const name, const char * value); ++#else ++#define attach_test_data(s) _attach_test_data(s, __FILE__, __LINE__) ++#define extend_test_data(s) _extend_test_data(s, __FILE__, __LINE__)
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/CMakeLists.txt -> _service:tar_scm:cmocka-1.1.7.tar.xz/CMakeLists.txt
Changed
@@ -15,7 +15,7 @@ include(DefineCompilerFlags) include(DefinePlatformDefaults) -project(cmocka VERSION 1.1.5 LANGUAGES C) +project(cmocka VERSION 1.1.7 LANGUAGES C) # global needed variables set(APPLICATION_NAME ${PROJECT_NAME}) @@ -27,7 +27,7 @@ # Increment AGE. Set REVISION to 0 # If the source code was changed, but there were no interface changes: # Increment REVISION. -set(LIBRARY_VERSION "0.7.0") +set(LIBRARY_VERSION "0.8.0") set(LIBRARY_SOVERSION "0") # include cmake files @@ -65,7 +65,7 @@ endif () # pkg-config file -configure_file(cmocka.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/cmocka.pc) +configure_file(cmocka.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/cmocka.pc @ONLY) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/cmocka.pc @@ -75,36 +75,19 @@ pkgconfig ) -# cmake config files -if (WIN32) - set(CMOCKA_LIBRARY_NAME ${CMAKE_SHARED_LIBRARY_PREFIX}${PROJECT_NAME}${CMAKE_IMPORT_LIBRARY_SUFFIX}) -else() - set(CMOCKA_LIBRARY_NAME ${CMAKE_SHARED_LIBRARY_PREFIX}${PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}) -endif() - -set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE INTERNAL "") -set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR} CACHE INTERNAL "") -configure_package_config_file(${PROJECT_NAME}-config.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake - PATH_VARS - INCLUDE_INSTALL_DIR LIB_INSTALL_DIR - INSTALL_DESTINATION - ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) - write_basic_package_version_file(${PROJECT_NAME}-config-version.cmake COMPATIBILITY AnyNewerVersion) -install( - FILES - ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake - ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake - DESTINATION - ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} - COMPONENT - devel -) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} + COMPONENT devel) # Add 'make dist' target which makes sure to invoke cmake before add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source) + +# Link combile database for clangd +execute_process(COMMAND cmake -E create_symlink + "${cmocka_BINARY_DIR}/compile_commands.json" + "${cmocka_SOURCE_DIR}/compile_commands.json")
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/CPackConfig.cmake -> _service:tar_scm:cmocka-1.1.7.tar.xz/CPackConfig.cmake
Changed
@@ -16,7 +16,11 @@ ### source generator set(CPACK_SOURCE_GENERATOR "TXZ") -set(CPACK_SOURCE_IGNORE_FILES "~$;.swp$;/.svn/;/.git/;.gitignore;/obj*;tags;cscope.*;.ycm_extra_conf.pyc") +set(CPACK_SOURCE_IGNORE_FILES "~$;.swp$;/.git;/.gitignore") +string(APPEND CPACK_SOURCE_IGNORE_FILES ";/build*;/obj*") +string(APPEND CPACK_SOURCE_IGNORE_FILES ";/tags;/cscope\.*") +string(APPEND CPACK_SOURCE_IGNORE_FILES ";/.ycm_extra_conf.pyc;") +string(APPEND CPACK_SOURCE_IGNORE_FILES ";/.clangd;/.cache;/compile_commands.json") set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") if (WIN32)
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/ChangeLog -> _service:tar_scm:cmocka-1.1.7.tar.xz/ChangeLog
Changed
@@ -1,3 +1,18 @@ +Thu Feb 23 2023 Andreas Schneider <asn@cryptomilk.org> + * cmocka version 1.1.7 + * Update ignore list for source tarball generation + +Fri Feb 16 2023 Andreas Schneider <asn@cryptomilk.org> + * cmocka version 1.1.6 + * Added new assert macros to compare 2 double given an epsilon + * Added meson build system + * Added header with version to TAP13 output + * Fixed issues with MSVC + * Fixed TAP output for skipped tests + * Fixed issue with fail_msg + * CMake generated configs for find_package(cmocka) + * Documentation improvements + Thu Mar 28 2019 Andreas Schneider <asn@cryptomilk.org> * cmocka version 1.1.5 * Added cmocka_set_skip_filter()
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/ConfigureChecks.cmake -> _service:tar_scm:cmocka-1.1.7.tar.xz/ConfigureChecks.cmake
Changed
@@ -70,6 +70,9 @@ check_struct_has_member("struct timespec" tv_sec "time.h" HAVE_STRUCT_TIMESPEC) endif (HAVE_TIME_H) +# TYPES +check_type_size(uintptr_t UINTPTR_T) + # FUNCTIONS check_function_exists(calloc HAVE_CALLOC) check_function_exists(exit HAVE_EXIT)
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/DefineOptions.cmake -> _service:tar_scm:cmocka-1.1.7.tar.xz/DefineOptions.cmake
Changed
@@ -1,13 +1,5 @@ -option(WITH_STATIC_LIB "Build with a static library" OFF) +option(BUILD_SHARED_LIBS "Build shared libraries" ON) option(WITH_CMOCKERY_SUPPORT "Install a cmockery header" OFF) option(WITH_EXAMPLES "Build examples" ON) option(UNIT_TESTING "Build with unit testing" OFF) option(PICKY_DEVELOPER "Build with picky developer flags" OFF) - -if (WITH_STATIC_LIB) - set(BUILD_STATIC_LIB ON) -endif (WITH_STATIC_LIB) - -if (UNIT_TESTING) - set(BUILD_STATIC_LIB ON) -endif (UNIT_TESTING)
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/INSTALL.md -> _service:tar_scm:cmocka-1.1.7.tar.xz/INSTALL.md
Changed
@@ -1,18 +1,33 @@ -# How to build from source +# Installing cmocka -## Requirements +## Use a package manger (also on Windows) -### Common requirements +If you're using a BSD or Linux distribution, cmocka is already packaged and +you should find it in your package manager. + + <your package manager> install cmocka-devel + or + <your package manager> install libcmocka-devel + +For Windows it is recommended to use: https://vcpkg.io/ + + vcpkg install cmocka + +## Building from source + +### Requirements + +#### Common requirements In order to build cmocka, you need to install several components: - A C compiler -- CMake(http://www.cmake.org) >= 2.8.0. +- CMake(http://www.cmake.org) >= 3.5.0. Note that these version numbers are version we know works correctly. If you build and run cmocka successfully with an older version, please let us know. -## Building +### Building First, you need to configure the compilation, using CMake. Go inside the `build` dir. Create it if it doesn't exist. @@ -29,7 +44,7 @@ available generators for MSVC on Windows. We only support Visual Studio 2013 or newer which supports C99. -### CMake standard options +#### CMake standard options Here is a list of the most interesting options provided out of the box by CMake. @@ -40,7 +55,7 @@ - CMAKE_C_COMPILER: The path to the C compiler - CMAKE_CXX_COMPILER: The path to the C++ compiler -### CMake options defined for cmocka +#### CMake options defined for cmocka Options are defined in the following files: @@ -50,29 +65,31 @@ `cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=ON ..` -### Browsing/editing CMake options +#### Browsing/editing CMake options In addition to passing options on the command line, you can browse and edit -CMake options using `cmakesetup` (Windows), `cmake-gui` or `ccmake` (GNU/Linux +CMake options using `cmake-gui.exe` (Windows) or `ccmake` (GNU/Linux and MacOS X). - Go to the build dir - On Windows: run `cmakesetup` - On GNU/Linux and MacOS X: run `ccmake ..` -## Installing +More at https://cmake.org/runningcmake/ + +### Installing If you want to install cmocka after compilation run: make install -## Running +### Running The cmocka library can be found in the `build/src` directory. You can run the binaries in `build/examples/*` which is a are example tests. -## Testing +### Testing As mention above you can turn on the unit tests and make it possible to easily execute them:
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/README.md -> _service:tar_scm:cmocka-1.1.7.tar.xz/README.md
Changed
@@ -13,7 +13,8 @@ To compile the cmocka library and example applications run, create a build dir, and in the build dir call 'cmake /path/to/cmocka' followed by 'make'. On -Windows you can use the cmake gui. More details can be found in the INSTALL file. +Windows you can use the cmake gui. More details can be found in the INSTALL.md +file. Website -------
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/cmake/Modules/AddCMockaTest.cmake -> _service:tar_scm:cmocka-1.1.7.tar.xz/cmake/Modules/AddCMockaTest.cmake
Changed
@@ -118,3 +118,26 @@ ) endfunction (ADD_CMOCKA_TEST) + +function(ADD_CMOCKA_TEST_ENVIRONMENT _TARGET_NAME) + if (WIN32 OR CYGWIN OR MINGW OR MSVC) + file(TO_NATIVE_PATH "${cmocka-library_BINARY_DIR}" CMOCKA_DLL_PATH) + + if (TARGET_SYSTEM_EMULATOR) + set(DLL_PATH_ENV "WINEPATH=${CMOCKA_DLL_PATH};$ENV{WINEPATH}") + else() + set(DLL_PATH_ENV "PATH=${CMOCKA_DLL_PATH}\\${CMAKE_BUILD_TYPE};$ENV{PATH}") + endif() + # + # IMPORTANT NOTE: The set_tests_properties(), below, internally + # stores its name/value pairs with a semicolon delimiter. + # because of this we must protect the semicolons in the path + # + string(REPLACE ";" "\\;" DLL_PATH_ENV "${DLL_PATH_ENV}") + + set_tests_properties(${_TARGET_NAME} + PROPERTIES + ENVIRONMENT + "${DLL_PATH_ENV}") + endif() +endfunction()
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/cmocka-build-tree-settings.cmake.in -> _service:tar_scm:cmocka-1.1.7.tar.xz/cmocka-build-tree-settings.cmake.in
Changed
@@ -1,1 +1,3 @@ -set(CMOCKA_INLUDE_DIR @PROJECT_SOURCE_DIR@/include) +set_and_check(CMOCKA_INLUDE_DIR @PROJECT_SOURCE_DIR@/include) +set_and_check(CMOCKA_LIBRARY @PROJECT_BINARY_DIR@/src/@CMOCKA_LIBRARY_NAME@) +set_and_check(CMOCKA_LIBRARIES @PROJECT_BINARY_DIR@/src/@CMOCKA_LIBRARY_NAME@)
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/cmocka.pc.cmake -> _service:tar_scm:cmocka-1.1.7.tar.xz/cmocka.pc.cmake
Changed
@@ -1,5 +1,11 @@ -Name: ${PROJECT_NAME} +# cmocka pkg-config source file + +prefix=@CMAKE_INSTALL_PREFIX@ +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ + +Name: @PROJECT_NAME@ Description: The cmocka unit testing library -Version: ${PROJECT_VERSION} -Libs: -L${CMAKE_INSTALL_FULL_LIBDIR} -lcmocka -Cflags: -I${CMAKE_INSTALL_FULL_INCLUDEDIR} +Version: @PROJECT_VERSION@ +Libs: -L${libdir} -lcmocka +Cflags: -I${includedir}
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/config.h.cmake -> _service:tar_scm:cmocka-1.1.7.tar.xz/config.h.cmake
Changed
@@ -75,6 +75,10 @@ #cmakedefine HAVE_STRUCT_TIMESPEC 1 +/***************************** TYPES *****************************/ + +#cmakedefine HAVE_UINTPTR_T 1 + /*************************** FUNCTIONS ***************************/ /* Define to 1 if you have the `calloc' function. */
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/doc/mainpage.dox -> _service:tar_scm:cmocka-1.1.7.tar.xz/doc/mainpage.dox
Changed
@@ -49,6 +49,7 @@ @code #include <stdarg.h> #include <stddef.h> +#include <stdint.h> #include <setjmp.h> #include <cmocka.h> @@ -79,9 +80,9 @@ Mock objects include some logic and the test driver is able to modify the behaviour and state. The object can call some functions or act on different input (abort a test if it is wrong). The test driver injects what it expects -the mock object to return. CMocka provides and API to easily mock code. +the mock object to return. CMocka provides an API to easily mock code. -<a href="https://lwn.net/Articles/558106/">Learn more ...</a> +Check out the examples <a href="https://git.cryptomilk.org/projects/cmocka.git/tree/example/mock">here</a>. @section main-embedded Embedded platforms
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/example/CMakeLists.txt -> _service:tar_scm:cmocka-1.1.7.tar.xz/example/CMakeLists.txt
Changed
@@ -1,28 +1,5 @@ project(cmocka-examples C) -function(ADD_CMOCKA_TEST_ENVIRONMENT _TARGET_NAME) - if (WIN32 OR CYGWIN OR MINGW) - file(TO_NATIVE_PATH "${cmocka-library_BINARY_DIR}" CMOCKA_DLL_PATH) - - if (TARGET_SYSTEM_EMULATOR) - set(DLL_PATH_ENV "WINEPATH=${CMOCKA_DLL_PATH};$ENV{WINEPATH}") - else() - set(DLL_PATH_ENV "PATH=${CMOCKA_DLL_PATH};$ENV{PATH}") - endif() - # - # IMPORTANT NOTE: The set_tests_properties(), below, internally - # stores its name/value pairs with a semicolon delimiter. - # because of this we must protect the semicolons in the path - # - string(REPLACE ";" "\\;" DLL_PATH_ENV "${DLL_PATH_ENV}") - - set_tests_properties(${_TARGET_NAME} - PROPERTIES - ENVIRONMENT - "${DLL_PATH_ENV}") - endif() -endfunction() - set_source_files_properties(calculator.c allocate_module.c assert_module.c @@ -35,13 +12,16 @@ add_cmocka_test(simple_test SOURCES simple_test.c COMPILE_OPTIONS ${DEFAULT_C_COMPILE_FLAGS} - LINK_LIBRARIES ${CMOCKA_SHARED_LIBRARY}) + LINK_OPTIONS ${DEFAULT_LINK_FLAGS} + LINK_LIBRARIES cmocka::cmocka) add_cmocka_test_environment(simple_test) ### Allocate module test add_cmocka_test(allocate_module_test SOURCES allocate_module.c allocate_module_test.c - LINK_LIBRARIES ${CMOCKA_SHARED_LIBRARY}) + COMPILE_OPTIONS ${DEFAULT_C_COMPILE_FLAGS} + LINK_OPTIONS ${DEFAULT_LINK_FLAGS} + LINK_LIBRARIES cmocka::cmocka) add_cmocka_test_environment(allocate_module_test) set_tests_properties(allocate_module_test @@ -51,7 +31,9 @@ ### Assert macro test add_cmocka_test(assert_macro_test SOURCES assert_macro.c assert_macro_test.c - LINK_LIBRARIES ${CMOCKA_SHARED_LIBRARY}) + COMPILE_OPTIONS ${DEFAULT_C_COMPILE_FLAGS} + LINK_OPTIONS ${DEFAULT_LINK_FLAGS} + LINK_LIBRARIES cmocka::cmocka) add_cmocka_test_environment(assert_macro_test) set_tests_properties(assert_macro_test @@ -61,7 +43,9 @@ ### Assert module test add_cmocka_test(assert_module_test SOURCES assert_module.c assert_module_test.c - LINK_LIBRARIES ${CMOCKA_SHARED_LIBRARY}) + COMPILE_OPTIONS ${DEFAULT_C_COMPILE_FLAGS} + LINK_OPTIONS ${DEFAULT_LINK_FLAGS} + LINK_LIBRARIES cmocka::cmocka) add_cmocka_test_environment(assert_module_test) set_tests_properties(assert_module_test
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/example/mock/chef_wrap/CMakeLists.txt -> _service:tar_scm:cmocka-1.1.7.tar.xz/example/mock/chef_wrap/CMakeLists.txt
Changed
@@ -7,7 +7,7 @@ ) add_executable(waiter_test_wrap waiter_test_wrap.c chef.c) -target_link_libraries(waiter_test_wrap ${CMOCKA_SHARED_LIBRARY}) +target_link_libraries(waiter_test_wrap cmocka::cmocka) add_test(waiter_test_wrap ${CMAKE_CURRENT_BINARY_DIR}/waiter_test_wrap)
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/example/mock/uptime/CMakeLists.txt -> _service:tar_scm:cmocka-1.1.7.tar.xz/example/mock/uptime/CMakeLists.txt
Changed
@@ -12,7 +12,7 @@ add_cmocka_test(test_uptime SOURCES test_uptime.c COMPILE_OPTIONS ${DEFAULT_C_COMPILE_FLAGS} - LINK_LIBRARIES ${CMOCKA_SHARED_LIBRARY}) + LINK_LIBRARIES cmocka::cmocka) set_property(TARGET test_uptime PROPERTY
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/include/cmocka.h -> _service:tar_scm:cmocka-1.1.7.tar.xz/include/cmocka.h
Changed
@@ -1,6 +1,6 @@ /* * Copyright 2008 Google Inc. - * Copyright 2014-2018 Andreas Schneider <asn@cryptomilk.org> + * Copyright 2014-2022 Andreas Schneider <asn@cryptomilk.org> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,6 +46,7 @@ * @code * #include <stdarg.h> * #include <stddef.h> + * #include <stdint.h> * #include <setjmp.h> * #include <stdint.h> * @endcode @@ -111,12 +112,16 @@ # define FloatPrintfFormat "%f" #endif /* FloatPrintfFormat */ +#ifndef DoublePrintfFormat +# define DoublePrintfFormat "%f" +#endif /* DoublePrintfFormat */ + /* Perform an unsigned cast to LargestIntegralType. */ #define cast_to_largest_integral_type(value) \ ((LargestIntegralType)(value)) /* Smallest integral type capable of holding a pointer. */ -#if !defined(_UINTPTR_T) && !defined(_UINTPTR_T_DEFINED) +#if !defined(_UINTPTR_T) && !defined(_UINTPTR_T_DEFINED) && !defined(HAVE_UINTPTR_T) # if defined(_WIN32) /* WIN32 is an ILP32 platform */ typedef unsigned int uintptr_t; @@ -168,6 +173,14 @@ #define CMOCKA_DEPRECATED #endif +#if defined(__GNUC__) +#define CMOCKA_NORETURN __attribute__ ((noreturn)) +#elif defined(_MSC_VER) +#define CMOCKA_NORETURN __declspec(noreturn) +#else +#define CMOCKA_NORETURN +#endif + #define WILL_RETURN_ALWAYS -1 #define WILL_RETURN_ONCE -2 @@ -175,7 +188,7 @@ * @defgroup cmocka_mock Mock Objects * @ingroup cmocka * - * Mock objects mock objects are simulated objects that mimic the behavior of + * Mock objects are simulated objects that mimic the behavior of * real objects. Instead of calling the real objects, the tested object calls a * mock object that merely asserts that the correct methods were called, with * the expected parameters, in the correct order. @@ -667,7 +680,7 @@ #ifdef DOXYGEN /** - * @brief Add an event to check if a parameter is the given value. + * @brief Add an event to check if a parameter is the given integer based value. * * The event is triggered by calling check_expected() in the mocked function. * @@ -677,7 +690,10 @@ * * @paramin value The value to check. * - * @see check_expected(). + * @see check_expected() + * @see expect_string() + * @see expect_memory() + * @see expect_any() */ void expect_value(#function, #parameter, LargestIntegralType value); #else @@ -687,7 +703,8 @@ #ifdef DOXYGEN /** - * @brief Add an event to repeatedly check if a parameter is the given value. + * @brief Add an event to repeatedly check if a parameter is the given integer + * based value. * * The event is triggered by calling check_expected() in the mocked function. * @@ -702,6 +719,8 @@ * to -1 the value will always be returned. * * @see check_expected(). + * @see expect_not_string() + * @see expect_not_memory() */ void expect_value_count(#function, #parameter, LargestIntegralType value, size_t count); #else @@ -1282,6 +1301,50 @@ __FILE__, __LINE__) #endif +#ifdef DOXYGEN +/** + * @brief Assert that the two given double are equal given an epsilon. + * + * The function prints an error message to standard error and terminates the + * test by calling fail() if the double are not equal (given an epsilon). + * + * @paramin a The first double to compare. + * + * @paramin b The double to compare against the first one. + * + * @paramin epsilon The epsilon used as margin for double comparison. + */ +void assert_double_equal(double a, double b, double epsilon); +#else +#define assert_double_equal(a, b, epsilon) \ + _assert_double_equal((double)a, \ + (double)b, \ + (double)epsilon, \ + __FILE__, __LINE__) +#endif + +#ifdef DOXYGEN +/** + * @brief Assert that the two given double are not equal given an epsilon. + * + * The function prints an error message to standard error and terminates the + * test by calling fail() if the double are not equal (given an epsilon). + * + * @paramin a The first double to compare. + * + * @paramin b The double to compare against the first one. + * + * @paramin epsilon The epsilon used as margin for double comparison. + */ +void assert_double_not_equal(double a, double b, double epsilon); +#else +#define assert_double_not_equal(a, b, epsilon) \ + _assert_double_not_equal((float)a, \ + (double)b, \ + (double)epsilon, \ + __FILE__, __LINE__) +#endif + #ifdef DOXYGEN /** @@ -1297,8 +1360,7 @@ void assert_string_equal(const char *a, const char *b); #else #define assert_string_equal(a, b) \ - _assert_string_equal((const char*)(a), (const char*)(b), __FILE__, \ - __LINE__) + _assert_string_equal((a), (b), __FILE__, __LINE__) #endif #ifdef DOXYGEN @@ -1315,8 +1377,7 @@ void assert_string_not_equal(const char *a, const char *b); #else #define assert_string_not_equal(a, b) \ - _assert_string_not_equal((const char*)(a), (const char*)(b), __FILE__, \ - __LINE__) + _assert_string_not_equal((a), (b), __FILE__, __LINE__) #endif #ifdef DOXYGEN @@ -1473,7 +1534,10 @@ * created (e.g. expect_function_call()) than consumed with function_called(). * There are provisions such as ignore_function_calls() which allow this * restriction to be circumvented in tests where mock calls for the code under - * test are not the focus of the test. + * test are not the focus of the test. function_called() must be called from + * the same thread as expect_function_call(), and that thread must have been + * initialized for use by cmocka (see also the Threading section of the main + * documentation page(index.html#main-threads)). * * The following example illustrates how a unit test instructs cmocka * to expect a function_called() from a particular mock, @@ -1643,7 +1707,7 @@ void fail_msg(const char *msg, ...); #else #define fail_msg(msg, ...) do { \ - print_error("ERROR: " msg "\n", ##__VA_ARGS__); \ + cm_print_error("ERROR: " msg "\n", ##__VA_ARGS__); \ fail(); \ } while (0) #endif @@ -1787,7 +1851,7 @@ * @code * static int setup(void **state) { * int *answer = malloc(sizeof(int)); - * if (*answer == NULL) { + * if (answer == NULL) { * return -1; * } * *answer = 42; @@ -1855,7 +1919,7 @@
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/include/cmocka_private.h -> _service:tar_scm:cmocka-1.1.7.tar.xz/include/cmocka_private.h
Changed
@@ -28,6 +28,7 @@ # ifdef _MSC_VER # include <stdio.h> /* _snprintf */ +# include <string.h> /* strtok_s */ # undef inline # define inline __inline @@ -38,6 +39,7 @@ # define strcasecmp _stricmp # define strncasecmp _strnicmp +# define strtok_r strtok_s # if defined(HAVE__SNPRINTF_S) # undef snprintf
View file
_service:tar_scm:cmocka-1.1.7.tar.xz/meson.build
Added
@@ -0,0 +1,60 @@ +project('cmocka', 'c', + version : '1.1.5', + license : 'Apache-2.0') + +cc = meson.get_compiler('c') + +conf = configuration_data() + +foreach hdr : 'assert.h', 'inttypes.h', 'io.h', 'malloc.h', 'memory.h', + 'setjmp.h', 'signal.h', 'stdarg.h', 'stddef.h', 'stdint.h', + 'stdio.h', 'stdlib.h', 'string.h', 'strings.h', 'sys/stat.h', + 'sys/types.h', 'time.h', 'unistd.h' + conf.set('HAVE_@0@'.format(hdr.underscorify().to_upper()), cc.has_header(hdr)) +endforeach + +code = '''#include <time.h> +int a = sizeof(struct timespec); +''' +conf.set('HAVE_STRUCT_TIMESPEC', cc.compiles(code, name : 'struct timepec')) + +foreach func: 'calloc', 'exit', 'fprintf', 'free', 'longjmp', 'siglongjmp', + 'malloc', 'memcpy', 'memset', 'printf', 'setjmp', 'signal', + 'strsignal', 'strcmp', 'clock_gettime' + conf.set('HAVE_@0@'.format(func.to_upper()), cc.has_function(func)) +endforeach + +code = '__thread int tls;' +conf.set('HAVE_GCC_THREAD_LOCAL_STORAGE', cc.compiles(code, name : '__thread')) + +code = '''#include <time.h> +clockid_t t = CLOCK_REALTIME;''' +conf.set('HAVE_CLOCK_REALTIME', cc.compiles(code, name : 'CLOCK_REALTIME')) + +configure_file(output : 'config.h', configuration : conf) + +cmocka_includes = include_directories('.'), include_directories('include') +libcmocka = library('cmocka', 'src/cmocka.c', + c_args : '-DHAVE_CONFIG_H', + include_directories : cmocka_includes, + install : meson.is_subproject(), + override_options : 'c_std=gnu99', + dependencies : cc.find_library('rt', required : false)) + +if meson.is_subproject() + cmocka_dep = declare_dependency(include_directories : cmocka_includes, + link_with : libcmocka) +else + install_headers('include/cmocka.h') + + pkgconfig = import('pkgconfig') + pkgconfig.generate(libraries : libcmocka, + version : meson.project_version(), + name : 'cmocka', + filebase : 'cmocka', + description : 'The cmocka unit testing library') +endif + +if get_option('unit_testing') + subdir('tests') +endif
View file
_service:tar_scm:cmocka-1.1.7.tar.xz/meson_options.txt
Added
@@ -0,0 +1,1 @@ +option('unit_testing', type: 'boolean', value: false)
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/src/CMakeLists.txt -> _service:tar_scm:cmocka-1.1.7.tar.xz/src/CMakeLists.txt
Changed
@@ -3,18 +3,6 @@ set(CMOCKA_PLATFORM_INCLUDE CACHE PATH "Path to include directory for cmocka_platform.h") mark_as_advanced(CMOCKA_PLATFORM_INCLUDE) -set(CMOCKA_SHARED_LIBRARY - cmocka - CACHE INTERNAL "cmocka shared library" -) - -if (BUILD_STATIC_LIB) - set(CMOCKA_STATIC_LIBRARY - cmocka-static - CACHE INTERNAL "cmocka static library" - ) -endif() - set(CMOCKA_LINK_LIBRARIES ${CMOCKA_REQUIRED_LIBRARIES} CACHE INTERNAL "cmocka link libraries" @@ -31,93 +19,88 @@ ) endif (WIN32) -add_library(${CMOCKA_SHARED_LIBRARY} SHARED ${cmocka_SRCS}) +add_library(cmocka ${cmocka_SRCS}) -target_include_directories(${CMOCKA_SHARED_LIBRARY} +target_include_directories(cmocka PRIVATE ${CMOCKA_PLATFORM_INCLUDE} ${cmocka_BINARY_DIR} PUBLIC - ${cmocka-header_SOURCE_DIR}) - + $<BUILD_INTERFACE:${cmocka-header_SOURCE_DIR}> + $<INSTALL_INTERFACE:include>) -target_compile_options(${CMOCKA_SHARED_LIBRARY} +target_compile_options(cmocka PRIVATE ${DEFAULT_C_COMPILE_FLAGS} -DHAVE_CONFIG_H) if (CMOCKA_PLATFORM_INCLUDE) - target_compile_options(${CMOCKA_SHARED_LIBRARY} + target_compile_options(cmocka PRIVATE -DCMOCKA_PLATFORM_INCLUDE) endif() -target_link_libraries(${CMOCKA_SHARED_LIBRARY} ${CMOCKA_LINK_LIBRARIES}) +target_link_libraries(cmocka PRIVATE ${CMOCKA_LINK_LIBRARIES}) set_property(TARGET - ${CMOCKA_SHARED_LIBRARY} + cmocka PROPERTY DEFINE_SYMBOL CMOCKA_EXPORTS - PROPERTY - LINKER_FLAGS - "${DEFAULT_LINK_FLAGS}") +) -if (NOT WIN32) - set_target_properties( - ${CMOCKA_SHARED_LIBRARY} - PROPERTIES +set_property(TARGET + cmocka + PROPERTY VERSION ${LIBRARY_VERSION} +) +set_property(TARGET + cmocka + PROPERTY SOVERSION - ${LIBRARY_SOVERSION} - ) -endif (NOT WIN32) - -install(TARGETS - ${CMOCKA_SHARED_LIBRARY} - ARCHIVE DESTINATION - ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION - ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION - ${CMAKE_INSTALL_BINDIR} - COMPONENT - ${PROJECT_NAME}) - -if (BUILD_STATIC_LIB) - add_library(${CMOCKA_STATIC_LIBRARY} STATIC ${cmocka_SRCS}) - - target_include_directories(${CMOCKA_STATIC_LIBRARY} + ${LIBRARY_SOVERSION}) + +set_property(TARGET + cmocka + PROPERTY + LINK_FLAGS + "${DEFAULT_LINK_FLAGS}") + +add_library(cmocka::cmocka ALIAS cmocka) + +install(TARGETS cmocka + EXPORT cmocka-config + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + COMPONENT ${PROJECT_NAME}) + +install(EXPORT cmocka-config + NAMESPACE cmocka:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cmocka) + +if (UNIT_TESTING) + # Internal library + add_library(cmocka-static STATIC ${cmocka_SRCS}) + + target_include_directories(cmocka-static PRIVATE ${CMOCKA_PLATFORM_INCLUDE} ${cmocka_BINARY_DIR} PUBLIC ${cmocka-header_SOURCE_DIR}) - target_compile_options(${CMOCKA_STATIC_LIBRARY} + + target_compile_options(cmocka-static PRIVATE ${DEFAULT_C_COMPILE_FLAGS} -DHAVE_CONFIG_H) if (CMOCKA_PLATFORM_INCLUDE) - target_compile_options(${CMOCKA_STATIC_LIBRARY} + target_compile_options(cmocka-static PRIVATE -DCMOCKA_PLATFORM_INCLUDE) endif() - set_property(TARGET - ${CMOCKA_STATIC_LIBRARY} - PROPERTY - DEFINE_SYMBOL - CMOCKA_EXPORTS - PROPERTY - LINK_FLAGS - "${DEFAULT_LINK_FLAGS}") - - if (WITH_STATIC_LIB) - install(TARGETS - ${CMOCKA_STATIC_LIBRARY} - ARCHIVE DESTINATION - ${CMAKE_INSTALL_LIBDIR} - COMPONENT - ${PROJECT_NAME}) - endif() -endif (BUILD_STATIC_LIB) + target_link_libraries(cmocka-static PRIVATE ${CMOCKA_LINK_LIBRARIES}) + + add_library(cmocka::static ALIAS cmocka-static) +endif()
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/src/cmocka.c -> _service:tar_scm:cmocka-1.1.7.tar.xz/src/cmocka.c
Changed
@@ -42,6 +42,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <stdbool.h> #include <time.h> #include <float.h> @@ -70,7 +71,9 @@ #define MALLOC_ALLOC_PATTERN 0xBA #define MALLOC_FREE_PATTERN 0xCD /* Alignment of allocated blocks. NOTE: This must be base2. */ +#ifndef MALLOC_ALIGNMENT #define MALLOC_ALIGNMENT sizeof(size_t) +#endif /* Printf formatting for source code locations. */ #define SOURCE_LOCATION_FORMAT "%s:%u" @@ -108,37 +111,17 @@ /* - * Declare and initialize the pointer member of ValuePointer variable name - * with ptr. + * Declare and initialize a LargestIntegralType variable name + * with value the conversion of ptr. */ #define declare_initialize_value_pointer_pointer(name, ptr) \ - ValuePointer name ; \ - name.value = 0; \ - name.x.pointer = (void*)(ptr) + LargestIntegralType name ; \ + name = (LargestIntegralType) (uintptr_t) ptr -/* - * Declare and initialize the value member of ValuePointer variable name - * with val. - */ -#define declare_initialize_value_pointer_value(name, val) \ - ValuePointer name ; \ - name.value = val - -/* Cast a LargestIntegralType to pointer_type via a ValuePointer. */ +/* Cast a LargestIntegralType to pointer_type. */ #define cast_largest_integral_type_to_pointer( \ pointer_type, largest_integral_type) \ - ((pointer_type)((ValuePointer*)&(largest_integral_type))->x.pointer) - -/* Used to cast LargetIntegralType to void* and vice versa. */ -typedef union ValuePointer { - LargestIntegralType value; - struct { -#if defined(WORDS_BIGENDIAN) && (WORDS_SIZEOF_VOID_P == 4) - unsigned int padding; -#endif - void *pointer; - } x; -} ValuePointer; + ((pointer_type)(uintptr_t)(largest_integral_type)) /* Doubly linked list node. */ typedef struct ListNode { @@ -273,8 +256,6 @@ static int cm_error_message_enabled = 1; static CMOCKA_THREAD char *cm_error_message; -void cm_print_error(const char * const format, ...) CMOCKA_PRINTF_ATTRIBUTE(1, 2); - /* * Keeps track of the calling context returned by setenv() so that the fail() * method can jump out of a test. @@ -414,6 +395,9 @@ cm_print_error(SOURCE_LOCATION_FORMAT ": Skipped!\n", file, line); global_skip_test = 1; exit_test(1); + + /* Unreachable */ + exit(-1); } /* Initialize a SourceLocation structure. */ @@ -720,9 +704,16 @@ SymbolMapValue * const map_value = (SymbolMapValue*)value; const LargestIntegralType children = cast_ptr_to_largest_integral_type(cleanup_value_data); assert_non_null(value); - list_free(&map_value->symbol_values_list_head, - children ? free_symbol_map_value : free_value, - (void *) ((uintptr_t)children - 1)); + if (children == 0) { + list_free(&map_value->symbol_values_list_head, + free_value, + NULL); + } else { + list_free(&map_value->symbol_values_list_head, + free_symbol_map_value, + (void *)((uintptr_t)children - 1)); + } + free(map_value); } @@ -901,7 +892,7 @@ child_node = child_node->next, ++leftover_count) { const FuncOrderingValue *const o = (const FuncOrderingValue*) child_node->value; - cm_print_error(error_message, "%s", o->function); + cm_print_error("%s: %s", error_message, o->function); cm_print_error(SOURCE_LOCATION_FORMAT ": note: remaining item was declared here\n", o->location.file, o->location.line); @@ -933,7 +924,7 @@ if (!list_empty(child_list)) { if (number_of_symbol_names == 1) { const ListNode *child_node; - cm_print_error(error_message, "%s", value->symbol_name); + cm_print_error("%s: %s", error_message, value->symbol_name); for (child_node = child_list->next; child_node != child_list; child_node = child_node->next) { @@ -1146,10 +1137,10 @@ absLeft = (left >= 0.f) ? left : -left; absRight = (right >= 0.f) ? right : -right; - largest = (absRight > absLeft) ? absRight : absLeft; + largest = (absRight > absLeft) ? absRight : absLeft; relDiff = largest * FLT_EPSILON; - if (diff > relDiff) { + if (diff > relDiff) { return 0; } return 1; @@ -1181,6 +1172,73 @@ return not_equal; } +/* Returns 1 if the specified double values are equal, else returns 0. */ +static int double_compare(const double left, + const double right, + const double epsilon) { + double absLeft; + double absRight; + double largest; + double relDiff; + + double diff = left - right; + diff = (diff >= 0.f) ? diff : -diff; + + /* + * Check if the numbers are really close -- needed + * when comparing numbers near zero. + */ + if (diff <= epsilon) { + return 1; + } + + absLeft = (left >= 0.f) ? left : -left; + absRight = (right >= 0.f) ? right : -right; + + largest = (absRight > absLeft) ? absRight : absLeft; + relDiff = largest * FLT_EPSILON; + + if (diff > relDiff) { + return 0; + } + + return 1; +} + +/* + * Returns 1 if the specified double values are equal. If the values are not + * equal an error is displayed and 0 is returned. + */ +static int double_values_equal_display_error(const double left, + const double right, + const double epsilon) { + const int equal = double_compare(left, right, epsilon); + + if (!equal) { + cm_print_error(DoublePrintfFormat " != " + DoublePrintfFormat "\n", left, right); + } + + return equal; +} + +/* + * Returns 1 if the specified double values are different. If the values are + * equal an error is displayed and 0 is returned. + */ +static int double_values_not_equal_display_error(const double left, + const double right, + const double epsilon) { + const int not_equal = (double_compare(left, right, epsilon) == 0); + + if (!not_equal) { + cm_print_error(DoublePrintfFormat " == " + DoublePrintfFormat "\n", left, right); + } +
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/src/cmocka.def -> _service:tar_scm:cmocka-1.1.7.tar.xz/src/cmocka.def
Changed
@@ -1,5 +1,7 @@ LIBRARY cmocka EXPORTS + _assert_double_equal + _assert_double_not_equal _assert_float_equal _assert_float_not_equal _assert_in_range
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/tests/CMakeLists.txt -> _service:tar_scm:cmocka-1.1.7.tar.xz/tests/CMakeLists.txt
Changed
@@ -1,6 +1,10 @@ project(tests C) set(TEST_EXCEPTION_HANDLER TRUE) +if (WIN32) + # FIXME: The exception handler doesn't work on Windows + set(TEST_EXCEPTION_HANDLER FALSE) +endif() if (CMAKE_BUILD_TYPE) string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER) if (CMAKE_BUILD_TYPE_LOWER STREQUAL "undefinedsanitizer") @@ -16,6 +20,7 @@ test_group_fixtures test_groups test_float_macros + test_double_macros test_assert_macros test_assert_macros_fail test_basics @@ -26,8 +31,10 @@ test_ordering_fail test_returns test_returns_fail + test_string test_wildcard test_skip_filter + test_cmockery ) if (TEST_EXCEPTION_HANDLER) @@ -38,20 +45,17 @@ add_cmocka_test(${_CMOCKA_TEST} SOURCES ${_CMOCKA_TEST}.c COMPILE_OPTIONS ${DEFAULT_C_COMPILE_FLAGS} - LINK_LIBRARIES ${CMOCKA_STATIC_LIBRARY} + LINK_LIBRARIES cmocka::static LINK_OPTIONS ${DEFAULT_LINK_FLAGS}) target_include_directories(${_CMOCKA_TEST} PRIVATE ${cmocka_BINARY_DIR}) + + add_cmocka_test_environment(${_CMOCKA_TEST}) endforeach() ### Special Cases if (${CMAKE_C_COMPILER_ID} MATCHES "(GNU|Clang)") set_source_files_properties(test_cmockery.c PROPERTIES COMPILE_FLAGS "-Wno-deprecated-declarations") endif() -add_cmocka_test(test_cmockery - SOURCES test_cmockery.c - COMPILE_OPTIONS ${DEFAULT_C_COMPILE_FLAGS} - LINK_LIBRARIES ${CMOCKA_STATIC_LIBRARY} - LINK_OPTIONS ${DEFAULT_LINK_FLAGS}) ### Exceptions @@ -68,7 +72,7 @@ test_assert_macros_fail PROPERTIES PASS_REGULAR_EXPRESSION - "\\ FAILED \\ 1 test" + "\\ FAILED \\ tests: 1 test" ) # test_ordering ensure proper failures @@ -76,7 +80,7 @@ test_ordering_fail PROPERTIES PASS_REGULAR_EXPRESSION - "\\ FAILED \\ 7 test" + "\\ FAILED \\ tests: 7 test" ) # test_returns_fail ensure proper failures @@ -84,22 +88,15 @@ test_returns_fail PROPERTIES PASS_REGULAR_EXPRESSION - "\\ FAILED \\ 3 test" + "\\ FAILED \\ alloc_tests: 3 test" ) # test_exception_handler if (TEST_EXCEPTION_HANDLER) - if (WIN32) - set_tests_properties(test_exception_handler - PROPERTIES - PASS_REGULAR_EXPRESSION - "EXCEPTION_ACCESS_VIOLATION occurred at") - else() - set_tests_properties(test_exception_handler - PROPERTIES - PASS_REGULAR_EXPRESSION - "Test failed with exception: (Segmentation fault|Segmentation Fault|11|Illegal instruction)") - endif (WIN32) + set_tests_properties(test_exception_handler + PROPERTIES + PASS_REGULAR_EXPRESSION + "Test failed with exception") endif (TEST_EXCEPTION_HANDLER) set_tests_properties( @@ -124,6 +121,7 @@ ) add_test(test_setup_fail_1_failed ${TARGET_SYSTEM_EMULATOR} test_setup_fail) +add_cmocka_test_environment(test_setup_fail_1_failed) set_tests_properties( test_setup_fail_1_failed PROPERTIES @@ -132,6 +130,7 @@ ) add_test (test_setup_fail_1_passed ${TARGET_SYSTEM_EMULATOR} test_setup_fail) +add_cmocka_test_environment(test_setup_fail_1_passed) set_tests_properties( test_setup_fail_1_passed PROPERTIES @@ -140,6 +139,7 @@ ) add_test (test_setup_fail_match_failed ${TARGET_SYSTEM_EMULATOR} test_setup_fail) +add_cmocka_test_environment(test_setup_fail_match_failed) set_tests_properties( test_setup_fail_match_failed PROPERTIES @@ -148,6 +148,7 @@ ) add_test (test_setup_fail_match_passed ${TARGET_SYSTEM_EMULATOR} test_setup_fail) +add_cmocka_test_environment(test_setup_fail_match_passed) set_tests_properties( test_setup_fail_match_passed PROPERTIES @@ -171,23 +172,26 @@ xml) set(test_basics_tap_out - "^1\\.\\.2" + "^TAP version 13" + "1\\.\\.2" "ok 1 - null_test_success" "ok 2 - int_test_success" "# ok - tests") set(test_assert_macros_fail_tap_out - "^1\\.\\.1" + "^TAP version 13" + "1\\.\\.1" "not ok 1 - test_assert_return_code_fail" "#^\n\r+\n\r#^\n\r+\n\r# not ok - tests") set(test_groups_tap_out - "^1\\.\\.1" + "^TAP version 13" + "1\\.\\.1" "ok 1 - null_test_success" "# ok - test_group1" "1\\.\\.1" "ok 1 - int_test_success" "# ok - test_group2") set(test_skip_tap_out - "not ok 1 # SKIP") + "ok 1 # SKIP") set(test_setup_fail_tap_out "not ok 1 - int_test_ignored Could not run test: Test setup failed") @@ -234,10 +238,12 @@ foreach(_OUTPUT_TEST ${OUTPUT_TESTS}) set(TEST_NAME ${_OUTPUT_TEST}_${_TEST_OUTPUT_FMT}) add_test(${TEST_NAME} ${TARGET_SYSTEM_EMULATOR} ${_OUTPUT_TEST}) + add_cmocka_test_environment(${TEST_NAME}) set_property( TEST ${TEST_NAME} + APPEND PROPERTY ENVIRONMENT CMOCKA_MESSAGE_OUTPUT=${_TEST_OUTPUT_FMT} )
View file
_service:tar_scm:cmocka-1.1.7.tar.xz/tests/meson.build
Added
@@ -0,0 +1,30 @@ +tests = { + 'alloc': false, + 'group_setup_assert': true, + 'group_setup_fail': true, + 'fixtures': false, + 'group_fixtures': false, + 'groups': false, + 'float_macros': false, + 'assert_macros': false, + 'assert_macros_fail': true, + 'basics': false, + 'skip': false, + 'strmatch': false, + 'setup_fail': true, + 'ordering': false, + 'ordering_fail': true, + 'returns': false, + 'returns_fail': true, + 'wildcard': false, + 'skip_filter': false, + 'cmockery': false +} + +foreach name, should_fail: tests + exe = executable(name, + 'test_@0@.c'.format(name), + include_directories: cmocka_includes, + link_with: libcmocka) + test(name, exe, should_fail: should_fail) +endforeach
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/tests/test_assert_macros.c -> _service:tar_scm:cmocka-1.1.7.tar.xz/tests/test_assert_macros.c
Changed
@@ -19,7 +19,7 @@ **************************************/ static void test_assert_return_code(void **state) { - struct stat sb; + struct stat sb = {0}; int rc; (void)state; /* unused */
View file
_service:tar_scm:cmocka-1.1.7.tar.xz/tests/test_double_macros.c
Added
@@ -0,0 +1,40 @@ +/* + * Copyright 2019 Arnaud Gelas <arnaud.gelas@sensefly.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* Use the unit test allocators */ +#define UNIT_TESTING 1 + +#include <stdarg.h> +#include <stddef.h> +#include <setjmp.h> +#include <cmocka.h> + +/* A test case that does check if double is equal. */ +static void double_test_success(void **state) +{ + (void)state; /* unused */ + + assert_double_equal(0.5, 1. / 2., 0.000001); + assert_double_not_equal(0.5, 0.499, 0.000001); +} + +int main(void) { + const struct CMUnitTest tests = { + cmocka_unit_test(double_test_success), + }; + + return cmocka_run_group_tests(tests, NULL, NULL); +}
View file
_service:tar_scm:cmocka-1.1.5.tar.xz/tests/test_exception_handler.c -> _service:tar_scm:cmocka-1.1.7.tar.xz/tests/test_exception_handler.c
Changed
@@ -3,20 +3,14 @@ #include <setjmp.h> #include <cmocka.h> -#include <stdlib.h> - -struct test_segv { - int x; - int y; -}; +#include <signal.h> static void test_segfault_recovery(void **state) { - struct test_segv *s = NULL; - - (void) state; /* unused */ + (void)state; /* unused */ - s->x = 1; + /* Raise segmentation fault */ + raise(SIGSEGV); } static void test_segfault_recovery1(void **state) @@ -35,11 +29,11 @@ } int main(void) { - const struct CMUnitTest tests = { + const struct CMUnitTest exception_tests = { cmocka_unit_test(test_segfault_recovery1), cmocka_unit_test(test_segfault_recovery2), cmocka_unit_test(test_segfault_recovery3), }; - return cmocka_run_group_tests(tests, NULL, NULL); + return cmocka_run_group_tests(exception_tests, NULL, NULL); }
View file
_service:tar_scm:cmocka-1.1.7.tar.xz/tests/test_string.c
Added
@@ -0,0 +1,40 @@ +/* + * Copyright 2020 Andreas Schneider <asn@cryptomilk.org> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <stdarg.h> +#include <stddef.h> +#include <stdint.h> +#include <setjmp.h> +#include <cmocka.h> + +static void torture_string_equal(void **state) +{ + assert_string_equal("wurst", "wurst"); +} + +static void torture_string_not_equal(void **state) +{ + assert_string_not_equal("wurst", "brot"); +} + +int main(void) { + const struct CMUnitTest tests = { + cmocka_unit_test(torture_string_equal), + cmocka_unit_test(torture_string_not_equal), + }; + + return cmocka_run_group_tests(tests, NULL, NULL); +}
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2