⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wmtestcommon.h

📁 pxa270平台 windows mobile 5.2 wm9713 触摸屏+音频驱动
💻 H
📖 第 1 页 / 共 2 页
字号:
/*-----------------------------------------------------------------------------
 * Copyright (c) Wolfson Microelectronics plc.  All rights reserved.
 *
 * This software as well as any related documentation is furnished under 
 * license and may only be used or copied in accordance with the terms of the 
 * license. The information in this file is furnished for informational use 
 * only, is subject to change without notice, and should not be construed as 
 * a commitment by Wolfson Microelectronics plc. Wolfson Microelectronics plc
 * assumes no responsibility or liability for any errors or inaccuracies that
 * may appear in this document or any software that may be provided in
 * association with this document. 
 *
 * Except as permitted by such license, no part of this document may be 
 * reproduced, stored in a retrieval system, or transmitted in any form or by 
 * any means without the express written consent of Wolfson Microelectronics plc. 
 *
 * $Id: WMTestCommon.h 4586 2007-08-16 11:15:10Z sapps_wince $
 *
 * Common definitions and utility macros for the testing.
 *
 *
 * Warning:
 *  This driver is specifically written for Wolfson Codecs. It is not a 
 *  general CODEC device driver.
 *
 * ---------------------------------------------------------------------------*/
#ifndef __WMTESTCOMMON_H__
#define __WMTESTCOMMON_H__

#include "WMStatus.h"

/*
 * This file holds the common definitions which simplify writing tests.
 * 
 * These definitions are as follows:
 * For the test functions:
 * 
 *   WMTEST_START           - start the body of a test function
 *   WMTEST_STATIC_START    - WMTEST_START for a static test function
 *   WMTEST_END             - end the body of the test function
 * 
 * Comparisons:
 * 
 *   WMTEST_TRUE            - check that a condition is TRUE
 *   WMTEST_FALSE           - check that a condition is FALSE
 *   WMTEST_EQUALS          - check that two things are equal
 *   WMTEST_NOTEQUALS       - check that two things are not equal
 *   WMTEST_GREATER         - check that the first is larger than the second
 *   WMTEST_GREATER_EQUAL   - check that the first is larger than or equal to
 *                            the second
 *   WMTEST_EQUALS_RANGE    - check that two things are within a given threshold
 *                            of each other (i.e. y-z <= x <= y+z)
 *   WMTEST_LESS_STR        - check that the first string is smaller than the second
 *   WMTEST_LESS_EQUAL_STR  - check that the first string is smaller than or equal to
 *                            the second
 *   WMTEST_EQUALS_STR      - check that two string are equal
 *   WMTEST_NOTEQUALS_STR   - check that two string are not equal
 *   WMTEST_GREATER_STR     - check that the first string is larger than the second
 *   WMTEST_GREATER_EQUAL_STR- check that the first string is larger than or equal to
 *                            the second
 *   WMTEST_LESS            - check that the first is smaller than the second
 *   WMTEST_LESS_EQUAL      - check that the first is smaller than or equal to
 *                            the second
 *   WMTEST_NULL            - check that a pointer is NULL
 *   WMTEST_NOTNULL         - check that a pointer is not NULL
 *   WMTEST_REGVAL          - check the current value of a register
 *   WMTEST_REG_FIELD       - check the current value certain bits of a register
 *   WMTEST_BITS_SET        - check that the given bits are set
 *   WMTEST_BITS_CLEAR      - check that the given bits are clear
 * 
 * Function calls:
 * 
 *   WMTEST_RUN             - run another test
 *   WMTEST_CALL            - make a call and check it returns WMS_SUCCESS
 *   WMTEST_CALL_STATUS     - make a call and check it returns the given status
 *   WMTEST_CALL_CHECK_RETURN - make a call and check it returns the given value
 *   WMTEST_CALL_CHECK      - make a call and make an arbitrary check after it
 *                            returns
 * 
 * Misc:
 * 
 *   WMTEST_SKIP            - skip the rest of the test
 * 
 * Example
 * =======
 * 
 * The following example is probably the easiest way of showing how to
 * use these.
 * 
 *  WM_BOOL WMTestFoo();
 *  static WM_BOOL private_SubTest( int param );
 * 
 *  #define TEST_INPUT  3
 * 
 *  WMTEST_START( WMTestFoo() )
 *  {
 *      WM_DEVICE_HANDLE    hDevice;
 * 
 *      WMTEST_CALL( WMOpenDevice( WM_DEV_AC97_PRIMARY,
 *                                 WM_DEVICE_AUDIO,
 *                                 &hDevice
 *                               )
 *                 );
 * 
 *      WMTEST_RUN( private_SubTest( TEST_INPUT ) );
 *  } WMTEST_END
 * 
 *  WMTEST_STATIC_START( private_SubTest( int param ) )
 *  {
 *      WMTEST_GREATER( param, 0 );
 *  } WMTEST_END;
 * 
 * How the tests behave depends on whether WM_TESTING_ASSERT is defined.
 * 
 *  - If WM_TESTING_ASSERT is defined, an error becomes a WMTEST_ASSERT.
 *    In this case, if a test returns at all, it returns TRUE.
 *  - If WM_TESTING_ASSERT is not defined, the test returns FALSE on errors
 *    (and still TRUE on success).
 * 
 * Note: The test macros print out messages using WMTEST_TRACE rather than
 * WM_TRACE.  This means they can only be called when system calls are allowed.
 * They cannot be called in interrupt handlers or power save/restore routines.
 */

