def launch(self, execparams={}, ossiehome=None, configure={}, initialize=True):
        """
        Launch the component. The component will be executed as a child process,
        then (optionally) initialized and configured.

        Arguments:
          execparams - Execparams to override on component execution.
          ossiehome  - Base location of REDHAWK installation for finding IDL files.
                       Default location is determined from $OSSIEHOME environment
                       variable.
          configure  - If a dictionary, a set of key/value pairs to override the
                       initial configuration values of the component.
                       If None, skip initial configuration.
          initialize - If true, call initialize() after launching the component.
                       If false, skip initialization.
        """
        if IDE_REF_ENV == None:
            if ossiehome:
                model._ossiehome = str(ossiehome)
                model._interface_list = importIDL.importStandardIdl(std_idl_path=str(ossiehome)+'/idl', std_idl_include_path=str(ossiehome)+'/idl')
                model._loadedInterfaceList = True
            component = sb.launch(self.spd_file, impl=self.impl, execparams=execparams,
                                  configure=configure, initialize=initialize)
        else:
            # spd file path passed in to unit test is relative to current component tests directory (i.e. "..")
            # IDE unit test requires spd file path relative to sca file system
            componentName = str(self.spd.get_name())
            sca_file_system_spd_file = "components/" + componentName + "/" + self.spd_file[3:]
            component = sb.launch(sca_file_system_spd_file, impl=self.impl, execparams=execparams,
                                  configure=configure, initialize=initialize)
        self.comp_obj = component.ref
        self.comp = component
    def launch(self, execparams={}, ossiehome=None, configure={}, initialize=True, objType=None):
        """
        Launch the component. The component will be executed as a child process,
        then (optionally) initialized and configured.

        Arguments:
          execparams - Execparams to override on component execution.
          ossiehome  - Base location of REDHAWK installation for finding IDL files.
                       Default location is determined from $OSSIEHOME environment
                       variable.
          configure  - If a dictionary, a set of key/value pairs to override the
                       initial configuration values of the component.
                       If None, skip initial configuration.
          initialize - If true, call initialize() after launching the component.
                       If false, skip initialization.
          objType    - Object type to be launched. Could be a component, device or service.
       """
        if IDE_REF_ENV == None:
            if ossiehome:
                model._idllib = IDLLibrary()
                model._idllib.addSearchPath(str(ossiehome)+'/idl')
            component = sb.launch(self.spd_file, impl=self.impl, execparams=execparams,
                                  configure=configure, initialize=initialize, objType=objType)
        else:
            # spd file path passed in to unit test is relative to current component tests directory (i.e. "..")
            # IDE unit test requires spd file path relative to sca file system
            componentName = str(self.spd.get_name())
            sca_file_system_spd_file = "components/" + componentName + "/" + self.spd_file[3:]
            component = sb.launch(sca_file_system_spd_file, impl=self.impl, execparams=execparams,
                                  configure=configure, initialize=initialize, objType=objType)
        self.comp_obj = component.ref
        self.comp = component
示例#3
0
 def __init__(self, format, numa_policy, shared):
     # TODO: Use NUMA launcher when supported in sandbox for .so components
     launcher = NumaLauncher(numa_policy)
     self.shared = shared
     self.writer = sb.launch(os.path.join(PATH, 'writer/writer.spd.xml'), shared=self.shared)
     self.reader = sb.launch(os.path.join(PATH, 'reader/reader.spd.xml'), shared=self.shared)
     self.writer.connect(self.reader)
     self.container = sb.domainless._getSandbox()._getComponentHost()
示例#4
0
    def setUp(self):
        c_spd_xml = os.path.join(test_dir, 'components', self.component,
                                 self.component + '.spd.xml')
        execparams = {
            'LOGGING_CONFIG_URI': 'file://' + os.getcwd() + '/log4j.ex1'
        }

        self.comp1 = sb.launch(c_spd_xml, execparams=execparams)
        self.comp2 = sb.launch(c_spd_xml, execparams=execparams)
示例#5
0
 def __init__(self, format, numa_policy, shared):
     launcher = NumaLauncher(numa_policy)
     self.shared = shared
     self.writer = sb.launch(os.path.join(PATH, 'writer/writer.spd.xml'),
                             debugger=launcher,
                             shared=self.shared)
     self.reader = sb.launch(os.path.join(PATH, 'reader/reader.spd.xml'),
                             debugger=launcher,
                             shared=self.shared)
     self.writer.connect(self.reader)
     self.container = sb.domainless._getSandbox()._getComponentHost()
    def launch(self,
               execparams={},
               ossiehome=None,
               configure={},
               initialize=True,
               objType=None,
               debugger=None):
        """
        Launch the component. The component will be executed as a child process,
        then (optionally) initialized and configured.

        Arguments:
          execparams - Execparams to override on component execution.
          ossiehome  - Base location of REDHAWK installation for finding IDL files.
                       Default location is determined from $OSSIEHOME environment
                       variable.
          configure  - If a dictionary, a set of key/value pairs to override the
                       initial configuration values of the component.
                       If None, skip initial configuration.
          initialize - If true, call initialize() after launching the component.
                       If false, skip initialization.
          objType    - Object type to be launched. Could be a component, device or service.
       """
        if IDE_REF_ENV == None:
            if ossiehome:
                model._idllib = IDLLibrary()
                model._idllib.addSearchPath(str(ossiehome) + '/idl')
            component = sb.launch(self.spd_file,
                                  impl=self.impl,
                                  execparams=execparams,
                                  configure=configure,
                                  initialize=initialize,
                                  objType=objType,
                                  debugger=debugger)
        else:
            # spd file path passed in to unit test is relative to current component tests directory (i.e. "..")
            # IDE unit test requires spd file path relative to redhawk file system
            componentName = str(self.spd.get_name())
            rh_file_system_spd_file = "components/" + componentName + "/" + self.spd_file[
                3:]
            component = sb.launch(rh_file_system_spd_file,
                                  impl=self.impl,
                                  execparams=execparams,
                                  configure=configure,
                                  initialize=initialize,
                                  objType=objType,
                                  debugger=debugger)
        self.comp_obj = component.ref
        self.comp = component
示例#7
0
    def __init__(self, sizeof, num_items):
        self.comp = None
        if str(sizeof.__name__).find("sizeof_char") != -1:
            self.comp = sb.launch("./components/gr_head_octet/gr_head_octet.spd.xml")
        elif str(sizeof.__name__).find("sizeof_float") != -1:
            self.comp = sb.launch("./components/gr_head_float/gr_head_float.spd.xml")
        elif str(sizeof.__name__).find("sizeof_gr_complex") != -1:
            self.comp = sb.launch("./components/gr_head_complex/gr_head_complex.spd.xml")
        elif str(sizeof.__name__).find("sizeof_int") != -1:
            self.comp = sb.launch("./components/gr_head_int/gr_head_int.spd.xml")
        elif str(sizeof.__name__).find("sizeof_short") != -1:
            self.comp = sb.launch("./components/gr_head_short/gr_head_short.spd.xml")

        if self.comp != None:
            self.comp.num = num_items
