-project(cmockery C)
+project(cmocka C)
# Required cmake version
cmake_minimum_required(VERSION 2.6.0)
set(CPACK_PACKAGE_NAME ${APPLICATION_NAME})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The lightweight C unit testing library")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README")
-set(CPACK_PACKAGE_VENDOR "Google Inc.")
+set(CPACK_PACKAGE_VENDOR "Andreas Schneider")
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
set(CPACK_GENERATOR "${CPACK_GENERATOR};NSIS")
set(CPACK_NSIS_DISPLAY_NAME ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
set(CPACK_NSIS_COMPRESSOR "/SOLID zlib")
- set(CPACK_NSIS_MENU_LINKS "https://code.google.com/p/cmockery/" "cmockery homepage")
+ set(CPACK_NSIS_MENU_LINKS "https://code.google.com/p/cmocka/" "cmocka homepage")
endif (NSIS_MAKE)
endif (WIN32)
-set(CPACK_PACKAGE_INSTALL_DIRECTORY "cmockery")
+set(CPACK_PACKAGE_INSTALL_DIRECTORY "cmocka")
set(CPACK_PACKAGE_FILE_NAME ${APPLICATION_NAME}-${CPACK_PACKAGE_VERSION})
set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries")
set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C/C++ Headers")
set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION
- "Libraries used to build programs which use cmockery")
+ "Libraries used to build programs which use cmocka")
set(CPACK_COMPONENT_HEADERS_DESCRIPTION
- "C/C++ header files for use with cmockery")
+ "C/C++ header files for use with cmocka")
set(CPACK_COMPONENT_HEADERS_DEPENDS libraries)
#set(CPACK_COMPONENT_APPLICATIONS_GROUP "Runtime")
set(CPACK_COMPONENT_LIBRARIES_GROUP "Development")
check_function_exists(_snprintf_s HAVE__SNPRINTF_S)
endif (WIN32)
-set(CMOCKERY_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CACHE INTERNAL "cmockery required system libraries")
+set(CMOCKA_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CACHE INTERNAL "cmocka required system libraries")
# OPTIONS
-For information about how to use the cmockery unit testing framework see
+CMOCKA
+=======
+
+cmocka is a fork for Google's cmockery unit testing framework to fix bugs and
+support it in future.
+See https://code.google.com/p/cmockery/
+
+For information about how to use the cmocka unit testing framework see
doc/index.html.
COMPILING
---------
-To compile the cmockery library and example applications run ./configure
-followed by make. On Windows from the command line run vsvars.bat then cd into
-the windows subdirectory of this project and run nmake.
-
-This code has been tested on Linux (Ubuntu) and Windows using VC++7 and VC++8.
+To compile the cmocka library and example applications run cmake /path/to/source
+followed by make. On Windows you can use the cmake gui.
+++ /dev/null
-#!/bin/bash
-#
-# Translate really simple html to googlecode.com wiki.
-#
-# Usage: cat input.html | html2wiki.sh > outputwiki.txt
-#
-# Most of this script is simple sed substitutions with an awk script to handle
-# hierarchical lists.
-
-# Awk program to escape all instances of * outside of <listing></listing>
-awk '
-BEGIN { in_listing = 0; }
-/<[Ll][Ii][Ss][Tt][Ii][Nn][Gg]>/ { in_listing = 1; }
-/<\/[Ll][Ii][Ss][Tt][Ii][Nn][Gg]>/ { in_listing = 0; }
-/.*/ {
- if (in_listing) {
- print $0;
- } else {
- print gensub("*", "`*`", "g", $0)
- }
-}' | \
-# Awk program to convert hierachical unordered and ordered lists into
-# googlecode wiki list markup. This is limited to converting very simple
-# html lists in the form:
-#
-# <ul>
-# <li>item 1</li>
-# ...
-# <li>item N</li>
-# </ul>
-#
-# This script also removes leading spaces from all lines outside of <listing>
-# sections.
-awk '
-BEGIN {
- list_type_none = 0;
- list_type_ordered = 1;
- list_type_unordered = 2;
- # Number of nested lists.
- list_depth = 0;
- # Number of items in the list.
- list_items[list_depth] = 0;
- # Type of list.
- list_type[list_depth] = list_type_none;
- # Do nott strip whitespace from listing sections.
- in_listing = 0;
-}
-
-# Generate a string of indent spaces.
-function list_indent(indent) {
- format = sprintf("%%%ds", indent);
- return sprintf(format, "");
-}
-
-/<[Ll][Ii][Ss][Tt][Ii][Nn][Gg]>/ { in_listing = 1; }
-/<\/[Ll][Ii][Ss][Tt][Ii][Nn][Gg]>/ { in_listing = 0; }
-
-# Process all lines non-blank lines.
-/^.*$/ {
- # Remove leading white space.
- if (!in_listing) {
- output_string = gensub(/^ */, "", 1, $0);
- } else {
- output_string = $0;
- }
- search_string = output_string
-
- # Replace list tags with googlecode wiki markup.
- while (match(search_string, /<[^>]*>/, matches)) {
- tag = matches[0];
- search_string = substr(search_string,
- matches[0, "start"] + matches[0, "length"]);
- if (match(tag, /^<[Uu][Ll]>$/)) {
- list_depth++;
- list_type[list_depth] = list_type_unordered;
- list_items[list_depth] = 0;
- output_string = gensub(tag, "", 1, output_string);
- } else if (match(tag, /^[Oo][Ll]>$/)) {
- list_depth++;
- list_type[list_depth] = list_type_ordered;
- list_items[list_depth] = 0;
- output_string = gensub(tag, "", 1, output_string);
- } else if (match(tag, /^<\/[Ll][Ii]>$/)) {
- output_string = gensub(tag, "", 1, output_string);
- } else if (list_depth) {
- if (match(tag, /^<[Ll][Ii]>$/)) {
- if (list_type[list_depth] == list_type_unordered) {
- output_string = gensub(tag, list_indent(list_depth) "* ", 1,
- output_string);
- } else if (list_type[list_depth] == list_type_ordered) {
- output_string = gensub(tag, list_indent(list_depth) "# ", 1,
- output_string);
- }
- } else if (match(tag, /^<\/[Uu][Ll]>$/) ||
- match(tag, /^<\/[Ou][Ll]>$/)) {
- output_string = gensub(tag, "", 1, output_string);
- list_depth --;
- }
- }
- }
- # If a list is being parsed then filter blank lines.
- if (list_depth == 0 || length(output_string)) {
- print output_string
- }
-}
-' | \
-# This sed program translates really simple html into wiki suitable for
-# googlecode.com.
-#
-# Supported tags:
-# <p>
-# <br>
-# <h1>
-# <h2>
-# <h3>
-# <h4>
-# <h5>
-# <b>
-# <i>
-# <a href="#.*">.*</a>
-# <a href=".*">.*</a>
-# <a name=".*'>.*</a>
-#
-# Supported entities:
-# >
-# <
-#
-# Limitations:
-# * Anchors must be on a single line and must contain one of either the name or
-# href attributes.
-# * Href of local anchors (href="#.*") should be set to the name of a heading
-# within the document. If the heading contains spaces the href should
-# contain underscores.
-# * All external links are relative to
-# http://cmockery.googlecode.com/svn/trunk/doc/
-sed -r '
-s@<[Pp]>@\n@g;
-s@<[[Bb][Rr]]>@\n@g;
-s@</?[Hh]1>@=@g;
-s@</?[Hh]2>@==@g;
-s@</?[Hh]3>@===@g;
-s@</?[Hh]4>@====@g;
-s@</?[Hh]5>@====@g;
-s@</?[Bb]>@*@g;
-s@</?[Ii]>@_@g;
-s@<[Ll][Ii][Ss][Tt][Ii][Nn][Gg]>@{{{@g;
-s@</[Ll][Ii][Ss][Tt][Ii][Nn][Gg]>@}}}@g;
-s@<[Aa].*?href="#(.*)?">(.*)?</[Aa]>@[#\1 \2]@g;
-s@<[Aa].*?href="(.*)?">(.*)?</[Aa]>@[http://cmockery.googlecode.com/svn/trunk/doc/\1 \2]@g;
-s@<[Aa].*?name="(.*)?">@@g;
-s@</[Aa]>@@g;
-s@<.*?>@@g;
-s@<@<@g;
-s@>@>@g;'
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html><head>
-<title>Cmockery</title>
+<title>cmocka</title>
</head>
<body>
-<h1>Cmockery Unit Testing Framework</h1>
-<p>Cmockery is a lightweight library that is used to author C unit tests.</p>
+<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>
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>Cmockery only requires a test application is linked with the standard C
+<p>cmocka only requires a test application is linked with the standard C
library which minimizes conflicts with standard C library headers. Also,
-Cmockery tries avoid the use of some of the newer features of C compilers.</p>
+cmocka tries avoid the use of some of the newer features of C compilers.</p>
-<p>This results in Cmockery being a relatively small library that can be used
+<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>Cmockery tests are compiled into stand-alone executables and linked with
-the Cmockery library, the standard C library and module being tested. Any
+<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
<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 Cmockery unit test applications are compiled so code within the
+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>Cmockery unit test cases are functions with the signature
-<b>void function(void **state)</b>. Cmockery test applications initialize 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.
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
-#include <cmockery.h>
+#include <cmocka.h>
// A test case that does nothing and succeeds.
void null_test_success(void **state) {
<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 Cmockery itself,
+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>
<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 Cmockery function <b>fail()</b>.
-The following events will result in the Cmockery library signalling a test
+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>
<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 Cmockery's <b>mock_assert()</b>
+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>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
-#include <cmockery.h>
+#include <cmocka.h>
extern void increment_value(int * const value);
<h3><a name="Assert_Macros">Assert Macros</a></h3>
-<p>Cmockery provides an assortment of assert macros that tests applications
+<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 Cmockery assert macro will write the failure to the
+assertion failure a cmocka assert macro will write the failure to the
standard error stream and signal a test failure. Due to limitations of the
-C language the general C standard library assert() and Cmockery's
+C language the general C standard library assert() and cmocka's
assert_true() and assert_false() macros can only display the expression that
-caused the assert failure. Cmockery's type specific assert macros,
+caused the assert failure. cmocka's type specific assert macros,
assert_{type}_equal() and assert_{type}_not_equal(), display the data that
caused the assertion failure which increases data visibility aiding
debugging of failing test cases.</p>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
-#include <cmockery.h>
+#include <cmocka.h>
extern const char* get_status_code_string(const unsigned int status_code);
extern unsigned int string_to_status_code(
<a name="Dynamic_Memory_Allocation"><h2>Dynamic Memory Allocation</h2></a>
<p>To test for memory leaks, buffer overflows and underflows a module being
-tested by Cmockery should replace calls to <b>malloc()</b>, <b>calloc()</b> and
+tested by cmocka should replace calls to <b>malloc()</b>, <b>calloc()</b> and
<b>free()</b> to <b>test_malloc()</b>, <b>test_calloc()</b> and
<b>test_free()</b> respectively. Each time a block is deallocated using
<b>test_free()</b> it is checked for corruption, if a corrupt block is found
a <a href="#Failure_Conditions">test failure</a> is signalled. All blocks
allocated using the <b>test_*()</b> allocation functions are tracked by the
-Cmockery library. When a test completes if any allocated blocks (memory leaks)
+cmocka library. When a test completes if any allocated blocks (memory leaks)
remain they are reported and a test failure is signalled.</p>
-<p>For simplicity Cmockery currently executes all tests in one process.
+<p>For simplicity cmocka currently executes all tests in one process.
Therefore all test cases in a test application share a single address space
which means memory corruption from a single test case could potentially cause
the test application to exit prematurely.</p>
-<h4>Using Cmockery's Allocators</h4>
+<h4>Using cmocka's Allocators</h4>
<a href="../src/example/allocate_module.c">allocate_module.c</a>
<listing>
#include <malloc.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
-#include <cmockery.h>
+#include <cmocka.h>
extern void leak_memory();
extern void buffer_overflow();
<a name="Return_Values"><h3>Return Values</h3></a>
-<p>In order to simplify the implementation of mock functions Cmockery provides
+<p>In order to simplify the implementation of mock functions cmocka provides
functionality which stores return values for mock functions in each test
case using <b>will_return()</b>. These values are then returned by each mock
function using calls to <b>mock()</b>.
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
-#include <cmockery.h>
+#include <cmocka.h>
#include <database.h>
</listing>
<a name="Checking_Parameters"><h3>Checking Parameters</h3></a>
-<p>In addition to storing the return values of mock functions, Cmockery
+<p>In addition to storing the return values of mock functions, cmocka
provides functionality to store expected values for mock function parameters
using the expect_*() functions provided. A mock function parameter can then
be validated using the check_expected() macro.
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
-#include <cmockery.h>
+#include <cmocka.h>
#include <database.h>
extern DatabaseConnection* connect_to_product_database();
<a name="Test_State"><h2>Test State</h2></a>
-<p>Cmockery allows the specification of multiple setup and tear down functions
+<p>cmocka allows the specification of multiple setup and tear down functions
for each test case. Setup functions, specified by the <b>unit_test_setup()</b>
or <b>unit_test_setup_teardown()</b> macros allow common initialization to be
shared between multiple test cases. In addition, tear down functions,
#include <stddef.h>
#include <setjmp.h>
#include <string.h>
-#include <cmockery.h>
+#include <cmocka.h>
/* This is duplicated here from the module setup_teardown.c to reduce the
* number of files used in this test. */
<a href="../src/example/calculator.c">calculator.c</a> application
and test application that full exercises the calculator application
<a href="../src/example/calculator_test.c">calculator_test.c</a>
-are provided as an example of Cmockery's features discussed in this document.
+are provided as an example of cmocka's features discussed in this document.
</p>
<hr>
+++ /dev/null
-#!/bin/bash -e
-
-# This takes one commandline argument, the name of the package. If no
-# name is given, then we'll end up just using the name associated with
-# an arbitrary .tar.gz file in the rootdir. That's fine: there's probably
-# only one.
-#
-# Run this from the 'packages' directory, just under rootdir
-
-## Set LIB to lib if exporting a library, empty-string else
-LIB=
-#LIB=lib
-
-PACKAGE="$1"
-
-# We can only build Debian packages, if the Debian build tools are installed
-if [ \! -x /usr/bin/debuild ]; then
- echo "Cannot find /usr/bin/debuild. Not building Debian packages." 1>&2
- exit 0
-fi
-
-# Double-check we're in the packages directory, just under rootdir
-if [ \! -r ../Makefile -a \! -r ../INSTALL ]; then
- echo "Must run $0 in the 'packages' directory, under the root directory." 1>&2
- echo "Also, you must run \"make dist\" before running this script." 1>&2
- exit 0
-fi
-
-# Find the top directory for this package
-topdir="${PWD%/*}"
-
-# Find the tar archive built by "make dist"
-archive="$(basename "$(ls -1 ${topdir}/$PACKAGE*.tar.gz | tail -n 1)" .tar.gz)"
-if [ -z "${archive}" ]; then
- echo "Cannot find ../$PACKAGE*.tar.gz. Run \"make dist\" first." 1>&2
- exit 0
-fi
-
-# Create a pristine directory for building the Debian package files
-trap 'rm -rf '`pwd`/tmp'; exit $?' EXIT SIGHUP SIGINT SIGTERM
-
-rm -rf tmp
-mkdir -p tmp
-cd tmp
-
-# Debian has very specific requirements about the naming of build
-# directories, and tar archives. It also wants to write all generated
-# packages to the parent of the source directory. We accommodate these
-# requirements by building directly from the tar file.
-ln -s "${topdir}/${archive}.tar.gz" "${LIB}${archive}.orig.tar.gz"
-tar zfx "${LIB}${archive}.orig.tar.gz"
-[ -n "${LIB}" ] && mv "${archive}" "${LIB}${archive}"
-cd "${LIB}${archive}"
-# This is one of those 'specific requirements': where the deb control files live
-ln -s "packages/deb" "debian"
-
-# Now, we can call Debian's standard build tool
-debuild -uc -us
-cd ../.. # get back to the original top-level dir
-
-# We'll put the result in a subdirectory that's named after the OS version
-# we've made this .deb file for.
-destdir="debian-$(cat /etc/debian_version 2>/dev/null || echo UNKNOWN)"
-
-rm -rf "$destdir"
-mkdir -p "$destdir"
-mv $(find tmp -mindepth 1 -maxdepth 1 -type f) "$destdir"
-
-echo
-echo "The Debian package files are located in $PWD/$destdir"
+++ /dev/null
-The list of files here isn't complete. For a step-by-step guide on
-how to set this package up correctly, check out
- http://www.debian.org/doc/maint-guide/
-
-Most of the files that are in this directory are boilerplate.
-However, you may need to change the list of binary-arch dependencies
-in 'rules'.
+++ /dev/null
-cmockery (0.1-2) unstable; urgency=low
- * cmockery: version 0.12
- Made it possible to specify additional compiler, lib tool and link
- flags on Windows.
- Added Windows makefile to the tar ball.
-
- -- Google Inc. <opensource@google.com> Mon, 28 Aug 2008 17:43:20 -0700
+++ /dev/null
-Source: cmockery
-Section: libdevel
-Priority: optional
-Maintainer: Google Inc, <opensource@google.com>
-Build-Depends: debhelper (>= 4.0.0), binutils
-Standards-Version: 3.6.1
-
-Package: libcmockery-dev
-Section: libdevel
-Architecture: any
-Depends: libcmockery0 (= ${Source-Version})
-Description: The cmockery package contains a lightweight library to simplify
- and generalize the process of writing unit tests for C applications.
-
-Package: libcmockery0
-Section: libs
-Architecture: any
-Description: The cmockery package contains static and debug libraries and
- header files for the development of test applications using %name.
-
+++ /dev/null
-This package was debianized by Google Inc. <opensource@google.com> on
-28 August 2008.
-
-It was downloaded from http://code.google.com/
-
-Upstream Author: opensource@google.com
-
-Copyright (c) 2006, Google Inc.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above
-copyright notice, this list of conditions and the following disclaimer
-in the documentation and/or other materials provided with the
-distribution.
- * Neither the name of Google Inc. nor the names of its
-contributors may be used to endorse or promote products derived from
-this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+++ /dev/null
-AUTHORS
-COPYING
-ChangeLog
-INSTALL
-NEWS
-README
-doc/index.html
+++ /dev/null
-usr/lib
-usr/include
-usr/include/google
-
+++ /dev/null
-usr/include/google/*
-usr/lib/lib*.so
-usr/lib/lib*.a
-usr/lib/lib*.la
-debian/tmp/usr/include/google/*
-debian/tmp/usr/lib/lib*.so
-debian/tmp/usr/lib/lib*.a
-debian/tmp/usr/lib/lib*.la
-
+++ /dev/null
-usr/lib/lib*.so.*
-debian/tmp/usr/lib/lib*.so.*
+++ /dev/null
-#!/usr/bin/make -f
-# -*- makefile -*-
-# Sample debian/rules that uses debhelper.
-# This file was originally written by Joey Hess and Craig Small.
-# As a special exception, when this file is copied by dh-make into a
-# dh-make output file, you may use that output file without restriction.
-# This special exception was added by Craig Small in version 0.37 of dh-make.
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-
-# These are used for cross-compiling and for saving the configure script
-# from having to guess our platform (since we know it already)
-DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
-DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
-
-
-CFLAGS = -Wall -g
-
-ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
- CFLAGS += -O0
-else
- CFLAGS += -O2
-endif
-ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
- INSTALL_PROGRAM += -s
-endif
-
-# shared library versions, option 1
-#version=2.0.5
-#major=2
-# option 2, assuming the library is created as src/.libs/libfoo.so.2.0.5 or so
-version=`ls src/.libs/lib*.so.* | \
- awk '{if (match($$0,/[0-9]+\.[0-9]+\.[0-9]+$$/)) print substr($$0,RSTART)}'`
-major=`ls src/.libs/lib*.so.* | \
- awk '{if (match($$0,/\.so\.[0-9]+$$/)) print substr($$0,RSTART+4)}'`
-
-config.status: configure
- dh_testdir
- # Add here commands to configure the package.
- CFLAGS="$(CFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info
-
-
-build: build-stamp
-build-stamp: config.status
- dh_testdir
-
- # Add here commands to compile the package.
- $(MAKE)
-
- touch build-stamp
-
-clean:
- dh_testdir
- dh_testroot
- rm -f build-stamp
-
- # Add here commands to clean up after the build process.
- -$(MAKE) distclean
-ifneq "$(wildcard /usr/share/misc/config.sub)" ""
- cp -f /usr/share/misc/config.sub config.sub
-endif
-ifneq "$(wildcard /usr/share/misc/config.guess)" ""
- cp -f /usr/share/misc/config.guess config.guess
-endif
-
-
- dh_clean
-
-install: build
- dh_testdir
- dh_testroot
- dh_clean -k
- dh_installdirs
-
- # Add here commands to install the package into debian/tmp
- $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
-
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
- dh_testdir
- dh_testroot
- dh_installchangelogs ChangeLog
- dh_installdocs
- dh_installexamples
- dh_install --sourcedir=debian/tmp
-# dh_installmenu
-# dh_installdebconf
-# dh_installlogrotate
-# dh_installemacsen
-# dh_installpam
-# dh_installmime
-# dh_installinit
-# dh_installcron
-# dh_installinfo
- dh_installman
- dh_link
- dh_strip
- dh_compress
- dh_fixperms
-# dh_perl
-# dh_python
- dh_makeshlibs
- dh_installdeb
- dh_shlibdeps
- dh_gencontrol
- dh_md5sums
- dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install
+++ /dev/null
-#!/bin/sh -e
-
-# Run this from the 'packages' directory, just under rootdir
-
-# We can only build rpm packages, if the rpm build tools are installed
-if [ \! -x /usr/bin/rpmbuild ]
-then
- echo "Cannot find /usr/bin/rpmbuild. Not building an rpm." 1>&2
- exit 0
-fi
-
-# Check the commandline flags
-PACKAGE="$1"
-VERSION="$2"
-fullname="${PACKAGE}-${VERSION}"
-archive=../$fullname.tar.gz
-
-if [ -z "$1" -o -z "$2" ]
-then
- echo "Usage: $0 <package name> <package version>" 1>&2
- exit 0
-fi
-
-# Double-check we're in the packages directory, just under rootdir
-if [ \! -r ../Makefile -a \! -r ../INSTALL ]
-then
- echo "Must run $0 in the 'packages' directory, under the root directory." 1>&2
- echo "Also, you must run \"make dist\" before running this script." 1>&2
- exit 0
-fi
-
-if [ \! -r "$archive" ]
-then
- echo "Cannot find $archive. Run \"make dist\" first." 1>&2
- exit 0
-fi
-
-# Create the directory where the input lives, and where the output should live
-RPM_SOURCE_DIR="/tmp/rpmsource-$fullname"
-RPM_BUILD_DIR="/tmp/rpmbuild-$fullname"
-
-trap 'rm -rf $RPM_SOURCE_DIR $RPM_BUILD_DIR; exit $?' EXIT SIGHUP SIGINT SIGTERM
-
-rm -rf "$RPM_SOURCE_DIR" "$RPM_BUILD_DIR"
-mkdir "$RPM_SOURCE_DIR"
-mkdir "$RPM_BUILD_DIR"
-
-cp "$archive" "$RPM_SOURCE_DIR"
-
-rpmbuild -bb rpm/rpm.spec \
- --define "NAME $PACKAGE" \
- --define "VERSION $VERSION" \
- --define "_sourcedir $RPM_SOURCE_DIR" \
- --define "_builddir $RPM_BUILD_DIR" \
- --define "_rpmdir $RPM_SOURCE_DIR"
-
-# We put the output in a directory based on what system we've built for
-destdir=rpm-unknown
-if [ -r /etc/issue ]
-then
- grep "Red Hat.*release 7" /etc/issue >/dev/null 2>&1 && destdir=rh7
- grep "Red Hat.*release 8" /etc/issue >/dev/null 2>&1 && destdir=rh8
- grep "Red Hat.*release 9" /etc/issue >/dev/null 2>&1 && destdir=rh9
- if grep Fedora /etc/issue >/dev/null; then
- destdir=fc`grep Fedora /etc/issue | cut -d' ' -f 4`;
- fi
-fi
-
-rm -rf "$destdir"
-mkdir -p "$destdir"
-# We want to get not only the main package but devel etc, hence the middle *
-mv "$RPM_SOURCE_DIR"/*/"${PACKAGE}"-*"${VERSION}"*.rpm "$destdir"
-
-echo
-echo "The rpm package file(s) are located in $PWD/$destdir"
+++ /dev/null
-## This is a boilerplate file for Google opensource projects.
-## To make it useful, replace <<TEXT>> with actual text for your project.
-## Also, look at comments with "## double hashes" to see if any are worth
-## uncommenting or modifying.
-
-%define RELEASE 1
-%define rel %{?CUSTOM_RELEASE} %{!?CUSTOM_RELEASE:%RELEASE}
-%define prefix /usr
-
-Name: %NAME
-Summary: Lightweight C unit testing framework.
-Version: %VERSION
-Release: %rel
-Group: Development/Libraries
-URL: http://code.google.com/p/cmockery
-License: Apache
-Vendor: Google
-Packager: Google Inc. <opensource@google.com>
-Source: http://%{NAME}.googlecode.com/files/%{NAME}-%{VERSION}.tar.gz
-Distribution: Redhat 7 and above.
-Buildroot: %{_tmppath}/%{name}-root
-Prefix: %prefix
-
-%description
-The %name package contains a lightweight library to simplify and generalize the
-process of writing unit tests for C applications.
-
-%package devel
-Summary: Lightweight C unit testing framework.
-Group: Development/Libraries
-Requires: %{NAME} = %{VERSION}
-
-%description devel
-The %name package contains static and debug libraries and header files for the
-development of test applications using %name.
-
-%changelog
- * Mon Aug 25 2008 <opensource@google.com>
- - First draft
-
-%prep
-%setup
-
-%build
-./configure
-make prefix=%prefix
-
-%install
-rm -rf $RPM_BUILD_ROOT
-make prefix=$RPM_BUILD_ROOT%{prefix} install
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%files
-%defattr(-,root,root)
-
-## Mark all installed files within /usr/share/doc/{package name} as
-## documentation. This depends on the following two lines appearing in
-## Makefile.am:
-## docdir = $(prefix)/share/doc/$(PACKAGE)-$(VERSION)
-## dist_doc_DATA = AUTHORS COPYING ChangeLog INSTALL NEWS README
-%docdir %{prefix}/share/doc/%{NAME}-%{VERSION}
-%{prefix}/share/doc/%{NAME}-%{VERSION}/*
-
-%{prefix}/lib/libcmockery.so.0
-%{prefix}/lib/libcmockery.so.0.0.0
-
-
-%files devel
-%defattr(-,root,root)
-
-%{prefix}/include/google
-%{prefix}/lib/libcmockery.a
-%{prefix}/lib/libcmockery.la
-%{prefix}/lib/libcmockery.so
-project(cmockery-library C)
+project(cmocka-library C)
-set(CMOCKERY_PUBLIC_INCLUDE_DIRS
- ${CMAKE_SOURCE_DIR}/src/google
- CACHE INTERNAL "cmockery public include directories"
+set(CMOCKA_PUBLIC_INCLUDE_DIRS
+ ${CMAKE_SOURCE_DIR}/src/include
+ CACHE INTERNAL "cmocka public include directories"
)
-set(CMOCKERY_PRIVATE_INCLUDE_DIRS
+set(CMOCKA_PRIVATE_INCLUDE_DIRS
${CMAKE_BINARY_DIR}
)
-set(CMOCKERY_SHARED_LIBRARY
- cmockery_shared
- CACHE INTERNAL "cmockery shared library"
+set(CMOCKA_SHARED_LIBRARY
+ cmocka_shared
+ CACHE INTERNAL "cmocka shared library"
)
if (WITH_STATIC_LIB)
- set(CMOCKERY_STATIC_LIBRARY
- cmockery_static
- CACHE INTERNAL "cmockery static library"
+ set(CMOCKA_STATIC_LIBRARY
+ cmocka_static
+ CACHE INTERNAL "cmocka static library"
)
endif (WITH_STATIC_LIB)
-set(CMOCKERY_LINK_LIBRARIES
- ${CMOCKERY_REQUIRED_LIBRARIES}
- CACHE INTERNAL "cmockery link libraries"
+set(CMOCKA_LINK_LIBRARIES
+ ${CMOCKA_REQUIRED_LIBRARIES}
+ CACHE INTERNAL "cmocka link libraries"
)
-set(cmockery_SRCS
- cmockery.c
+set(cmocka_SRCS
+ cmocka.c
)
if (WIN32)
- set(cmockery_SRCS
- ${cmockery_SRCS}
- cmockery.def
+ set(cmocka_SRCS
+ ${cmocka_SRCS}
+ cmocka.def
)
endif (WIN32)
include_directories(
- ${CMOCKERY_PUBLIC_INCLUDE_DIRS}
- ${CMOCKERY_PRIVATE_INCLUDE_DIRS}
+ ${CMOCKA_PUBLIC_INCLUDE_DIRS}
+ ${CMOCKA_PRIVATE_INCLUDE_DIRS}
)
add_definitions(-DHAVE_CONFIG_H=1)
-add_library(${CMOCKERY_SHARED_LIBRARY} SHARED ${cmockery_SRCS})
+add_library(${CMOCKA_SHARED_LIBRARY} SHARED ${cmocka_SRCS})
-target_link_libraries(${CMOCKERY_SHARED_LIBRARY} ${CMOCKERY_LINK_LIBRARIES})
+target_link_libraries(${CMOCKA_SHARED_LIBRARY} ${CMOCKA_LINK_LIBRARIES})
set_target_properties(
- ${CMOCKERY_SHARED_LIBRARY}
+ ${CMOCKA_SHARED_LIBRARY}
PROPERTIES
VERSION
${LIBRARY_VERSION}
SOVERSION
${LIBRARY_SOVERSION}
OUTPUT_NAME
- cmockery
+ cmocka
DEFINE_SYMBOL
- CMOCKERY_EXPORTS
+ CMOCKA_EXPORTS
)
install(
- TARGETS ${CMOCKERY_SHARED_LIBRARY}
+ TARGETS ${CMOCKA_SHARED_LIBRARY}
RUNTIME DESTINATION ${BIN_INSTALL_DIR}
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
)
if (WITH_STATIC_LIB)
- add_library(${CMOCKERY_STATIC_LIBRARY} STATIC ${cmockery_SRCS})
+ add_library(${CMOCKA_STATIC_LIBRARY} STATIC ${cmocka_SRCS})
set_target_properties(
- ${CMOCKERY_STATIC_LIBRARY}
+ ${CMOCKA_STATIC_LIBRARY}
PROPERTIES
VERSION
${LIBRARY_VERSION}
SOVERSION
${LIBRARY_SOVERSION}
OUTPUT_NAME
- cmockery
+ cmocka
)
install(
- TARGETS ${CMOCKERY_STATIC_LIBRARY}
+ TARGETS ${CMOCKA_STATIC_LIBRARY}
DESTINATION ${LIB_INSTALL_DIR}
COMPONENT libraries
)
endif (WITH_STATIC_LIB)
-add_subdirectory(google)
+add_subdirectory(include)
add_subdirectory(example)
#include <signal.h>
#endif /* _WIN32 */
-#include <cmockery.h>
+#include <cmocka.h>
// Size of guard bytes around dynamically allocated blocks.
#define MALLOC_GUARD_SIZE 16
-LIBRARY cmockery
+LIBRARY cmocka
EXPORTS
_assert_in_range
_assert_in_set
-project(cmockery-examples C CXX)
+project(cmocka-examples C CXX)
include_directories(
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
- ${CMOCKERY_PUBLIC_INCLUDE_DIRS}
+ ${CMOCKA_PUBLIC_INCLUDE_DIRS}
)
add_definitions(-DUNIT_TESTING=1)
add_executable(calculator_test calculator.c calculator_test.c)
-target_link_libraries(calculator_test ${CMOCKERY_SHARED_LIBRARY})
+target_link_libraries(calculator_test ${CMOCKA_SHARED_LIBRARY})
add_executable(allocate_module_test allocate_module.c allocate_module_test.c)
-target_link_libraries(allocate_module_test ${CMOCKERY_SHARED_LIBRARY})
+target_link_libraries(allocate_module_test ${CMOCKA_SHARED_LIBRARY})
add_executable(assert_macro_test assert_macro.c assert_macro_test.c)
-target_link_libraries(assert_macro_test ${CMOCKERY_SHARED_LIBRARY})
+target_link_libraries(assert_macro_test ${CMOCKA_SHARED_LIBRARY})
add_executable(customer_database_test customer_database.c customer_database_test.c)
-target_link_libraries(customer_database_test ${CMOCKERY_SHARED_LIBRARY})
+target_link_libraries(customer_database_test ${CMOCKA_SHARED_LIBRARY})
add_executable(key_value_test key_value.c key_value_test.c)
-target_link_libraries(key_value_test ${CMOCKERY_SHARED_LIBRARY})
+target_link_libraries(key_value_test ${CMOCKA_SHARED_LIBRARY})
add_executable(product_database_test product_database.c product_database_test.c)
-target_link_libraries(product_database_test ${CMOCKERY_SHARED_LIBRARY})
+target_link_libraries(product_database_test ${CMOCKA_SHARED_LIBRARY})
add_executable(run_tests run_tests.c)
-target_link_libraries(run_tests ${CMOCKERY_SHARED_LIBRARY})
+target_link_libraries(run_tests ${CMOCKA_SHARED_LIBRARY})
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
-#include <cmockery.h>
+#include <cmocka.h>
extern void leak_memory();
extern void buffer_overflow();
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
-#include <cmockery.h>
+#include <cmocka.h>
extern const char* get_status_code_string(const unsigned int status_code);
extern unsigned int string_to_status_code(
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
-#include <cmockery.h>
+#include <cmocka.h>
extern void increment_value(int * const value);
* limitations under the License.
*/
-// A calculator example used to demonstrate the cmockery testing library.
+// A calculator example used to demonstrate the cmocka testing library.
#ifdef HAVE_CONFIG_H
#include "config.h"
extern int example_test_fprintf(FILE * const file, const char *format, ...);
-// Redirect assert to mock_assert() so assertions can be caught by cmockery.
+// Redirect assert to mock_assert() so assertions can be caught by cmocka.
#ifdef assert
#undef assert
#endif // assert
void mock_assert(const int result, const char* expression, const char *file,
const int line);
-/* Redirect calloc and free to test_calloc() and test_free() so cmockery can
+/* Redirect calloc and free to test_calloc() and test_free() so cmocka can
* check for memory leaks. */
#ifdef calloc
#undef calloc
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
-#include "cmockery.h"
+#include "cmocka.h"
#include <stdio.h>
#ifdef _WIN32
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
-#include <cmockery.h>
+#include <cmocka.h>
#include <database.h>
extern DatabaseConnection* connect_to_customer_database();
#include <stddef.h>
#include <setjmp.h>
#include <string.h>
-#include <cmockery.h>
+#include <cmocka.h>
#include "key_value.h"
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
-#include <cmockery.h>
+#include <cmocka.h>
#include <database.h>
extern DatabaseConnection* connect_to_product_database(void);
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
-#include <cmockery.h>
+#include <cmocka.h>
// A test case that does nothing and succeeds.
static void null_test_success(void **state) {
+++ /dev/null
-project(cmockery-headers C)
-
-set(cmockery_HDRS
- cmockery.h
-)
-
-install(
- FILES
- ${cmockery_HDRS}
- DESTINATION
- ${INCLUDE_INSTALL_DIR}/google
- COMPONENT
- headers
-)
--- /dev/null
+project(cmocka-headers C)
+
+set(cmocka_HDRS
+ cmocka.h
+)
+
+install(
+ FILES
+ ${cmocka_HDRS}
+ DESTINATION
+ ${INCLUDE_INSTALL_DIR}
+ COMPONENT
+ headers
+)
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef CMOCKERY_H_
-#define CMOCKERY_H_
+#ifndef CMOCKA_H_
+#define CMOCKA_H_
#ifdef _WIN32
#if _MSC_VER < 1500
#ifdef __cplusplus
void vprint_message(const char* const format, va_list args);
void vprint_error(const char* const format, va_list args);
-#endif // CMOCKERY_H_
+#endif // CMOCKA_H_