示例#1
0
文件: test6.c 项目: 0xCA5A/dd-wrt
void task1( unsigned int arg )
{
    ER ercd;
    int tests = 0;

    CYG_TEST_INFO( "Task 1 running" );

    ercd = dis_dsp();
    CYG_TEST_CHECK( E_OK == ercd, "dis_dsp bad ercd" );
    ercd = sta_tsk( 2, 22222 );
    CYG_TEST_CHECK( E_OK == ercd, "sta_tsk bad ercd" );
    ercd = chg_pri( 2, 5 );
    CYG_TEST_CHECK( E_OK == ercd, "chg_pri bad ercd" );
    ercd = ena_dsp();
    CYG_TEST_CHECK( E_OK == ercd, "ena_dsp bad ercd" );
    ercd = dly_tsk( 10 );
    CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );

#ifdef CYGPKG_UITRON_SEMAS_CREATE_DELETE
    tests++;
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
    ercd = del_sem( -6 );
    CYG_TEST_CHECK( E_ID == ercd, "del_sem bad ercd !E_ID" );
    ercd = del_sem( 99 );
    CYG_TEST_CHECK( E_ID == ercd, "del_sem bad ercd !E_ID" );
    ercd = cre_sem( -6, &t_csem );
    CYG_TEST_CHECK( E_ID == ercd, "cre_sem bad ercd !E_ID" );
    ercd = cre_sem( 99, &t_csem );
    CYG_TEST_CHECK( E_ID == ercd, "cre_sem bad ercd !E_ID" );
#endif // we can test bad param error returns
    // try a pre-existing object
    ercd = cre_sem( 3, &t_csem );
    CYG_TEST_CHECK( E_OBJ == ercd, "cre_sem bad ercd !E_OBJ" );
    // delete it so we can play
    ercd = del_sem( 3 );
    CYG_TEST_CHECK( E_OK == ercd, "del_sem bad ercd" );
    // check it is deleted
    ercd = sig_sem( 3 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "sig_sem bad ercd !E_NOEXS" );
    ercd = preq_sem( 3 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "preq_sem bad ercd !E_NOEXS" );
    ercd = twai_sem( 3, 10 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "twai_sem bad ercd !E_NOEXS" );
    ercd = wai_sem( 3 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "wai_sem bad ercd !E_NOEXS" );
    ercd = ref_sem( &t_rsem, 3 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "ref_sem bad ercd !E_NOEXS" );
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
    // now try creating it (badly)
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
    ercd = cre_sem( 3, NULL );
    CYG_TEST_CHECK( E_PAR == ercd, "cre_sem bad ercd !E_PAR" );
#endif
    ercd = cre_sem( 3, NADR );
    CYG_TEST_CHECK( E_PAR == ercd, "cre_sem bad ercd !E_PAR" );
    t_csem.sematr = 0xfff;
    ercd = cre_sem( 3, &t_csem );
    CYG_TEST_CHECK( E_RSATR == ercd, "cre_sem bad ercd !E_RSATR" );
    t_csem.sematr = 0;
#endif // we can test bad param error returns
    ercd = cre_sem( 3, &t_csem );
    CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" );
    // and check we can use it
    ercd = sig_sem( 3 );
    CYG_TEST_CHECK( E_OK == ercd, "sig_sem bad ercd" );
    ercd = wai_sem( 3 );
    CYG_TEST_CHECK( E_OK == ercd, "wai_sem bad ercd" );
    ercd = preq_sem( 3 );
    CYG_TEST_CHECK( E_TMOUT == ercd, "preq_sem bad ercd !E_TMOUT" );
    ercd = twai_sem( 3, 2 );
    CYG_TEST_CHECK( E_TMOUT == ercd, "twai_sem bad ercd !E_TMOUT" );
    ercd = ref_sem( &t_rsem, 3 );
    CYG_TEST_CHECK( E_OK == ercd, "ref_sem bad ercd" );

    // now wait while task 2 deletes the wait objects
    ercd = wup_tsk( 2 );
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
    ercd = wai_sem( 1 );
    CYG_TEST_CHECK( E_DLT == ercd, "wai_sem bad ercd !E_DLT" );
    ercd = wup_tsk( 2 );
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
    ercd = twai_sem( 2, 20 );
    CYG_TEST_CHECK( E_DLT == ercd, "twai_sem bad ercd !E_DLT" );

    // check they are deleted
    ercd = sig_sem( 1 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "sig_sem bad ercd !E_NOEXS" );
    ercd = sig_sem( 2 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "sig_sem bad ercd !E_NOEXS" );
    // re-create and do it again
    ercd = cre_sem( 1, &t_csem );
    CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" );
    ercd = cre_sem( 2, &t_csem );
    CYG_TEST_CHECK( E_OK == ercd, "cre_sem bad ercd" );

    // now wait while task 2 deletes the wait objects again
    ercd = wup_tsk( 2 );
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
    ercd = wai_sem( 1 );
    CYG_TEST_CHECK( E_DLT == ercd, "wai_sem bad ercd !E_DLT" );
    ercd = wup_tsk( 2 );
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
    ercd = twai_sem( 2, 20 );
    CYG_TEST_CHECK( E_DLT == ercd, "twai_sem bad ercd !E_DLT" );

    // check they are deleted
    ercd = sig_sem( 1 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "sig_sem bad ercd !E_NOEXS" );
    ercd = sig_sem( 2 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "sig_sem bad ercd !E_NOEXS" );

    CYG_TEST_PASS("create/delete semaphores");
#endif // CYGPKG_UITRON_SEMAS_CREATE_DELETE


#ifdef CYGPKG_UITRON_FLAGS_CREATE_DELETE
    tests++;
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
    ercd = del_flg( -6 );
    CYG_TEST_CHECK( E_ID == ercd, "del_flg bad ercd !E_ID" );
    ercd = del_flg( 99 );
    CYG_TEST_CHECK( E_ID == ercd, "del_flg bad ercd !E_ID" );
    ercd = cre_flg( -6, &t_cflg );
    CYG_TEST_CHECK( E_ID == ercd, "cre_flg bad ercd !E_ID" );
    ercd = cre_flg( 99, &t_cflg );
    CYG_TEST_CHECK( E_ID == ercd, "cre_flg bad ercd !E_ID" );
#endif // we can test bad param error returns
    // try a pre-existing object
    ercd = cre_flg( 3, &t_cflg );
    CYG_TEST_CHECK( E_OBJ == ercd, "cre_flg bad ercd !E_OBJ" );
    // delete it so we can play
    ercd = del_flg( 3 );
    CYG_TEST_CHECK( E_OK == ercd, "del_flg bad ercd" );
    // check it is deleted
    ercd = set_flg( 3, 0x6789 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "set_flg bad ercd !E_NOEXS" );
    ercd = clr_flg( 3, 0x9876 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "clr_flg bad ercd !E_NOEXS" );
    ercd = pol_flg( &scratch, 3, 0xdddd, TWF_ANDW );
    CYG_TEST_CHECK( E_NOEXS == ercd, "pol_flg bad ercd !E_NOEXS" );
    ercd = twai_flg( &scratch, 3, 0x4444, TWF_ORW, 10 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "twai_flg bad ercd !E_NOEXS" );
    ercd = wai_flg( &scratch, 3, 0xbbbb, TWF_ANDW | TWF_CLR );
    CYG_TEST_CHECK( E_NOEXS == ercd, "wai_flg bad ercd !E_NOEXS" );
    ercd = ref_flg( &t_rflg, 3 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "ref_flg bad ercd !E_NOEXS" );
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
    // now try creating it (badly)
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
    ercd = cre_flg( 3, NULL );
    CYG_TEST_CHECK( E_PAR == ercd, "cre_flg bad ercd !E_PAR" );
#endif
    ercd = cre_flg( 3, NADR );
    CYG_TEST_CHECK( E_PAR == ercd, "cre_flg bad ercd !E_PAR" );
    t_cflg.flgatr = 0xfff;
    ercd = cre_flg( 3, &t_cflg );
    CYG_TEST_CHECK( E_RSATR == ercd, "cre_flg bad ercd !E_RSATR" );
#endif // we can test bad param error returns
    // now create it well
    t_cflg.flgatr = 0;
    t_cflg.iflgptn = 0;
    ercd = cre_flg( 3, &t_cflg );
    CYG_TEST_CHECK( E_OK == ercd, "cre_flg bad ercd" );
    // and check we can use it
    ercd = clr_flg( 3, 0x7256 );
    CYG_TEST_CHECK( E_OK == ercd, "clr_flg bad ercd" );
    ercd = set_flg( 3, 0xff );
    CYG_TEST_CHECK( E_OK == ercd, "set_flg bad ercd" );
    ercd = wai_flg( &scratch, 3, 0xaa, TWF_ANDW | TWF_CLR );
    CYG_TEST_CHECK( E_OK == ercd, "wai_flg bad ercd" );
    ercd = pol_flg( &scratch, 3, 0xaa, TWF_ANDW | TWF_CLR );
    CYG_TEST_CHECK( E_TMOUT == ercd, "pol_flg bad ercd !E_TMOUT" );
    ercd = twai_flg( &scratch, 3, 0xaa, TWF_ANDW | TWF_CLR, 2 );
    CYG_TEST_CHECK( E_TMOUT == ercd, "twai_flg bad ercd !E_TMOUT" );
    ercd = ref_flg( &t_rflg, 3 );
    CYG_TEST_CHECK( E_OK == ercd, "ref_flg bad ercd" );
    CYG_TEST_CHECK( 0 == t_rflg.flgptn, "ref_flg bad ercd" );
    // now create it again with a preset pattern and check that we can
    // detect that pattern:
    ercd = del_flg( 3 );
    CYG_TEST_CHECK( E_OK == ercd, "del_flg bad ercd" );
    t_cflg.flgatr = 0;
    t_cflg.iflgptn = 0x1234;
    ercd = cre_flg( 3, &t_cflg );
    CYG_TEST_CHECK( E_OK == ercd, "cre_flg bad ercd" );
    // and check we can use it
    ercd = wai_flg( &scratch, 3, 0x1200, TWF_ANDW );
    CYG_TEST_CHECK( E_OK == ercd, "wai_flg bad ercd" );
    ercd = pol_flg( &scratch, 3, 0x0034, TWF_ANDW );
    CYG_TEST_CHECK( E_OK == ercd, "pol_flg bad ercd" );
    ercd = twai_flg( &scratch, 3, 0x1004, TWF_ANDW, 10 );
    CYG_TEST_CHECK( E_OK == ercd, "twai_flg bad ercd" );
    ercd = pol_flg( &scratch, 3, 0xffedcb, TWF_ORW );
    CYG_TEST_CHECK( E_TMOUT == ercd, "pol_flg bad ercd !E_TMOUT" );
    ercd = ref_flg( &t_rflg, 3 );
    CYG_TEST_CHECK( E_OK == ercd, "ref_flg bad ercd" );
    CYG_TEST_CHECK( 0x1234 == t_rflg.flgptn, "ref_flg bad ercd" );
    ercd = clr_flg( 3, 0 );
    ercd = ref_flg( &t_rflg, 3 );
    CYG_TEST_CHECK( E_OK == ercd, "ref_flg bad ercd" );
    CYG_TEST_CHECK( 0 == t_rflg.flgptn, "ref_flg bad ercd" );

    // now wait while task 2 deletes the wait objects
    ercd = wup_tsk( 2 );
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
    ercd = wai_flg( &scratch, 1, 0xaa, TWF_ANDW );
    CYG_TEST_CHECK( E_DLT == ercd, "wai_flg bad ercd !E_DLT" );
    ercd = wup_tsk( 2 );
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
    ercd = twai_flg( &scratch, 2, 0x55, TWF_ANDW, 20 );
    CYG_TEST_CHECK( E_DLT == ercd, "twai_flg bad ercd !E_DLT" );

    // check they are deleted
    ercd = set_flg( 1, 0x22 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "set_flg bad ercd !E_NOEXS" );
    ercd = clr_flg( 2, 0xdd );
    CYG_TEST_CHECK( E_NOEXS == ercd, "clr_flg bad ercd !E_NOEXS" );
    // re-create and do it again
    t_cflg.iflgptn = 0x5555;
    ercd = cre_flg( 1, &t_cflg );
    CYG_TEST_CHECK( E_OK == ercd, "cre_flg bad ercd" );
    t_cflg.iflgptn = 0;
    ercd = cre_flg( 2, &t_cflg );
    CYG_TEST_CHECK( E_OK == ercd, "cre_flg bad ercd" );

    // now wait while task 2 deletes the wait objects again
    ercd = wup_tsk( 2 );
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
    ercd = wai_flg( &scratch, 1, 0xaaaa, TWF_ORW | TWF_CLR );
    CYG_TEST_CHECK( E_DLT == ercd, "wai_flg bad ercd !E_DLT" );
    ercd = wup_tsk( 2 );
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
    ercd = twai_flg( &scratch, 2, 0xffff, TWF_ORW, 20 );
    CYG_TEST_CHECK( E_DLT == ercd, "twai_flg bad ercd !E_DLT" );

    // check they are deleted
    ercd = clr_flg( 1, 0xd00d );
    CYG_TEST_CHECK( E_NOEXS == ercd, "clr_flg bad ercd !E_NOEXS" );
    ercd = set_flg( 2, 0xfff00 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "set_flg bad ercd !E_NOEXS" );

    CYG_TEST_PASS("create/delete flags");
#endif // CYGPKG_UITRON_FLAGS_CREATE_DELETE

#ifdef CYGPKG_UITRON_MBOXES_CREATE_DELETE
    tests++;
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
    ercd = del_mbx( -6 );
    CYG_TEST_CHECK( E_ID == ercd, "del_mbx bad ercd !E_ID" );
    ercd = del_mbx( 99 );
    CYG_TEST_CHECK( E_ID == ercd, "del_mbx bad ercd !E_ID" );
    ercd = cre_mbx( -6, &t_cmbx );
    CYG_TEST_CHECK( E_ID == ercd, "cre_mbx bad ercd !E_ID" );
    ercd = cre_mbx( 99, &t_cmbx );
    CYG_TEST_CHECK( E_ID == ercd, "cre_mbx bad ercd !E_ID" );
#endif // we can test bad param error returns
    // try a pre-existing object
    ercd = cre_mbx( 3, &t_cmbx );
    CYG_TEST_CHECK( E_OBJ == ercd, "cre_mbx bad ercd !E_OBJ" );
    // delete it so we can play
    ercd = del_mbx( 3 );
    CYG_TEST_CHECK( E_OK == ercd, "del_mbx bad ercd" );
    // check it is deleted
    ercd = snd_msg( 3, t_msg );
    CYG_TEST_CHECK( E_NOEXS == ercd, "snd_msg bad ercd !E_NOEXS" );
    ercd = rcv_msg( &msg, 3 );       
    CYG_TEST_CHECK( E_NOEXS == ercd, "rcv_msg bad ercd !E_NOEXS" );
    ercd = trcv_msg( &msg, 3, 10 );   
    CYG_TEST_CHECK( E_NOEXS == ercd, "trcv_msg bad ercd !E_NOEXS" );
    ercd = prcv_msg( &msg, 3 );        
    CYG_TEST_CHECK( E_NOEXS == ercd, "prcv_msg bad ercd !E_NOEXS" );
    ercd = ref_mbx( &t_rmbx, 3 );
    CYG_TEST_CHECK( E_NOEXS == ercd, "ref_mbx bad ercd !E_NOEXS" );