示例#8
0
 def setUp(self):
     ossie.utils.testing.ScaComponentTestCase.setUp(self)
     #self.source = sb.launch("../multiout_attachable.spd.xml", impl=self.impl, execparams={"DEBUG_LEVEL":4})
     #self.sink1 = sb.launch("../multiout_attachable.spd.xml", impl=self.impl)#, execparams={"DEBUG_LEVEL":4})
     self.source = sb.launch("../multiout_attachable.spd.xml",
                             impl=self.impl)
     self.sink1 = sb.launch("../multiout_attachable.spd.xml",
                            impl=self.impl)
     self.sink2 = sb.launch("../multiout_attachable.spd.xml",
                            impl=self.impl)
     self.sink3 = sb.launch("../multiout_attachable.spd.xml",
                            impl=self.impl)
     self.sink4 = sb.launch("../multiout_attachable.spd.xml",
                            impl=self.impl)
     sb.start()
    def test_Callbacks(self):
        comp = sb.launch('PyCallbacks')

        # Clear callback log
        comp.callbacks_run = []

        # Simple
        count = comp.count + 1
        comp.count = count
        self.assertEqual(comp.callbacks_run.count('count'), 1)

        # Simple sequence
        constellation = comp.constellation[::2]
        comp.constellation = constellation
        self.assertEqual(comp.callbacks_run.count('constellation'), 1)

        # Struct
        station = {'name': 'WYPR', 'frequency': 88.1}
        comp.station = station
        self.assertEqual(comp.callbacks_run.count('station'), 1)

        # Struct sequence
        servers = comp.servers + [{'host': 'localhost', 'port':8080}]
        comp.servers = servers
        self.assertEqual(comp.callbacks_run.count('servers'), 1)
示例#10
0
    def setUp(self):
        self.dataSource = sb.DataSource()
        self.dataSource._sampleRate = 8000
        self.dataSink = sb.DataSink()
        self.sink = sb.launch("../SinkVITA49.spd.xml", execparams={"DEBUG_LEVEL":SINK_DEBUG_LEVEL})#, debugger=myDebugger)
        self.source = sb.launch("rh.SourceVITA49", execparams={"DEBUG_LEVEL":SOURCE_DEBUG_LEVEL})#, debugger=myDebugger)


        # Setup sink/source settings
        self.sink.network_settings.enable = True
        self.sink.network_settings.ip_address = IP_ADDRESS
        self.sink.network_settings.interface = NIC_INTERFACE
        self.source.interface = NIC_INTERFACE

        self.attaches = 0
        self.detaches = 0
    def test_Services(self):
        service = sb.launch(sb.getSDRROOT() + '/dev/services/BasicService_java/BasicService_java.spd.xml')
        comp = sb.launch('ServiceComponent')
        comp.connect(service)
        self.assertEquals(len(sb.domainless.ConnectionManager.instance().getConnections().keys()), 1)

        # Check that all the parameters got set correctly
        props = service.query([])
        d = dict([(p.id, any.from_any(p.value)) for p in props])
        self.assertEqual(d["SERVICE_NAME"], "BasicService_java_1")
        self.assertEqual(d["PARAM1"], "ABCD")
        self.assertEqual(d["PARAM2"], 42)
        self.assertAlmostEqual(d["PARAM3"], 3.1459)
        self.assertEqual(d["PARAM4"], False)
        self.assertEqual(d["PARAM5"], "Hello World")
        self.assertEqual(d.has_key("PARAM6"), False)
 def test_structPropertyRange(self):
     comp = sb.launch('TestPythonPropsRange')
     comp.api()
     
     # Test upper range
     comp.my_struct_name.struct_octet_name = 255
     comp.my_struct_name.struct_short_name = 32767
     comp.my_struct_name.struct_ushort_name = 65535
     comp.my_struct_name.struct_long_name = 2147483647
     comp.my_struct_name.struct_ulong_name = 4294967295
     comp.my_struct_name.struct_longlong_name = 9223372036854775807
     comp.my_struct_name.struct_ulonglong_name = 18446744073709551615
     self.assertEquals(comp.my_struct_name.struct_octet_name, 255)
     self.assertEquals(comp.my_struct_name.struct_short_name, 32767)
     self.assertEquals(comp.my_struct_name.struct_ushort_name, 65535)
     self.assertEquals(comp.my_struct_name.struct_long_name, 2147483647)
     self.assertEquals(comp.my_struct_name.struct_ulong_name, 4294967295)
     self.assertEquals(comp.my_struct_name.struct_longlong_name, 9223372036854775807)
     self.assertEquals(comp.my_struct_name.struct_ulonglong_name, 18446744073709551615)
     
     # Test lower range
     comp.my_struct_name.struct_octet_name = 0
     comp.my_struct_name.struct_short_name = -32768
     comp.my_struct_name.struct_ushort_name = 0
     comp.my_struct_name.struct_long_name = -2147483648
     comp.my_struct_name.struct_ulong_name = 0
     comp.my_struct_name.struct_longlong_name = -9223372036854775808
     comp.my_struct_name.struct_ulonglong_name = 0
     self.assertEquals(comp.my_struct_name.struct_octet_name, 0)
     self.assertEquals(comp.my_struct_name.struct_short_name, -32768)
     self.assertEquals(comp.my_struct_name.struct_ushort_name, 0)
     self.assertEquals(comp.my_struct_name.struct_long_name, -2147483648)
     self.assertEquals(comp.my_struct_name.struct_ulong_name, 0)
     self.assertEquals(comp.my_struct_name.struct_longlong_name, -9223372036854775808)
     self.assertEquals(comp.my_struct_name.struct_ulonglong_name, 0)
     
     # Test one beyond upper bound
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_struct_name.struct_octet_name.configureValue, 256)
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_struct_name.struct_short_name.configureValue, 32768)
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_struct_name.struct_ushort_name.configureValue, 65536)
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_struct_name.struct_long_name.configureValue, 2147483648)
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_struct_name.struct_ulong_name.configureValue, 4294967296)
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_struct_name.struct_longlong_name.configureValue, 9223372036854775808)
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_struct_name.struct_ulonglong_name.configureValue, 18446744073709551616)
     
     # Test one beyond lower bound
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_struct_name.struct_octet_name.configureValue, -1)
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_struct_name.struct_short_name.configureValue, -32769)
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_struct_name.struct_ushort_name.configureValue, -1)
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_struct_name.struct_long_name.configureValue, -2147483649)
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_struct_name.struct_ulong_name.configureValue, -1)
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_struct_name.struct_longlong_name.configureValue, -9223372036854775809)
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_struct_name.struct_ulonglong_name.configureValue, -1)       
     
     # Makes sure the struct can be set without error
     # NB: This test used to use names instead of ids, which silently failed in 1.8.
     new_value = {'struct_octet': 100, 'struct_short': 101, 'struct_ushort': 102, 'struct_long': 103,
                  'struct_ulong': 104, 'struct_longlong': 105, 'struct_ulonglong': 106}
     comp.my_struct_name = new_value
     self.assertEquals(comp.my_struct_name, new_value)
示例#13
0
 def test_javaDevDomainless(self):
     if not java_support:
         return
     dev = sb.launch('sdr/dev/devices/java_dev/java_dev.spd.xml')
     self.assertEqual(dev.devmgr_id, "")
     self.assertEqual(dev.dom_id, "")
     dev.releaseObject()
示例#14
0
 def test_changeDelay(self):
     self.comp = sb.launch('check_noop')
     self.comp.start()
     self.assertEquals(self.comp.evaluate, 'done')
     self.assertEquals(self.comp.average_delay, 0.0)
     self.comp.evaluate = 'go'
     begin_time = time.time()
     while time.time(
     ) - begin_time < self.timeout and self.comp.evaluate != 'done':
         time.sleep(0.1)
     self.assertAlmostEquals(self.comp.average_delay, 0.1, places=2)
     new_delay = 0.05
     self.comp.noop_delay = new_delay
     self.comp.evaluate = 'go'
     begin_time = time.time()
     while time.time(
     ) - begin_time < self.timeout and self.comp.evaluate != 'done':
         time.sleep(0.1)
     self.assertAlmostEquals(self.comp.average_delay, new_delay, places=2)
     new_delay = 0.15
     self.comp.noop_delay = new_delay
     self.comp.evaluate = 'go'
     begin_time = time.time()
     while time.time(
     ) - begin_time < self.timeout and self.comp.evaluate != 'done':
         time.sleep(0.1)
     self.assertAlmostEquals(self.comp.average_delay, new_delay, places=2)
示例#15
0
    def test_inport_using_componet(self):
        c_spd_xml = test_dir + self.c_dir + '/' + self.c_name + '/' + self.c_name + '.spd.xml'
        print "Test Component:" + c_spd_xml
        test_comp=sb.launch( c_spd_xml, execparams=self.execparams)

        ##
        ## grab port from component... this is corba port
        ##
        iport = test_comp.getPort(self.c_inport)
        self.assertNotEqual(iport,None,"Cannot get Input Port")

        ps = iport._get_statistics()
        self.assertNotEqual(ps,None,"Cannot get Port Statistics")

        s = iport._get_state()
        self.assertNotEqual(s,None,"Cannot get Port State")
        self.assertEqual(s,IDLE,"Invalid Port State")

        streams = iport._get_activeSRIs()
        self.assertNotEqual(streams,None,"Cannot get Streams List")

        ts = bulkio.timestamp.now()
        sri = bulkio.sri.create()
        sri.streamID = "test_port_api"
        iport.pushSRI(sri)
示例#16
0
    def test_push_packet_cplx(self):
        in_sri = bulkio.sri.create()
        in_sri.streamID = "VECTOR-PUSHPACKET-CPLX"
        in_sri.mode = 1
        in_sri.xdelta  = 1/33.0
        dsource=sb.DataSource()
        dsink=sb.DataSink()
        c_spd_xml = test_dir + self.c_dir + '/' + self.c_name + '/' + self.c_name + '.spd.xml'
        print "Test Component:" + c_spd_xml
        test_comp=sb.launch( c_spd_xml, execparams=self.execparams)
        data=self.seq

        dsource.connect(test_comp, providesPortName=self.c_inport )
        test_comp.connect(dsink, providesPortName=self.sink_inport, usesPortName=self.c_outport)
        sb.start()
        dsource.push( data, EOS=True, streamID=in_sri.streamID, sampleRate=33.0, complexData=(in_sri.mode==1) )
        adata=dsink.getData(eos_block=True)
        #print "Result data: " + str(len(adata))
        #print data
        #print adata
        self.assertEqual(len(data),len(adata),"PUSH PACKET CPLX FAILED....Data Vector Mismatch")

        #
        # check sri values
        #
        sri = dsink.sri()
        print "StreamID   in:" + str(in_sri.streamID)+ " arrive:" + str(sri.streamID) 
        self.assertEqual(sri.streamID,in_sri.streamID,"PUSH PACKET CPLX FAILED....SRI StreamID Mismatch")

        print "Mode in:" + str(in_sri.mode)+ " arrive:" + str(sri.mode) 
        self.assertEqual(sri.mode,in_sri.mode,"PUSH PACKET CPLX FAILED....SRI Mode Mismatch")

        print "SampleRate in:" + str(in_sri.xdelta)+ " arrive:" + str(sri.xdelta) 
        self.assertAlmostEqual(sri.xdelta,in_sri.xdelta, 3, msg="PUSH PACKET CPLX FAILED....SRI SampleRate Mismatch")
 def test_javaDevDomainless(self):
     if not java_support:
         return
     dev = sb.launch('sdr/dev/devices/java_dev/java_dev.spd.xml')
     self.assertEqual(dev.devmgr_id, "")
     self.assertEqual(dev.dom_id, "")
     dev.releaseObject()
示例#18
0
    def setUp(self):
        # Launch the device, using the selected implementation
        configure = {
            "msdd_configuration": {
                "msdd_configuration::msdd_ip_address": "192.168.103.250",
                "msdd_configuration::msdd_port": "23"
            },
            "msdd_output_configuration": [{
                "msdd_output_configuration::tuner_number":
                0,
                "msdd_output_configuration::protocol":
                "UDP_SDDS",
                "msdd_output_configuration::ip_address":
                "234.168.103.100",
                "msdd_output_configuration::port":
                0,
                "msdd_output_configuration::vlan":
                0,
                "msdd_output_configuration::enabled":
                True,
                "msdd_output_configuration::timestamp_offset":
                0,
                "msdd_output_configuration::endianess":
                1,
                "msdd_output_configuration::mfp_flush":
                63,
                "msdd_output_configuration::vlan_enable":
                False
            }]
        }

        self.comp = sb.launch(self.spd_file,
                              impl=self.impl,
                              configure=configure,
                              execparams={'DEBUG_LEVEL': DEBUG_LEVEL})
示例#19
0
    def setUp(self):
        # reset device
        subprocess.call(['./reset_msdd', IP_ADDRESS])

        self.temp_files = []

        properties = {
            "msdd": {
                "msdd::ip_address": IP_ADDRESS,
                "msdd::port": "23",
            },
            "time_of_day": {
                "time_of_day::mode": TOD_MODE,
                "time_of_day::tracking_interval": 3.0,
            },
            "tuner_output": [{
                "tuner_output::tuner_number": 0,
                "tuner_output::protocol": "UDP_SDDS",
                "tuner_output::interface": MSDD_INTERFACE,
                "tuner_output::ip_address": "234.168.103.100",
                "tuner_output::port": 0,
                "tuner_output::vlan": 0,
                "tuner_output::enabled": True,
                "tuner_output::timestamp_offset": 0,
                "tuner_output::endianess": 1,
                "tuner_output::mfp_flush": 63,
                "tuner_output::vlan_enable": False
            }],
            'LOGGING_CONFIG_URI':
            'file://' + os.getcwd() + '/OnePpsTests.log.cfg',
        }
        self.comp = sb.launch(self.spd_file,
                              impl=self.impl,
                              properties=properties)
示例#20
0
    def test_Callbacks(self):
        comp = sb.launch('CppCallbacks')
        self.assertEqual(comp.callbacks_run, [])

        # Simple
        count = comp.count + 1
        comp.count = count
        self.assertEqual(comp.callbacks_run.count('count'), 1)

        # Simple sequence
        constellation = comp.constellation[::2]
        comp.constellation = constellation
        self.assertEqual(comp.callbacks_run.count('constellation'), 1)

        # Struct
        station = {'name': 'WYPR', 'frequency': 88.1}
        comp.station = station
        self.assertEqual(comp.callbacks_run.count('station'), 1)

        # Struct sequence
        servers = comp.servers + [{'host': 'localhost', 'port': 8080}]
        comp.servers = servers
        self.assertEqual(comp.callbacks_run.count('servers'), 1)

        # Clear callback tracking and set the same values to ensure that the
        # callbacks do not get triggered
        comp.callbacks_run = []
        comp.count = count
        comp.constellation = constellation
        comp.station = station
        comp.servers = servers
        self.assertEqual(comp.callbacks_run, [])
