Name Last Update
..
README Loading commit data...
test_MAIN.c Loading commit data...
test_config.c Loading commit data...
test_exits.c Loading commit data...
test_init.c Loading commit data...
test_log.c Loading commit data...
test_network.c Loading commit data...
test_notenforced_lists.c Loading commit data...
test_notifications.c Loading commit data...
test_policy.c Loading commit data...
test_policy_cache.c Loading commit data...
test_setup_requests.c Loading commit data...
test_utility.c Loading commit data...

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 OpenAM Web Policy Agent.

Tests are placed in C source files and will look something like the following.
Let us assume this is the file test_blah.c. You will definitely need cmocka.h and
for that you will need setjmp.h.
-------------------------------------------------------------------------------------

#include
#include
#include
#include
#include

#include "cmocka.h"

/**
* 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.
}

-------------------------------------------------------------------------------------
You can build all the tests with:

make tests

or alternatively if you only want to run the tests in the file, say, test_blah.c then use
this (note you must drop the ".c" suffix from the filename):

make "TESTS=test_blah" tests

Make invokes sed to produce a number of files, all of which can be ignored except for

build/tests/tests.h

which will look something like this:

-------------------------------------------------------------------------------------
void test_blah1(void** state) ;
void test_blah2(void** state) ;
const struct CMUnitTest tests[] = {
cmocka_unit_test(test_blah1),
cmocka_unit_test(test_blah2),
};
-------------------------------------------------------------------------------------

Note that tests are only included in the array if:
- the return value is void
- function has single void** parameter called "state"
- the function is "public", as opposed to static
- the function name starts with "test_"