Skip to content

Commit

Permalink
Adding cunit code base
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhijith Sriram committed Oct 28, 2024
1 parent 62d4ec3 commit 3c8b04a
Show file tree
Hide file tree
Showing 166 changed files with 27,397 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tools/cunit-master/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 1,16 @@
*.o
*.exe
*.so
*.a
*.dll
*.xml
*.html
.idea/
cmake-build-*/
build-*/
CUnit-Memory-Dump.xml
html/
latex/
bld/
packages/
docs/
136 changes: 136 additions & 0 deletions tools/cunit-master/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 1,136 @@

include:
- local: default-runners.yml
- local: gitlab-runners.yml
rules:
- if: ($CI_SERVER_HOST == "gitlab.com") && ($CI_PROJECT_NAMESPACE == "cunity")

stages:
- build
- test
- results
- release


.cunit-build-template-base:
stage: build
script:
- mkdir build-${CI_JOB_NAME}
- cd build-${CI_JOB_NAME}
- cmake ..
- cmake --build . -j2
- ctest --output-on-failure
- ./Examples/CI/cicd-pass-plain
- ./Examples/CI/cicd-pass-setupfuncs
- python3 -m junit2htmlreport --summary-matrix Examples/CI/*-Results.xml
- cpack -G TGZ CUnit
artifacts:
paths:
- CUnit/CUnit/CUnitCI.h
- build-*/cunit-*.tar.gz
- build-*/cunit-*.deb
- build-*/Examples/CI/*-Results.*
- build-*/Tests/*.xml
reports:
junit:
- build-*/Examples/CI/*-Results.xml
- build-*/Tests/*-Results.xml


.cunit-build-template:
extends:
- .docker-linux-job
- .cunit-build-template-base

apple:
extends:
- .macos-job
- .cunit-build-template-base

windows:
stage: build
tags:
- saas-windows-medium-amd64
script:
- mkdir build-windows
- cd build-windows
- cmake ..
- cmake --build .
- ctest -C Debug

ubuntu2004:
extends:
- .cunit-build-template
image: ubuntu:20.04
before_script:
- apt-get update
- export DEBIAN_FRONTEND=noninteractive
- apt-get install -y --no-install-recommends cmake build-essential make python3-pip
- pip install junit2html

ubuntu2004-notests:
extends:
- ubuntu2004
script:
- mkdir build-${CI_JOB_NAME}
- cd build-${CI_JOB_NAME}
- cmake .. -DCUNIT_DISABLE_TESTS=TRUE -DCUNIT_DISABLE_EXAMPLES=TRUE
- cmake --build . -j 2
- find . -type f

alpine:
extends:
- .cunit-build-template
image: alpine:3.14
before_script:
- apk update
- apk add cmake gcc make libc-dev python3 py3-pip
- pip3 install junit2html


alpine-dirbuild:
stage: test
needs:
- alpine
extends:
- alpine
script:
- cd CMakeExamples/CMakeSubmodule
- ln -s ../../. cunit-x.y.z
- mkdir bld
- cd bld
- cmake ..
- cmake --build .
- ./test-program


alpine-pkgbuild:
stage: test
needs:
- alpine
extends:
- alpine
script:
- find . -type f -name "*.tar.gz"
- mkdir -p packages/cunit
- tar -vxf build-alpine/cunit-3.*.tar.gz --strip-components=1 -C packages/cunit
- cd CMakeExamples/CMakeFindPackage
- mkdir bld
- cd bld
- cmake .. -DCUnit_DIR=$(pwd)/../../../packages/cunit/CUnit/share/cmake
- cmake --build .
- ./test-program

pages:
stage: release
image: alpine:3.14
needs:
- alpine
script:
- apk update
- apk add doxygen
- doxygen Doxyfile
- mv doc/html/ public/
artifacts:
paths:
- public
12 changes: 12 additions & 0 deletions tools/cunit-master/AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 1,12 @@
Anil Kumar (AK)
Email : [email protected]

Jerry St.Clair (JDS)
Email : [email protected]

-----------------------------------------------------------
Special thanks to the following contributors to CUnit:

K. Cheung and Aurema Pty Ltd.
Shortcut code for efficient registration of
CUnit tests and suites.
26 changes: 26 additions & 0 deletions tools/cunit-master/CMakeExamples/CMakeFindPackage/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 1,26 @@
project(CUnitExamplePackage C)
cmake_minimum_required(VERSION 3.5)

# uncomment to test pre-building cunit

#set(EXT_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/ext/cunit/install)
#set(EXT_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/ext/cunit/build)
#
#file(MAKE_DIRECTORY ${EXT_INSTALL_DIR})
#file(MAKE_DIRECTORY ${EXT_BUILD_DIR})
#execute_process(
# COMMAND ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${EXT_INSTALL_DIR} ${CMAKE_SOURCE_DIR}/../../
# WORKING_DIRECTORY ${EXT_BUILD_DIR}
#)
#execute_process(
# COMMAND ${CMAKE_COMMAND} --build . --target install
# WORKING_DIRECTORY ${EXT_BUILD_DIR}
#)

#set(CUnit_DIR ${EXT_INSTALL_DIR}/CUnit/share/cmake)


find_package(CUnit REQUIRED)

add_executable(test-program test-program.c)
target_link_libraries(test-program PUBLIC cunit)
33 changes: 33 additions & 0 deletions tools/cunit-master/CMakeExamples/CMakeFindPackage/test-program.c
Original file line number Diff line number Diff line change
@@ -0,0 1,33 @@
/*
* Simple example test for cunit
*/