示例#21
0
def main(argv):
	usage="usage: %prog [options] componentName"
	parser = OptionParser(usage, description="Benchmark a specific redhawk component")
	parser.add_option("-t", "--time", action="store", type="int", dest="time", default=10,
			help="Time for benchmark to calculate confidence", metavar="NUM")
	parser.add_option("-p", "--packets", action="store", type="int", dest="packets", default=100,
			help="# of packets BenchmarkGen pushes out to calculate output rate", metavar="NUM")
	parser.add_option("-s", "--size", action="store", type="int", dest="packetSize", default=1000,
			help="size of the packets pushed out by BenchmarkGen component in redhawk", metavar="NUM")
	parser.add_option("--shift", action="store", type="int", dest="firstSample", default=10,
			help="skips NUM amount of samples before benchmark starts recording values", metavar="NUM")
	parser.add_option("-g", "--showPlot", action="store_true", dest="plotFlag", default=False,
			help="Shows plot at the end of benchmark")
	parser.add_option("--debug", action="store_true", dest="debugFlag", default=False,
			help="Set debug flag on")
	(options, args) = parser.parse_args();
	if len(args) < 1:
		parser.print_help()
		exit()
	try:
		testComponent = sb.launch(args[0])
	except ValueError:
		print 'Component cannot be found.'
		print '	Make sure the component is within your SDR root or'
		print '	give the full path to the xml file of the component'
	except:
		print 'Unknown error: Program exiting'
		exit()
	else:
		print "Testing component: " + args[0]
		bm = Benchmark(testComponent, options.time, options.packets, options.packetSize, options.firstSample, options.plotFlag, options.debugFlag)
		bm.run()
示例#22
0
 def test_MessageMarshalCpp(self):
     snk = sb.MessageSink('my_msg', MyMsg, self.filtering_callback)
     c = sb.launch('huge_msg_cpp',
                   execparams={
                       'LOGGING_CONFIG_URI':
                       'file://' + os.getcwd() + '/logconfig.cfg'
                   })
     c.connect(snk)
     sb.start()
     time.sleep(5)
     fp = None
     try:
         fp = open('foo/bar/test.log', 'r')
     except:
         pass
     if fp != None:
         log_contents = fp.read()
         fp.close()
     try:
         os.remove('foo/bar/test.log')
     except:
         pass
     try:
         os.rmdir('foo/bar')
     except:
         pass
     try:
         os.rmdir('foo')
     except:
         pass
     number_warnings = log_contents.count('Maximum message size exceeded')
     self.assertEquals(number_warnings, 2)
     self.assertEqual(self.messages_passed, 101)
 def test_log_level(self):
     self.comp = sb.launch(self.cname,
                           impl="python",
                           execparams={'DISABLE_CB': 'True'})
     self.comp.ref._set_log_level(CF.LogLevels.OFF)
     lvl = self.comp.ref._get_log_level()
     self.assertEquals(lvl, CF.LogLevels.OFF)
     self.comp.ref._set_log_level(CF.LogLevels.FATAL)
     lvl = self.comp.ref._get_log_level()
     self.assertEquals(lvl, CF.LogLevels.FATAL)
     self.comp.ref._set_log_level(CF.LogLevels.ERROR)
     lvl = self.comp.ref._get_log_level()
     self.assertEquals(lvl, CF.LogLevels.ERROR)
     self.comp.ref._set_log_level(CF.LogLevels.WARN)
     lvl = self.comp.ref._get_log_level()
     self.assertEquals(lvl, CF.LogLevels.WARN)
     self.comp.ref._set_log_level(CF.LogLevels.INFO)
     lvl = self.comp.ref._get_log_level()
     self.assertEquals(lvl, CF.LogLevels.INFO)
     self.comp.ref._set_log_level(CF.LogLevels.DEBUG)
     lvl = self.comp.ref._get_log_level()
     self.assertEquals(lvl, CF.LogLevels.DEBUG)
     self.comp.ref._set_log_level(CF.LogLevels.TRACE)
     lvl = self.comp.ref._get_log_level()
     self.assertEquals(lvl, CF.LogLevels.TRACE)
     self.comp.ref._set_log_level(CF.LogLevels.ERROR)
    def test_Callbacks(self):
        comp = sb.launch('CppCallbacks')
        self.assertEqual(comp.callbacks_run, [])

        # Simple
        count = comp.count + 1
        comp.count = count
        self.assertEqual(comp.callbacks_run.count('count'), 1)

        # Simple sequence
        constellation = comp.constellation[::2]
        comp.constellation = constellation
        self.assertEqual(comp.callbacks_run.count('constellation'), 1)

        # Struct
        station = {'name': 'WYPR', 'frequency': 88.1}
        comp.station = station
        self.assertEqual(comp.callbacks_run.count('station'), 1)

        # Struct sequence
        servers = comp.servers + [{'host': 'localhost', 'port':8080}]
        comp.servers = servers
        self.assertEqual(comp.callbacks_run.count('servers'), 1)

        # Clear callback tracking and set the same values to ensure that the
        # callbacks do not get triggered
        comp.callbacks_run = []
        comp.count = count
        comp.constellation = constellation
        comp.station = station
        comp.servers = servers
        self.assertEqual(comp.callbacks_run, [])
 def test_comp_macro_directories_config_java(self):
     file_loc = os.getcwd()
     self.comp = sb.launch(self.cname,
                           impl="java",
                           execparams={
                               'LOGGING_CONFIG_URI':
                               'file://' + os.getcwd() + '/logconfig.cfg'
                           })
     fp = None
     try:
         fp = open('foo/bar/test.log', 'r')
     except:
         pass
     try:
         os.remove('foo/bar/test.log')
     except:
         pass
     try:
         os.rmdir('foo/bar')
     except:
         pass
     try:
         os.rmdir('foo')
     except:
         pass
     self.assertNotEquals(fp, None)
示例#26
0
 def test_iohelper(self):
     t1 = sb.launch('../components/Python_Ports/Python_Ports.spd.xml')
     t2 = sb.launch('../components/Python_Ports/Python_Ports.spd.xml')
     source = sb.StreamSource()
     destination = sb.StreamSink()
     source.connect(t1, usesPortName="shortOut")
     t1.connect(t2, usesPortName="dataShortOut")
     t2.connect(destination, providesPortName="shortIn")
     try:
         sad = sb.generateSADXML("testsadxml")
     except:
         traceback.print_exc()
         self.fail("Generate SAD raised exception")
     self.assertEqual(sad.find("StreamSource"), -1,
                      "Found StreamSource in SAD")
     self.assertEqual(sad.find("StreamSink"), -1, "Found StreamSink in SAD")
 def setUp(self):
     self.ntuners=20
     self.verbose=False
     # Launch the device, using the selected implementation
     self.comp = sb.launch(self.spd_file,
                           properties={'DEBUG_LEVEL': 3, 'tuners' : self.ntuners },
                           impl=self.impl)
示例#28
0
 def basetest_getTime(self, comp_name):
     comp = sb.launch(comp_name)
     _prop=CF.DataType(id='prop',value=any.to_any(None))
     _retval = comp.query([_prop])
     self.assertEqual(_retval[0].value._v, 'value')
     self.assertEqual(len(_retval), 1)
     
     _retval = comp.query([])
     self.assertEqual(_retval[0].value._v, 'value')
     self.assertEqual(len(_retval), 1)
     
     _retval = comp.query([_prop, rhtime.queryTimestamp()])
     self.assertEqual(_retval[0].value._v, 'value')
     self.assertEqual(len(_retval), 2)
     
     myl = PropertyChangeListener_Receiver()
     t=float(0.5)
     regid=comp.registerPropertyListener( myl._this(), ['prop'],t)
     
     comp.prop = 'hello'
     time.sleep(1)
     
     _retval = comp.query([_prop])
     self.assertEqual(_retval[0].value._v, 'hello')
     self.assertEqual(myl.rcv_event.properties[0].value._v, 'hello')
     
     _retval = comp.query([rhtime.queryTimestamp()])
     self.assertEqual(len(_retval), 1)
     self.assertEqual(_retval[0].value._v.tcstatus, 1)
     _time1 = myl.rcv_event.timestamp.twsec + myl.rcv_event.timestamp.tfsec
     _time2 = _retval[0].value._v.twsec + _retval[0].value._v.tfsec
     between = True
     if _time2 - _time1 < 0.25 or _time2 - _time1 > 0.75:
         between = False
     self.assertEqual(between, True)
