mirror of https://github.com/ARMmbed/mbed-os.git
				
				
				
			Removing references to yotta and minar within utest
							parent
							
								
									e965aa6640
								
							
						
					
					
						commit
						96a71ce59a
					
				| 
						 | 
				
			
			@ -15,8 +15,6 @@
 | 
			
		|||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
// define this to get rid of the minar dependency.
 | 
			
		||||
#define YOTTA_CFG_UTEST_USE_CUSTOM_SCHEDULER 1
 | 
			
		||||
 | 
			
		||||
#include "mbed.h"
 | 
			
		||||
#include "greentea-client/test_env.h"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,8 +15,6 @@
 | 
			
		|||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
// define this to get rid of the minar dependency.
 | 
			
		||||
#define YOTTA_CFG_UTEST_USE_CUSTOM_SCHEDULER 1
 | 
			
		||||
 | 
			
		||||
#include "mbed.h"
 | 
			
		||||
#include "greentea-client/test_env.h"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,50 +18,9 @@
 | 
			
		|||
 | 
			
		||||
#include "utest/utest_shim.h"
 | 
			
		||||
#include "utest/utest_stack_trace.h"
 | 
			
		||||
 | 
			
		||||
#if UTEST_SHIM_SCHEDULER_USE_MINAR
 | 
			
		||||
#include "minar/minar.h"
 | 
			
		||||
 | 
			
		||||
static int32_t utest_minar_init()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
static void *utest_minar_post(const utest_v1_harness_callback_t callback, const uint32_t delay_ms)
 | 
			
		||||
{
 | 
			
		||||
    void *handle = minar::Scheduler::postCallback(callback).delay(minar::milliseconds(delay_ms)).getHandle();
 | 
			
		||||
    return handle;
 | 
			
		||||
}
 | 
			
		||||
static int32_t utest_minar_cancel(void *handle)
 | 
			
		||||
{
 | 
			
		||||
    int32_t ret = minar::Scheduler::cancelCallback(handle);
 | 
			
		||||
    return ret;
 | 
			
		||||
}
 | 
			
		||||
