def test_loader():
    """
    Basic Loader test, by it's lonesome, so that Loader can be assumed
    to be valid in other invidual tests (without needing to reload
    each time).
    """
    loader = Loader("MultihopOscilloscope_app.xml", None)
class DummyProber(object):
    # PST- Gross hack to make up imaginary test buffer. For better or
    # worse (I tend to think the latter), python 2.5 does not have a
    # pure python way of creating real immutable buffers.
    def get_buffer(self, node, var):
        return " " * 4096

    def get_shadow_buffer(self, node, var, length):
        return " " * length

    def get_dirty_list(self, lst):
        return []


loader = Loader("MultihopOscilloscope_app.xml", DummyProber())


def looks_like_oscilloscope_t(probe):
    items = ["version", "interval", "id", "count", "readings"]
    return all(probe.get_item(x) for x in items)


def looks_like_message_t(probe):
    items = ["header", "metadata", "data", "footer"]
    return all(probe.get_item(x) for x in items)


def test_lookup1():
    probe_def = loader.lookup("MultihopOscilloscopeC$sendbuf")
    probe = probe_def.bind(1)
Beispiel #3
0
"""
Startup Runner for Simx Act/React.

@author Paul Stickney - Oct 2008
"""

import sys

from TOSSIM import Tossim
import SimxProbe

from simx.probe import Loader, Probe

tossim = Tossim([])
loader = Loader('app.xml', SimxProbe)

#tossim.addChannel("Tossim", sys.stdout)
#tossim.addChannel("TossimPacketModelC", sys.stdout)
#tossim.addChannel("SimMoteP", sys.stdout)
#tossim.addChannel("Gain", sys.stdout)
#tossim.addChannel("AM", sys.stdout)
#tossim.addChannel("Acks", sys.stdout)
#tossim.addChannel("Packet", sys.stdout)
#tossim.addChannel("Scheduler", sys.stdout)
#tossim.addChannel("Insert", sys.stdout)
#tossim.addChannel("HASH", sys.stdout)
#tossim.addChannel("NoiseAudit", sys.stdout)
#tossim.addChannel("Noise_c", sys.stdout)
#tossim.addChannel("Noise", sys.stdout)
#tossim.addChannel("Noise_output", sys.stdout)
Beispiel #4
0
#!/usr/bin/env python

import re
import sys
import unittest
import random

from TOSSIM import Tossim
import SimxProbe

from simx.probe import Loader

# Tossim /must/ be initialized first -- doesn't matter if not used directly
Tossim([])
# Only load once, should be tested elsewhere :-)
loader = Loader('app.xml', SimxProbe)


#hack(s) to get unittest asserts
class _Check(unittest.TestCase):
    def runTest(self):
        pass


check = _Check()
# PST- beautiful, but perhaps too much magic
# allows direct use of assertEquals, etc. by importing them
for f in (x for x in dir(check) if re.match("(?:assert|fail)", x)):
    globals()[f] = getattr(check, f)

from simx.probe import Loader

from TOSSIM import Tossim
import SimxProbe

_tossim = Tossim([])
loader = Loader('app.xml', SimxProbe)

print "--1--"
v1 = loader.lookup("OctopusC$alpha")
print "have def: %s" % v1
p1 = v1.bind(1)

print "have probe: %s" % p1.get()

print "--2--"
v2 = loader.lookup("OctopusC$ttt")
print "have def: %s" % v2
p2 = v2.bind(2)
print "have probe: %s" % p2.print_buf()

print "--3--"
v3 = loader.lookup("OctopusC$ttt_optimized_out")
print "have def: %s" % 32
try:
    p3 = v3.bind(3)
    print "have probe: %s" % p3
except Exception, e:
    print "it is expected this raises an exception: %s" % e.message
#!/usr/bin/env python
"""
Startup Runner for Simx Act/React.

@author Paul Stickney - Oct 2008
"""

import sys

from TOSSIM import Tossim
import SimxProbe

from simx.probe import Loader, Probe

tossim = Tossim([])
loader = Loader('app.xml', SimxProbe)

#tossim.addChannel("Tossim", sys.stdout)
#tossim.addChannel("TossimPacketModelC", sys.stdout)
#tossim.addChannel("SimMoteP", sys.stdout)
#tossim.addChannel("Gain", sys.stdout)
#tossim.addChannel("AM", sys.stdout)
#tossim.addChannel("Acks", sys.stdout)
#tossim.addChannel("Packet", sys.stdout)
#tossim.addChannel("Scheduler", sys.stdout)
#tossim.addChannel("Insert", sys.stdout)
#tossim.addChannel("HASH", sys.stdout)
#tossim.addChannel("NoiseAudit", sys.stdout)
#tossim.addChannel("Noise_c", sys.stdout)
#tossim.addChannel("Noise", sys.stdout)
#tossim.addChannel("Noise_output", sys.stdout)