/*
 * Include files
 */
#include "WMConfig.h"

/*
 * Only build this if we are asked to.
 */
#if WM_TESTING

/*
 * Global definitions
 */

/*
 * A version of trace and assert which don't require a handle.  Note these are
 * only suitable if we can guarantee we won't be called when system calls are
 * prohibited.
 */
#define WMTEST_TRACE( args )    WMTrace args
#define WMTEST_TRACE_LINE( args )    do                                         \
    {                                                                           \
        WMTEST_TRACE(( "WMTest: %s(%d):", __FILE__, __LINE__ ));                \
        WMTEST_TRACE( args );                                                   \
    } while ( 0 )

/*
 * Test body.  This handles the common wrappers.
 */
#define WMTEST_START_TITLED( _test, _title )                                    \
    WM_BOOL _test                                                               \
    {                                                                           \
        const char *_WMTestTitle = _title;                                      \
        WMTEST_TRACE(( "----------------------------------------------------------------------" ));\
        WMTEST_TRACE(( "Wolfson: Running test %s", _WMTestTitle ));             \
        {

#define WMTEST_START_UNTITLED( _test )                                          \
    WM_BOOL _test                                                               \
    {                                                                           \
        const char *_WMTestTitle = NULL;                                        \
        {
         
#define WMTEST_START( _test )                                                   \
    WMTEST_START_TITLED( _test, #_test )
         
#define WMTEST_STATIC_START( _test )                                            \
    static WMTEST_START_UNTITLED( _test )

#define WMTEST_FOOTER                                                           \
            if ( _WMTestTitle )                                                 \
            {                                                                   \
                WMTEST_TRACE(( "Test %s completed successfully", _WMTestTitle ));\
                WMTEST_TRACE(( "======================================================================" ));\
            }
            
#if WM_TESTING_ASSERT
    #define WMTEST_END                                                          \
            }                                                                   \
            WMTEST_FOOTER                                                       \
			/* Added to stop unreferenced label warnings */                     \
            goto _testEnd;                                                      \
        _testEnd:                                                               \
            return TRUE;                                                        \
        }
#else
    #define WMTEST_END                                                          \
            }                                                                   \
            WMTEST_FOOTER                                                       \
			/* Added to stop unreferenced label warnings */                     \
            goto _testEnd;                                                      \
        _testEnd:                                                               \
            return TRUE;                                                        \
			/* Added to stop unreferenced label warnings */                     \
            goto _testError;                                                    \
        _testError:                                                             \
            return FALSE;                                                       \
        }
#endif	/* WM_TESTING_ASSERT */

/*
 * Early finish.
 */
#define WMTEST_COMPLETE()       goto _testEnd     

/*
 * Skip a test.
 */
#define WMTEST_SKIP()  do                                                       \
        {                                                                       \
            if ( _WMTestTitle )                                                 \
            {                                                                   \
                WMTEST_TRACE(( " - skipping %s", _WMTestTitle ));               \
                WMTEST_TRACE(( "======================================================================" ));\
            }                                                                   \
            goto _testEnd;                                                      \
        } while ( 0 )           
/*
 * The basic unit of testing - handle a comparison and fail with a message.
 */
#define WMTEST_BOOLEAN_MSG_ASSERT( _comparison, _message ) do {                 \

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -