forked from Imagelibrary/rtems
@@ -1857,6 +1857,7 @@ librtemstest_a_SOURCES += libtest/testextension.c
|
|||||||
librtemstest_a_SOURCES += libtest/testparallel.c
|
librtemstest_a_SOURCES += libtest/testparallel.c
|
||||||
librtemstest_a_SOURCES += libtest/testwrappers.c
|
librtemstest_a_SOURCES += libtest/testwrappers.c
|
||||||
librtemstest_a_SOURCES += libtest/t-test.c
|
librtemstest_a_SOURCES += libtest/t-test.c
|
||||||
|
librtemstest_a_SOURCES += libtest/t-test-busy.c
|
||||||
librtemstest_a_SOURCES += libtest/t-test-checks.c
|
librtemstest_a_SOURCES += libtest/t-test-checks.c
|
||||||
librtemstest_a_SOURCES += libtest/t-test-checks-eno.c
|
librtemstest_a_SOURCES += libtest/t-test-checks-eno.c
|
||||||
librtemstest_a_SOURCES += libtest/t-test-checks-psx.c
|
librtemstest_a_SOURCES += libtest/t-test-checks-psx.c
|
||||||
|
|||||||
@@ -305,17 +305,7 @@ void rtems_test_parallel(
|
|||||||
void rtems_test_busy_cpu_usage(time_t seconds, long nanoseconds);
|
void rtems_test_busy_cpu_usage(time_t seconds, long nanoseconds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Performs a busy loop with the specified iteration count.
|
* @brief Returns a count value for T_busy() which yields roughly a
|
||||||
*
|
|
||||||
* This function is optimized to not perform memory accesses and should have a
|
|
||||||
* small jitter.
|
|
||||||
*
|
|
||||||
* @param[in] count The iteration count.
|
|
||||||
*/
|
|
||||||
void rtems_test_busy(uint_fast32_t count);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Returns a count value for rtems_test_busy() which yields roughly a
|
|
||||||
* duration of one clock tick.
|
* duration of one clock tick.
|
||||||
*/
|
*/
|
||||||
uint_fast32_t rtems_test_get_one_tick_busy_count(void);
|
uint_fast32_t rtems_test_get_one_tick_busy_count(void);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*
|
*
|
||||||
* Copyright (C) 2018, 2019 embedded brains GmbH
|
* Copyright (C) 2017, 2020 embedded brains GmbH
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -2261,6 +2261,8 @@ void T_case_body_##name(void)
|
|||||||
|
|
||||||
#define T_TEST_CASE(name) T_TEST_CASE_FIXTURE(name, NULL)
|
#define T_TEST_CASE(name) T_TEST_CASE_FIXTURE(name, NULL)
|
||||||
|
|
||||||
|
void T_busy(uint_fast32_t);
|
||||||
|
|
||||||
void T_report_hash_sha256(T_event, const char *);
|
void T_report_hash_sha256(T_event, const char *);
|
||||||
|
|
||||||
void T_check_heap(T_event, const char *);
|
void T_check_heap(T_event, const char *);
|
||||||
|
|||||||
58
cpukit/libtest/t-test-busy.c
Normal file
58
cpukit/libtest/t-test-busy.c
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
*
|
||||||
|
* @ingroup RTEMSTestFrameworkImpl
|
||||||
|
*
|
||||||
|
* @brief Implementation of T_busy().
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2014, 2020 embedded brains GmbH (http://www.embedded-brains.de)
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <rtems/test.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* It is important that we actually use the same T_busy() function at the
|
||||||
|
* various places. So, the compiler must not inline this function. Take care
|
||||||
|
* of link time optimization.
|
||||||
|
*/
|
||||||
|
__attribute__((__noinline__)) void
|
||||||
|
T_busy(uint_fast32_t count)
|
||||||
|
{
|
||||||
|
uint_fast32_t i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
__asm__ volatile ("");
|
||||||
|
++i;
|
||||||
|
} while (i < count);
|
||||||
|
}
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <rtems/test-info.h>
|
#include <rtems/test-info.h>
|
||||||
#include <rtems.h>
|
#include <rtems.h>
|
||||||
|
#include <rtems/test.h>
|
||||||
#include <rtems/score/threadimpl.h>
|
#include <rtems/score/threadimpl.h>
|
||||||
|
|
||||||
static uint_fast32_t estimate_busy_loop_maximum( void )
|
static uint_fast32_t estimate_busy_loop_maximum( void )
|
||||||
@@ -45,21 +46,6 @@ static uint_fast32_t wait_for_tick_change( void )
|
|||||||
return now;
|
return now;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* It is important that we use actually use the same rtems_test_busy() function
|
|
||||||
* at the various places, since otherwise the obtained maximum value might be
|
|
||||||
* wrong. So, the compiler must not inline this function.
|
|
||||||
*/
|
|
||||||
RTEMS_NO_INLINE void rtems_test_busy( uint_fast32_t count )
|
|
||||||
{
|
|
||||||
uint_fast32_t i = 0;
|
|
||||||
|
|
||||||
do {
|
|
||||||
__asm__ volatile ("");
|
|
||||||
++i;
|
|
||||||
} while ( i < count );
|
|
||||||
}
|
|
||||||
|
|
||||||
uint_fast32_t rtems_test_get_one_tick_busy_count( void )
|
uint_fast32_t rtems_test_get_one_tick_busy_count( void )
|
||||||
{
|
{
|
||||||
uint_fast32_t last;
|
uint_fast32_t last;
|
||||||
@@ -78,7 +64,7 @@ uint_fast32_t rtems_test_get_one_tick_busy_count( void )
|
|||||||
|
|
||||||
while ( true ) {
|
while ( true ) {
|
||||||
last = wait_for_tick_change();
|
last = wait_for_tick_change();
|
||||||
rtems_test_busy( b );
|
T_busy( b );
|
||||||
now = rtems_clock_get_ticks_since_boot();
|
now = rtems_clock_get_ticks_since_boot();
|
||||||
|
|
||||||
if ( now != last ) {
|
if ( now != last ) {
|
||||||
@@ -94,7 +80,7 @@ uint_fast32_t rtems_test_get_one_tick_busy_count( void )
|
|||||||
m = ( a + b ) / 2;
|
m = ( a + b ) / 2;
|
||||||
|
|
||||||
last = wait_for_tick_change();
|
last = wait_for_tick_change();
|
||||||
rtems_test_busy( m );
|
T_busy( m );
|
||||||
now = rtems_clock_get_ticks_since_boot();
|
now = rtems_clock_get_ticks_since_boot();
|
||||||
|
|
||||||
if ( now != last ) {
|
if ( now != last ) {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include <tmacros.h>
|
#include <tmacros.h>
|
||||||
#include <intrcritical.h>
|
#include <intrcritical.h>
|
||||||
|
#include <rtems/test.h>
|
||||||
|
|
||||||
#define INTERRUPT_CRITICAL_NAME rtems_build_name( 'I', 'C', 'R', 'I' )
|
#define INTERRUPT_CRITICAL_NAME rtems_build_name( 'I', 'C', 'R', 'I' )
|
||||||
|
|
||||||
@@ -49,7 +50,7 @@ static bool interrupt_critical_busy_wait( void )
|
|||||||
interrupt_critical.maximum_current = max - 1;
|
interrupt_critical.maximum_current = max - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rtems_test_busy( max );
|
T_busy( max );
|
||||||
|
|
||||||
return reset;
|
return reset;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user