diff options
Diffstat (limited to 'bestflags')
-rw-r--r-- | bestflags/hill_climb_best_neighbor.py | 6 | ||||
-rw-r--r-- | bestflags/mock_task.py | 21 | ||||
-rw-r--r-- | bestflags/task.py | 2 |
3 files changed, 21 insertions, 8 deletions
diff --git a/bestflags/hill_climb_best_neighbor.py b/bestflags/hill_climb_best_neighbor.py index 409b42c9..4f59bca3 100644 --- a/bestflags/hill_climb_best_neighbor.py +++ b/bestflags/hill_climb_best_neighbor.py @@ -41,6 +41,12 @@ class HillClimbingBestBranch(Generation): Generation.__init__(self, exe_set, parents) self._specs = specs + # This variable will be used, by the Next method, to generate the tasks for + # the next iteration. This self._next_task contains the best task in the + # current iteration and it will be set by the IsImproved method. The tasks + # of the next iteration are the neighbor of self._next_task. + self._next_task = None + def IsImproved(self): """True if this generation has improvement over its parent generation. diff --git a/bestflags/mock_task.py b/bestflags/mock_task.py index e1d91e29..144b7747 100644 --- a/bestflags/mock_task.py +++ b/bestflags/mock_task.py @@ -28,17 +28,21 @@ class MockTask(object): identifier: the identifier of this task. cost: the mock cost of this task. - The _pre_cost field stored the cost. Once this task is performed, i.e., by - calling the work method, the _cost field will have this cost. The stage - field verifies that the module being tested and the unitest are in the - same stage. If the unitest does not care about cost of this task, the cost - parameter should be leaved blank. + The _cost field stored the cost. Once this task is performed, i.e., by + calling the work method or by setting the result from other task, the + _cost field will have this cost. The stage field verifies that the module + being tested and the unitest are in the same stage. If the unitest does + not care about cost of this task, the cost parameter should be leaved + blank. """ self._identifier = identifier - self._pre_cost = cost + self._cost = cost self._stage = stage + # Indicate that this method has not been performed yet. + self._performed = False + def __eq__(self, other): if isinstance(other, MockTask): return (self._identifier == other.GetIdentifier(self._stage) and @@ -52,10 +56,11 @@ class MockTask(object): def SetResult(self, stage, cost): assert stage == self._stage self._cost = cost + self._performed = True def Work(self, stage): assert stage == self._stage - self._cost = self._pre_cost + self._performed = True def GetResult(self, stage): assert stage == self._stage @@ -65,7 +70,7 @@ class MockTask(object): """Indicates whether the task has been performed.""" assert stage == self._stage - return '_cost' in self.__dict__ + return self._performed def LogSteeringCost(self): pass diff --git a/bestflags/task.py b/bestflags/task.py index f1ac417f..e41b0aea 100644 --- a/bestflags/task.py +++ b/bestflags/task.py @@ -101,6 +101,8 @@ class Task(object): self._exe_cost = None self._checksum = None self._image = None + self._file_length = None + self._text_length = None def __eq__(self, other): """Test whether two tasks are equal. |