#ifdef CYGSEM_UITRON_BAD_PARAMS_RETURN_ERRORS
    // now try creating it (badly)
#ifndef CYGSEM_UITRON_PARAMS_NULL_IS_GOOD_PTR
    ercd = cre_mbx( 3, NULL );
    CYG_TEST_CHECK( E_PAR == ercd, "cre_mbx bad ercd !E_PAR" );
#endif
    ercd = cre_mbx( 3, NADR );
    CYG_TEST_CHECK( E_PAR == ercd, "cre_mbx bad ercd !E_PAR" );
    t_cmbx.mbxatr = 0xfff;
    ercd = cre_mbx( 3, &t_cmbx );
    CYG_TEST_CHECK( E_RSATR == ercd, "cre_mbx bad ercd !E_RSATR" );
    t_cmbx.mbxatr = 0;
#endif // we can test bad param error returns
    ercd = cre_mbx( 3, &t_cmbx );
    CYG_TEST_CHECK( E_OK == ercd, "cre_mbx bad ercd" );
    // and check we can use it
    ercd = snd_msg( 3, t_msg );
    CYG_TEST_CHECK( E_OK == ercd, "snd_msg bad ercd" );
    ercd = rcv_msg( &msg, 3 );       
    CYG_TEST_CHECK( E_OK == ercd, "rcv_msg bad ercd" );
    ercd = trcv_msg( &msg, 3, 2 );   
    CYG_TEST_CHECK( E_TMOUT == ercd, "trcv_msg bad ercd !E_TMOUT" );
    ercd = prcv_msg( &msg, 3 );                            
    CYG_TEST_CHECK( E_TMOUT == ercd, "prcv_msg bad ercd !E_TMOUT" );
    ercd = ref_mbx( &t_rmbx, 3 );
    CYG_TEST_CHECK( E_OK == ercd, "ref_mbx bad ercd" );

    // now wait while task 2 deletes the wait objects
    ercd = wup_tsk( 2 );
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
    ercd = rcv_msg( &msg, 1 );
    CYG_TEST_CHECK( E_DLT == ercd, "wai_mbx bad ercd !E_DLT" );
    ercd = wup_tsk( 2 );
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
    ercd = trcv_msg( &msg, 2, 20 );
    CYG_TEST_CHECK( E_DLT == ercd, "twai_mbx bad ercd !E_DLT" );

    // check they are deleted
    ercd = snd_msg( 1, t_msg );
    CYG_TEST_CHECK( E_NOEXS == ercd, "snd_msg bad ercd !E_NOEXS" );
    ercd = snd_msg( 2, t_msg );       
    CYG_TEST_CHECK( E_NOEXS == ercd, "snd_msg bad ercd !E_NOEXS" );
    // re-create and do it again
    ercd = cre_mbx( 1, &t_cmbx );
    CYG_TEST_CHECK( E_OK == ercd, "cre_mbx bad ercd" );
    ercd = cre_mbx( 2, &t_cmbx );
    CYG_TEST_CHECK( E_OK == ercd, "cre_mbx bad ercd" );

    // now wait while task 2 deletes the wait objects again
    ercd = wup_tsk( 2 );
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
    ercd = rcv_msg( &msg, 1 );
    CYG_TEST_CHECK( E_DLT == ercd, "wai_mbx bad ercd !E_DLT" );
    ercd = wup_tsk( 2 );
    CYG_TEST_CHECK( E_OK == ercd, "wup_tsk bad ercd" );
    ercd = trcv_msg( &msg, 2, 20 );
    CYG_TEST_CHECK( E_DLT == ercd, "twai_mbx bad ercd !E_DLT" );

    // check they are deleted
    ercd = snd_msg( 1, t_msg );
    CYG_TEST_CHECK( E_NOEXS == ercd, "snd_msg bad ercd !E_NOEXS" );
    ercd = snd_msg( 2, t_msg );       
    CYG_TEST_CHECK( E_NOEXS == ercd, "snd_msg bad ercd !E_NOEXS" );

    CYG_TEST_PASS("create/delete mboxes");
