scripts: twister: testinstance: store run id between builds
Cache value of run id between builds. Save it in file and later load during next build. Signed-off-by: Piotr Kosycarz <piotr.kosycarz@nordicsemi.no>
This commit is contained in:
parent
47da4e2e76
commit
a3d0c63797
1 changed files with 17 additions and 7 deletions
|
@ -55,7 +55,6 @@ class TestInstance:
|
||||||
self.retries = 0
|
self.retries = 0
|
||||||
|
|
||||||
self.name = os.path.join(platform.name, testsuite.name)
|
self.name = os.path.join(platform.name, testsuite.name)
|
||||||
self.run_id = self._get_run_id()
|
|
||||||
self.dut = None
|
self.dut = None
|
||||||
if testsuite.detailed_test_id:
|
if testsuite.detailed_test_id:
|
||||||
self.build_dir = os.path.join(outdir, platform.name, testsuite.name)
|
self.build_dir = os.path.join(outdir, platform.name, testsuite.name)
|
||||||
|
@ -64,6 +63,7 @@ class TestInstance:
|
||||||
source_dir_rel = testsuite.source_dir_rel.rsplit(os.pardir+os.path.sep, 1)[-1]
|
source_dir_rel = testsuite.source_dir_rel.rsplit(os.pardir+os.path.sep, 1)[-1]
|
||||||
self.build_dir = os.path.join(outdir, platform.name, source_dir_rel, testsuite.name)
|
self.build_dir = os.path.join(outdir, platform.name, source_dir_rel, testsuite.name)
|
||||||
|
|
||||||
|
self.run_id = self._get_run_id()
|
||||||
self.domains = None
|
self.domains = None
|
||||||
|
|
||||||
self.run = False
|
self.run = False
|
||||||
|
@ -85,12 +85,22 @@ class TestInstance:
|
||||||
|
|
||||||
def _get_run_id(self):
|
def _get_run_id(self):
|
||||||
""" generate run id from instance unique identifier and a random
|
""" generate run id from instance unique identifier and a random
|
||||||
number"""
|
number
|
||||||
|
If exist, get cached run id from previous run."""
|
||||||
hash_object = hashlib.md5(self.name.encode())
|
run_id = ""
|
||||||
random_str = f"{random.getrandbits(64)}".encode()
|
run_id_file = os.path.join(self.build_dir, "run_id.txt")
|
||||||
hash_object.update(random_str)
|
if os.path.exists(run_id_file):
|
||||||
return hash_object.hexdigest()
|
with open(run_id_file, "r") as fp:
|
||||||
|
run_id = fp.read()
|
||||||
|
else:
|
||||||
|
hash_object = hashlib.md5(self.name.encode())
|
||||||
|
random_str = f"{random.getrandbits(64)}".encode()
|
||||||
|
hash_object.update(random_str)
|
||||||
|
run_id = hash_object.hexdigest()
|
||||||
|
os.makedirs(self.build_dir, exist_ok=True)
|
||||||
|
with open(run_id_file, 'w+') as fp:
|
||||||
|
fp.write(run_id)
|
||||||
|
return run_id
|
||||||
|
|
||||||
def add_missing_case_status(self, status, reason=None):
|
def add_missing_case_status(self, status, reason=None):
|
||||||
for case in self.testcases:
|
for case in self.testcases:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue