README
# The contents of this file are subject to the terms of the Common Development and
# Distribution License (the License). You may not use this file except in compliance with the
# License.
#
# You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
# specific language governing permission and limitations under the License.
#
# When distributing Covered Software, include this CDDL Header Notice in each file and include
# the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
# Header, with the fields enclosed by brackets [] replaced by your own identifying
# information: "Portions copyright [year] [name of copyright owner]".
#
# Copyright 2015 ForgeRock AS.
This directory contains the unit tests for the C Web Agents version 4.
Tests are placed in C source files and will look something like the following. Let us assume this is the file test_blah.c:
#include
/**
* Test the blah functionality.
*/
void test_blah1(void** state) {
// avoids "state not used" messages
(void)state;
assert_int_equal(AM_OK, AM_OK);
// etc.
}
void test_blah2(void** state) {
// etc. etc.
}
Each test must be prototyped in a corresponding header file, in this case test_blah.h:
void test_blah1(void** state);
void test_blah2(void** state);
then this header file must be included in test_MAIN.c so the tests can be invoked. Fortunately, if you have access to either the
Korn shell, or the Born Again shell, together with the sed utility, there are two scripts which can automate these two steps.
The script mh.sh ("make header") will build one header file for each C source file (the default is to rebuild all header files).
Once this is done, the script mm.sh ("make main") will build the main test harness test_MAIN.c which is compiled by the Makefile.
Note that you will need to have the cmocka framework installed (i.e. available to the compiler with "-lcmocka") before the unit
tests can be built.