#endif // CYGPKG_UITRON_MBOXES_CREATE_DELETE

    ercd = ter_tsk( 2 );
    CYG_TEST_CHECK( E_OK == ercd, "ter_tsk bad ercd" );
    ercd = dly_tsk( 5 );
    CYG_TEST_CHECK( E_OK == ercd, "dly_tsk bad ercd" );

    // all done
    if ( 0 == tests ) {
        CYG_TEST_NA( "No objects have create/delete enabled" );
    }
    else {
        CYG_TEST_EXIT( "All done" );
    }
    ext_tsk();
}
示例#2
0
static int __ui_preq_sem(struct pt_regs *regs)
{
	ID semid = __xn_reg_arg1(regs);

	return preq_sem(semid);
}
示例#3
0
void ITRON_Init( void )
{
  ER      status;
  T_CSEM  pk_csem;
  T_RSEM  pk_rsem;

  printf( "\n\n*** ITRONSEM01 -- ITRON SEMAPHORE TEST ***\n" );

  /*
   *  Exercise cre_sem - this code seems to exercise every path.
   */

  puts( "Init - cre_sem - NULL pk_sem returns E_PAR" );
  status = cre_sem( 1, NULL );
  assert( status == E_PAR );

  puts( "Init - cre_sem - isemcnt > maxsem returns E_PAR" );
  pk_csem.sematr = 0;
  pk_csem.isemcnt = 3;
  pk_csem.maxsem  = 2;
  status = cre_sem( 1, &pk_csem );
  assert( status == E_PAR );

  puts( "Init - cre_sem - maxsem of 0 returns E_PAR" );
  pk_csem.isemcnt = 0;
  pk_csem.maxsem  = 0;
  status = cre_sem( 1, &pk_csem );
  assert( status == E_PAR );

  /*
   *  Now run through all the bad ID errors
   */

  pk_csem.isemcnt = 2;
  pk_csem.maxsem  = 3;
  puts( "Init - cre_sem - bad id (less than -4) - E_OACV" );
  status = cre_sem( -5, &pk_csem );
  assert( status == E_OACV );

  puts( "Init - cre_sem - bad id (between 0 and -4) - E_ID" );
  status = cre_sem( -4, &pk_csem );
  assert( status == E_ID );

  puts( "Init - cre_sem - bad id (0) - E_ID" );
  status = cre_sem( 0, &pk_csem );
  assert( status == E_ID );

  puts( "Init - cre_sem - bad id (too great) - E_ID" );
  status = cre_sem( CONFIGURE_MAXIMUM_ITRON_SEMAPHORES + 1, &pk_csem );
  assert( status == E_ID );

  puts( "Init - cre_sem - create semaphore 1 TA_TFIFO - E_OK" );
  pk_csem.isemcnt = 2;
  pk_csem.maxsem  = 3;
  pk_csem.sematr  = TA_TFIFO;
  status = cre_sem( 1, &pk_csem );
  assert( status == E_OK );

  puts( "Init - cre_sem - create semaphore 1 again - E_OBJ" );
  status = cre_sem( 1, &pk_csem );
  assert( status == E_OBJ );

  puts( "Init - cre_sem - create semaphore 2 TA_TPRI - E_OK" );
  pk_csem.isemcnt = 2;
  pk_csem.maxsem  = 3;
  pk_csem.sematr  = TA_TPRI;
  status = cre_sem( 2, &pk_csem );
  assert( status == E_OK );

  /*
   *  Generate all the bad id errors for del_sem
   */

  puts( "Init - del_sem - bad id (less than -4) - E_OACV" );
  status = del_sem( -5 );
  assert( status == E_OACV );

  puts( "Init - del_sem - bad id (between 0 and -4) - E_ID" );
  status = del_sem( -4 );
  assert( status == E_ID );

  puts( "Init - del_sem - bad id (0) - E_ID" );
  status = del_sem( 0 );
  assert( status == E_ID );

  puts( "Init - del_sem - bad id (too great) - E_ID" );
  status = del_sem( CONFIGURE_MAXIMUM_ITRON_SEMAPHORES + 1 );
  assert( status == E_ID );

  /*
   *  Generate all the bad id errors for sig_sem
   */

  puts( "Init - sig_sem - bad id (less than -4) - E_OACV" );
  status = sig_sem( -5 );
  assert( status == E_OACV );

  puts( "Init - sig_sem - bad id (between 0 and -4) - E_ID" );
  status = sig_sem( -4 );
  assert( status == E_ID );

  puts( "Init - sig_sem - bad id (0) - E_ID" );
  status = sig_sem( 0 );
  assert( status == E_ID );

  puts( "Init - sig_sem - bad id (too great) - E_ID" );
  status = wai_sem( CONFIGURE_MAXIMUM_ITRON_SEMAPHORES + 1 );
  assert( status == E_ID );

  /*
   *  Generate all the bad id errors for preq_sem
   */

  puts( "Init - preq_sem - bad id (less than -4) - E_OACV" );
  status = preq_sem( -5 );
  assert( status == E_OACV );

  puts( "Init - preq_sem - bad id (between 0 and -4) - E_ID" );
  status = preq_sem( -4 );
  assert( status == E_ID );

  puts( "Init - preq_sem - bad id (0) - E_ID" );
  status = preq_sem( 0 );
  assert( status == E_ID );

  puts( "Init - preq_sem - bad id (too great) - E_ID" );
  status = preq_sem( CONFIGURE_MAXIMUM_ITRON_SEMAPHORES + 1 );
  assert( status == E_ID );

  /*
   *  Generate all the bad id errors for wai_sem
   */

  puts( "Init - wai_sem - bad id (less than -4) - E_OACV" );
  status = wai_sem( -5 );
  assert( status == E_OACV );

  puts( "Init - wai_sem - bad id (between 0 and -4) - E_ID" );
  status = wai_sem( -4 );
  assert( status == E_ID );

  puts( "Init - wai_sem - bad id (0) - E_ID" );
  status = wai_sem( 0 );
  assert( status == E_ID );

  puts( "Init - wai_sem - bad id (too great) - E_ID" );
  status = wai_sem( CONFIGURE_MAXIMUM_ITRON_SEMAPHORES + 1 );
  assert( status == E_ID );

  /*
   *  Generate all the bad id errors for twai_sem
   */

  puts( "Init - twai_sem - bad id (less than -4) - E_OACV" );
  status = twai_sem( -5, 1000 );
  assert( status == E_OACV );

  puts( "Init - twai_sem - bad id (between 0 and -4) - E_ID" );
  status = twai_sem( -4, 1000 );
  assert( status == E_ID );

  puts( "Init - twai_sem - bad id (0) - E_ID" );
  status = twai_sem( 0, 1000 );
  assert( status == E_ID );

  puts( "Init - twai_sem - bad id (too great) - E_ID" );
  status = twai_sem( CONFIGURE_MAXIMUM_ITRON_SEMAPHORES + 1, 1000 );
  assert( status == E_ID );

  /*
   *  Generate all the bad id errors for ref_sem
   */

  puts( "Init - ref_sem - bad id (less than -4) - E_OACV" );
  status = ref_sem( -5, &pk_rsem );
  assert( status == E_OACV );

  puts( "Init - ref_sem - bad id (between 0 and -4) - E_ID" );
  status = ref_sem( -4, &pk_rsem );
  assert( status == E_ID );

  puts( "Init - ref_sem - bad id (0) - E_ID" );
  status = ref_sem( 0, &pk_rsem );
  assert( status == E_ID );

  puts( "Init - ref_sem - bad id (too great) - E_ID" );
  status = ref_sem( CONFIGURE_MAXIMUM_ITRON_SEMAPHORES + 1, &pk_rsem );
  assert( status == E_ID );

  /*
   *  Exercise preq_sem (and sig_sem a little)
   */


  puts( "Init - preq_sem - semaphore 1 available (count --> 1) - E_OK" );
  status = preq_sem( 1 );
  assert( status == E_OK );

  puts( "Init - preq_sem - semaphore 1 available (count --> 0) - E_OK" );
  status = preq_sem( 1 );
  assert( status == E_OK );

  puts( "Init - preq_sem - semaphore 1 unavailable - E_TMOUT" );
  status = preq_sem( 1 );
  assert( status == E_TMOUT );

  puts( "Init - sig_sem - semaphore 1 (count --> 1) - E_OK" );
  status = sig_sem( 1 );
  assert( status == E_OK );

  puts("Init - twai_sem(TMO_POL) - semaphore 1 available (count --> 0) - E_OK");
  status = twai_sem( 1, TMO_POL );
  assert( status == E_OK );

  puts( "Init - twai_sem(TMO_POL) - semaphore 1 available - E_TMOUT" );
  status = twai_sem( 1, TMO_POL );
  assert( status == E_TMOUT );

  /*
   *  Exercise twai_sem
   */

  puts( "Init - twai_sem - semaphore 1 unavailable - 1 second E_TMOUT" );
  put_time( "Init - starting to block at ");
  status = twai_sem( 1, 1000 );
  assert( status == E_TMOUT );
  put_time( "Init - timed out at ");
  puts( "Init - twai_sem - semaphore 1 unavailable - timeout completed" );

  /*
   *  Now let's test exceed the maximum count of semaphore 1
   */

  puts( "Init - sig_sem - semaphore 1 (count --> 1) - E_OK" );
  status = sig_sem( 1 );
  assert( status == E_OK );

  puts( "Init - sig_sem - semaphore 1 (count --> 2) - E_OK" );
  status = sig_sem( 1 );
  assert( status == E_OK );

  puts( "Init - sig_sem - semaphore 1 (count --> 3) - E_OK" );
  status = sig_sem( 1 );
  assert( status == E_OK );

  puts( "Init - sig_sem - semaphore 1 (count > maximum) - E_QOVR" );
  status = sig_sem( 1 );
  assert( status == E_QOVR );

  /*
   *  Exercise ref_sem
   */

  puts( "Init - ref_sem - NULL pk_sem returns E_PAR" );
  status = ref_sem( 1, NULL );
  assert( status == E_PAR );

  puts( "Init - ref_sem - semaphore 1 - E_OK" );
  status = ref_sem( 1, &pk_rsem );
  assert( status == E_OK );
  printf( "Init - semaphore 1 count = %d\n", pk_rsem.semcnt );
  printf( "Init - semaphore 1 waiting tasks = %d\n", pk_rsem.wtsk );

  puts( "Init - preq_sem - semaphore 1 (count --> 2) - E_OK" );
  status = preq_sem( 1 );
  assert( status == E_OK );

  puts( "Init - ref_sem - semaphore 1 - E_OK" );
  status = ref_sem( 1, &pk_rsem );
  assert( status == E_OK );
  printf( "Init - semaphore 1 count = %d\n", pk_rsem.semcnt );
  printf( "Init - semaphore 1 waiting tasks = %d\n", pk_rsem.wtsk );


  /*
   *  Exercise del_sem
   */

  /* XXX really want another task blocking on the semaphore XXX */

  puts( "Init - del_sem - semaphore 1 deleted - E_OK" );
  status = del_sem( 1 );
  assert( status == E_OK );

  puts( "Init - XXX need other tasks to complete the test XXX" );

  puts( "Init - dly_tsk - 1 second to let other task run" );
  status = dly_tsk( 1000 );
  assert( status == E_OK );

  printf( "*** END OF ITRONSEM01 -- ITRON SEMAPHORE TEST ***\n" );
  rtems_test_exit( 0 );
}