aboutsummaryrefslogtreecommitdiff
path: root/bestflags
diff options
context:
space:
mode:
authorYuheng Long <yuhenglong@google.com>2013-08-14 10:17:25 -0700
committerChromeBot <chrome-bot@google.com>2013-08-15 15:51:21 -0700
commit25cdf79e17a73858ffa28db8a5b387210fea9e25 (patch)
treeee03554b03c33028c9e9e8c1fdda3a465bcf3d63 /bestflags
parentd5a0ef17c7a611ff0a8c19e1103ef3c73dc4e195 (diff)
downloadtoolchain-utils-25cdf79e17a73858ffa28db8a5b387210fea9e25.tar.gz
Initiate all the class fields in the init method.
BUG=None TEST=unit testings for the pipeline stage, pipeline workers, generation, steering, task, flag and hill climbing. Change-Id: I170f4c3a719e0b6aedfdbd90aa29803c011c9ba0 Reviewed-on: https://gerrit-int.chromium.org/42835 Reviewed-by: Simon Que <sque@google.com> Reviewed-by: Luis Lozano <llozano@chromium.org> Tested-by: Yuheng Long <yuhenglong@google.com> Commit-Queue: Yuheng Long <yuhenglong@google.com>
Diffstat (limited to 'bestflags')
-rw-r--r--bestflags/hill_climb_best_neighbor.py6
-rw-r--r--bestflags/mock_task.py21
-rw-r--r--bestflags/task.py2
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.