/testrun.info

Tools to create testrun based projects.

Primary LanguageCApache License 2.0Apache-2.0

Project testrun_lib

LOGO

Testrun_lib is a toolset to create lightweight, customizable, but common makefile based C (unit) testing frameworks.

All Lib functionality is related to the central header testrun.h and makefile integrated testrunner scripts.

This lib MAY be used for own project initialization executables, OR as standalone command line tool.

Overview

Description

testrun_lib is a library to build custom project file structures for C development. It SHALL provide basic integrated copyright mangement for the most common open source copyrigths and integrated testing capabilities for C projects.

This lib may be seen as a framework to create an own custom company framework for C development, which includes a basic, lightweight and higly customizable testrunning and test creation infrastructure or as a command line tool for standard project creations.

Usage

Installation will create an executable copied to /usr/local/bin, as well as library objects for static and dynamic linking under /usr/local/lib. A package config file to include the lib will be provied in the standard path /usr/local/lib/pkgconfig.

Command line version

HELP

testrun_lib -h

Example

Create a project /tmp/project/name

testrun_lib --project name --author Markus Toepfer --dir /tmp/project --gpl

Library version

To include the library for custom testrun_lib based development link with pkg-config.

pkg-config --libs libtestrun_lib

Installation

Package installation will be done by default as static library /usr/local/lib/testrun_lib.a as well as shared library /usr/local/lib/testrun_lib.so. In addition the executable will be placed at: /usr/local/bin/testrun_lib.

A package config file will be written to /usr/local/lib/pkgconfig/testrun_lib.pc

In addition to the installation all header files of the module will be provided for external development at /usr/local/include/testrun_lib/

build sources

make

build documentation

make documentation

test sources

make tested

install binaries

sudo make install

uninstall binaries

sudo make uninstall

Requirements

This library requires the C99 ISO-C standard and is implemented using some POSIX headers (e.g. <sys/stat.h> or <sys/time.h>).

It compiles using GCC (5.4.0 Ubuntu) or CLANG (3.8.0-2ubuntu) on LINUX (Ubuntu 16.04) without any dependencies.

Structure

Default structure of the folder:

<pre>
.
├── COPYRIGHT
├── README.MD
├── makefile
├── makefile_general.mk
│
├── doxygen
│   ├── documentation (autogenerated)
│   └── doxygen.config
│
├── docs
│   ├── CHANGELOG.MD
│   └── ...
│
├── include
│   ├── testrun_lib.h
│   └── ...
│
├── src
│   ├── testrun_lib.c
│   └── ...
│
└── tests
    ├── resources
    ├── tools
    │   ├── testrun_runner.h
    │   ├── testrun_gcov.sh
    │   ├── testrun_gprof.sh
    │   ├── testrun_simple_coverage_tests.sh
    │   ├── testrun_simple_unit_tests.sh
    │   ├── testrun_simple_acceptance_tests.sh
    │   └── testrun_simple_loc.sh

    ├── acceptance
    │   ├── ...
    │   └── ...
    └── unit
        ├── testrun_lib_tests.c
        └── ...

</pre>

Tests

Test a project (all files contained in tests/unit)

Test compile and run

make tested

Test a dedicated source file (single file of tests/unit)

To develop a test for a specific source file, it may be helpful to use a separated test run. This may be done via an integrated make functionality.

Test compile example

make test testname=tests/unit/filename_tests.c

Test compile and run in valgrind

make test testname=tests/unit/filename_tests.c && valgrind ./build/test/unit/filename_tests.test

Tips

Copyrights

This lib provides the following copyright statements

  • Apache Version 2
  • GPL v3 (General, Lesser, Affero)
  • BSD (3Clause, 2Clause)
  • MIT
  • All rights reserved

Configuration

Any configuration option is shown in testrun_config_default() Default definitions for folder names are done in testrun_config.

testrun_config testrun_config_default(){

        testrun_config config = {

                .author  = TESTRUN_TAG_DEFAULT_AUTHOR,
                .project =
                {
                        .name = TESTRUN_TAG_DEFAULT_PROJECT,
                        .type = TESTRUN_LIB,
                        .path = path,
                        .doxygen = true
                },
                .copyright =
                {
                        .intro          = TESTRUN_COPYRIGHT_INTRO_DEFAULT,
                        .year           = TESTRUN_COPYRIGHT_TAG_YEAR,
                        .owner          = TESTRUN_COPYRIGHT_TAG_OWNER,
                        .text           = TESTRUN_COPYRIGHT_TEXT_DEFAULT,

                        .note           = NULL,
                        .variant        = NULL,
                        .program        = NULL,

                        .to_string      = testrun_copyright_to_string
                },
                .format =
                {
                        .line_length    = 80,
                        .indent_c       = 8,
                        .offset_docu    = 3 * 8,
                        .indent_sh      = 4
                }
        };

        return config;
}

Support

If the tools are helpful for you and you may support the development with a donation or by spreading the word. Thanks a lot for both.

twitter

paypal

Copyright

Copyright 2017 Markus Toepfer

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.

This file is part of the testrun project. http://testrun.info