static int32_t utest_minar_run()
 | 
			
		||||
{
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
extern "C" {
 | 
			
		||||
static const utest_v1_scheduler_t utest_v1_scheduler =
 | 
			
		||||
{
 | 
			
		||||
    utest_minar_init,
 | 
			
		||||
    utest_minar_post,
 | 
			
		||||
    utest_minar_cancel,
 | 
			
		||||
    utest_minar_run
 | 
			
		||||
};
 | 
			
		||||
utest_v1_scheduler_t utest_v1_get_scheduler()
 | 
			
		||||
{
 | 
			
		||||
    return utest_v1_scheduler;
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#elif UTEST_SHIM_SCHEDULER_USE_US_TICKER
 | 
			
		||||
#ifdef YOTTA_MBED_HAL_VERSION_STRING
 | 
			
		||||
#   include "mbed-hal/us_ticker_api.h"
 | 
			
		||||
#else
 | 
			
		||||
#include "platform/SingletonPtr.h"
 | 
			
		||||
#include "Timeout.h"
 | 
			
		||||
using mbed::Timeout;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// only one callback is active at any given time
 | 
			
		||||
static volatile utest_v1_harness_callback_t minimal_callback;
 | 
			
		||||
| 
						 | 
				
			
			@ -79,7 +38,7 @@ static void ticker_handler()
 | 
			
		|||
static int32_t utest_us_ticker_init()
 | 
			
		||||
{
 | 
			
		||||
    UTEST_LOG_FUNCTION();
 | 
			
		||||
    // initialize the Timeout object to makes sure it is not initialized in 
 | 
			
		||||
    // initialize the Timeout object to makes sure it is not initialized in
 | 
			
		||||
    // interrupt context.
 | 
			
		||||
    utest_timeout_object.get();
 | 
			
		||||
    return 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -88,13 +47,13 @@ static void *utest_us_ticker_post(const utest_v1_harness_callback_t callback, ti
 | 
			
		|||
{
 | 
			
		||||
    UTEST_LOG_FUNCTION();
 | 
			
		||||
    timestamp_t delay_us = delay_ms *1000;
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    if (delay_ms) {
 | 
			
		||||
        ticker_callback = callback;
 | 
			
		||||
        // fire the interrupt in 1000us * delay_ms
 | 
			
		||||
        utest_timeout_object->attach_us(ticker_handler, delay_us);
 | 
			
		||||
        
 | 
			
		||||
    } 
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
        minimal_callback = callback;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -142,10 +101,3 @@ utest_v1_scheduler_t utest_v1_get_scheduler()
 | 
			
		|||
    return utest_v1_scheduler;
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef YOTTA_CORE_UTIL_VERSION_STRING
 | 
			
		||||
// their functionality is implemented using the CriticalSectionLock class
 | 
			
		||||
void utest_v1_enter_critical_section(void) {}
 | 
			
		||||
void utest_v1_leave_critical_section(void) {}
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -41,11 +41,6 @@ namespace v1 {
 | 
			
		|||
     * The harness executes the test specification in an asynchronous fashion, therefore
 | 
			
		||||
     * `run()` returns immediately.
 | 
			
		||||
     *
 | 
			
		||||
     * By default, this harness uses the MINAR scheduler for asynchronous callbacks.
 | 
			
		||||
     * If you wamt to provide your own custom scheduler, set `config.utest.use_custom_scheduler` to `true`
 | 
			
		||||
     * inside your yotta config and set a custom scheduler implementation using the `set_scheduler()` function.
 | 
			
		||||
     * You must set the scheduler before running a specification.
 | 
			
		||||
     *
 | 
			
		||||
     * @note In case of an test abort, the harness will busy-wait and never finish.
 | 
			
		||||
     */
 | 
			
		||||
    class Harness
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,50 +27,22 @@
 | 
			
		|||
#include <stdio.h>
 | 
			
		||||
#include "utest/utest_scheduler.h"
 | 
			
		||||
 | 
			
		||||
#ifdef YOTTA_CFG
 | 
			
		||||
#   include "compiler-polyfill/attributes.h"
 | 
			
		||||
#else
 | 
			
		||||
#   ifndef __deprecated_message
 | 
			
		||||
#       if defined(__CC_ARM)
 | 
			
		||||
#           define __deprecated_message(msg) __attribute__((deprecated))
 | 
			
		||||
#       elif defined (__ICCARM__)
 | 
			
		||||
#           define __deprecated_message(msg)
 | 
			
		||||
#       else
 | 
			
		||||
#           define __deprecated_message(msg) __attribute__((deprecated(msg)))
 | 
			
		||||
#       endif
 | 
			
		||||
#   endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef YOTTA_CORE_UTIL_VERSION_STRING
 | 
			
		||||
#   include "core-util/CriticalSectionLock.h"
 | 
			
		||||
#   define UTEST_ENTER_CRITICAL_SECTION mbed::util::CriticalSectionLock lock
 | 
			
		||||
#   define UTEST_LEAVE_CRITICAL_SECTION
 | 
			
		||||
#else
 | 
			
		||||
#   ifndef UTEST_ENTER_CRITICAL_SECTION
 | 
			
		||||
#   	define UTEST_ENTER_CRITICAL_SECTION utest_v1_enter_critical_section()
 | 
			
		||||
#   endif
 | 
			
		||||
#   ifndef UTEST_LEAVE_CRITICAL_SECTION
 | 
			
		||||
#   	define UTEST_LEAVE_CRITICAL_SECTION utest_v1_leave_critical_section()
 | 
			
		||||
#   endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef YOTTA_CFG_UTEST_USE_CUSTOM_SCHEDULER
 | 
			
		||||
#   ifdef YOTTA_MINAR_VERSION_STRING
 | 
			
		||||
#       define UTEST_MINAR_AVAILABLE 1
 | 
			
		||||
#ifndef __deprecated_message
 | 
			
		||||
#   if defined(__CC_ARM)
 | 
			
		||||
#       define __deprecated_message(msg) __attribute__((deprecated))
 | 
			
		||||
#   elif defined (__ICCARM__)
 | 
			
		||||
#       define __deprecated_message(msg)
 | 
			
		||||
#   else
 | 
			
		||||
#       define UTEST_MINAR_AVAILABLE 0
 | 
			
		||||
#       define __deprecated_message(msg) __attribute__((deprecated(msg)))
 | 
			
		||||
#   endif
 | 
			
		||||
#   ifndef UTEST_SHIM_SCHEDULER_USE_MINAR
 | 
			
		||||
#       define UTEST_SHIM_SCHEDULER_USE_MINAR UTEST_MINAR_AVAILABLE
 | 
			
		||||
#   endif
 | 
			
		||||
#   ifndef UTEST_SHIM_SCHEDULER_USE_US_TICKER
 | 
			
		||||
#       ifdef __MBED__
 | 
			
		||||
#           define UTEST_SHIM_SCHEDULER_USE_US_TICKER 1
 | 
			
		||||
#       else
 | 
			
		||||
#           define UTEST_SHIM_SCHEDULER_USE_US_TICKER 0
 | 
			
		||||
#       endif
 | 
			
		||||
#   endif
 | 
			
		||||
#endif  // YOTTA_CFG_UTEST_USE_CUSTOM_SCHEDULER
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef UTEST_ENTER_CRITICAL_SECTION
 | 
			
		||||
#	define UTEST_ENTER_CRITICAL_SECTION utest_v1_enter_critical_section()
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef UTEST_LEAVE_CRITICAL_SECTION
 | 
			
		||||
#	define UTEST_LEAVE_CRITICAL_SECTION utest_v1_leave_critical_section()
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue