[Tinyos-2-commits] CVS: tinyos-2.x-contrib/tunit/tests/tinyos-2.x/tos/system/TestFcfsArbiterC Makefile, NONE, 1.1 TestFcfsArbiterC.nc, NONE, 1.1 TestFcfsArbiterP.nc, NONE, 1.1 suite.properties, NONE, 1.1

Kevin Klues klueska at users.sourceforge.net
Wed Sep 26 09:58:03 PDT 2007


Update of /cvsroot/tinyos/tinyos-2.x-contrib/tunit/tests/tinyos-2.x/tos/system/TestFcfsArbiterC
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv10777/TestFcfsArbiterC

Added Files:
	Makefile TestFcfsArbiterC.nc TestFcfsArbiterP.nc 
	suite.properties 
Log Message:
Adding TestFcfsArbiterC application

--- NEW FILE: Makefile ---
COMPONENT=TestFcfsArbiterC

include $(MAKERULES)


--- NEW FILE: TestFcfsArbiterC.nc ---
/*
 * Copyright (c) 2005-2006 Rincon Research Corporation
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * - Redistributions of source code must retain the above copyright
 *   notice, this list of conditions and the following disclaimer.
 * - Redistributions in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in the
 *   documentation and/or other materials provided with the
 *   distribution.
 * - Neither the name of the Rincon Research Corporation nor the names of
 *   its contributors may be used to endorse or promote products derived
 *   from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
 * RINCON RESEARCH OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE
 */

/**
 * @author Kevin Klues
 */
configuration TestFcfsArbiterC {
}

implementation {
  #define TEST_FCFSARBITERC_RESOURCE	"Test.FcfsArbiterC.Resource"
  components new FcfsArbiterC(TEST_FCFSARBITERC_RESOURCE) as Arbiter,
      TestFcfsArbiterP;

  enum {
    RESOURCE0_ID = unique(TEST_FCFSARBITERC_RESOURCE),
    RESOURCE1_ID = unique(TEST_FCFSARBITERC_RESOURCE),
    RESOURCE2_ID = unique(TEST_FCFSARBITERC_RESOURCE),
  };

  TestFcfsArbiterP.Resource0 -> Arbiter.Resource[RESOURCE0_ID];
  TestFcfsArbiterP.Resource1 -> Arbiter.Resource[RESOURCE1_ID];
  TestFcfsArbiterP.Resource2 -> Arbiter.Resource[RESOURCE2_ID];

  //Tunit Test cases 
  components new TestCaseC() as TestFcfsOrderC;
  TestFcfsArbiterP.SetUpOneTime -> TestFcfsOrderC.SetUpOneTime;
  TestFcfsArbiterP.TearDownOneTime -> TestFcfsOrderC.TearDownOneTime;
  TestFcfsArbiterP.TestFcfsOrder -> TestFcfsOrderC;
}

--- NEW FILE: TestFcfsArbiterP.nc ---
/*
 * Copyright (c) 2004, Technische Universitat Berlin
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * - Redistributions of source code must retain the above copyright notice,
 *   this list of conditions and the following disclaimer.
 * - Redistributions in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in the
 *   documentation and/or other materials provided with the distribution.
 * - Neither the name of the Technische Universitat Berlin nor the names
 *   of its contributors may be used to endorse or promote products derived
 *   from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/**
 *
 * @author Kevin Klues <klues at tkn.tu-berlin.de>
 * @version  $Revision: 1.1 $
 * @date $Date: 2007/09/26 16:58:01 $
 */

#include "TestCase.h"

module TestFcfsArbiterP {
  uses {
    interface Resource as Resource0;
    interface Resource as Resource1;
    interface Resource as Resource2;

    interface TestCase as TestFcfsOrder; 
    interface TestControl as SetUpOneTime;
    interface TestControl as TearDownOneTime;
  }
}
implementation {

  uint8_t resource;

  event void SetUpOneTime.run() {
    call SetUpOneTime.done();
  }

  event void TearDownOneTime.run() {
    call TearDownOneTime.done();
  }
  
  //All resources try to gain access
  event void TestFcfsOrder.run() {
    resource = 0;
    call Resource0.request();
    call Resource2.request();
    call Resource1.request();
  }
  
  //If granted the resource, turn on an LED  
  event void Resource0.granted() {
    assertEquals("Resource Granted Out of Order: 0", resource, 0);
    resource = 2;
    call Resource0.release();
  }  
  event void Resource1.granted() {
    assertEquals("Resource Granted Out of Order: 1", resource, 1);
    call TestFcfsOrder.done();
  }  
  event void Resource2.granted() {
    assertEquals("Resource Granted Out of Order: 2", resource, 2);
    resource = 1;
    call Resource0.release();
  }  
}

--- 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 FcfsArbiterC
@author Kevin Klues
@description Tests the functionality of the FcfsArbiter component.  Verifies that resources are allocated in FCFS order.
@exactnodes 1



More information about the Tinyos-2-commits mailing list