The Best Defense is a Good Offense
The LongBow C language software framework
$ git clone [email protected]:PARC/LongBow.git LongBow
$ mkdir LongBow.build
$ cd LongBow.build
$ cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} ../LongBow
$ make
$ make test
$ make install
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.
This framework grew out of the need for a unit testing for Test Driven Development on the CCNx Distillery software distribution.
Two other test frameworks were considered and used to develop unit tests: Unity and GoogleTest. Ultimately Unity wash't used (although this framework is indebted to Unity for inspiration) mainly due to ease-of-use problems, and Googletest was not used mainly because it is a C++ framework, is not compatible with some features of C99, and is difficult to use.
Libparc is part of CCNx Distillery. You may want to get the software via that distribution if you want to work on CCNx.
Libparc has been tested in:
- Ubuntu 14.04 (x86_64)
- MacOSX 10.10
- MacOSX 10.11
Other platforms and architectures may work.
- 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
If these tools are provided to LongBow, the utility scripts will provide more value to the programmer.
LongBow is built using cmake. You will need to have CMake 3.4 installed in order to build it.
Download LongBow
$ git clone [email protected]:PARC/LongBow.git LongBow
Create build directory
$ mkdir LongBow.build
$ cd LongBow.build
Prepare the build, give an install directory
$ cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} ../LongBow
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}
.
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 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 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.
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
This software is distributed under the following license:
Copyright (c) 2013, 2014, 2015, 2016, Xerox Corporation (Xerox)and Palo Alto
Research Center (PARC)
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.
* Patent rights are not granted under this agreement. Patent rights are
available under FRAND terms.
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 XEROX or PARC 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.