示例#29
0
    def testTunerStatus(self):
       self.fei_dev, alloc_params = self.getAllocationContext(ALLOCATE_RCV)

       self.alloc1=frontend.createTunerAllocation(tuner_type="RX_DIGITIZER_CHANNELIZER", 
                                            center_frequency=100e6, 
                                            sample_rate=alloc_params['wbddc_srate'],
                                            sample_rate_tolerance=100.0)
       ret=self.fei_dev.allocateCapacity(self.alloc1)
       self.assertTrue(ret) 
       alloc1_aid = self.alloc1["FRONTEND::tuner_allocation"]["FRONTEND::tuner_allocation::allocation_id"]

       expected=True
       actual=self.fei_dev.frontend_tuner_status[0].enabled
       self.assertEqual(expected,actual, "Tuner status enabled failed")

       expected=True
       actual=self.fei_dev.frontend_tuner_status[0].output_enabled
       self.assertEqual(expected,actual, "Tuner status output enabled failed")

       sink=sb.StreamSink()
       sdds_in=sb.launch('rh.SourceSDDS',
                         properties={'interface': INTERFACE}) 
       sb.start()
       self.fei_dev.connect(sdds_in, connectionId=alloc1_aid,
                            usesPortName='dataSDDS_out') 
       sdds_in.connect(sink,usesPortName="dataShortOut")

       sink_data=None 
       try: 
           sink_data=sink.read(timeout=1.0) 
       except:
           pass 
       self.assertNotEqual( None, sink_data, "MSDD did not produce data for allocation")
       self.assertNotEqual( 0, len(sink_data.data), "MSDD did not produce data for allocation")
 def test_BasicDevice(self):
     dev = sb.launch('sdr/dev/devices/alloc_test/alloc_test.spd.xml')
     self.assertNotEqual(dev, None)
     alloc = dev.allocateCapacity({'callback_test':5})
     self.assertEquals(alloc, True)
     self.assertEquals(dev.callback_value, 5)
     dev.deallocateCapacity({'callback_test':7})
     self.assertEquals(dev.callback_value, 7)
 def test_BasicDevice(self):
     dev = sb.launch('sdr/dev/devices/alloc_test/alloc_test.spd.xml')
     self.assertNotEqual(dev, None)
     alloc = dev.allocateCapacity({'callback_test': 5})
     self.assertEquals(alloc, True)
     self.assertEquals(dev.callback_value, 5)
     dev.deallocateCapacity({'callback_test': 7})
     self.assertEquals(dev.callback_value, 7)
示例#32
0
 def basetest_Now(self, comp_name):
     comp = sb.launch(comp_name)
     self.assertNotEqual(comp, None)
     cur_time = rhtime.now()
     comp_time = comp.rightnow.queryValue()
     _cur_time = cur_time.twsec + cur_time.tfsec
     _comp_time = comp_time.twsec + comp_time.tfsec
     self.assertTrue(abs(_cur_time-_comp_time)<1, True)
示例#33
0
    def test_InvalidCapacity_simple(self):
        from ossie.utils import sb
        self.dev=sb.launch('DevC', impl="java")

        self.assertRaises(CF.Device.InvalidCapacity, self.dev.allocateCapacity, {'myulong': 3 } )
        self.dev.releaseObject()
        self.dev=None
        sb.release()
示例#34
0
 def setUp(self):
     self.alloc1 = None
     self.alloc2 = None
     self.comp = sb.launch(
         self.spd_file,
         properties={
             "DEBUG_LEVEL":
             DEBUG_LEVEL,
             "msdd_configuration": {
                 "msdd_configuration::msdd_ip_address": IP_ADDRESS
             },
             "advanced": {
                 "advanced::allow_internal_allocations": False
             },
             "msdd_output_configuration": [{
                 "msdd_output_configuration::tuner_number":
                 0,
                 "msdd_output_configuration::protocol":
                 "UDP_SDDS",
                 "msdd_output_configuration::ip_address":
                 "239.1.1.1",
                 "msdd_output_configuration::port":
                 29000,
                 "msdd_output_configuration::vlan":
                 0,
                 "msdd_output_configuration::enabled":
                 True,
                 "msdd_output_configuration::timestamp_offset":
                 0,
                 "msdd_output_configuration::endianess":
                 1,
                 "msdd_output_configuration::mfp_flush":
                 63,
                 "msdd_output_configuration::vlan_enable":
                 False
             }, {
                 "msdd_output_configuration::tuner_number":
                 1,
                 "msdd_output_configuration::protocol":
                 "UDP_SDDS",
                 "msdd_output_configuration::ip_address":
                 "239.1.1.2",
                 "msdd_output_configuration::port":
                 29001,
                 "msdd_output_configuration::vlan":
                 0,
                 "msdd_output_configuration::enabled":
                 True,
                 "msdd_output_configuration::timestamp_offset":
                 0,
                 "msdd_output_configuration::endianess":
                 1,
                 "msdd_output_configuration::mfp_flush":
                 63,
                 "msdd_output_configuration::vlan_enable":
                 False
             }]
         })
示例#35
0
    def testFloatPort(self):
        #######################################################################
        # Test FLOAT Functionality
        print "\n**TESTING FLOAT PORT"

        # Define test files
        dataFileIn = "./data.in"
        dataFileOut = "./data.out"

        # Create Test Data File if it doesn't exist
        if not os.path.isfile(dataFileIn):
            with open(dataFileIn, "wb") as dataIn:
                dataIn.write(os.urandom(1024))

        # Read in Data from Test File
        size = os.path.getsize(dataFileIn)
        with open(dataFileIn, "rb") as dataIn:
            data = list(struct.unpack("f" * (size / 4), dataIn.read(size)))

        # Create Components and Connections
        comp = sb.launch("../FileWriter.spd.xml")
        comp.destination_uri = dataFileOut
        comp.advanced_properties.existing_file = "TRUNCATE"

        source = sb.DataSource(bytesPerPush=64, dataFormat="32f")
        source.connect(comp, providesPortName="dataFloat_in")

        # Start Components & Push Data
        sb.start()
        source.push(data)
        time.sleep(2)
        sb.stop()

        # Check that the input and output files are the same
        try:
            self.assertEqual(filecmp.cmp(dataFileIn, dataFileOut), True)
        except self.failureException as e:
            # unpacked bytes may be NaN, which could cause test to fail unnecessarily
            size = os.path.getsize(dataFileOut)
            with open(dataFileOut, "rb") as dataOut:
                data2 = list(struct.unpack("f" * (size / 4), dataOut.read(size)))
            for a, b in zip(data, data2):
                if a != b:
                    if a != a and b != b:
                        print "Difference in NaN format, ignoring..."
                    else:
                        print "FAILED:", a, "!=", b
                        raise e

        # Release the components and remove the generated files
        finally:
            comp.releaseObject()
            source.releaseObject()
            os.remove(dataFileIn)
            os.remove(dataFileOut)

        print "........ PASSED\n"
        return
