def tearDown(self): self.comp.releaseObject() sb.release() # Try to clean up the event channel, if it was created context = None try: channel = self._root.resolve( URI.stringToName('TEST_APPENDER/TEST_EVT_CH1')) channel = channel._narrow(CosEventChannelAdmin.EventChannel) channel.destroy() except: pass # Clean up naming context, too try: context = self._root.resolve(URI.stringToName('TEST_APPENDER')) context = context._narrow(CosNaming.NamingContext) self._root.unbind(URI.stringToName('TEST_APPENDER')) context.destroy() except: pass # Do all application shutdown before calling the base class tearDown, # or failures will probably occur. scatest.CorbaTestCase.tearDown(self)
def testBasicBehavior(self): ####################################################################### # Make sure start and stop can be called without throwing exceptions self.comp.start() alloc = frontend.createTunerAllocation(tuner_type='RX_DIGITIZER',allocation_id='master',center_frequency=100) listen_alloc = frontend.createTunerListenerAllocation('master','slave') another_listen_alloc = frontend.createTunerListenerAllocation('master','another_slave') self.comp.allocateCapacity(alloc) self.comp.allocateCapacity(listen_alloc) self.comp.allocateCapacity(another_listen_alloc) master=sb.DataSink() slave=sb.DataSink() another_slave=sb.DataSink() self.comp.connect(master,connectionId='master') self.comp.connect(slave,connectionId='slave') self.comp.connect(another_slave,connectionId='another_slave') time.sleep(3) self.assertEquals(master.eos(),False) self.assertEquals(slave.eos(),False) self.assertEquals(another_slave.eos(),False) self.comp.deallocateCapacity(listen_alloc) self.assertEquals(master.eos(),False) self.assertEquals(slave.eos(),True) self.assertEquals(another_slave.eos(),False) self.comp.deallocateCapacity(alloc) self.assertEquals(master.eos(),True) self.assertEquals(slave.eos(),True) self.assertEquals(another_slave.eos(),True) sb.release() self.fp.close() self.fp = open(self.filename,'r') stuff = self.fp.read() self.fp.close() self.assertEquals(stuff.find('the application attempted to invoke an operation on a nil reference'), -1)
def tearDown(self): self.comp.releaseObject() sb.release() # Do all application shutdown before calling the base class tearDown, # or failures will probably occur. scatest.CorbaTestCase.tearDown(self)
def tearDown(self): for fname in self.temp_files: try: os.remove(fname) except: pass sb.release()
def tearDown(self): for tempfile in self._tempfiles: try: os.unlink(tempfile) except: pass sb.release()
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()
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()
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 tearDown(self): # Clean up all sandbox artifacts created during test sb.release() if self.uclient: if self.uclient.sock: try: self.uclient.sock.close() except: traceback.print_exc() del (self.uclient)
def tearDown(self): # Clean up all sandbox artifacts created during test sb.release() try: self.fp.close() except: pass try: os.remove(self.filename) except: pass
def test_deallocate_overage_java(self): from ossie.utils import sb self.dev=sb.launch('DevC', impl="java",configure={'myulong': 3 } ) res=self.dev.allocateCapacity({'myulong': 3 } ) self.assertEquals(res,True) a=[ CF.DataType(id='myulong', value=CORBA.Any(CORBA.TC_ulong,3)), CF.DataType(id='myulong', value=CORBA.Any(CORBA.TC_ulong,3))] self.assertRaises(CF.Device.InvalidCapacity, self.dev.deallocateCapacity, a) self.dev.releaseObject() self.dev=None sb.release()
def tearDown(self): try: if self.alloc1: self.comp.deallocateCapacity(alloc1) except: pass try: if self.alloc2: self.comp.deallocateCapacity(alloc2) except: pass # Clean up all sandbox artifacts created during test sb.release()
def tearDown(self): try: if self.alloc2 and self.fei_dev: self.fei_dev.deallocateCapacity(self.alloc2) except: pass try: if self.alloc1 and self.fei_dev: self.fei_dev.deallocateCapacity(self.alloc1) except: pass # Clean up all sandbox artifacts created during test sb.release()
def testBasicBehavior(self): ####################################################################### # Make sure start and stop can be called without throwing exceptions sb.start() alloc = frontend.createTunerAllocation(tuner_type='RX_DIGITIZER',allocation_id='master',center_frequency=100) listen_alloc = frontend.createTunerListenerAllocation('master','slave') another_listen_alloc = frontend.createTunerListenerAllocation('master','another_slave') self.comp.allocateCapacity(alloc) self.comp.allocateCapacity(listen_alloc) self.comp.allocateCapacity(another_listen_alloc) master = sb.StreamSink() slave = sb.StreamSink() another_slave = sb.StreamSink() self.comp.connect(master,connectionId='master') self.comp.connect(slave,connectionId='slave') self.comp.connect(another_slave,connectionId='another_slave') def get_eos(streamSink, **kwargs): streamData = streamSink.read(**kwargs) if streamData: return streamData.eos return False time.sleep(1) self.assertEquals(get_eos(master), False) self.assertEquals(get_eos(slave), False) self.assertEquals(get_eos(another_slave), False) self.comp.deallocateCapacity(listen_alloc) self.assertEquals(get_eos(master), False) # Save result so we dont call read() twice after eos. eos_slave = get_eos(slave, timeout=1, eos=True) self.assertEquals(eos_slave, True) self.assertEquals(get_eos(another_slave), False) self.comp.deallocateCapacity(alloc) self.assertEquals(get_eos(master, timeout=1, eos=True), True) self.assertEquals(eos_slave, True) self.assertEquals(get_eos(another_slave, timeout=1, eos=True), True) sb.release() self.fp.close() self.fp = open(self.filename,'r') stuff = self.fp.read() self.fp.close() self.assertEquals(stuff.find('the application attempted to invoke an operation on a nil reference'), -1)
def testReleaseWhileStreaming(self): problem = False self.octetConnect() sink = sb.DataSinkSDDS() self.comp.connect(sink) sb.start() fakeData = 1024 * [10] self.source.push(1000 * fakeData, EOS=False, streamID=self.id(), sampleRate=1.0, complexData=False, loop=True) time.sleep(1) try: sb.release() except: e = sys.exc_info()[0] print(type(e.message)) print("Unexpected error: %s", e) problem = True self.assertTrue(not problem, "exception was raised while releasing the component")
def tearDown(self): # Clean up all sandbox artifacts created during test ossie.utils.sandbox.local.log.removeHandler(self.var) sb.release()
def terminate(self): sb.release()
def tearDown(self): # Clean up all sandbox artifacts created during test sb.release()
def tearDown(self): #Tear down the rest of the object. ossie.utils.testing.ScaComponentTestCase.tearDown(self) sb.release() del(self.mserver) del(self.userver)
def main(argv): sadfile = '' inputfile = '' dataformat = '' samplerate = '' iscomplex = False outputfile = '' try: opts, args = getopt.getopt(argv, "hs:i:f:r:co:", [ "sadfile=", "ifile=", "dataformat=", "samplerate=", "complex", "ofile=" ]) except getopt.GetoptError: print 'runWaveform.py -s <sadfile> -i <inputfile> -f <dataFormat> -r <sampleRate> -c -o <outputfile>' sys.exit(2) for opt, arg in opts: #print 'evaluating opt - ',opt,' arg - ',arg if opt == '-h': print 'runWaveform.py -s <sadfile> -i <inputfile> -f <dataFormat> -r <sampleRate> -c o <outputfile>' sys.exit() elif opt in ("-s", "--sadfile"): sadfile = arg elif opt in ("-i", "--ifile"): inputfile = arg elif opt in ("-f", "--dataformat"): dataformat = arg elif opt in ("-r", "--samplerate"): samplerate = arg elif opt in ("-c", "--complex"): iscomplex = True elif opt in ("-o", "--ofile"): outputfile = arg print 'setting outputfile', outputfile print 'Processing ', inputfile, " through waveform - ", sadfile sadFile = open(sadfile) sadFileString = sadFile.read() usesPort = '' usesComponent = '' providesPort = '' providesComponent = '' sadXML = parsers.sad.parseString(sadFileString) if sadXML.get_externalports(): for port in sadXML.get_externalports().get_port(): if port.get_usesidentifier(): usesPort = port.get_usesidentifier() usesComponent = port.get_componentinstantiationref() elif port.get_providesidentifier(): providesPort = port.get_providesidentifier() providesComponent = port.get_componentinstantiationref() if not usesPort and not providesPort: print 'Need uses and provides external ports' sys.exit() else: print 'No external ports' sys.exit() print usesPort, providesPort if not usesPort or not providesPort: print 'Require external uses & provides port' sys.exit() sb.loadSADFile(sadfile) fileSource = sb.FileSource(filename=inputfile, dataFormat=dataformat, sampleRate=samplerate) fileSink = sb.FileSink(filename=outputfile) #FIXME check file type matches external port fileSource.connect(sb.getComponent(providesComponent.get_refid()), providesPortName=providesPort) sb.getComponent(usesComponent.get_refid()).connect(fileSink, usesPortName=usesPort) sb.start() fileSink.waitForEOS() sb.stop() sb.release()
def tearDown(self): # Clean up all sandbox artifacts created during test sb.release()
def tearDown(self): sb.release() sb.setDEBUG(False) os.environ['SDRROOT'] = globalsdrRoot
def tearDown(self): sb.release()
def testMultipleStreamsDifferentPort(self): self.octetConnect() short_source = sb.DataSource() short_source.connect(self.comp, usesPortName='shortOut') sink = sb.DataSinkSDDS() ad_cb = SddsAttachDetachCB() sink.registerAttachCallback(ad_cb.attach_cb) sink.registerDetachCallback(ad_cb.detach_cb) self.comp.connect(sink) sb.start() goodData1 = 1024 * [1] deckedData = 512 * [2] goodData2 = 512 * [3] # No data pushed, no attaches or detaches self.assertEqual(len(ad_cb.get_attach()), 0, "Should not have received any attaches") # Push one good packet and confirm it was received self.source.push(goodData1, EOS=False, streamID=self.id(), sampleRate=1.0, complexData=False, loop=False) self.assertEqual( goodData1, list(struct.unpack('1024B', self.getPacket()[-1024:]))) # Since we pushed, we should get an attach, no detach self.assertEqual(len(ad_cb.get_attach()), 1, "Should have received 1 attach total") # Push a new stream, it should get decked, and disabled, confirm we receive no data and still have only a single attach short_source.push(deckedData, EOS=False, streamID="Decked Stream", sampleRate=1.0, complexData=False, loop=False) self.assertEqual( len(self.getPacket()), 0, "Should not have passed on new stream, stream already active") self.assertEqual(len(ad_cb.get_attach()), 1, "Should have received 1 attach total") # Push an EOS which should cause a detach, the decked stream to become active and the goodData pushed and us to have another attach called. self.source.push(goodData1, EOS=True, streamID=self.id(), sampleRate=1.0, complexData=False, loop=False) self.assertEqual( goodData1, list(struct.unpack('1024B', self.getPacket()[-1024:]))) time.sleep(2) self.assertEqual(len(ad_cb.get_attach()), 2, "Should have received 2 attach total") # Push decked data and EOS It. short_source.push(deckedData, EOS=True, streamID="Decked Stream", sampleRate=1.0, complexData=False, loop=False) self.assertEqual( deckedData, list(struct.unpack('!512H', self.getPacket()[-1024:]))) # Send a new stream, which means a new attach short_source.push(goodData2, EOS=False, streamID="New Stream", sampleRate=1.0, complexData=False, loop=False) self.assertEqual( goodData2, list(struct.unpack('!512H', self.getPacket()[-1024:]))) self.assertEqual(len(ad_cb.get_attach()), 3, "Should have received 3 attach total") # Tear stuff down, confirm we get the final detach sb.release() self.assertEqual(len(ad_cb.get_attach()), 3, "Should have received 3 attach total") self.assertEqual(len(ad_cb.get_detach()), 3, "Should have received 3 detach total")
def testMultipleStreamsSamePort(self): self.octetConnect() sink = sb.DataSinkSDDS() ad_cb = SddsAttachDetachCB() sink.registerAttachCallback(ad_cb.attach_cb) sink.registerDetachCallback(ad_cb.detach_cb) self.comp.connect(sink) sb.start() goodData1 = 1024 * [1] deckedStream = 1024 * [2] goodData2 = 1024 * [3] # No data pushed, no attaches or detaches self.assertEqual( len(ad_cb.get_attach()), 0, "Should not have received any attaches but we have: %s " % len(ad_cb.get_attach())) # self.assertEqual(len(ad_cb.get_detach()), 0, "Should not have received any detaches") # Push one good packet and confirm it was received self.source.push(goodData1, EOS=False, streamID=self.id(), sampleRate=1.0, complexData=False, loop=False) self.assertEqual( goodData1, list(struct.unpack('1024B', self.getPacket()[-1024:]))) # Since we pushed, we should get an attach, no detach self.assertEqual(len(ad_cb.get_attach()), 1, "Should have received 1 attach total") # self.assertEqual(len(ad_cb.get_detach()), 0, "Should not have received any detaches") # Push a new stream, it should get ignored, confirm we receive no data and still have only a single attach self.source.push(deckedStream, EOS=False, streamID="Decked Stream", sampleRate=1.0, complexData=False, loop=False) self.assertEqual( len(self.getPacket()), 0, "Should not have passed on new stream, stream already active") self.assertEqual(len(ad_cb.get_attach()), 1, "Should have received 1 attach total") # self.assertEqual(len(ad_cb.get_detach()), 0, "Should not have received any detaches") # Push an EOS which should cause a detach self.source.push(goodData1, EOS=True, streamID=self.id(), sampleRate=1.0, complexData=False, loop=False) self.assertEqual( goodData1, list(struct.unpack('1024B', self.getPacket()[-1024:]))) time.sleep(1) self.source.push(deckedStream, EOS=False, streamID="Decked Stream", sampleRate=1.0, complexData=False, loop=False) time.sleep(1) self.assertEqual(len(ad_cb.get_attach()), 2, "Should have received 2 attach total") # self.assertEqual(len(ad_cb.get_detach()), 1, "Should have received 1 detach total") # Send a new stream, which means a new attach self.source.push(goodData2, EOS=False, streamID="Another on the deck stream", sampleRate=1.0, complexData=False, loop=False) self.assertEqual( deckedStream, list(struct.unpack('1024B', self.getPacket()[-1024:]))) self.assertEqual(len(ad_cb.get_attach()), 2, "Should have received 2 attach total") # self.assertEqual(len(ad_cb.get_detach()), 1, "Should have received 1 detach total") # Tear stuff down, confirm we get the final detach sb.release() self.assertEqual(len(ad_cb.get_attach()), 2, "Should have received 2 attach total") self.assertEqual(len(ad_cb.get_detach()), 2, "Should have received 2 detach total")
def tearDown(self): sb.release() scatest.CorbaTestCase.tearDown(self)