Added a bunch of docs, removed additional links in index.

This commit is contained in:
Snaipe 2015-02-10 01:37:45 +01:00
parent 721ac7e5d6
commit 7eb03b68d0
4 changed files with 108 additions and 7 deletions

48
doc/hooks.rst Normal file
View file

@ -0,0 +1,48 @@
Report Hooks
============
Report hooks are functions that are called at key moments during the testing
process. These are useful to report statistics gathered during the execution.
A report hook can be declared using the ``ReportHook`` macro:
.. code-block:: c
#include <criterion/criterion.h>
#include <criterion/hooks.h>
ReportHook(Phase)() {
}
The macro takes a Phase parameter that indicates the phase at which the function
shall be run. Valid phases are described below.
Testing Phases
--------------
The flow of the test process goes as follows:
1. ``PRE_EVERYTHING``: occurs before running the tests.
#. ``PRE_INIT``: occurs before a test is initialized.
#. ``PRE_TEST``: occurs after the test initialization, but before the test is run.
#. ``ASSERT``: occurs when an assertion is hit
#. ``TEST_CRASH``: occurs when a test crashes unexpectedly.
#. ``POST_TEST``: occurs after a test ends, but before the test finalization.
#. ``POST_FINI``: occurs after a test finalization.
#. ``POST_EVERYTHING``: occurs after all the tests are done.
Hook Parameters
---------------
A report hook may take zero or one parameter. If a parameter is given, it
is undefined behaviour if it is not a pointer type and not of the proper pointed
type for that phase.
Valid types for each phases are:
* ``struct criterion_test *`` for ``PRE_INIT`` and ``PRE_TEST``.
* ``struct criterion_test_stats *`` for ``POST_TEST``, ``POST_FINI``, and ``TEST_CRASH``.
* ``struct criterion_assert_stats *`` for ``ASSERT``.
* ``struct criterion_global_stats *`` for ``POST_EVERYTHING``.
``PRE_EVERYTHING`` does not take any parameter.

View file

@ -4,11 +4,7 @@ Criterion
.. toctree::
:maxdepth: 2
intro
setup
starter
Indices and tables
==================
* :ref:`genindex`
* :ref:`search`
* :ref:`glossary`
hooks

28
doc/intro.rst Normal file
View file

@ -0,0 +1,28 @@
Introduction
============
Criterion is a dead-simple, non-intrusive testing framework for the C
programming language.
Philosophy
----------
Most test frameworks for C require a lot of boilerplate code to
set up tests and test suites -- you need to create a main,
then register new test suites, then register the tests within
these suits, and finally call the right functions.
This gives the user great control, at the unfortunate cost of simplicity.
Criterion follows the KISS principle, while keeping the control
the user would have with other frameworks.
Features
--------
* Tests are automatically registered when declared.
* A default entry point is provided, no need to declare a main
unless you want to do special handling.
* Test are isolated in their own process, crashes and signals can be
reported and tested.
* Progress and statistics can be followed in real time with report hooks.

29
doc/setup.rst Normal file
View file

@ -0,0 +1,29 @@
Setup
=====
Prerequisites
-------------
Currently, this library only works under \*nix systems.
To compile the static library and its dependencies, GCC 4.9+ is needed.
To use the static library, GCC or Clang are needed.
Installation
------------
.. code-block:: bash
$ git clone https://github.com/Snaipe/Criterion.git
$ cd Criterion
$ ./autogen.sh && ./configure && make && sudo make install
Usage
-----
Given a test file named test.c, compile it with `-lcriterion`:
.. code-block:: bash
$ gcc -o test test.c -lcriterion