Remove building with NOCRYPTO option
[minix.git] / external / bsd / dhcp / dist / server / tests / simple_unittest.c
blobb6cc5a71642abd8a710516eae619d359bf34ebee
1 /* $NetBSD: simple_unittest.c,v 1.1.1.2 2014/07/12 11:58:17 spz Exp $ */
2 /*
3 * Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
18 #include <config.h>
19 #include <atf-c.h>
21 /* That is an example ATF test case, tailored to ISC DHCP sources.
22 For detailed description with examples, see man 3 atf-c-api. */
24 /* this macro defines a name of a test case. Typical test case constists
25 of an initial test declaration (ATF_TC()) followed by 3 phases:
27 - Initialization: ATF_TC_HEAD()
28 - Main body: ATF_TC_BODY()
29 - Cleanup: ATF_TC_CLEANUP()
31 In many cases initialization or cleanup are not needed. Use
32 ATF_TC_WITHOUT_HEAD() or ATF_TC_WITH_CLEANUP() as needed. */
33 ATF_TC(simple_test_case);
36 ATF_TC_HEAD(simple_test_case, tc)
38 atf_tc_set_md_var(tc, "descr", "This test case is a simple DHCP test.");
40 ATF_TC_BODY(simple_test_case, tc)
42 int condition = 1;
43 int this_is_linux = 1;
44 /* Failing condition will fail the test, but the code
45 itself will continue */
46 ATF_CHECK( 2 > 1 );
48 /* assert style check. Test will abort if the condition is not met. */
49 ATF_REQUIRE( 5 > 4 );
51 ATF_CHECK_EQ(4, 2 + 2); /* Non-fatal test. */
52 ATF_REQUIRE_EQ(4, 2 + 2); /* Fatal test. */
54 /* tests can also explicitly report test result */
55 if (!condition) {
56 atf_tc_fail("Condition not met!"); /* Explicit failure. */
59 if (!this_is_linux) {
60 atf_tc_skip("Skipping test. This Linux-only test.");
63 if (condition && this_is_linux) {
64 /* no extra comments for pass needed. It just passed. */
65 atf_tc_pass();
70 /* This macro defines main() method that will call specified
71 test cases. tp and simple_test_case names can be whatever you want
72 as long as it is a valid variable identifier. */
73 ATF_TP_ADD_TCS(tp)
75 ATF_TP_ADD_TC(tp, simple_test_case);
77 return (atf_no_error());