def test_serialize_resmodel(self): r.initialize_resource_model(self.ts) self.t1.resmodel[1].add_request(1) self.t2.resmodel[1].add_read_request(2) self.t2.resmodel['serial I/O'].add_request(2) self.t3.resmodel['serial I/O'].add_request(3) for t in self.ts: s.write_xml(s.task(t), self.f) self.f.seek(0) x = s.load(self.f) self.assertIsInstance(x.resmodel, r.ResourceRequirements) self.assertEqual(len(x.resmodel), len(t.resmodel)) self.assertEqual(x.resmodel.keys(), t.resmodel.keys()) for res_id in x.resmodel: self.assertEqual(x.resmodel[res_id].max_reads, t.resmodel[res_id].max_reads) self.assertEqual(x.resmodel[res_id].max_writes, t.resmodel[res_id].max_writes) self.assertEqual(x.resmodel[res_id].max_requests, t.resmodel[res_id].max_requests) self.assertEqual(x.resmodel[res_id].max_read_length, t.resmodel[res_id].max_read_length) self.assertEqual(x.resmodel[res_id].max_write_length, t.resmodel[res_id].max_write_length) self.assertEqual(x.resmodel[res_id].max_length, t.resmodel[res_id].max_length) self.f.seek(0) self.f.truncate()
def test_serialize_task(self): for t in self.ts: s.write_xml(s.task(t), self.f) self.f.seek(0) x = s.load(self.f) self.assertIsInstance(x, m.SporadicTask) self.assertEqual(x.cost, t.cost) self.assertEqual(x.deadline, t.deadline) self.assertEqual(x.period, t.period) self.assertEqual(x.id, t.id) self.f.seek(0) self.f.truncate()