def test_keywords_retrieval_long(self): filename = 'bf-kw-test.out' self._tempfiles.append(filename) bf = bluefile_helpers.BlueFileWriter(filename, 'dataLong') kdata = 2147483648L kws = props_from_dict({'TEST_KW': kdata}) sid = 'streamID' srate = 5e6 sri = bulkio.sri.create('test_stream', srate) sri.mode = False sri.blocking = False sri.keywords = kws bf.start() bf.pushSRI(sri) tmpData = range(0, 1024) bf.pushPacket(tmpData, bulkio.timestamp.now(), True, sid) # Read back the timecode from the output file hdr, data = bluefile.read(filename, ext_header_type=list) sri = bluefile_helpers.hdr_to_sri(hdr, sid) srid = ossie.properties.props_to_dict(sri.keywords) self.assertEqual(kdata, srid['TEST_KW']) self.assertEqual(type(kdata), type(srid['TEST_KW']))
def _createtempfile(self, name): #Populate hdr (header) and data filename = 'test_bluefile_%s.tmp' % name self._tempfiles.append(filename) #filename = self._tempfileName(name) data = numpy.arange(1024) hdr = bluefile.header(1000, 'SI') bluefile.write(filename, hdr, data) #populate ext (extended header) mkdata = 3 mykw = props_from_dict({'mykeyword': mkdata}) bf = bluefile_helpers.BlueFileWriter(filename, 'dataLong') srate = 5e6 sri = bulkio.sri.create('test_stream', srate) sri.mode = False sri.blocking = False sri.keywords = mykw bf.start() bf.pushSRI(sri) tmpData = range(0, 1024) srid = ossie.properties.props_to_dict(sri.keywords) return filename
def testBlueShortPortSwapped(self): ####################################################################### # Test Bluefile Swapped SHORT Functionality print "\n**TESTING BLUEFILE Swapped + SHORT PORT" #Define test files dataFileIn = './bluefile.in' dataFileInSwap = './bluefile.in.swap' #Create Test Data File if it doesn't exist if not os.path.isfile(dataFileIn): tmpSink = bluefile_helpers.BlueFileWriter(dataFileIn, BULKIO__POA.dataShort) tmpSink.start() tmpSri = createSri('bluefileShortSwapped', 5000) #kwVal = 1234 #kwSwap = swap([kwVal], 'long')[0] #tmpSri.keywords = props_from_dict({'TEST_KW':kwSwap}) tmpSri.keywords = props_from_dict({'TEST_KW': 1234}) tmpSink.pushSRI(tmpSri) tmpTs = createTs() #tmpSink.pushPacket(swap(range(1024),'short'), tmpTs, True, 'bluefileShortSwapped') tmpSink.pushPacket(range(1024), tmpTs, True, 'bluefileShortSwapped') #Read in Data from Test File, modify header, and rewrite hdr, d = bluefile.read(dataFileIn, dict) hdr['file_name'] = dataFileInSwap hdr['head_rep'] = 'IEEE' hdr['data_rep'] = 'IEEE' bluefile.write(dataFileInSwap, hdr, d) #Read in Data from Swapped Test File hdr, d = bluefile.read(dataFileInSwap, dict) data = list(d) keywords = hdr['ext_header'] #Create Components and Connections comp = sb.launch('../FileReader.spd.xml') comp.source_uri = dataFileInSwap comp.file_format = 'BLUEFILE' sink = sb.DataSink() comp.connect(sink, usesPortName='dataShort_out') #Start Components & Push Data sb.start() comp.playback_state = 'PLAY' time.sleep(2) readData = sink.getData() readKeywords = props_to_dict(sink.sri().keywords) 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) os.remove(dataFileInSwap) raise e #Check that the keywords are the same try: self.assertEqual(keywords, readKeywords) except self.failureException as e: comp.releaseObject() sink.releaseObject() os.remove(dataFileIn) os.remove(dataFileInSwap) raise e #Release the components and remove the generated files comp.releaseObject() sink.releaseObject() os.remove(dataFileIn) os.remove(dataFileInSwap) print "........ PASSED\n" return