Annotation of embedaddon/strongswan/src/libcharon/tests/utils/job_asserts.h, revision 1.1

1.1     ! misho       1: /*
        !             2:  * Copyright (C) 2016 Tobias Brunner
        !             3:  * HSR Hochschule fuer Technik Rapperswil
        !             4:  *
        !             5:  * This program is free software; you can redistribute it and/or modify it
        !             6:  * under the terms of the GNU General Public License as published by the
        !             7:  * Free Software Foundation; either version 2 of the License, or (at your
        !             8:  * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
        !             9:  *
        !            10:  * This program is distributed in the hope that it will be useful, but
        !            11:  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
        !            12:  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
        !            13:  * for more details.
        !            14:  */
        !            15: 
        !            16: /**
        !            17:  * Special assertions against job handling.
        !            18:  *
        !            19:  * @defgroup job_asserts job_asserts
        !            20:  * @{ @ingroup test_utils_c
        !            21:  */
        !            22: 
        !            23: #ifndef JOB_ASSERTS_H_
        !            24: #define JOB_ASSERTS_H_
        !            25: 
        !            26: /**
        !            27:  * Initialize an assertion that enforces that no jobs were scheduled.
        !            28:  * Must be matched by a call to assert_scheduler().
        !            29:  */
        !            30: #define assert_no_jobs_scheduled() _assert_jobs_scheduled(0)
        !            31: 
        !            32: /**
        !            33:  * Initialize an assertion that enforces that a specific number of jobs was
        !            34:  * scheduled.
        !            35:  * Must be matched by a call to assert_scheduler().
        !            36:  *
        !            37:  * @param count                        expected number of jobs getting scheduled
        !            38:  */
        !            39: #define assert_jobs_scheduled(count) _assert_jobs_scheduled(count)
        !            40: 
        !            41: /**
        !            42:  * Initialize assertions against job scheduling.
        !            43:  * Must be matched by a call to assert_scheduler().
        !            44:  */
        !            45: #define _assert_jobs_scheduled(count) \
        !            46: do { \
        !            47:        u_int _initial = lib->scheduler->get_job_load(lib->scheduler); \
        !            48:        u_int _expected = count
        !            49: 
        !            50: /**
        !            51:  * Enforce scheduler asserts.
        !            52:  */
        !            53: #define assert_scheduler() \
        !            54:        u_int _actual = lib->scheduler->get_job_load(lib->scheduler) - _initial; \
        !            55:        test_assert_msg(_expected == _actual, "unexpected number of jobs " \
        !            56:                                        "scheduled (%u != %u)", _expected, _actual); \
        !            57: } while(FALSE)
        !            58: 
        !            59: #endif /** JOB_ASSERTS_H_ @}*/

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>