From 952830ab12fe41a266d7edea2bf5d632b9426d4a Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Fri, 20 Dec 2019 01:19:27 +0100 Subject: [PATCH] ttfw_idf: IDFApp: add method to get SHA256(elf file) --- tools/ci/python_packages/ttfw_idf/IDFApp.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/ci/python_packages/ttfw_idf/IDFApp.py b/tools/ci/python_packages/ttfw_idf/IDFApp.py index 386ab1679..209cfcb07 100644 --- a/tools/ci/python_packages/ttfw_idf/IDFApp.py +++ b/tools/ci/python_packages/ttfw_idf/IDFApp.py @@ -14,7 +14,7 @@ """ IDF Test Applications """ import subprocess - +import hashlib import json import os import sys @@ -151,6 +151,7 @@ class IDFApp(App.BaseApp): self.idf_path = self.get_sdk_path() self.binary_path = self.get_binary_path(app_path, config_name, target) self.elf_file = self._get_elf_file_path(self.binary_path) + self._elf_file_sha256 = None assert os.path.exists(self.binary_path) if self.IDF_DOWNLOAD_CONFIG_FILE not in os.listdir(self.binary_path): if self.IDF_FLASH_ARGS_FILE not in os.listdir(self.binary_path): @@ -319,6 +320,16 @@ class IDFApp(App.BaseApp): return partition_table + def get_elf_sha256(self): + if self._elf_file_sha256: + return self._elf_file_sha256 + + sha256 = hashlib.sha256() + with open(self.elf_file, 'rb') as f: + sha256.update(f.read()) + self._elf_file_sha256 = sha256.hexdigest() + return self._elf_file_sha256 + class Example(IDFApp): def _get_sdkconfig_paths(self):