/*
* CUnit - A Unit testing framework library for C.
* Copyright (C) 2001 Anil Kumar
* Copyright (C) 2004-2006 Anil Kumar, Jerry St.Clair
* Copyright (C) 2018 Ian Norton
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#include "CUnit/CUnitCI.h"

static void test_simple_pass1(void) {
CU_ASSERT_FATAL(1 == 1);
}

CUNIT_CI_RUN(CU_MAIN_EXE_NAME,
CUNIT_CI_TEST(test_simple_pass1));
Original file line number Diff line number Diff line change
@@ -0,0 1,7 @@
project(CUnitExampleSubmodule C)
cmake_minimum_required(VERSION 3.5)

add_subdirectory(cunit-x.y.z/CUnit)

add_executable(test-program test-program.c)
target_link_libraries(test-program PUBLIC cunit)
33 changes: 33 additions & 0 deletions tools/cunit-master/CMakeExamples/CMakeSubmodule/test-program.c
Original file line number Diff line number Diff line change
@@ -0,0 1,33 @@
/*
* Simple example test for cunit
*/

/*
* CUnit - A Unit testing framework library for C.
* Copyright (C) 2001 Anil Kumar
* Copyright (C) 2004-2006 Anil Kumar, Jerry St.Clair
* Copyright (C) 2018 Ian Norton
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#include "CUnit/CUnitCI.h"

static void test_simple_pass1(void) {
CU_ASSERT_FATAL(1 == 1);
}

CUNIT_CI_RUN(CU_MAIN_EXE_NAME,
CUNIT_CI_TEST(test_simple_pass1));
38 changes: 38 additions & 0 deletions tools/cunit-master/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 1,38 @@
# Static file is generated/linked against for this project
# Fixes issues with toolchains which only support static linking
cmake_minimum_required (VERSION 3.5)
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
project(CUnit C)


# If the user hasn't specified a preference for disabling
# tests/examples, default to leaving them enabled.
if (NOT DEFINED CUNIT_DISABLE_TESTS)
set (CUNIT_DISABLE_TESTS FALSE)
endif ()
if (NOT DEFINED CUNIT_DISABLE_EXAMPLES)
set (CUNIT_DISABLE_EXAMPLES FALSE)
endif ()

set(CUNIT_DISABLE_TESTS "${CUNIT_DISABLE_TESTS}" CACHE INTERNAL "Disable CUnit tests")
set(CUNIT_DISABLE_EXAMPLES "${CUNIT_DISABLE_EXAMPLES}" CACHE INTERNAL "Disable CUnit examples")

enable_testing()
set(CUNIT_CMAKE_INSTALL yes)

if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -Werror=strict-prototypes")
endif()

if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3 /WX /wd4996")
endif()

add_subdirectory(CUnit)
if(NOT CUNIT_DISABLE_TESTS)
add_subdirectory(Tests)
endif()

if(NOT CUNIT_DISABLE_EXAMPLES)
add_subdirectory(Examples)
endif()
Loading

0 comments on commit 3c8b04a

Please sign in to comment.