示例#36
0
    def launch(self,
               execparams={},
               ossiehome=None,
               configure={},
               initialize=True):
        """
        Launch the component. The component will be executed as a child process,
        then (optionally) initialized and configured.

        Arguments:
          execparams - Execparams to override on component execution.
          ossiehome  - Base location of REDHAWK installation for finding IDL files.
                       Default location is determined from $OSSIEHOME environment
                       variable.
          configure  - If a dictionary, a set of key/value pairs to override the
                       initial configuration values of the component.
                       If None, skip initial configuration.
          initialize - If true, call initialize() after launching the component.
                       If false, skip initialization.
        """
        if IDE_REF_ENV == None:
            if ossiehome:
                model._ossiehome = str(ossiehome)
                model._interface_list = importIDL.importStandardIdl(
                    std_idl_path=str(ossiehome) + '/idl',
                    std_idl_include_path=str(ossiehome) + '/idl')
                model._loadedInterfaceList = True
            component = sb.launch(self.spd_file,
                                  impl=self.impl,
                                  execparams=execparams,
                                  configure=configure,
                                  initialize=initialize)
        else:
            # spd file path passed in to unit test is relative to current component tests directory (i.e. "..")
            # IDE unit test requires spd file path relative to sca file system
            componentName = str(self.spd.get_name())
            sca_file_system_spd_file = "components/" + componentName + "/" + self.spd_file[
                3:]
            component = sb.launch(sca_file_system_spd_file,
                                  impl=self.impl,
                                  execparams=execparams,
                                  configure=configure,
                                  initialize=initialize)
        self.comp_obj = component.ref
        self.comp = component
 def test_RFSource_Out(self):
     self.assertEquals(self.got_logmsg, False)
     #######################################################################
     # Make sure start and stop can be called without throwing exceptions
     exc_src = sb.launch('./build/fei_exception_through/tests/fei_exc_src/fei_exc_src.spd.xml')
     self.comp.connect(exc_src,usesPortName='RFSource_out')
     self.comp.start();
     self.comp.stop();
     sb.release()
 def setUp(self):
     # Launch the device, using the selected implementation
     self.filename = 'somefile.tst'
     try:
         os.remove(self.filename)
     except:
         pass
     self.fp = open(self.filename,'w')
     self.comp = sb.launch(self.spd_file, impl=self.impl, stdout=self.fp)
 def setUp(self):
     # Launch the component, using the selected implementation
     self.comp = sb.launch(self.spd_file, impl=self.impl)
     self._filePort = FilePort()
     self._propertyEmitterPort = PropertyEmitterPort()
     self._testableObjectPort = TestableObjectPort()
     self._filePort_2 = FilePort()
     self._propertyEmitterPort_2 = PropertyEmitterPort()
     self._testableObjectPort_2 = TestableObjectPort()
示例#40
0
 def test_InvalidCapacity_simple(self):
     from ossie.utils import sb
     self.dev=sb.launch('DevC', impl="cpp")
     
     res=self.dev.allocateCapacity({'myulong': 3 } )
     self.assertEquals(res,False)
     self.dev.releaseObject()
     self.dev=None
     sb.release()
示例#41
0
    def testDoublePort(self):
        #######################################################################
        # Test DOUBLE Functionality
        print "\n**TESTING DOUBLE PORT"

        #Define test files
        dataFileIn = './data.in'

        #Create Test Data File if it doesn't exist
        #Floats and Doubles are a special case, as
        #NaNs can be generated randomly and will
        #not equal one another
        if not os.path.isfile(dataFileIn):
            with open(dataFileIn, 'wb') as dataIn:
                for i in range(1024 / 8):
                    doubleNum = struct.unpack('d', os.urandom(8))[0]
                    while isnan(doubleNum):
                        doubleNum = struct.unpack('d', os.urandom(8))[0]
                    dataIn.write(struct.pack('d', doubleNum))

        #Read in Data from Test File
        size = os.path.getsize(dataFileIn)
        with open(dataFileIn, 'rb') as dataIn:
            data = list(struct.unpack('d' * (size / 8), dataIn.read(size)))

        #Create Components and Connections
        comp = sb.launch('../FileReader.spd.xml')
        comp.source_uri = dataFileIn
        comp.file_format = 'DOUBLE'

        sink = sb.DataSink()
        comp.connect(sink, usesPortName='dataDouble_out')

        #Start Components & Push Data
        sb.start()
        comp.playback_state = 'PLAY'
        time.sleep(2)
        readData = sink.getData()
        sb.stop()

        #Check that the input and output files are the same
        try:
            self.assertEqual(data, readData)
        except self.failureException as e:
            comp.releaseObject()
            sink.releaseObject()
            os.remove(dataFileIn)
            raise e

        #Release the components and remove the generated files
        comp.releaseObject()
        sink.releaseObject()
        os.remove(dataFileIn)

        print "........ PASSED\n"
        return
 def test_readOnlyProps(self):
     comp = sb.launch('Sandbox')
     comp.api()
     
     # Properties should be able to be read, but not set, and all should throw the saem exception
     exception = None
     comp.readonly_simp
     try:
         comp.readonly_simp = 'bad'
     except Exception, e:
         self.assertEquals(e.__class__, Exception)    
    def test_nestedSoftPkgDeps(self):
        cwd = os.getcwd()
        depLibraryPath = cwd + "/sdr/dom/components/softpkgNestedDep/spdNestedDepLibrary"
        if not depLibraryPath in sys.path:
            sys.path.append(depLibraryPath)
        if os.environ.has_key('PYTHONPATH'):
            os.environ['PYTHONPATH'] = "%s:%s" % (depLibraryPath, os.environ['PYTHONPATH'])
        else:
            os.environ['PYTHONPATH'] = "%s" % (depLibraryPath)

        comp= sb.launch('sdr/dom/components/CommandWrapperNestedSPDDep/CommandWrapperNestedSPDDep.spd.xml')
        self.assertComponentCount(1)
 def test_simplePropertyRange(self):
     comp = sb.launch('TestPythonPropsRange')
     comp.api()
     
     # Test upper range
     comp.my_octet_name = 255
     comp.my_short_name = 32767
     comp.my_ushort_name = 65535
     comp.my_long_name = 2147483647
     comp.my_ulong_name = 4294967295
     comp.my_longlong_name = 9223372036854775807
     comp.my_ulonglong_name = 18446744073709551615
     self.assertEquals(comp.my_octet_name, 255)
     self.assertEquals(comp.my_short_name, 32767)
     self.assertEquals(comp.my_ushort_name, 65535)
     self.assertEquals(comp.my_long_name, 2147483647)
     self.assertEquals(comp.my_ulong_name, 4294967295)
     self.assertEquals(comp.my_longlong_name, 9223372036854775807)
     self.assertEquals(comp.my_ulonglong_name, 18446744073709551615)
     
     # Test lower range
     comp.my_octet_name = 0
     comp.my_short_name = -32768
     comp.my_ushort_name = 0
     comp.my_long_name = -2147483648
     comp.my_ulong_name = 0
     comp.my_longlong_name = -9223372036854775808
     comp.my_ulonglong_name = 0
     self.assertEquals(comp.my_octet_name, 0)
     self.assertEquals(comp.my_short_name, -32768)
     self.assertEquals(comp.my_ushort_name, 0)
     self.assertEquals(comp.my_long_name, -2147483648)
     self.assertEquals(comp.my_ulong_name, 0)
     self.assertEquals(comp.my_longlong_name, -9223372036854775808)
     self.assertEquals(comp.my_ulonglong_name, 0)
     
     # Test one beyond upper bound
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_octet_name.configureValue, 256)
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_short_name.configureValue, 32768)
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_ushort_name.configureValue, 65536)
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_long_name.configureValue, 2147483648)
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_ulong_name.configureValue, 4294967296)
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_longlong_name.configureValue, 9223372036854775808)
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_ulonglong_name.configureValue, 18446744073709551616)
     
     # Test one beyond lower bound
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_octet_name.configureValue, -1)
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_short_name.configureValue, -32769)
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_ushort_name.configureValue, -1)
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_long_name.configureValue, -2147483649)
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_ulong_name.configureValue, -1)
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_longlong_name.configureValue, -9223372036854775809)
     self.assertRaises(type_helpers.OutOfRangeException, comp.my_ulonglong_name.configureValue, -1)                
