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

📄 testcx4.cxx

📁 eCos/RedBoot for勤研ARM AnywhereII(4510) 含全部源代码
💻 CXX
📖 第 1 页 / 共 2 页
字号:
//===========================================================================
//
//      testcx4.cxx
//
//      uITRON "C++" test program four
//
//===========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s):   dsm
// Contributors:        dsm
// Date:        1998-06-12
// Purpose:     uITRON API testing
// Description: 
//
//####DESCRIPTIONEND####
//
//===========================================================================

#include <pkgconf/uitron.h>             // uITRON setup CYGNUM_UITRON_SEMAS
                                        // CYGPKG_UITRON et al
#include <cyg/infra/testcase.h>         // testing infrastructure

#ifdef CYGPKG_UITRON                    // we DO want the uITRON package

#ifdef CYGSEM_KERNEL_SCHED_MLQUEUE      // we DO want prioritized threads

#ifdef CYGFUN_KERNEL_THREADS_TIMER      // we DO want timout-able calls

#ifdef CYGVAR_KERNEL_COUNTERS_CLOCK     // we DO want the realtime clock

// we're OK if it's C++ or neither of those two is defined:
#if defined( __cplusplus ) || \    (!defined( CYGIMP_UITRON_INLINE_FUNCS ) && \     !defined( CYGIMP_UITRON_CPP_OUTLINE_FUNCS) )

// =================== TEST CONFIGURATION ===================
#if \    /* test configuration for enough tasks */                      \    (CYGNUM_UITRON_TASKS >= 4)                                  && \    (CYGNUM_UITRON_TASKS < 90)                                  && \    (CYGNUM_UITRON_START_TASKS == 1)                            && \    ( !defined(CYGPKG_UITRON_TASKS_CREATE_DELETE) ||               \      CYGNUM_UITRON_TASKS_INITIALLY >= 4             )          && \                                                                   \    /* test configuration for enough cyclic handlers */            \    defined( CYGPKG_UITRON_CYCLICS )                            && \    (CYGNUM_UITRON_CYCLICS >= 3)                                && \    (CYGNUM_UITRON_CYCLICS < 90)                                && \                                                                   \    /* test configuration for enough alarm handlers */             \    defined( CYGPKG_UITRON_ALARMS )                             && \    (CYGNUM_UITRON_ALARMS >= 3)                                 && \    (CYGNUM_UITRON_ALARMS < 90)                                 && \                                                                   \    /* the end of the large #if statement */                       \    1 

// ============================ END ============================



#include <cyg/compat/uitron/uit_func.h> // uITRON

externC void
cyg_package_start( void )
{
    CYG_TEST_INIT();
    CYG_TEST_INFO( "Calling cyg_uitron_start()" );
    cyg_uitron_start();
}

volatile int intercount = 0;
INT scratch;

void hand1(void)
{
    CYG_TEST_INFO("Handler 1 called");
    intercount++;
}

void hand2(void)
{
    CYG_TEST_CHECK( 2 == intercount, "handler out of sync" );
    CYG_TEST_INFO("Handler 2 called");
    intercount++;
}

extern "C" {
    void task1( unsigned int arg );
    void task2( unsigned int arg );
    void task3( unsigned int arg );
    void task4( unsigned int arg );
}

void task1( unsigned int arg )
{
    ER ercd;

    T_DCYC dcyc;
    T_DALM dalm;
    T_RCYC rcyc;
    T_RALM ralm;

    unsigned int tm;

    static char foo[] = "Test message";
    VP info = (VP)foo;

    // Increase times when running on HW since overhead of GDB packet
    // acknowledgements may cause tests of timing to fail.
    if (cyg_test_is_simulator)
        tm = 1;
    else
        tm = 4;

    CYG_TEST_INFO( "Task 1 running" );
    ercd = get_tid( &scratch );
    CYG_TEST_CHECK( E_OK == ercd, "get_tid bad ercd" );
    CYG_TEST_CHECK( 1 == scratch, "tid not 1" );

    dcyc.exinf  = (VP)info;
    dcyc.cycatr = TA_HLNG;
    dcyc.cychdr = (FP)&hand1;
    dcyc.cycact = TCY_INI;              // bad
    dcyc.cyctim = 2;

#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
    ercd = def_cyc(3, &dcyc);
    CYG_TEST_CHECK( E_PAR == ercd, "def_cyc bad ercd !E_PAR" );
#endif // we can test bad param error returns

    dcyc.cycact = TCY_OFF;              // make good
    dcyc.cyctim = 0;                    // bad

#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
    ercd = def_cyc(3, &dcyc);
    CYG_TEST_CHECK( E_PAR == ercd, "def_cyc bad ercd !E_PAR" );
#endif // we can test bad param error returns

    dcyc.cyctim = 1;                    // make good

    ercd = def_cyc(3, &dcyc);
    CYG_TEST_CHECK( E_OK == ercd, "def_cyc bad ercd" );    

#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
    ercd = def_cyc(-6, &dcyc);
    CYG_TEST_CHECK( E_PAR == ercd, "def_cyc bad ercd !E_PAR" );
    ercd = def_cyc(99, &dcyc);
    CYG_TEST_CHECK( E_PAR == ercd, "def_cyc bad ercd !E_PAR" );

    ercd = act_cyc(-6, TCY_OFF);
    CYG_TEST_CHECK( E_PAR == ercd, "act_cyc bad ercd !E_PAR" );
    ercd = act_cyc(99, TCY_OFF);
    CYG_TEST_CHECK( E_PAR == ercd, "act_cyc bad ercd !E_PAR" );
    ercd = act_cyc( 3, ~0);
    CYG_TEST_CHECK( E_PAR == ercd, "act_cyc bad ercd !E_PAR" );
    
    ercd = ref_cyc(&rcyc, -6);
    CYG_TEST_CHECK( E_PAR == ercd, "ref_cyc bad ercd !E_PAR" );
    ercd = ref_cyc(&rcyc, 99);
    CYG_TEST_CHECK( E_PAR == ercd, "ref_cyc bad ercd !E_PAR" );
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
    ercd = ref_cyc(NULL,  3);
    CYG_TEST_CHECK( E_PAR == ercd, "ref_cyc bad ercd !E_PAR" );
#endif
#endif // we can test bad param error returns

    ercd = def_cyc(3, (T_DCYC *)NADR);
    CYG_TEST_CHECK( E_OK == ercd, "def_cyc bad ercd" );
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS

⌨️ 快捷键说明

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