Cframework

From fd.io
Revision as of 15:19, 18 April 2017 by Mauro91 (Talk | contribs)

Jump to: navigation, search

LongBow

The LongBow C language software framework

Quick Start

Installation from binary packages

Ubuntu 14.04 and Ubuntu 16.04

 $ echo "deb [trusted=yes] https://nexus.fd.io/content/repositories/fd.io.master.ubuntu.$(lsb_release -sc).main/ ./" \
          | sudo tee -a /etc/apt/sources.list.d/99fd.io.list
 $ sudo apt-get update
 $ sudo apt-get install longbow

Centos 7

$ cat << EOF | sudo tee -a /etc/yum.repos.d/99fd.io.repo
[fdio-cicn-master]
name=fd.io master branch latest merge
baseurl=https://nexus.fd.io/content/repositories/fd.io.master.centos7/
enabled=1
gpgcheck=0
EOF
$ sudo yum install longbow

Installation from source code

$ git clone -b cframework/master https://gerrit.fd.io/r/cicn cframework
$ cd cframework/longbow
$ mkdir build
$ cd build
$ cmake ..
$ make
$ make test
$ make install

Introduction

LongBow is a C language software framework that combines the fail-fast philosophy of an offensive-stance of program development and xUnit style unit testing. Using LongBow's to aid an offensive-development stance is largely a matter of using its entry and exit assertions in your code. Similarly using LongBow's unit-test framework uses the same entry and exit assertions in the unit test cases themselves. The runtime assertions and the unit-test assertions work together in the unit test framework and do not conflict.

Using LongBow

Platforms

LongBow has been tested in:

  • Ubuntu 16.04 (x86_64)
  • Debian Testing
  • MacOSX 10.12

Other platforms and architectures may work.

Dependencies

  • c99 (clang / gcc)
  • CMake 3.4
  • Python 2.7

While the LongBow unit test framework and runtime assertions don't have any unusual requirements other than CMake, the software quality development tools that LongBow provides can make use of the following tools:

  • Doxygen
  • Uncrustify

Using LongBow

LongBow Lib

To use LongBow in your software you will need to link your programs to the LongBow libraries.
Longbow comes as a set of libraries. A main library and a set of reporting libraries. Your software will need to link to the main library (liblongbow) and one of the reporting libraries. Currently there are 2 reporting libraries available longbow-textplain and longbow-ansiterm.

LONGBOW_DIR=<directory-where-longbow-is-installed>

-I${LONGBOW_DIR}/include -L${LONGBOW_DIR}/lib -llongbow -llongbow_textplain.a

LongBow Unit Testing

LongBow unit testing works in conjuction with the LongBow library. Please take a look at the examples and the documentation for information on how to write unit tests. You can also look at some of the software that uses LongBow for unit testing as examples. A good starting point would be Libparc.

LongBow Utilities

LongBow comes with a set of utilities (scripts) to make C programs better. This includes code analysis and reporting tools. You will find these in the ${INSTALL_DIR}/bin directory. Each of those utilities should come with a -h option that will give you online help. For more information please check the LongBow documentation.

GDB and LongBow

LongBow uses signals to interrupt program flow when an assertion fails. When using gdb this will cause gdb to stop running of the test which probably isn't what you want. You probably would prefer that gdb just ignore the signal and let the LongBow unit test signal handler take care of the signal. To do this, you must configure gdb to ignore the signal and to allow it to pass to the programme being executed.

handle 6 nostop pass

Libparc

The PARC C Library

Quick Start

Installation from binary packages

Ubuntu 14.04 and Ubuntu 16.04

 $ echo "deb [trusted=yes] https://nexus.fd.io/content/repositories/fd.io.master.ubuntu.$(lsb_release -sc).main/ ./" \
          | sudo tee -a /etc/apt/sources.list.d/99fd.io.list
 $ sudo apt-get update
 $ sudo apt-get install libparc

Centos 7

$ cat << EOF | sudo tee -a /etc/yum.repos.d/99fd.io.repo
[fdio-cicn-master]
name=fd.io master branch latest merge
baseurl=https://nexus.fd.io/content/repositories/fd.io.master.centos7/
enabled=1
gpgcheck=0
EOF
$ sudo yum install libparc

Installation from source code

From the code tree root

$ mkdir Libparc.build
$ cd Libparc.build
$ cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} ../Libparc
$ make
$ make test
$ make install

Introduction

The PARC Library is a C runtime providing an array of features and capabilities for C programs and programmers.

Functionality is grouped into:

  • Data structures
  • Input Output
  • Memory and Buffer Management
  • Threading and Concurrency
  • Security
  • Developer Aids
  • Networking and Communication

Using Libparc

Platforms

Libparc has been tested in:

  • Ubuntu 16.04 (x86_64)
  • Debian testing
  • MacOSX 10.12

Other platforms and architectures may work.

Dependencies

Build dependencies:

  • c99 ( clang / gcc )
  • CMake 3.4

Basic dependencies:

  • OpenSSL
  • pthreads
  • Libevent
  • LongBow

Documentation dependencies:

  • Doxygen

Getting Started

Installation from source code

Libparc is built using cmake. You will need to have CMake 3.4 installed in order to build it.

Download Libparc

Create build directory
$ mkdir Libparc.build
$ cd Libparc.build

Prepare the build, give an install directory
$ cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} ../Libparc

On MacOSX 10.12 you need to install openssl and pass it to cmake

$ cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} ../Libparc -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/


Compile the software
$ make

Run unit tests
$ make test

Install the software
$ make install

This will create the include and lib directories containing the necessary files to compile with LongBow in the ${INSTALL_DIR}.

Using Libparc

Libparc is a set of functions and data structures for C. You can use it in your code by including the right header files and linking to the libparc library.

LIBPARC=<directory-where-libparc-is-installed>

-I${LIBPARC}/include -L${LIBPARC}/lib -lparc

License

This software is distributed under the following license:

Copyright (c) 2017 Cisco and/or its affiliates.
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.