示例#45
0
    def test_outport_using_component(self):
        c_spd_xml = test_dir + self.c_dir + '/' + self.c_name + '/' + self.c_name + '.spd.xml'
        print "Test Component:" + c_spd_xml
        test_comp=sb.launch( c_spd_xml, execparams=self.execparams)

        ##
        ## grab port from component... this is a corba port
        ##
        oport = test_comp.getPort(self.c_outport)
        self.assertNotEqual(oport,None,"Cannot get Output Port")

        ps = oport._get_statistics()
        self.assertNotEqual(ps,None,"Cannot get Port Statistics")

        dsink=sb.DataSink()
        test_comp.connect(dsink, providesPortName=self.sink_inport, usesPortName=self.c_outport)

        cl = oport._get_connections()
        self.assertNotEqual(cl,None,"Cannot get Connections List")
        self.assertEqual(len(cl),1,"Incorrect Connections List Length")

        test_comp.disconnect(dsink)

        cl = oport._get_connections()
        self.assertNotEqual(cl,None,"Cannot get Connections List")
        self.assertEqual(len(cl),0,"Incorrect Connections List Length")

        ##
        ## Create bulkio base class port object
        ##
        bio = self.bio_out_module("xxx")
        cl = bio._get_connections()
        self.assertNotEqual(cl,None,"Cannot get Connections List")
        self.assertEqual(len(cl),0,"Incorrect Connections List Length")

        ts = bulkio.timestamp.now()
        sri = bulkio.sri.create()
        sri.streamID = "test_port_api"
        bio.pushSRI(sri)

        data=range(50)
        bio.pushPacket(data, ts, False, "test_port_api")
        bio.pushPacket(data, ts, True,  "test_port_api")
        bio.pushPacket(data, ts, False, "unknown_port_api")

        ps = bio._get_statistics()
        self.assertNotEqual(ps,None,"Cannot get Port Statistics")

        cnt = len(bio.sriDict)
        self.assertEqual(cnt,1,"SRI list should be 1")

        bio.enableStats(False)
示例#46
0
    def testCharPort(self):
        #######################################################################
        # Test Char Functionality
        print "\n**TESTING CHAR PORT"

        # Define test files
        dataFileIn = "./data.in"
        dataFileOut = "./data.out"

        # Create Test Data File if it doesn't exist
        if not os.path.isfile(dataFileIn):
            with open(dataFileIn, "wb") as dataIn:
                dataIn.write(os.urandom(1024))

        # Read in Data from Test File
        size = os.path.getsize(dataFileIn)
        with open(dataFileIn, "rb") as dataIn:
            data = list(struct.unpack("b" * size, dataIn.read(size)))

        # Create Components and Connections
        comp = sb.launch("../FileWriter.spd.xml")
        comp.destination_uri = dataFileOut
        comp.advanced_properties.existing_file = "TRUNCATE"

        source = sb.DataSource(bytesPerPush=64, dataFormat="8t")
        source.connect(comp, providesPortName="dataChar_in")

        # Start Components & Push Data
        sb.start()
        source.push(data)
        time.sleep(2)
        sb.stop()

        # Check that the input and output files are the same
        try:
            self.assertEqual(filecmp.cmp(dataFileIn, dataFileOut), True)
        except self.failureException as e:
            comp.releaseObject()
            source.releaseObject()
            os.remove(dataFileIn)
            os.remove(dataFileOut)
            raise e

        # Release the components and remove the generated files
        comp.releaseObject()
        source.releaseObject()
        os.remove(dataFileIn)
        os.remove(dataFileOut)

        print "........ PASSED\n"
        return
 def test_componentInit(self):        
     # Bad descriptors
     self.assertRaises(TypeError, sb.launch)
     self.assertRaises(ValueError, sb.launch, "test_name")
             
     # Make sure only one instance name and refid can be used
     comp = sb.launch(self.test_comp, "comp")
     comp.api()
     refid = comp._refid
     self.assertRaises(ValueError, sb.launch, self.test_comp, "comp")
     self.assertRaises(ValueError, sb.launch, self.test_comp, "new_comp", refid)
     
     # Only 1 component should be running
     self.assertComponentCount(1)
 def test_cpp_flush(self):
     comp = sb.launch('../components/sri_changed_cpp/sri_changed_cpp.spd.xml')
     self.assertNotEqual(comp,None)
     source=sb.DataSource(blocking=False)
     source.connect(comp)
     source.start()
     for i in range(1000):
         source.push(range(100))
     comp.start()
     time.sleep(1)
     self.assertEquals(comp.verified,True)
     self.assertEquals(comp.changed,True)
     self.assertEquals(len(comp.ports[0].ref._get_statistics().keywords),1)
     self.assertEquals(comp.ports[0].ref._get_statistics().keywords[0].id,'timeSinceLastFlush')
 def test_float_to_complex_2 (self):
     src_data_0 = [0, 1, -1, 3, -3, 2, -4, -2]
     src_data_1 = [0, 0, 0, 4, -4, 4, -4, 4]
     expected_result = (0, 1, -1, 3+4j, -3-4j, 2+4j, -4-4j, -2+4j)
     src0 = sb.DataSource()
     src1 = sb.DataSource()
     op = sb.launch('../components/float_to_complex_2i/float_to_complex_2i.spd.xml')
     dst = gr.vector_sink_c ()
     src0.connect(op, providesPortName='real_float_in')
     src1.connect(op, providesPortName='imag_float_in')
     op.connect(dst)
     sb.start()
     src0.push(src_data_0, EOS=True)
     src1.push(src_data_1, EOS=True)
     actual_result = dst.data ()
     self.assertComplexTuplesAlmostEqual (expected_result, actual_result)
示例#50
0
	def __init__(self, testComponent, time=10, packets=100, packetSize=1000, firstSample=10, showPlot=0, debug=0):
		# initilizing the benchmark generator component
		self.bc = sb.launch('BenchmarkGen')
		self.bc.packets_per_time_avg = packets 
		self.bc.packet_size = packetSize
	
		# test component loaded up
		self.bc.connect(testComponent)
		
		# class variables
		self.bmTime = time
		self.showPlot = showPlot
		self.debug = debug
		self.samplesAway = firstSample
		self.samples = []
		self.outputRates = []
		self.times = []
    def test_outport_api(self):
        ##print self.ctx
        c_spd_xml = test_dir + self.c_dir + '/' + self.c_name + '/' + self.c_name + '.spd.xml'
	print c_spd_xml
        test_comp=sb.launch( c_spd_xml, execparams=self.execparams)

        ##
        ## grab port from component... this is a corba port 
        ##
        oport = test_comp.getPort(self.c_outport)
        self.assertNotEqual(oport,None,"Cannot get Output Port")

        ps = oport._get_statistics()
        self.assertNotEqual(ps,None,"Cannot get Port Statistics")

        ## Missing in Python bulkio interface port class
        ##s = oport._get_state()
        ##self.assertNotEqual(s,None,"Cannot get Port State")

        ##
        ## bulkio base class
        ##
        bio = self.bio_out_module("xxx")
        cl = bio._get_connections()
        self.assertNotEqual(cl,None,"Cannot get Connections List")
        self.assertEqual(len(cl),0,"Incorrect Connections List Length")
        
        ts = bulkio.timestamp.now()
        sri = bulkio.sri.create()
        sri.streamID = "test_port_api"
        bio.pushSRI(sri)

        data=range(50)
        bio.pushPacket(data, ts, False, "test_port_api")
        bio.pushPacket(data, ts, True,  "test_port_api")
        bio.pushPacket(data, ts, False, "unknown_port_api")

        ps = bio._get_statistics()
        self.assertNotEqual(ps,None,"Cannot get Port Statistics")

        cnt = len(bio.sriDict)
        self.assertEqual(cnt,0,"SRI list should be 0")

        bio.enableStats(False)
 def startTest(self, client='sinksocket',portType='octet'):
     self.assertNotEqual(self.comp, None)
     self.src = sb.DataSource()
     self.sink = sb.DataSink()
     self.sourceSocket = self.comp
     self.sinkSocket = sb.launch('../../sinksocket/sinksocket.spd.xml')
     
     if client=='sinksocket':
         self.client = self.sinkSocket
         self.server = self.sourceSocket
     else:
         self.server = self.sinkSocket
         self.client = self.sourceSocket
     
     sinkSocktName = 'data%s_in'%portType.capitalize()
     #print self.sinkSocket.api()
     #print self.sink.api()
     self.src.connect(self.sinkSocket, sinkSocktName)
     self.sourceSocket.connect(self.sink, None, 'data%s_out'%portType.capitalize())
