[Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/ustutt/ncunit/example
Makefile, NONE, 1.1 .cvsignore, NONE, 1.1 ToTestC.nc, NONE,
1.1 TestAssertM.nc, NONE, 1.1 TestAssert.nc, NONE,
1.1 ToTestM.nc, NONE, 1.1
Andreas Lachenmann
lachenmann at users.sourceforge.net
Tue Feb 20 04:33:08 PST 2007
Update of /cvsroot/tinyos/tinyos-1.x/contrib/ustutt/ncunit/example
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv4808/contrib/ustutt/ncunit/example
Added Files:
Makefile .cvsignore ToTestC.nc TestAssertM.nc TestAssert.nc
ToTestM.nc
Log Message:
added files to repository
--- NEW FILE: Makefile ---
COMPONENT=TestAssert
PFLAGS += -I$(NCUNIT_ROOT)/mote
#uncomment for debug output with support for floating point numbers
#PFLAGS += -Wl,-u,vfprintf -lprintf_flt -lm
GOALS += ncunit
TOSMAKE_PATH += $(NCUNIT_ROOT)/scripts
include $(TOSROOT)/apps/Makerules
--- NEW FILE: .cvsignore ---
build
*.out
--- NEW FILE: ToTestC.nc ---
/**
* Copyright (c) 2007, Institute of Parallel and Distributed Systems
* (IPVS), Universität Stuttgart.
* 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 names of the Institute of Parallel and Distributed
* Systems and Universität Stuttgart 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.
*
*/
configuration ToTestC {
provides interface StdControl;
}
implementation {
components ToTestM, LedsC, GenericCommPromiscuous as Comm;
StdControl = ToTestM;
StdControl = Comm;
ToTestM.Leds -> LedsC;
ToTestM.SendMsg -> Comm.SendMsg[10];
}
--- NEW FILE: TestAssertM.nc ---
/**
* Copyright (c) 2007, Institute of Parallel and Distributed Systems
* (IPVS), Universität Stuttgart.
* 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 names of the Institute of Parallel and Distributed
* Systems and Universität Stuttgart 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.
*
*/
module TestAssertM {
provides interface StdControl;
uses interface Assert;
uses interface Assert as Assert2;
uses interface StdControl as TestControl;
uses interface Leds;
}
implementation {
#include "ncunit.h"
#include "AM.h"
command result_t StdControl.init() {
uint8_t i = 123;
debug(DBG_USR1, "You can output arbitrary text similar to TOSSIM: %u", i);
return SUCCESS;
}
command result_t StdControl.start() {
call TestControl.init();
return SUCCESS;
}
command result_t StdControl.stop() {
return SUCCESS;
}
void testFunction1() @test() {
uint8_t* varPtr;
volatile uint16_t bcastAddr = TOS_BCAST_ADDR;
call Assert.assertJavaClassMsg("java class", "example.TestJavaAssert", 1000);
// call Assert.failMsg("Failed assertion");
call Assert.assertCalls("ToTestM.SendMsg.send", "address", &bcastAddr, COMP_EQUALS);
call Assert.assertCalls("ToTestM.Leds.redToggle", NULL, NULL, COMP_NONE);
// modify variable to cause previous assert fail
varPtr = (uint8_t*) call Assert.getDataPointer("ToTestM.variable");
*varPtr = 0;
// call function under test
call TestControl.start();
}
void testFunction2() @test() {
uint8_t* varPtr;
volatile uint16_t bcastAddr = TOS_BCAST_ADDR;
call Assert.assertJavaClassMsg("java class", "example.TestJavaAssert", 1000);
// call Assert.failMsg("Failed assertion");
call Assert.assertCalls("ToTestM.SendMsg.send", "address", &bcastAddr, COMP_EQUALS);
call Assert.assertCalls("ToTestM.Leds.redToggle", NULL, NULL, COMP_NONE);
// call function under test
call TestControl.start();
}
}
--- NEW FILE: TestAssert.nc ---
/**
* Copyright (c) 2007, Institute of Parallel and Distributed Systems
* (IPVS), Universität Stuttgart.
* 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 names of the Institute of Parallel and Distributed
* Systems and Universität Stuttgart 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.
*
*/
configuration TestAssert {
}
implementation {
components AssertC, Main, TestAssertM, ToTestC, LedsC;
Main.StdControl -> TestAssertM;
TestAssertM.Assert -> AssertC;
TestAssertM.Assert2 -> AssertC;
TestAssertM.TestControl -> ToTestC;
TestAssertM.Leds -> LedsC;
}
--- NEW FILE: ToTestM.nc ---
/**
* Copyright (c) 2007, Institute of Parallel and Distributed Systems
* (IPVS), Universität Stuttgart.
* 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 names of the Institute of Parallel and Distributed
* Systems and Universität Stuttgart 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.
*
*/
module ToTestM {
provides {
interface StdControl;
}
uses {
interface Leds;
interface SendMsg;
}
}
implementation {
uint8_t variable;
TOS_Msg message;
command result_t StdControl.init() {
call Leds.init();
variable = 1;
return SUCCESS;
}
command result_t StdControl.start() {
if (variable != 0) {
call Leds.redToggle();
}
call SendMsg.send(TOS_BCAST_ADDR, 0, &message);
return SUCCESS;
}
command result_t StdControl.stop() {
return SUCCESS;
}
event result_t SendMsg.sendDone(TOS_MsgPtr msg, result_t success) {
return SUCCESS;
}
}
More information about the Tinyos-contrib-commits
mailing list