Migrate "loadable elf" test from hello_world example to test_apps

This commit is contained in:
Roland Dobai
2020-04-16 14:42:33 +02:00
parent 819f7a4e57
commit 2d709c6384
11 changed files with 105 additions and 42 deletions

View File

@@ -4,7 +4,7 @@
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:#www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import unicode_literals
from io import open
from tiny_test_fw import Utility
import pexpect
@@ -19,10 +21,10 @@ import pexpect
class CustomProcess(object):
def __init__(self, cmd, logfile, verbose):
self.verbose = verbose
self.f = open(logfile, 'wb')
self.f = open(logfile, 'w')
if self.verbose:
Utility.console_log('Starting {} > {}'.format(cmd, self.f.name))
self.pexpect_proc = pexpect.spawn(cmd, timeout=60, logfile=self.f)
self.pexpect_proc = pexpect.spawn(cmd, timeout=60, logfile=self.f, encoding='utf-8')
def __enter__(self):
return self

View File

@@ -368,35 +368,6 @@ class Example(IDFApp):
raise OSError("Failed to find example binary")
class LoadableElfExample(Example):
def __init__(self, app_path, app_files, config_name=None, target=None):
# add arg `app_files` for loadable elf example.
# Such examples only build elf files, so it doesn't generate flasher_args.json.
# So we can't get app files from config file. Test case should pass it to application.
super(IDFApp, self).__init__(app_path)
self.app_files = app_files
self.config_name = config_name
self.target = target
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)
assert os.path.exists(self.binary_path)
def get_binary_path(self, app_path, config_name=None, target=None):
path = self._try_get_binary_from_local_fs(app_path, config_name, target)
if path:
return path
else:
artifacts = Artifacts(self.idf_path,
CIAssignExampleTest.get_artifact_index_file(case_group=CIAssignExampleTest.ExampleGroup),
app_path, config_name, target)
path = artifacts.download_artifact_files(self.app_files)
if path:
return os.path.join(self.idf_path, path)
else:
raise OSError("Failed to find example binary")
class UT(IDFApp):
def get_binary_path(self, app_path, config_name=None, target=None):
if not config_name:
@@ -437,6 +408,35 @@ class TestApp(Example):
raise OSError("Failed to find example binary")
class LoadableElfTestApp(TestApp):
def __init__(self, app_path, app_files, config_name=None, target=None):
# add arg `app_files` for loadable elf test_app.
# Such examples only build elf files, so it doesn't generate flasher_args.json.
# So we can't get app files from config file. Test case should pass it to application.
super(IDFApp, self).__init__(app_path)
self.app_files = app_files
self.config_name = config_name
self.target = target
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)
assert os.path.exists(self.binary_path)
def get_binary_path(self, app_path, config_name=None, target=None):
path = self._try_get_binary_from_local_fs(app_path, config_name, target, local_build_dir="build_test_apps")
if path:
return path
else:
artifacts = Artifacts(self.idf_path,
CIAssignExampleTest.get_artifact_index_file(case_group=CIAssignExampleTest.TestAppsGroup),
app_path, config_name, target)
path = artifacts.download_artifact_files(self.app_files)
if path:
return os.path.join(self.idf_path, path)
else:
raise OSError("Failed to find the loadable ELF file")
class SSC(IDFApp):
def get_binary_path(self, app_path, config_name=None, target=None):
# TODO: to implement SSC get binary path

View File

@@ -15,7 +15,7 @@ import os
import re
from tiny_test_fw import TinyFW, Utility
from .IDFApp import IDFApp, Example, LoadableElfExample, UT, TestApp # noqa: export all Apps for users
from .IDFApp import IDFApp, Example, LoadableElfTestApp, UT, TestApp # noqa: export all Apps for users
from .IDFDUT import IDFDUT, ESP32DUT, ESP32S2DUT, ESP8266DUT, ESP32QEMUDUT # noqa: export DUTs for users
from .DebugUtils import OCDProcess, GDBProcess # noqa: export DebugUtils for users