示例#53
0
    def testXmlPort(self):
        #######################################################################
        # Test XML Functionality
        print "\n**TESTING XML PORT"

        # Create Test Data
        dataFileOut = "./data.out"

        with open("data.xml", "rb") as file:
            inputData = file.read()

        # Connect DataSource to FileWriter
        comp = sb.launch("../FileWriter.spd.xml")
        comp.destination_uri = dataFileOut
        comp.advanced_properties.existing_file = "TRUNCATE"

        source = sb.DataSource(bytesPerPush=64, dataFormat="xml")
        source.connect(comp, providesPortName="dataXML_in")

        # Start Components & Push Data
        sb.start()
        source.push(inputData)
        time.sleep(2)
        sb.stop()

        # Check that the input and output files are the same
        try:
            self.assertEqual(filecmp.cmp("./data.xml", dataFileOut), True)
        except self.failureException as e:
            comp.releaseObject()
            source.releaseObject()
            os.remove(dataFileOut)
            raise e

        # Release the components and remove the generated files
        comp.releaseObject()
        source.releaseObject()
        os.remove(dataFileOut)

        print "........ PASSED\n"
        return
 def test_comp_macro_directories_config_java(self):
     file_loc = os.getcwd()
     self.comp = sb.launch(self.cname, impl="java", execparams={'LOGGING_CONFIG_URI':'file://'+os.getcwd()+'/logconfig.cfg'} )
     fp = None
     try:
         fp = open('foo/bar/test.log','r')
     except:
         pass
     try:
         os.remove('foo/bar/test.log')
     except:
         pass
     try:
         os.rmdir('foo/bar')
     except:
         pass
     try:
         os.rmdir('foo')
     except:
         pass
     self.assertNotEquals(fp, None)
    def test_push_packet(self):
        ##print self.ctx
        dsource=sb.DataSource()
        dsink=sb.DataSink()
        c_spd_xml = test_dir + self.c_dir + '/' + self.c_name + '/' + self.c_name + '.spd.xml'
	print c_spd_xml
        test_comp=sb.launch( c_spd_xml, execparams=self.execparams)
        if self.seq:
            data=self.seq

        cmp_data = data
        if self.cmpData:
            cmp_data = self.cmpData

        dsource.connect(test_comp, providesPortName=self.c_inport )
        test_comp.connect(dsink, providesPortName=self.sink_inport, usesPortName=self.c_outport)
        sb.start()
        dsource.push(data,EOS=True)
        dest_data=dsink.getData(eos_block=True)
        sb.stop()
        self.assertEqual(data, dest_data)
 def test_illegalPropertyNames(self):
     comp = sb.launch(self.test_comp)
     comp.api()
         
     self.initValues(comp)
     
     # Makes sure that no getters cause exceptions
     comp.escape__simple
     comp.escape__struct.es__1
     comp.escape__struct.es__2
     comp.escape__struct.normal
     comp.my_struct.es__3
     comp.my_struct_seq
     comp.escape__structseq
     comp.my_struct_seq[0].simp__bad
     comp.my_struct_seq[1].simp_bool
     comp.escape__structseq[0].val__1
     comp.escape__structseq[1].val_2
     
     # Makes sure that no setters cause exceptions
     comp.escape__simple = 1234
     comp.escape__struct.es__1 = 5678
     comp.escape__struct.es__2 = 4321
     comp.escape__struct.normal = 8765
     comp.my_struct.es__3 = 333
     comp.my_struct_seq[0].simp_bool = True
     comp.my_struct_seq[1].simp__bad = 11
     comp.escape__structseq[0].val_2 = "test" 
     comp.escape__structseq[1].val__1 = 22        
     
     # Makes sure that values got set properly
     self.assertEquals(comp.escape__simple, 1234)
     self.assertEquals(comp.escape__struct.es__1, 5678)
     self.assertEquals(comp.escape__struct.es__2, 4321)
     self.assertEquals(comp.escape__struct.normal, 8765)
     self.assertEquals(comp.my_struct.es__3, 333)
     self.assertEquals(comp.my_struct_seq[0].simp_bool, True)
     self.assertEquals(comp.my_struct_seq[1].simp__bad, 11)
     self.assertEquals(comp.escape__structseq[0].val_2, "test")
     self.assertEquals(comp.escape__structseq[1].val__1, 22)
    def test_log_callback(self):
        self.comp = sb.launch(self.cname, impl="python", instanceName="TestLoggingAPI_1" )
        cfg = "log4j.rootLogger=ERROR,STDOUT,pse\n" + \
            "# Direct log messages to STDOUT \n" + \
            "log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender\n" + \
            "log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout\n" + \
            "log4j.appender.STDOUT.layout.ConversionPattern=@@@COMPONENT.NAME@@@\n" + \
            "# Direct log messages to event channel\n" + \
            "log4j.appender.pse=org.ossie.logging.RH_LogEventAppender\n" + \
            "log4j.appender.pse.name_context=TEST_APPENDER\n" + \
            "log4j.appender.pse.event_channel=TEST_EVT_CH1\n" + \
            "log4j.appender.pse.producer_id=PRODUCER1\n" + \
            "log4j.appender.pse.producer_name=THE BIG CHEESE\n" + \
            "log4j.appender.pse.layout=org.apache.log4j.PatternLayout\n" + \
            "log4j.appender.pse.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c:%L - %m%n\n"

        exp_cfg = "log4j.rootLogger=ERROR,STDOUT,pse\n" + \
            "# Direct log messages to STDOUT \n" + \
            "log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender\n" + \
            "log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout\n" + \
            "log4j.appender.STDOUT.layout.ConversionPattern=TestLoggingAPI_1\n" + \
            "# Direct log messages to event channel\n" + \
            "log4j.appender.pse=org.ossie.logging.RH_LogEventAppender\n" + \
            "log4j.appender.pse.name_context=TEST_APPENDER\n" + \
            "log4j.appender.pse.event_channel=TEST_EVT_CH1\n" + \
            "log4j.appender.pse.producer_id=PRODUCER1\n" + \
            "log4j.appender.pse.producer_name=THE BIG CHEESE\n" + \
            "log4j.appender.pse.layout=org.apache.log4j.PatternLayout\n" + \
            "log4j.appender.pse.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c:%L - %m%n\n"

        # change log level, callback will intercept
        orig = self.comp.ref._get_log_level()
        self.comp.ref._set_log_level( CF.LogLevels.TRACE )
        lvl = self.comp.ref._get_log_level()
        self.assertEquals( lvl, orig )

        # change config
        c_cfg=self.comp.ref.setLogConfig(cfg)
        self.assertEquals( self.comp.new_log_cfg, exp_cfg)