diff options
| author | Bjoern Brandenburg <bbb@mpi-sws.org> | 2012-09-30 03:33:40 -0400 |
|---|---|---|
| committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2012-11-24 09:30:02 -0500 |
| commit | 01251da14f0d3fb2bf4ed2299a70998ff3aa5a1f (patch) | |
| tree | 962c6c78b8a442e702be703c5bebd39219c47f0b | |
| parent | 47ca70df678bc698c51a1f8f2dfbc2112add13a9 (diff) | |
TaskSystem.copy() should make deep copies
Otherwise, the resource model will not be copied correctly, which
can lead to wrong results if parameters are inflated to account
for overheads.
| -rw-r--r-- | schedcat/model/tasks.py | 2 | ||||
| -rw-r--r-- | tests/model.py | 18 |
2 files changed, 18 insertions, 2 deletions
diff --git a/schedcat/model/tasks.py b/schedcat/model/tasks.py index a6d6d11..f7fb9b1 100644 --- a/schedcat/model/tasks.py +++ b/schedcat/model/tasks.py | |||
| @@ -143,5 +143,5 @@ class TaskSystem(list): | |||
| 143 | return max([t.wss for t in self]) | 143 | return max([t.wss for t in self]) |
| 144 | 144 | ||
| 145 | def copy(self): | 145 | def copy(self): |
| 146 | ts = TaskSystem([copy.copy(t) for t in self]) | 146 | ts = TaskSystem((copy.deepcopy(t) for t in self)) |
| 147 | return ts | 147 | return ts |
diff --git a/tests/model.py b/tests/model.py index 60c7cb4..341abb5 100644 --- a/tests/model.py +++ b/tests/model.py | |||
| @@ -18,7 +18,7 @@ class Tasks(unittest.TestCase): | |||
| 18 | self.assertTrue(self.t1.implicit_deadline()) | 18 | self.assertTrue(self.t1.implicit_deadline()) |
| 19 | self.assertFalse(self.t2.implicit_deadline()) | 19 | self.assertFalse(self.t2.implicit_deadline()) |
| 20 | self.assertFalse(self.t3.implicit_deadline()) | 20 | self.assertFalse(self.t3.implicit_deadline()) |
| 21 | 21 | ||
| 22 | self.assertTrue(self.t1.constrained_deadline()) | 22 | self.assertTrue(self.t1.constrained_deadline()) |
| 23 | self.assertTrue(self.t2.constrained_deadline()) | 23 | self.assertTrue(self.t2.constrained_deadline()) |
| 24 | self.assertFalse(self.t3.implicit_deadline()) | 24 | self.assertFalse(self.t3.implicit_deadline()) |
| @@ -80,6 +80,22 @@ class Tasks(unittest.TestCase): | |||
| 80 | self.assertEqual(req.max_read_length, 4) | 80 | self.assertEqual(req.max_read_length, 4) |
| 81 | self.assertEqual(req.max_length, 10) | 81 | self.assertEqual(req.max_length, 10) |
| 82 | 82 | ||
| 83 | def test_copy(self): | ||
| 84 | ts = m.TaskSystem([ | ||
| 85 | m.SporadicTask(10, 100), | ||
| 86 | ]) | ||
| 87 | r.initialize_resource_model(ts) | ||
| 88 | ts[0].resmodel[0].add_request(10) | ||
| 89 | |||
| 90 | ts2 = ts.copy() | ||
| 91 | ts[0].resmodel[0].add_request(30) | ||
| 92 | |||
| 93 | self.assertEqual(ts[0].resmodel[0].max_length, 30) | ||
| 94 | self.assertEqual(ts[0].resmodel[0].max_requests, 2) | ||
| 95 | |||
| 96 | self.assertEqual(ts2[0].resmodel[0].max_length, 10) | ||
| 97 | self.assertEqual(ts2[0].resmodel[0].max_requests, 1) | ||
| 98 | |||
| 83 | 99 | ||
| 84 | class Serialization(unittest.TestCase): | 100 | class Serialization(unittest.TestCase): |
| 85 | def setUp(self): | 101 | def setUp(self): |
