[Tinyos-2-commits] CVS: tinyos-2.x-contrib/tunit/tests/tinyos-2.x/tos/chips/cc2420/TestRadioSplitControl Makefile, NONE, 1.1 TestRadioC.nc, NONE, 1.1 TestRadioP.nc, NONE, 1.1 suite.properties, NONE, 1.1

David Moss mossmoss at users.sourceforge.net
Sat Jul 21 22:31:56 PDT 2007


Update of /cvsroot/tinyos/tinyos-2.x-contrib/tunit/tests/tinyos-2.x/tos/chips/cc2420/TestRadioSplitControl
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv19699/TestRadioSplitControl

Added Files:
	Makefile TestRadioC.nc TestRadioP.nc suite.properties 
Log Message:
Moved from a flat directory structure to a project-oriented directory structure

--- NEW FILE: Makefile ---
COMPONENT=TestRadioC
include $(MAKERULES)


--- NEW FILE: TestRadioC.nc ---

#include "TestCase.h"

/**
 * @author David Moss
 */
configuration TestRadioC {
}

implementation {
  components
      new TestCaseC() as TestRadioPowerCycleC,
      new TestCaseC() as TestAlreadyOnC,
      new TestCaseC() as TestAlreadyOffC,
      new TestCaseC() as TestAlreadyTurningOnC,
      new TestCaseC() as TestAlreadyTurningOffC;
      
  components TestRadioP,
      ActiveMessageC,
      new AMSenderC(4),
      new AMReceiverC(4),
      new TimerMilliC(),
      new StateC(),
      LedsC;

  TestRadioP.SetUp -> TestRadioPowerCycleC.SetUp;
  
  TestRadioP.TestRadioPowerCycle -> TestRadioPowerCycleC;
  TestRadioP.TestAlreadyOn -> TestAlreadyOnC;
  TestRadioP.TestAlreadyOff -> TestAlreadyOffC;
  TestRadioP.TestAlreadyTurningOn -> TestAlreadyTurningOnC;
  TestRadioP.TestAlreadyTurningOff -> TestAlreadyTurningOffC;
  
  TestRadioP.SplitControl -> ActiveMessageC;
  TestRadioP.AMSend -> AMSenderC;
  TestRadioP.Receive -> AMReceiverC;
  TestRadioP.Timer -> TimerMilliC;
  TestRadioP.State -> StateC;
  TestRadioP.Leds -> LedsC;

}

--- NEW FILE: TestRadioP.nc ---

#include "TestCase.h"

/**
 * @author David Moss
 */
module TestRadioP {
  uses {
    interface TestControl as SetUp;
    
    interface TestCase as TestRadioPowerCycle;
    interface TestCase as TestAlreadyOn;
    interface TestCase as TestAlreadyOff;
    interface TestCase as TestAlreadyTurningOn;
    interface TestCase as TestAlreadyTurningOff;
    
    interface SplitControl;
    interface AMSend;
    interface Receive;
    interface Timer<TMilli>;
    interface State;
    interface Leds;
  }
}

