feat(tools): Run Tools related host tests on Win

This commit is contained in:
Marek Fiala
2023-12-08 16:36:05 +01:00
parent 71c6304f71
commit a97e355e74
7 changed files with 659 additions and 204 deletions

View File

@@ -1,8 +1,7 @@
#!/usr/bin/env python
#
# SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
import json
import os
import re
@@ -47,6 +46,12 @@ RISCV_ESP_GDB = 'riscv32-esp-elf-gdb'
ESP_ROM_ELFS = 'esp-rom-elfs'
QEMU_RISCV = 'qemu-riscv32'
QEMU_XTENSA = 'qemu-xtensa'
# Win tools
CMAKE = 'cmake'
NINJA = 'ninja'
IDF_EXE = 'idf-exe'
CCACHE = 'ccache'
DFU_UTIL = 'dfu-util'
def get_version_dict():
@@ -73,7 +78,12 @@ RISCV_ESP_GDB_VERSION = version_dict[RISCV_ESP_GDB]
ESP_ROM_ELFS_VERSION = version_dict[ESP_ROM_ELFS]
QEMU_RISCV_VERSION = version_dict[QEMU_RISCV]
QEMU_XTENSA_VERSION = version_dict[QEMU_XTENSA]
# Win tools
CMAKE_VERSION = version_dict[CMAKE]
NINJA_VERSION = version_dict[NINJA]
IDF_EXE_VERSION = version_dict[IDF_EXE]
CCACHE_VERSION = version_dict[CCACHE]
DFU_UTIL_VERSION = version_dict[DFU_UTIL]
# There are some complex search patterns to detect download snippets
@@ -87,6 +97,8 @@ XTENSA_ELF_ARCHIVE_PATTERN = XTENSA_ELF + '-' \
+ (XTENSA_ELF_VERSION[len('esp-'):] if XTENSA_ELF_VERSION.startswith('esp-') else XTENSA_ELF_VERSION)
# TestUsage takes care of general test setup and executes tests that behaves the same on both platforms
# TestUsage class serves as a parent for classes TestUsageUnix and TestUsageWin
class TestUsage(unittest.TestCase):
@classmethod
@@ -99,10 +111,10 @@ class TestUsage(unittest.TestCase):
mirror_prefix_map = None
if os.path.exists(old_tools_dir):
mirror_prefix_map = 'https://dl.espressif.com/dl/toolchains/preview,file://' + os.path.join(old_tools_dir,
'dist')
mirror_prefix_map += ';https://dl.espressif.com/dl,file://' + os.path.join(old_tools_dir, 'dist')
mirror_prefix_map += ';https://github.com/espressif/.*/releases/download/.*/,file://' + os.path.join(
mirror_prefix_map = 'https://dl.espressif.com/dl/toolchains/preview,file:' + os.path.join(old_tools_dir,
'dist')
mirror_prefix_map += ';https://dl.espressif.com/dl,file:' + os.path.join(old_tools_dir, 'dist')
mirror_prefix_map += ';https://github.com/espressif/.*/releases/download/.*/,file:' + os.path.join(
old_tools_dir, 'dist', '')
if mirror_prefix_map:
print('Using IDF_MIRROR_PREFIX_MAP={}'.format(mirror_prefix_map))
@@ -132,13 +144,13 @@ class TestUsage(unittest.TestCase):
if tool_archive_name is None:
tool_archive_name = tool
self.assertIn('Installing %s@' % tool + tool_version, output)
self.assertRegex(output, re.compile(rf'Downloading \S+/{tool_archive_name}'))
self.assertRegex(output, re.compile(rf'Downloading \S+{tool_archive_name}'))
def assert_tool_not_installed(self, output, tool, tool_version, tool_archive_name=None):
if tool_archive_name is None:
tool_archive_name = tool
self.assertNotIn('Installing %s@' % tool + tool_version, output)
self.assertNotRegex(output, re.compile(rf'Downloading \S+/{tool_archive_name}'))
self.assertNotRegex(output, re.compile(rf'Downloading \S+{tool_archive_name}'))
def run_idf_tools_with_action(self, action):
output_stream = StringIO()
@@ -147,6 +159,129 @@ class TestUsage(unittest.TestCase):
output = output_stream.getvalue()
return output
def test_tools_for_wildcards1(self):
required_tools_installed = 2
output = self.run_idf_tools_with_action(['install', '*gdb*'])
self.assert_tool_not_installed(output, OPENOCD, OPENOCD_VERSION)
self.assert_tool_not_installed(output, RISCV_ELF, RISCV_ELF_VERSION,RISCV_ELF_ARCHIVE_PATTERN)
self.assert_tool_installed(output, RISCV_ESP_GDB, RISCV_ESP_GDB_VERSION)
self.assert_tool_not_installed(output, XTENSA_ELF, XTENSA_ELF_VERSION, XTENSA_ELF_ARCHIVE_PATTERN)
self.assert_tool_not_installed(output, ESP32ULP, ESP32ULP_VERSION)
self.assert_tool_installed(output, XTENSA_ESP_GDB, XTENSA_ESP_GDB_VERSION)
self.assert_tool_not_installed(output, ESP_ROM_ELFS, ESP_ROM_ELFS_VERSION)
self.assertIn('Destination: {}'.format(os.path.join(self.temp_tools_dir, 'dist')), output)
self.assertEqual(required_tools_installed, output.count('Done'))
def test_tools_for_wildcards2(self):
required_tools_installed = 1
output = self.run_idf_tools_with_action(['install', '*gdb*', '--targets=esp32c3'])
self.assert_tool_not_installed(output, OPENOCD, OPENOCD_VERSION)
self.assert_tool_not_installed(output, RISCV_ELF, RISCV_ELF_VERSION, RISCV_ELF_ARCHIVE_PATTERN)
self.assert_tool_installed(output, RISCV_ESP_GDB, RISCV_ESP_GDB_VERSION)
self.assert_tool_not_installed(output, XTENSA_ELF, XTENSA_ELF_VERSION, XTENSA_ELF_ARCHIVE_PATTERN)
self.assert_tool_not_installed(output, ESP32ULP, ESP32ULP_VERSION)
self.assert_tool_not_installed(output, XTENSA_ESP_GDB, XTENSA_ESP_GDB_VERSION)
self.assert_tool_not_installed(output, ESP_ROM_ELFS, ESP_ROM_ELFS_VERSION)
self.assertIn('Destination: {}'.format(os.path.join(self.temp_tools_dir, 'dist')), output)
self.assertEqual(required_tools_installed, output.count('Done'))
def test_tools_for_wildcards3(self):
required_tools_installed = 1
output = self.run_idf_tools_with_action(['install', '*gdb*', '--targets=esp32s3'])
self.assert_tool_not_installed(output, OPENOCD, OPENOCD_VERSION)
self.assert_tool_not_installed(output, RISCV_ELF, RISCV_ELF_VERSION, RISCV_ELF_ARCHIVE_PATTERN)
self.assert_tool_not_installed(output, RISCV_ESP_GDB, RISCV_ESP_GDB_VERSION)
self.assert_tool_not_installed(output, XTENSA_ELF, XTENSA_ELF_VERSION, XTENSA_ELF_ARCHIVE_PATTERN)
self.assert_tool_not_installed(output, ESP32ULP, ESP32ULP_VERSION)
self.assert_tool_installed(output, XTENSA_ESP_GDB, XTENSA_ESP_GDB_VERSION)
self.assert_tool_not_installed(output, ESP_ROM_ELFS, ESP_ROM_ELFS_VERSION)
self.assertIn('Destination: {}'.format(os.path.join(self.temp_tools_dir, 'dist')), output)
self.assertEqual(required_tools_installed, output.count('Done'))
def test_uninstall_option(self):
self.run_idf_tools_with_action(['install', '--targets=esp32'])
test_tool_name = XTENSA_ELF
test_tool_version = 'test_version'
tools_json_new = os.path.join(self.temp_tools_dir, 'tools', 'tools.new.json')
self.run_idf_tools_with_action(
[
'add-version',
'--tool',
test_tool_name,
'--url-prefix',
'http://test.com',
'--version',
test_tool_version,
'--override',
'--checksum-file',
'add_version/checksum.sha256',
'--output',
tools_json_new
])
output = self.run_idf_tools_with_action(['--tools-json', tools_json_new, 'uninstall', '--dry-run'])
self.assertIn('For removing old versions of ' + test_tool_name, output)
output = self.run_idf_tools_with_action(['--tools-json', tools_json_new, 'uninstall'])
self.assertIn(os.path.join(self.temp_tools_dir, 'tools', test_tool_name, XTENSA_ELF_VERSION) + ' was removed.', output)
output = self.run_idf_tools_with_action(['uninstall'])
self.assertEqual('', output)
def test_deactivate(self):
self.run_idf_tools_with_action(['install'])
output = self.run_idf_tools_with_action(['export'])
self.assertIn('export IDF_DEACTIVATE_FILE_PATH=', output, 'No IDF_DEACTIVATE_FILE_PATH exported into environment')
deactivate_file = re.findall(r'(?:IDF_DEACTIVATE_FILE_PATH=")(.*)(?:")', output)[0]
self.assertTrue(os.path.isfile(deactivate_file), 'File {} was not found. '.format(deactivate_file))
self.assertNotEqual(os.stat(self.idf_env_json).st_size, 0, 'File {} is empty. '.format(deactivate_file))
def test_export_recommended_version(self):
always_install_and_recommended_tools = []
for tool in self.tools_dict['tools']:
if tool['install'] != 'always':
continue
for version in tool['versions']:
if version['status'] != 'recommended':
continue
always_install_and_recommended_tools.append({
'name': tool['name'],
'version': version['name']
})
self.run_idf_tools_with_action(['install'])
output = self.run_idf_tools_with_action(['export'])
for tool in always_install_and_recommended_tools:
self.assertIn(os.path.join(tool['name'], tool['version']), output)
def test_export_recommended_version_cmake(self):
tool_to_test = 'cmake'
tool_version = ''
for tool in self.tools_dict['tools']:
if tool['name'] != tool_to_test:
continue
for version in tool['versions']:
if version['status'] == 'recommended':
tool_version = version['name']
break
self.run_idf_tools_with_action(['install'])
self.run_idf_tools_with_action(['install', tool_to_test])
output = self.run_idf_tools_with_action(['export'])
self.assertIn(os.path.join(tool_to_test, tool_version), output)
def test_export_prefer_system_cmake(self):
tool_to_test = 'cmake'
self.run_idf_tools_with_action(['install'])
self.run_idf_tools_with_action(['install', tool_to_test])
# cmake is installed via apt
output = self.run_idf_tools_with_action(['export', '--prefer-system'])
self.assertNotIn(tool_to_test, output)
# TestUsageUnix tests installed tools on UNIX platforms
@unittest.skipIf(sys.platform == 'win32', reason='Tools for UNIX differ')
class TestUsageUnix(TestUsage):
def test_usage_basic(self):
output = self.run_idf_tools_with_action(['list'])
self.assertIn('* %s:' % ESP32ULP, output)
@@ -171,13 +306,9 @@ class TestUsage(unittest.TestCase):
self.assertEqual(required_tools_installed, output.count('Done'))
output = self.run_idf_tools_with_action(['check'])
self.assertIn('version installed in tools directory: ' + ESP32ULP_VERSION, output)
self.assertIn('version installed in tools directory: ' + OPENOCD_VERSION, output)
self.assertIn('version installed in tools directory: ' + RISCV_ELF_VERSION, output)
self.assertIn('version installed in tools directory: ' + XTENSA_ELF_VERSION, output)
self.assertIn('version installed in tools directory: ' + XTENSA_ESP_GDB_VERSION, output)
self.assertIn('version installed in tools directory: ' + RISCV_ESP_GDB_VERSION, output)
self.assertIn('version installed in tools directory: ' + ESP_ROM_ELFS_VERSION, output)
for tool_version in [ESP32ULP_VERSION, OPENOCD_VERSION, RISCV_ELF_VERSION, XTENSA_ELF_VERSION,
XTENSA_ESP_GDB_VERSION, RISCV_ESP_GDB_VERSION, ESP_ROM_ELFS_VERSION]:
self.assertIn('version installed in tools directory: ' + tool_version, output)
output = self.run_idf_tools_with_action(['export'])
self.assertIn('%s/tools/esp32ulp-elf/%s/esp32ulp-elf/bin' %
@@ -240,11 +371,9 @@ class TestUsage(unittest.TestCase):
self.assertEqual(required_tools_installed, output.count('Done'))
output = self.run_idf_tools_with_action(['check'])
self.assertIn('version installed in tools directory: ' + ESP32ULP_VERSION, output)
self.assertIn('version installed in tools directory: ' + XTENSA_ELF_VERSION, output)
self.assertIn('version installed in tools directory: ' + OPENOCD_VERSION, output)
self.assertIn('version installed in tools directory: ' + XTENSA_ESP_GDB_VERSION, output)
self.assertIn('version installed in tools directory: ' + ESP_ROM_ELFS_VERSION, output)
for tool_version in [ESP32ULP_VERSION, OPENOCD_VERSION, XTENSA_ELF_VERSION,
XTENSA_ESP_GDB_VERSION, ESP_ROM_ELFS_VERSION]:
self.assertIn('version installed in tools directory: ' + tool_version, output)
output = self.run_idf_tools_with_action(['export'])
self.assertIn('%s/tools/esp32ulp-elf/%s/esp32ulp-elf/bin' %
@@ -270,16 +399,14 @@ class TestUsage(unittest.TestCase):
self.assert_tool_installed(output, RISCV_ESP_GDB, RISCV_ESP_GDB_VERSION)
self.assert_tool_not_installed(output, XTENSA_ELF, XTENSA_ELF_VERSION, XTENSA_ELF_ARCHIVE_PATTERN)
self.assert_tool_not_installed(output, ESP32ULP, ESP32ULP_VERSION)
self.assert_tool_not_installed(output, XTENSA_ESP_GDB_VERSION, XTENSA_ESP_GDB_VERSION)
self.assert_tool_not_installed(output, XTENSA_ESP_GDB, XTENSA_ESP_GDB_VERSION)
self.assert_tool_installed(output, ESP_ROM_ELFS, ESP_ROM_ELFS_VERSION)
self.assertIn('Destination: {}'.format(os.path.join(self.temp_tools_dir, 'dist')), output)
self.assertEqual(required_tools_installed, output.count('Done'))
output = self.run_idf_tools_with_action(['check'])
self.assertIn('version installed in tools directory: ' + OPENOCD_VERSION, output)
self.assertIn('version installed in tools directory: ' + RISCV_ELF_VERSION, output)
self.assertIn('version installed in tools directory: ' + RISCV_ESP_GDB_VERSION, output)
self.assertIn('version installed in tools directory: ' + ESP_ROM_ELFS_VERSION, output)
for tool_version in [OPENOCD_VERSION, RISCV_ELF_VERSION, RISCV_ESP_GDB_VERSION, ESP_ROM_ELFS_VERSION]:
self.assertIn('version installed in tools directory: ' + tool_version, output)
output = self.run_idf_tools_with_action(['export'])
self.assertIn('%s/tools/openocd-esp32/%s/openocd-esp32/bin' %
@@ -309,10 +436,8 @@ class TestUsage(unittest.TestCase):
self.assertEqual(required_tools_installed, output.count('Done'))
output = self.run_idf_tools_with_action(['check'])
self.assertIn('version installed in tools directory: ' + OPENOCD_VERSION, output)
self.assertIn('version installed in tools directory: ' + XTENSA_ELF_VERSION, output)
self.assertIn('version installed in tools directory: ' + XTENSA_ESP_GDB_VERSION, output)
self.assertIn('version installed in tools directory: ' + ESP_ROM_ELFS_VERSION, output)
for tool_version in [OPENOCD_VERSION, XTENSA_ELF_VERSION, XTENSA_ESP_GDB_VERSION, ESP_ROM_ELFS_VERSION]:
self.assertIn('version installed in tools directory: ' + tool_version, output)
output = self.run_idf_tools_with_action(['export'])
self.assertIn('%s/tools/xtensa-esp-elf/%s/xtensa-esp-elf/bin' %
@@ -344,11 +469,9 @@ class TestUsage(unittest.TestCase):
self.assertEqual(required_tools_installed, output.count('Done'))
output = self.run_idf_tools_with_action(['check'])
self.assertIn('version installed in tools directory: ' + OPENOCD_VERSION, output)
self.assertIn('version installed in tools directory: ' + XTENSA_ELF_VERSION, output)
self.assertIn('version installed in tools directory: ' + XTENSA_ESP_GDB_VERSION, output)
self.assertIn('version installed in tools directory: ' + RISCV_ESP_GDB_VERSION, output)
self.assertIn('version installed in tools directory: ' + ESP_ROM_ELFS_VERSION, output)
for tool_version in [OPENOCD_VERSION, XTENSA_ELF_VERSION, XTENSA_ESP_GDB_VERSION,
RISCV_ESP_GDB_VERSION, ESP_ROM_ELFS_VERSION]:
self.assertIn('version installed in tools directory: ' + tool_version, output)
output = self.run_idf_tools_with_action(['export'])
self.assertIn('%s/tools/openocd-esp32/%s/openocd-esp32/bin' %
@@ -382,125 +505,6 @@ class TestUsage(unittest.TestCase):
self.assertIn('Destination: {}'.format(os.path.join(self.temp_tools_dir, 'dist')), output)
self.assertEqual(required_tools_installed, output.count('Done'))
def test_tools_for_wildcards1(self):
required_tools_installed = 2
output = self.run_idf_tools_with_action(['install', '*gdb*'])
self.assert_tool_not_installed(output, OPENOCD, OPENOCD_VERSION)
self.assert_tool_not_installed(output, RISCV_ELF, RISCV_ELF_VERSION,RISCV_ELF_ARCHIVE_PATTERN)
self.assert_tool_installed(output, RISCV_ESP_GDB, RISCV_ESP_GDB_VERSION)
self.assert_tool_not_installed(output, XTENSA_ELF, XTENSA_ELF_VERSION, XTENSA_ELF_ARCHIVE_PATTERN)
self.assert_tool_not_installed(output, ESP32ULP, ESP32ULP_VERSION)
self.assert_tool_installed(output, XTENSA_ESP_GDB, XTENSA_ESP_GDB_VERSION)
self.assert_tool_not_installed(output, ESP_ROM_ELFS, ESP_ROM_ELFS_VERSION)
self.assertIn('Destination: {}'.format(os.path.join(self.temp_tools_dir, 'dist')), output)
self.assertEqual(required_tools_installed, output.count('Done'))
def test_tools_for_wildcards2(self):
required_tools_installed = 1
output = self.run_idf_tools_with_action(['install', '*gdb*', '--targets=esp32c3'])
self.assert_tool_not_installed(output, OPENOCD, OPENOCD_VERSION)
self.assert_tool_not_installed(output, RISCV_ELF, RISCV_ELF_VERSION, RISCV_ELF_ARCHIVE_PATTERN)
self.assert_tool_installed(output, RISCV_ESP_GDB, RISCV_ESP_GDB_VERSION)
self.assert_tool_not_installed(output, XTENSA_ELF, XTENSA_ELF_VERSION, XTENSA_ELF_ARCHIVE_PATTERN)
self.assert_tool_not_installed(output, ESP32ULP, ESP32ULP_VERSION)
self.assert_tool_not_installed(output, XTENSA_ESP_GDB, XTENSA_ESP_GDB_VERSION)
self.assert_tool_not_installed(output, ESP_ROM_ELFS, ESP_ROM_ELFS_VERSION)
self.assertIn('Destination: {}'.format(os.path.join(self.temp_tools_dir, 'dist')), output)
self.assertEqual(required_tools_installed, output.count('Done'))
def test_tools_for_wildcards3(self):
required_tools_installed = 1
output = self.run_idf_tools_with_action(['install', '*gdb*', '--targets=esp32s3'])
self.assert_tool_not_installed(output, OPENOCD, OPENOCD_VERSION)
self.assert_tool_not_installed(output, RISCV_ELF, RISCV_ELF_VERSION, RISCV_ELF_ARCHIVE_PATTERN)
self.assert_tool_not_installed(output, RISCV_ESP_GDB, RISCV_ESP_GDB_VERSION)
self.assert_tool_not_installed(output, XTENSA_ELF, XTENSA_ELF_VERSION, XTENSA_ELF_ARCHIVE_PATTERN)
self.assert_tool_not_installed(output, ESP32ULP, ESP32ULP_VERSION)
self.assert_tool_installed(output, XTENSA_ESP_GDB, XTENSA_ESP_GDB_VERSION)
self.assert_tool_not_installed(output, ESP_ROM_ELFS, ESP_ROM_ELFS_VERSION)
self.assertIn('Destination: {}'.format(os.path.join(self.temp_tools_dir, 'dist')), output)
self.assertEqual(required_tools_installed, output.count('Done'))
def test_uninstall_option(self):
self.run_idf_tools_with_action(['install', '--targets=esp32'])
test_tool_name = XTENSA_ELF
test_tool_version = 'test_version'
tools_json_new = os.path.join(self.temp_tools_dir, 'tools', 'tools.new.json')
self.run_idf_tools_with_action(
[
'add-version',
'--tool',
test_tool_name,
'--url-prefix',
'http://test.com',
'--version',
test_tool_version,
'--override',
'--checksum-file',
'add_version/checksum.sha256',
'--output',
tools_json_new
])
output = self.run_idf_tools_with_action(['--tools-json', tools_json_new, 'uninstall', '--dry-run'])
self.assertIn('For removing old versions of ' + test_tool_name, output)
output = self.run_idf_tools_with_action(['--tools-json', tools_json_new, 'uninstall'])
self.assertIn(os.path.join(self.temp_tools_dir, 'tools', test_tool_name, XTENSA_ELF_VERSION) + ' was removed.', output)
output = self.run_idf_tools_with_action(['uninstall'])
self.assertEqual('', output)
def test_deactivate(self):
self.run_idf_tools_with_action(['install'])
output = self.run_idf_tools_with_action(['export'])
self.assertIn('export IDF_DEACTIVATE_FILE_PATH=', output, 'No IDF_DEACTIVATE_FILE_PATH exported into environment')
deactivate_file = re.findall(r'(?:IDF_DEACTIVATE_FILE_PATH=")(.*)(?:")', output)[0]
self.assertTrue(os.path.isfile(deactivate_file), 'File {} was not found. '.format(deactivate_file))
self.assertNotEqual(os.stat(self.idf_env_json).st_size, 0, 'File {} is empty. '.format(deactivate_file))
def test_export_recommended_version(self):
always_install_and_recommended_tools = []
for tool in self.tools_dict['tools']:
if tool['install'] != 'always':
continue
for version in tool['versions']:
if version['status'] != 'recommended':
continue
always_install_and_recommended_tools.append({
'name': tool['name'],
'version': version['name']
})
self.run_idf_tools_with_action(['install'])
output = self.run_idf_tools_with_action(['export'])
for tool in always_install_and_recommended_tools:
self.assertIn(f"{tool['name']}/{tool['version']}", output)
def test_export_recommended_version_cmake(self):
tool_to_test = 'cmake'
tool_version = ''
for tool in self.tools_dict['tools']:
if tool['name'] != tool_to_test:
continue
for version in tool['versions']:
if version['status'] == 'recommended':
tool_version = version['name']
break
self.run_idf_tools_with_action(['install'])
self.run_idf_tools_with_action(['install', tool_to_test])
output = self.run_idf_tools_with_action(['export'])
self.assertIn(f'{tool_to_test}/{tool_version}', output)
def test_export_prefer_system_cmake(self):
tool_to_test = 'cmake'
self.run_idf_tools_with_action(['install'])
self.run_idf_tools_with_action(['install', tool_to_test])
# cmake is installed via apt
output = self.run_idf_tools_with_action(['export', '--prefer-system'])
self.assertNotIn(tool_to_test, output)
def test_export_supported_version_cmake(self):
tool_to_test = 'cmake'
self.run_idf_tools_with_action(['install'])
@@ -509,6 +513,380 @@ class TestUsage(unittest.TestCase):
self.assertNotIn(tool_to_test, output)
# TestUsageWin tests installed tools on Windows platforms
@unittest.skipIf(sys.platform != 'win32', reason='Tools for WIN differ')
class TestUsageWin(TestUsage):
def test_usage_basic_win(self):
output = self.run_idf_tools_with_action(['list'])
self.assertIn('* %s:' % ESP32ULP, output)
self.assertIn('- %s (recommended)' % ESP32ULP_VERSION, output)
self.assertIn('* %s:' % OPENOCD, output)
self.assertIn('- %s (recommended)' % OPENOCD_VERSION, output)
self.assertIn('* %s:' % RISCV_ELF, output)
self.assertIn('- %s (recommended)' % RISCV_ELF_VERSION, output)
self.assertIn('* %s:' % XTENSA_ELF, output)
self.assertIn('- %s (recommended)' % XTENSA_ELF_VERSION, output)
required_tools_installed = 12
output = self.run_idf_tools_with_action(['install'])
self.assert_tool_installed(output, OPENOCD, OPENOCD_VERSION)
self.assert_tool_installed(output, RISCV_ELF, RISCV_ELF_VERSION, RISCV_ELF_ARCHIVE_PATTERN)
self.assert_tool_installed(output, XTENSA_ELF, XTENSA_ELF_VERSION, XTENSA_ELF_ARCHIVE_PATTERN)
self.assert_tool_installed(output, ESP32ULP, ESP32ULP_VERSION)
self.assert_tool_installed(output, XTENSA_ESP_GDB, XTENSA_ESP_GDB_VERSION)
self.assert_tool_installed(output, RISCV_ESP_GDB, RISCV_ESP_GDB_VERSION)
self.assert_tool_installed(output, ESP_ROM_ELFS, ESP_ROM_ELFS_VERSION)
self.assert_tool_installed(output, CMAKE, CMAKE_VERSION)
self.assert_tool_installed(output, NINJA, NINJA_VERSION)
self.assert_tool_installed(output, IDF_EXE, IDF_EXE_VERSION)
self.assert_tool_installed(output, CCACHE, CCACHE_VERSION)
self.assert_tool_installed(output, DFU_UTIL, DFU_UTIL_VERSION)
self.assertIn('Destination: {}'.format(os.path.join(self.temp_tools_dir, 'dist')), output)
self.assertEqual(required_tools_installed, output.count('Done'))
output = self.run_idf_tools_with_action(['check'])
for tool_version in [ESP32ULP_VERSION, OPENOCD_VERSION, RISCV_ELF_VERSION, XTENSA_ELF_VERSION,
XTENSA_ESP_GDB_VERSION, RISCV_ESP_GDB_VERSION, ESP_ROM_ELFS_VERSION, CMAKE_VERSION,
NINJA_VERSION, IDF_EXE_VERSION, CCACHE_VERSION, DFU_UTIL_VERSION]:
self.assertIn('version installed in tools directory: ' + tool_version, output)
output = self.run_idf_tools_with_action(['export'])
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'esp32ulp-elf', ESP32ULP_VERSION, 'esp32ulp-elf', 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'xtensa-esp-elf', XTENSA_ELF_VERSION, 'xtensa-esp-elf', 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'openocd-esp32', OPENOCD_VERSION, 'openocd-esp32', 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'riscv32-esp-elf', RISCV_ELF_VERSION, 'riscv32-esp-elf', 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'xtensa-esp-elf-gdb', XTENSA_ESP_GDB_VERSION, 'xtensa-esp-elf-gdb', 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'riscv32-esp-elf-gdb', RISCV_ESP_GDB_VERSION, 'riscv32-esp-elf-gdb', 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'esp-rom-elfs', ESP_ROM_ELFS_VERSION
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', CMAKE, CMAKE_VERSION, 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', NINJA, NINJA_VERSION
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', IDF_EXE, IDF_EXE_VERSION
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', CCACHE, CCACHE_VERSION, 'ccache-4.8-windows-x86_64'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', DFU_UTIL, DFU_UTIL_VERSION, 'dfu-util-0.11-win64'
), output)
output = self.run_idf_tools_with_action(['list', '--outdated'])
self.assertEqual('', output)
tools_json_outdated = os.path.join(self.temp_tools_dir, 'tools', 'tools.outdated.json')
new_version = 'zzzzzz'
self.run_idf_tools_with_action(
[
'add-version',
'--tool',
XTENSA_ELF,
'--url-prefix',
'http://test.com',
'--version',
new_version,
'--override',
'--checksum-file',
'add_version/checksum.sha256',
'--output',
tools_json_outdated
])
output = self.run_idf_tools_with_action(
[
'--tools-json',
tools_json_outdated,
'list',
'--outdated'
])
self.assertIn((f'{XTENSA_ELF}: version {XTENSA_ELF_VERSION} '
f'is outdated by {new_version}'), output)
def test_tools_for_esp32_win(self):
required_tools_installed = 9
output = self.run_idf_tools_with_action(['install', '--targets=esp32'])
self.assert_tool_installed(output, XTENSA_ELF, XTENSA_ELF_VERSION, XTENSA_ELF_ARCHIVE_PATTERN)
self.assert_tool_installed(output, OPENOCD, OPENOCD_VERSION)
self.assert_tool_installed(output, ESP32ULP, ESP32ULP_VERSION)
self.assert_tool_installed(output, XTENSA_ESP_GDB, XTENSA_ESP_GDB_VERSION)
self.assert_tool_not_installed(output, RISCV_ELF, RISCV_ELF_VERSION, RISCV_ELF_ARCHIVE_PATTERN)
self.assert_tool_not_installed(output, RISCV_ESP_GDB, RISCV_ESP_GDB_VERSION)
self.assert_tool_installed(output, ESP_ROM_ELFS, ESP_ROM_ELFS_VERSION)
self.assert_tool_installed(output, CMAKE, CMAKE_VERSION)
self.assert_tool_installed(output, NINJA, NINJA_VERSION)
self.assert_tool_installed(output, IDF_EXE, IDF_EXE_VERSION)
self.assert_tool_installed(output, CCACHE, CCACHE_VERSION)
self.assert_tool_not_installed(output, DFU_UTIL, DFU_UTIL_VERSION)
self.assertIn('Destination: {}'.format(os.path.join(self.temp_tools_dir, 'dist')), output)
self.assertEqual(required_tools_installed, output.count('Done'))
output = self.run_idf_tools_with_action(['check'])
for tool_version in [ESP32ULP_VERSION, OPENOCD_VERSION, XTENSA_ELF_VERSION, XTENSA_ESP_GDB_VERSION,
ESP_ROM_ELFS_VERSION, CMAKE_VERSION, NINJA_VERSION, IDF_EXE_VERSION, CCACHE_VERSION]:
self.assertIn('version installed in tools directory: ' + tool_version, output)
self.assertNotIn('version installed in tools directory: ' + DFU_UTIL_VERSION, output)
output = self.run_idf_tools_with_action(['export'])
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'esp32ulp-elf', ESP32ULP_VERSION, 'esp32ulp-elf', 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'xtensa-esp-elf', XTENSA_ELF_VERSION, 'xtensa-esp-elf', 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'openocd-esp32', OPENOCD_VERSION, 'openocd-esp32', 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'xtensa-esp-elf-gdb', XTENSA_ESP_GDB_VERSION, 'xtensa-esp-elf-gdb', 'bin'
), output)
self.assertNotIn(os.path.join(
self.temp_tools_dir, 'tools', 'riscv32-esp-elf', RISCV_ELF_VERSION, 'riscv32-esp-elf', 'bin'
), output)
self.assertNotIn(os.path.join(
self.temp_tools_dir, 'tools', 'riscv32-esp-elf-gdb', RISCV_ESP_GDB_VERSION, 'riscv32-esp-elf-gdb', 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'esp-rom-elfs', ESP_ROM_ELFS_VERSION,
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', CMAKE, CMAKE_VERSION, 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', NINJA, NINJA_VERSION
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', IDF_EXE, IDF_EXE_VERSION
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', CCACHE, CCACHE_VERSION, 'ccache-4.8-windows-x86_64'
), output)
self.assertNotIn(os.path.join(
self.temp_tools_dir, 'tools', DFU_UTIL, DFU_UTIL_VERSION, 'dfu-util-0.11-win64'
), output)
def test_tools_for_esp32c3_win(self):
required_tools_installed = 8
output = self.run_idf_tools_with_action(['install', '--targets=esp32c3'])
self.assert_tool_installed(output, OPENOCD, OPENOCD_VERSION)
self.assert_tool_installed(output, RISCV_ELF, RISCV_ELF_VERSION, RISCV_ELF_ARCHIVE_PATTERN)
self.assert_tool_installed(output, RISCV_ESP_GDB, RISCV_ESP_GDB_VERSION)
self.assert_tool_not_installed(output, XTENSA_ELF, XTENSA_ELF_VERSION, XTENSA_ELF_ARCHIVE_PATTERN)
self.assert_tool_not_installed(output, ESP32ULP, ESP32ULP_VERSION)
self.assert_tool_not_installed(output, XTENSA_ESP_GDB, XTENSA_ESP_GDB_VERSION)
self.assert_tool_installed(output, ESP_ROM_ELFS, ESP_ROM_ELFS_VERSION)
self.assert_tool_installed(output, CMAKE, CMAKE_VERSION)
self.assert_tool_installed(output, NINJA, NINJA_VERSION)
self.assert_tool_installed(output, IDF_EXE, IDF_EXE_VERSION)
self.assert_tool_installed(output, CCACHE, CCACHE_VERSION)
self.assert_tool_not_installed(output, DFU_UTIL, DFU_UTIL_VERSION)
self.assertIn('Destination: {}'.format(os.path.join(self.temp_tools_dir, 'dist')), output)
self.assertEqual(required_tools_installed, output.count('Done'))
output = self.run_idf_tools_with_action(['check'])
for tool_version in [OPENOCD_VERSION, RISCV_ELF_VERSION, RISCV_ESP_GDB_VERSION, ESP_ROM_ELFS_VERSION,
CMAKE_VERSION, NINJA_VERSION, IDF_EXE_VERSION, CCACHE_VERSION]:
self.assertIn('version installed in tools directory: ' + tool_version, output)
self.assertNotIn('version installed in tools directory: ' + DFU_UTIL_VERSION, output)
output = self.run_idf_tools_with_action(['export'])
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'openocd-esp32', OPENOCD_VERSION, 'openocd-esp32', 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'riscv32-esp-elf', RISCV_ELF_VERSION, 'riscv32-esp-elf', 'bin'
), output)
self.assertNotIn(os.path.join(
self.temp_tools_dir, 'tools', 'esp32ulp-elf', ESP32ULP_VERSION, 'esp32ulp-elf', 'bin'
), output)
self.assertNotIn(os.path.join(
self.temp_tools_dir, 'tools', 'xtensa-esp-elf', XTENSA_ELF_VERSION, 'xtensa-esp-elf', 'bin'
), output)
self.assertNotIn(os.path.join(
self.temp_tools_dir, 'tools', 'xtensa-esp-elf-gdb', XTENSA_ESP_GDB_VERSION, 'xtensa-esp-elf-gdb', 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'esp-rom-elfs', ESP_ROM_ELFS_VERSION,
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', CMAKE, CMAKE_VERSION, 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', NINJA, NINJA_VERSION
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', IDF_EXE, IDF_EXE_VERSION
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', CCACHE, CCACHE_VERSION, 'ccache-4.8-windows-x86_64'
), output)
self.assertNotIn(os.path.join(
self.temp_tools_dir, 'tools', DFU_UTIL, DFU_UTIL_VERSION, 'dfu-util-0.11-win64'
), output)
def test_tools_for_esp32s2_win(self):
required_tools_installed = 11
output = self.run_idf_tools_with_action(['install', '--targets=esp32s2'])
self.assert_tool_installed(output, XTENSA_ELF, XTENSA_ELF_VERSION, XTENSA_ELF_ARCHIVE_PATTERN)
self.assert_tool_installed(output, OPENOCD, OPENOCD_VERSION)
self.assert_tool_installed(output, RISCV_ELF, RISCV_ELF_VERSION, RISCV_ELF_ARCHIVE_PATTERN)
self.assert_tool_installed(output, ESP32ULP, ESP32ULP_VERSION)
self.assert_tool_installed(output, XTENSA_ESP_GDB, XTENSA_ESP_GDB_VERSION)
self.assert_tool_installed(output, ESP_ROM_ELFS, ESP_ROM_ELFS_VERSION)
self.assert_tool_not_installed(output, RISCV_ESP_GDB, RISCV_ESP_GDB_VERSION)
self.assert_tool_installed(output, CMAKE, CMAKE_VERSION)
self.assert_tool_installed(output, NINJA, NINJA_VERSION)
self.assert_tool_installed(output, IDF_EXE, IDF_EXE_VERSION)
self.assert_tool_installed(output, CCACHE, CCACHE_VERSION)
self.assert_tool_installed(output, DFU_UTIL, DFU_UTIL_VERSION)
self.assertIn('Destination: {}'.format(os.path.join(self.temp_tools_dir, 'dist')), output)
self.assertEqual(required_tools_installed, output.count('Done'))
output = self.run_idf_tools_with_action(['check'])
for tool_version in [OPENOCD_VERSION, XTENSA_ELF_VERSION, XTENSA_ESP_GDB_VERSION, DFU_UTIL_VERSION,
ESP_ROM_ELFS_VERSION, CMAKE_VERSION, NINJA_VERSION, IDF_EXE_VERSION, CCACHE_VERSION]:
self.assertIn('version installed in tools directory: ' + tool_version, output)
output = self.run_idf_tools_with_action(['export'])
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'xtensa-esp-elf', XTENSA_ELF_VERSION, 'xtensa-esp-elf', 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'openocd-esp32', OPENOCD_VERSION, 'openocd-esp32', 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'esp32ulp-elf', ESP32ULP_VERSION, 'esp32ulp-elf', 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'riscv32-esp-elf', RISCV_ELF_VERSION, 'riscv32-esp-elf', 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'xtensa-esp-elf-gdb', XTENSA_ESP_GDB_VERSION, 'xtensa-esp-elf-gdb', 'bin'
), output)
self.assertNotIn(os.path.join(
self.temp_tools_dir, 'tools', 'riscv32-esp-elf-gdb', RISCV_ESP_GDB_VERSION, 'riscv32-esp-elf-gdb', 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'esp-rom-elfs', ESP_ROM_ELFS_VERSION,
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', CMAKE, CMAKE_VERSION, 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', NINJA, NINJA_VERSION
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', IDF_EXE, IDF_EXE_VERSION
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', CCACHE, CCACHE_VERSION, 'ccache-4.8-windows-x86_64'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', DFU_UTIL, DFU_UTIL_VERSION, 'dfu-util-0.11-win64'
), output)
def test_tools_for_esp32s3_win(self):
required_tools_installed = 11
output = self.run_idf_tools_with_action(['install', '--targets=esp32s3'])
print(output)
self.assert_tool_installed(output, XTENSA_ELF, XTENSA_ELF_VERSION, XTENSA_ELF_ARCHIVE_PATTERN)
self.assert_tool_installed(output, OPENOCD, OPENOCD_VERSION)
self.assert_tool_installed(output, RISCV_ELF, RISCV_ELF_VERSION, RISCV_ELF_ARCHIVE_PATTERN)
self.assert_tool_installed(output, ESP32ULP, ESP32ULP_VERSION)
self.assert_tool_installed(output, XTENSA_ESP_GDB, XTENSA_ESP_GDB_VERSION)
self.assert_tool_installed(output, ESP_ROM_ELFS, ESP_ROM_ELFS_VERSION)
self.assert_tool_not_installed(output, RISCV_ESP_GDB, RISCV_ESP_GDB_VERSION)
self.assert_tool_installed(output, CMAKE, CMAKE_VERSION)
self.assert_tool_installed(output, NINJA, NINJA_VERSION)
self.assert_tool_installed(output, IDF_EXE, IDF_EXE_VERSION)
self.assert_tool_installed(output, CCACHE, CCACHE_VERSION)
self.assert_tool_installed(output, DFU_UTIL, DFU_UTIL_VERSION)
self.assertIn('Destination: {}'.format(os.path.join(self.temp_tools_dir, 'dist')), output)
self.assertEqual(required_tools_installed, output.count('Done'))
output = self.run_idf_tools_with_action(['check'])
for tool_version in [OPENOCD_VERSION, XTENSA_ELF_VERSION, XTENSA_ESP_GDB_VERSION, RISCV_ESP_GDB_VERSION,
DFU_UTIL_VERSION, ESP_ROM_ELFS_VERSION, CMAKE_VERSION, NINJA_VERSION,
IDF_EXE_VERSION, CCACHE_VERSION]:
self.assertIn('version installed in tools directory: ' + tool_version, output)
output = self.run_idf_tools_with_action(['export'])
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'openocd-esp32', OPENOCD_VERSION, 'openocd-esp32', 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'xtensa-esp-elf', XTENSA_ELF_VERSION, 'xtensa-esp-elf', 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'esp32ulp-elf', ESP32ULP_VERSION, 'esp32ulp-elf', 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'riscv32-esp-elf', RISCV_ELF_VERSION, 'riscv32-esp-elf', 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'xtensa-esp-elf-gdb', XTENSA_ESP_GDB_VERSION, 'xtensa-esp-elf-gdb', 'bin'
), output)
self.assertNotIn(os.path.join(
self.temp_tools_dir, 'tools', 'riscv32-esp-elf-gdb', RISCV_ESP_GDB_VERSION, 'riscv32-esp-elf-gdb', 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', 'esp-rom-elfs', ESP_ROM_ELFS_VERSION,
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', CMAKE, CMAKE_VERSION, 'bin'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', NINJA, NINJA_VERSION
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', IDF_EXE, IDF_EXE_VERSION
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', CCACHE, CCACHE_VERSION, 'ccache-4.8-windows-x86_64'
), output)
self.assertIn(os.path.join(
self.temp_tools_dir, 'tools', DFU_UTIL, DFU_UTIL_VERSION, 'dfu-util-0.11-win64'
), output)
# a different test for qemu because of "on_request"
def test_tools_for_qemu_with_required_win(self):
required_tools_installed = 14
output = self.run_idf_tools_with_action(['install', 'required', 'qemu-xtensa', 'qemu-riscv32'])
self.assert_tool_installed(output, OPENOCD, OPENOCD_VERSION)
self.assert_tool_installed(output, RISCV_ELF, RISCV_ELF_VERSION, RISCV_ELF_ARCHIVE_PATTERN)
self.assert_tool_installed(output, XTENSA_ELF, XTENSA_ELF_VERSION, XTENSA_ELF_ARCHIVE_PATTERN)
self.assert_tool_installed(output, ESP32ULP, ESP32ULP_VERSION)
self.assert_tool_installed(output, XTENSA_ESP_GDB, XTENSA_ESP_GDB_VERSION)
self.assert_tool_installed(output, RISCV_ESP_GDB, RISCV_ESP_GDB_VERSION)
self.assert_tool_installed(output, ESP_ROM_ELFS, ESP_ROM_ELFS_VERSION)
self.assert_tool_installed(output, QEMU_RISCV, QEMU_RISCV_VERSION)
self.assert_tool_installed(output, QEMU_XTENSA, QEMU_XTENSA_VERSION)
self.assert_tool_installed(output, CMAKE, CMAKE_VERSION)
self.assert_tool_installed(output, NINJA, NINJA_VERSION)
self.assert_tool_installed(output, IDF_EXE, IDF_EXE_VERSION)
self.assert_tool_installed(output, CCACHE, CCACHE_VERSION)
self.assert_tool_installed(output, DFU_UTIL, DFU_UTIL_VERSION)
self.assertIn('Destination: {}'.format(os.path.join(self.temp_tools_dir, 'dist')), output)
self.assertEqual(required_tools_installed, output.count('Done'))
class TestMaintainer(unittest.TestCase):
@classmethod