Migrate to threading_helpers.h
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
parent
a021d63bf7
commit
17c119a5e3
6 changed files with 50 additions and 24 deletions
|
@ -13,7 +13,7 @@
|
||||||
#include "ssl_test_lib.h"
|
#include "ssl_test_lib.h"
|
||||||
|
|
||||||
#if defined(MBEDTLS_TEST_HOOKS)
|
#if defined(MBEDTLS_TEST_HOOKS)
|
||||||
#include "test/helpers.h"
|
#include "test/threading_helpers.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(MBEDTLS_SSL_TEST_IMPOSSIBLE)
|
#if !defined(MBEDTLS_SSL_TEST_IMPOSSIBLE)
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <mbedtls/platform.h>
|
#include <mbedtls/platform.h>
|
||||||
#include <mbedtls/platform_util.h>
|
#include <mbedtls/platform_util.h>
|
||||||
#include "test/helpers.h"
|
#include "test/helpers.h"
|
||||||
|
#include "test/threading_helpers.h"
|
||||||
#include "test/macros.h"
|
#include "test/macros.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -35,11 +35,7 @@
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_THREADING_C) && defined(MBEDTLS_THREADING_PTHREAD) && \
|
#include "test/threading_helpers.h"
|
||||||
defined(MBEDTLS_TEST_HOOKS)
|
|
||||||
#define MBEDTLS_TEST_MUTEX_USAGE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "mbedtls/platform.h"
|
#include "mbedtls/platform.h"
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
@ -254,24 +250,6 @@ int mbedtls_test_hexcmp(uint8_t *a, uint8_t *b,
|
||||||
#include "test/fake_external_rng_for_test.h"
|
#include "test/fake_external_rng_for_test.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_TEST_MUTEX_USAGE)
|
|
||||||
/**
|
|
||||||
* Activate the mutex usage verification framework. See threading_helpers.c for
|
|
||||||
* information.
|
|
||||||
* */
|
|
||||||
void mbedtls_test_mutex_usage_init(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deactivate the mutex usage verification framework. See threading_helpers.c
|
|
||||||
* for information.
|
|
||||||
*/
|
|
||||||
void mbedtls_test_mutex_usage_end(void);
|
|
||||||
|
|
||||||
/** Call this function after executing a test case to check for mutex usage
|
|
||||||
* errors. */
|
|
||||||
void mbedtls_test_mutex_usage_check(void);
|
|
||||||
#endif /* MBEDTLS_TEST_MUTEX_USAGE */
|
|
||||||
|
|
||||||
#if defined(MBEDTLS_TEST_HOOKS)
|
#if defined(MBEDTLS_TEST_HOOKS)
|
||||||
/**
|
/**
|
||||||
* \brief Check that only a pure high-level error code is being combined with
|
* \brief Check that only a pure high-level error code is being combined with
|
||||||
|
|
45
tests/include/test/threading_helpers.h
Normal file
45
tests/include/test/threading_helpers.h
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
/**
|
||||||
|
* \file threading_helpers.h
|
||||||
|
*
|
||||||
|
* \brief This file contains the prototypes of helper functions for the purpose
|
||||||
|
* of testing threading.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright The Mbed TLS Contributors
|
||||||
|
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef THREADING_HELPERS_H
|
||||||
|
#define THREADING_HELPERS_H
|
||||||
|
|
||||||
|
#if defined MBEDTLS_THREADING_C
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_THREADING_PTHREAD) && defined(MBEDTLS_TEST_HOOKS)
|
||||||
|
#define MBEDTLS_TEST_MUTEX_USAGE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_TEST_MUTEX_USAGE)
|
||||||
|
/**
|
||||||
|
* Activate the mutex usage verification framework. See threading_helpers.c for
|
||||||
|
* information.
|
||||||
|
*/
|
||||||
|
void mbedtls_test_mutex_usage_init(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deactivate the mutex usage verification framework. See threading_helpers.c
|
||||||
|
* for information.
|
||||||
|
*/
|
||||||
|
void mbedtls_test_mutex_usage_end(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call this function after executing a test case to check for mutex usage
|
||||||
|
* errors.
|
||||||
|
*/
|
||||||
|
void mbedtls_test_mutex_usage_check(void);
|
||||||
|
#endif /* MBEDTLS_TEST_MUTEX_USAGE */
|
||||||
|
|
||||||
|
#endif /* MBEDTLS_THREADING_C */
|
||||||
|
|
||||||
|
#endif /* THREADING_HELPERS_H */
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <test/helpers.h>
|
#include <test/helpers.h>
|
||||||
|
#include <test/threading_helpers.h>
|
||||||
#include <test/macros.h>
|
#include <test/macros.h>
|
||||||
|
|
||||||
#if defined(MBEDTLS_TEST_MUTEX_USAGE)
|
#if defined(MBEDTLS_TEST_MUTEX_USAGE)
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <test/random.h>
|
#include <test/random.h>
|
||||||
#include <test/bignum_helpers.h>
|
#include <test/bignum_helpers.h>
|
||||||
#include <test/psa_crypto_helpers.h>
|
#include <test/psa_crypto_helpers.h>
|
||||||
|
#include <test/threading_helpers.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
Loading…
Reference in a new issue