implementation {

  uint16_t myIndex;
  
  /** TRUE if the radio is on */
  bool on;
  
  enum {
    S_IDLE,
    S_SETUP,
    S_TESTRADIOPOWERCYCLE,
    S_TESTALREADYON,
    S_TESTALREADYOFF,
    S_TESTALREADYTURNINGON,
    S_TESTALREADYTURNINGOFF,
  };
  
    
  enum {
    RADIO_POWER_CYCLES = 1000,
  };

  /***************** Prototypes ****************/
  task void testAlreadyTurningOn_finish();
  task void testAlreadyTurningOff_finish();
   
  /***************** SetUp Events ****************/
  event void SetUp.run() {
    call State.forceState(S_SETUP);
    if(call SplitControl.stop() != SUCCESS) {
      call SetUp.done();
    }
  }
  
  
  /***************** Tests ****************/
  /**
   * Turn the radio on and off RADIO_POWER_CYCLES times, verify we don't lock 
   * up or have any problems with SplitControl
   */
  event void TestRadioPowerCycle.run() {
    call State.forceState(S_TESTRADIOPOWERCYCLE);
    myIndex = 0;
    if(call SplitControl.start() != SUCCESS) {
      assertFail("start() failed");
      call TestRadioPowerCycle.done();
    }
  }
  
  event void TestAlreadyOn.run() {
    call State.forceState(S_TESTALREADYON);
    if(call SplitControl.start() != SUCCESS) {
      assertFail("start() failed");
      call TestAlreadyOn.done();
    }
  }
  
  event void TestAlreadyOff.run() {
    call State.forceState(S_TESTALREADYOFF);
    assertEquals("stop() didn't return EALREADY", EALREADY, call SplitControl.stop());
    call TestAlreadyOff.done();
  }
  
  event void TestAlreadyTurningOn.run() {
    call State.forceState(S_TESTALREADYTURNINGON);
    if(call SplitControl.start() != SUCCESS) {
      assertFail("start() failed");
      call TestAlreadyOn.done();
    }
    
    if(!on) {
      // SplitControl.startDone() hasn't signaled yet
      assertEquals("restart() wasn't SUCCESS", SUCCESS, call SplitControl.start());
      assertEquals("stop() wasn't EBUSY", EBUSY, call SplitControl.stop());
    } else {
      // There's no way for this to fail since the call wasn't split phase
      assertSuccess();
    }
  }
  
  event void TestAlreadyTurningOff.run() {
    call State.forceState(S_TESTALREADYTURNINGOFF);
    if(call SplitControl.start() != SUCCESS) {
      assertFail("start() failed");
      call TestAlreadyTurningOff.done();
    }
  }
  
  
    
  /***************** SplitControl Events ****************/
  event void SplitControl.startDone(error_t error) {
    call Leds.led2On();
    on = TRUE;
    switch(call State.getState()) {
    case S_TESTRADIOPOWERCYCLE:
      if(error != SUCCESS) {
        // Do it like this so we don't generate a lot of assertions
        assertEquals("startDone([error])", SUCCESS, error);
      }
      
      if(call SplitControl.stop() != SUCCESS) {
        assertFail("stop() failed");
        call TestRadioPowerCycle.done();
      }
      break;
      
    case S_TESTALREADYON:
      if(error != SUCCESS) {
        assertEquals("startDone([error])", SUCCESS, error);
      }
      
      assertEquals("restart() wasn't EALREADY", EALREADY, call SplitControl.start());
      call TestAlreadyOn.done();
      break;
    
    case S_TESTALREADYTURNINGON:
      post testAlreadyTurningOn_finish();
      break;
    
    case S_TESTALREADYTURNINGOFF:
      if(call SplitControl.stop() != SUCCESS) {
        assertFail("stop() failed");
        call TestAlreadyTurningOff.done();
      
      } else {
        if(on) {
          // SplitControl.stopDone hasn't signaled yet
          assertEquals("start() wasn't EBUSY", EBUSY, call SplitControl.start());
          assertEquals("stop() wasn't SUCCESS", SUCCESS, call SplitControl.stop());
          
        } else {
          // There's no way for this to fail since the call wasn't split phase
          assertSuccess();
          call TestAlreadyTurningOff.done();
        }
        
      }
      break;
      
    default:
    }
  }
  
  event void SplitControl.stopDone(error_t error) {
    call Leds.led2Off();
    on = FALSE;
    
    switch(call State.getState()) {
    case S_SETUP:
      call State.toIdle();
      call SetUp.done();
      break;
    
    case S_TESTRADIOPOWERCYCLE:
      myIndex++;
      if(error != SUCCESS) {
        // Do it like this so we don't generate a lot of assertions
        assertEquals("stopDone([error])", SUCCESS, error);
      }
      
      if(myIndex < RADIO_POWER_CYCLES) {
        if(call SplitControl.start() != SUCCESS) {
          assertFail("restart() failed");
          call TestRadioPowerCycle.done();
        }
        
      } else {
        assertEquals("Not enough cycles", RADIO_POWER_CYCLES, myIndex);
        call TestRadioPowerCycle.done();
      }
      break;
    
    case S_TESTALREADYTURNINGOFF:
      post testAlreadyTurningOff_finish();
      break;
      
    default:
    }
  }
  
  /***************** AMSend Events ****************/
  event void AMSend.sendDone(message_t *msg, error_t error) {
  }
  
  /***************** Receive Events ****************/
  event message_t *Receive.receive(message_t *msg, void *payload, uint8_t len) {
   return msg;
  }
  
  /***************** Timer Events ****************/
  event void Timer.fired() {
  }
  
  /***************** Tasks ****************/
  task void testAlreadyTurningOn_finish() {
    call TestAlreadyTurningOn.done();
  }
  
  task void testAlreadyTurningOff_finish() {
    call TestAlreadyTurningOff.done();
  }
  
  
}

--- NEW FILE: suite.properties ---
/**
 * Valid keywords are:
 *  @author <optional author(s)>  (multiple)
 *  @testname <optional testname>  (once)
 *  @description <optional, multiline description>  (once)
 *  @extra <any build/install extras> (multiple)
 *  @ignore <single target>  (multiple)
 *  @only <single target> (multiple)
 *  @minnodes <# nodes>  (once)
 *  @maxnodes <# nodes>  (once)
 *  @exactnodes <# of exact nodes>  (once)
 *  @mintargets <# of minimum targets for heterogeneous network testing>  (once)
 *  @timeout <timeout duration of the test in minutes, default is 1 min.>
 *  @skip  (once)
 */

@testname Test Radio SplitControl Behavior
@author David Moss
@description Test the behavior of radio power cycling
@exactnodes 1
@ignore mica2
@ignore mica2dot



More information about the Tinyos-2-commits mailing list