2019-04-17 03:30:30 -04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
|
|
|
# Copyright 2019 Espressif Systems (Shanghai) PTE LTD
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
import os
|
2021-01-25 21:49:01 -05:00
|
|
|
import shutil
|
2019-04-17 03:30:30 -04:00
|
|
|
import sys
|
|
|
|
import tempfile
|
2021-01-25 21:49:01 -05:00
|
|
|
import unittest
|
2019-04-17 03:30:30 -04:00
|
|
|
|
|
|
|
try:
|
|
|
|
from contextlib import redirect_stdout
|
|
|
|
except ImportError:
|
|
|
|
import contextlib
|
|
|
|
|
2021-06-03 01:09:52 -04:00
|
|
|
@contextlib.contextmanager # type: ignore
|
2019-04-17 03:30:30 -04:00
|
|
|
def redirect_stdout(target):
|
|
|
|
original = sys.stdout
|
|
|
|
sys.stdout = target
|
|
|
|
yield
|
|
|
|
sys.stdout = original
|
|
|
|
|
|
|
|
try:
|
|
|
|
from cStringIO import StringIO
|
|
|
|
except ImportError:
|
|
|
|
from io import StringIO
|
|
|
|
|
|
|
|
# Need to do this before importing idf_tools.py
|
|
|
|
os.environ['IDF_MAINTAINER'] = '1'
|
|
|
|
|
|
|
|
try:
|
|
|
|
import idf_tools
|
|
|
|
except ImportError:
|
|
|
|
sys.path.append('..')
|
|
|
|
import idf_tools
|
|
|
|
|
2021-04-26 15:34:48 -04:00
|
|
|
ESP32ULP = 'esp32ulp-elf'
|
2021-07-27 06:19:16 -04:00
|
|
|
ESP32ULP_ARCHIVE = 'binutils-esp32ulp'
|
2021-04-26 15:34:48 -04:00
|
|
|
ESP32S2ULP = 'esp32s2ulp-elf'
|
2021-07-27 06:19:16 -04:00
|
|
|
ESP32S2ULP_ARCHIVE = 'binutils-esp32s2ulp'
|
2021-04-26 15:34:48 -04:00
|
|
|
OPENOCD = 'openocd-esp32'
|
2021-07-27 06:19:16 -04:00
|
|
|
RISCV_ELF = 'riscv32-esp-elf'
|
2021-04-26 15:34:48 -04:00
|
|
|
XTENSA_ESP32_ELF = 'xtensa-esp32-elf'
|
|
|
|
XTENSA_ESP32S2_ELF = 'xtensa-esp32s2-elf'
|
|
|
|
XTENSA_ESP32S3_ELF = 'xtensa-esp32s3-elf'
|
|
|
|
|
|
|
|
ESP32ULP_VERSION = '2.28.51-esp-20191205'
|
|
|
|
ESP32S2ULP_VERSION = '2.28.51-esp-20191205'
|
2021-07-26 07:15:48 -04:00
|
|
|
OPENOCD_VERSION = 'v0.10.0-esp32-20210721'
|
2021-07-27 06:19:16 -04:00
|
|
|
RISCV_ELF_VERSION = 'esp-2021r1-8.4.0'
|
2021-04-26 15:34:48 -04:00
|
|
|
XTENSA_ESP32_ELF_VERSION = 'esp-2021r1-8.4.0'
|
|
|
|
XTENSA_ESP32S2_ELF_VERSION = 'esp-2021r1-8.4.0'
|
|
|
|
XTENSA_ESP32S3_ELF_VERSION = 'esp-2021r1-8.4.0'
|
|
|
|
|
2019-04-17 03:30:30 -04:00
|
|
|
|
|
|
|
class TestUsage(unittest.TestCase):
|
|
|
|
|
2021-04-26 15:34:48 -04:00
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
2019-04-17 03:30:30 -04:00
|
|
|
old_tools_dir = os.environ.get('IDF_TOOLS_PATH') or os.path.expanduser(idf_tools.IDF_TOOLS_PATH_DEFAULT)
|
|
|
|
|
|
|
|
mirror_prefix_map = None
|
|
|
|
if os.path.exists(old_tools_dir):
|
2021-07-27 06:19:16 -04:00
|
|
|
mirror_prefix_map = 'https://dl.espressif.com/dl/toolchains/preview,file://' + os.path.join(old_tools_dir,
|
|
|
|
'dist')
|
2019-07-07 21:16:06 -04:00
|
|
|
mirror_prefix_map += ';https://dl.espressif.com/dl,file://' + os.path.join(old_tools_dir, 'dist')
|
2021-07-27 06:19:16 -04:00
|
|
|
mirror_prefix_map += ';https://github.com/espressif/.*/releases/download/.*/,file://' + os.path.join(
|
|
|
|
old_tools_dir, 'dist', '')
|
2019-04-17 03:30:30 -04:00
|
|
|
if mirror_prefix_map:
|
|
|
|
print('Using IDF_MIRROR_PREFIX_MAP={}'.format(mirror_prefix_map))
|
|
|
|
os.environ['IDF_MIRROR_PREFIX_MAP'] = mirror_prefix_map
|
|
|
|
|
2021-04-26 15:34:48 -04:00
|
|
|
cls.temp_tools_dir = tempfile.mkdtemp(prefix='idf_tools_tmp')
|
2019-04-17 03:30:30 -04:00
|
|
|
|
2021-04-26 15:34:48 -04:00
|
|
|
print('Using IDF_TOOLS_PATH={}'.format(cls.temp_tools_dir))
|
|
|
|
os.environ['IDF_TOOLS_PATH'] = cls.temp_tools_dir
|
2019-04-17 03:30:30 -04:00
|
|
|
|
2021-04-26 15:34:48 -04:00
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
|
|
|
shutil.rmtree(cls.temp_tools_dir)
|
2019-04-17 03:30:30 -04:00
|
|
|
|
2021-04-26 15:34:48 -04:00
|
|
|
def tearDown(self):
|
|
|
|
if os.path.isdir(os.path.join(self.temp_tools_dir, 'dist')):
|
|
|
|
shutil.rmtree(os.path.join(self.temp_tools_dir, 'dist'))
|
2019-04-17 03:30:30 -04:00
|
|
|
|
2021-04-26 15:34:48 -04:00
|
|
|
if os.path.isdir(os.path.join(self.temp_tools_dir, 'tools')):
|
|
|
|
shutil.rmtree(os.path.join(self.temp_tools_dir, 'tools'))
|
2019-04-17 03:30:30 -04:00
|
|
|
|
2021-04-26 15:34:48 -04:00
|
|
|
if os.path.isfile(os.path.join(self.temp_tools_dir, 'idf-env.json')):
|
|
|
|
os.remove(os.path.join(self.temp_tools_dir, 'idf-env.json'))
|
2019-04-17 03:30:30 -04:00
|
|
|
|
2021-07-27 06:19:16 -04:00
|
|
|
def assert_tool_installed(self, output, tool, tool_version, tool_archive_name=None):
|
|
|
|
if tool_archive_name is None:
|
|
|
|
tool_archive_name = tool
|
|
|
|
self.assertIn('Installing %s@' % tool + tool_version, output)
|
|
|
|
self.assertIn('Downloading %s' % tool_archive_name, output)
|
|
|
|
|
|
|
|
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.assertNotIn('Downloading %s' % tool_archive_name, output)
|
|
|
|
|
|
|
|
def run_idf_tools_with_action(self, action):
|
2019-04-17 03:30:30 -04:00
|
|
|
output_stream = StringIO()
|
|
|
|
with redirect_stdout(output_stream):
|
2021-07-27 06:19:16 -04:00
|
|
|
idf_tools.main(['--non-interactive'] + action)
|
2019-04-17 03:30:30 -04:00
|
|
|
output = output_stream.getvalue()
|
2021-04-26 15:34:48 -04:00
|
|
|
return output
|
|
|
|
|
|
|
|
def test_usage_basic(self):
|
|
|
|
output = self.run_idf_tools_with_action(['list'])
|
|
|
|
self.assertIn('* %s:' % ESP32ULP, output)
|
|
|
|
self.assertIn('- %s (recommended)' % ESP32ULP_VERSION, output)
|
|
|
|
self.assertIn('* %s:' % ESP32S2ULP, output)
|
|
|
|
self.assertIn('- %s (recommended)' % ESP32S2ULP_VERSION, output)
|
|
|
|
self.assertIn('* %s:' % OPENOCD, output)
|
|
|
|
self.assertIn('- %s (recommended)' % OPENOCD_VERSION, output)
|
2021-07-27 06:19:16 -04:00
|
|
|
self.assertIn('* %s:' % RISCV_ELF, output)
|
|
|
|
self.assertIn('- %s (recommended)' % RISCV_ELF_VERSION, output)
|
2021-04-26 15:34:48 -04:00
|
|
|
self.assertIn('* %s:' % XTENSA_ESP32_ELF, output)
|
|
|
|
self.assertIn('- %s (recommended)' % XTENSA_ESP32_ELF_VERSION, output)
|
|
|
|
self.assertIn('* %s:' % XTENSA_ESP32S2_ELF, output)
|
|
|
|
self.assertIn('- %s (recommended)' % XTENSA_ESP32S2_ELF_VERSION, output)
|
|
|
|
self.assertIn('* %s:' % XTENSA_ESP32S3_ELF, output)
|
|
|
|
self.assertIn('- %s (recommended)' % XTENSA_ESP32S3_ELF_VERSION, output)
|
|
|
|
|
|
|
|
required_tools_installed = 7
|
|
|
|
output = self.run_idf_tools_with_action(['install'])
|
2021-07-27 06:19:16 -04:00
|
|
|
self.assert_tool_installed(output, OPENOCD, OPENOCD_VERSION)
|
|
|
|
self.assert_tool_installed(output, RISCV_ELF, RISCV_ELF_VERSION)
|
|
|
|
self.assert_tool_installed(output, XTENSA_ESP32_ELF, XTENSA_ESP32_ELF_VERSION)
|
|
|
|
self.assert_tool_installed(output, XTENSA_ESP32S2_ELF, XTENSA_ESP32S2_ELF_VERSION)
|
|
|
|
self.assert_tool_installed(output, XTENSA_ESP32S3_ELF, XTENSA_ESP32S3_ELF_VERSION)
|
|
|
|
self.assert_tool_installed(output, ESP32ULP, ESP32ULP_VERSION, ESP32ULP_ARCHIVE)
|
|
|
|
self.assert_tool_installed(output, ESP32S2ULP, ESP32S2ULP_VERSION, ESP32S2ULP_ARCHIVE)
|
2021-04-26 15:34:48 -04:00
|
|
|
self.assertIn('to ' + os.path.join(self.temp_tools_dir, 'dist'), output)
|
2021-07-27 06:19:16 -04:00
|
|
|
self.assertEqual(required_tools_installed, output.count('Done'))
|
2019-04-17 03:30:30 -04:00
|
|
|
|
2021-04-26 15:34:48 -04:00
|
|
|
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: ' + ESP32S2ULP_VERSION, output)
|
|
|
|
self.assertIn('version installed in tools directory: ' + OPENOCD_VERSION, output)
|
2021-07-27 06:19:16 -04:00
|
|
|
self.assertIn('version installed in tools directory: ' + RISCV_ELF_VERSION, output)
|
2021-04-26 15:34:48 -04:00
|
|
|
self.assertIn('version installed in tools directory: ' + XTENSA_ESP32_ELF_VERSION, output)
|
|
|
|
self.assertIn('version installed in tools directory: ' + XTENSA_ESP32S2_ELF_VERSION, output)
|
|
|
|
self.assertIn('version installed in tools directory: ' + XTENSA_ESP32S3_ELF_VERSION, output)
|
|
|
|
|
|
|
|
output = self.run_idf_tools_with_action(['export'])
|
|
|
|
self.assertIn('%s/tools/esp32ulp-elf/%s/esp32ulp-elf-binutils/bin' %
|
|
|
|
(self.temp_tools_dir, ESP32ULP_VERSION), output)
|
|
|
|
self.assertIn('%s/tools/xtensa-esp32-elf/%s/xtensa-esp32-elf/bin' %
|
|
|
|
(self.temp_tools_dir, XTENSA_ESP32_ELF_VERSION), output)
|
|
|
|
self.assertIn('%s/tools/openocd-esp32/%s/openocd-esp32/bin' %
|
|
|
|
(self.temp_tools_dir, OPENOCD_VERSION), output)
|
|
|
|
self.assertIn('%s/tools/riscv32-esp-elf/%s/riscv32-esp-elf/bin' %
|
2021-07-27 06:19:16 -04:00
|
|
|
(self.temp_tools_dir, RISCV_ELF_VERSION), output)
|
2021-04-26 15:34:48 -04:00
|
|
|
self.assertIn('%s/tools/esp32s2ulp-elf/%s/esp32s2ulp-elf-binutils/bin' %
|
|
|
|
(self.temp_tools_dir, ESP32S2ULP_VERSION), output)
|
|
|
|
self.assertIn('%s/tools/xtensa-esp32s2-elf/%s/xtensa-esp32s2-elf/bin' %
|
|
|
|
(self.temp_tools_dir, XTENSA_ESP32S2_ELF_VERSION), output)
|
|
|
|
self.assertIn('%s/tools/xtensa-esp32s3-elf/%s/xtensa-esp32s3-elf/bin' %
|
|
|
|
(self.temp_tools_dir, XTENSA_ESP32S3_ELF_VERSION), output)
|
|
|
|
|
|
|
|
def test_tools_for_esp32(self):
|
|
|
|
required_tools_installed = 3
|
|
|
|
output = self.run_idf_tools_with_action(['install', '--targets=esp32'])
|
2021-07-27 06:19:16 -04:00
|
|
|
self.assert_tool_installed(output, XTENSA_ESP32_ELF, XTENSA_ESP32_ELF_VERSION)
|
|
|
|
self.assert_tool_installed(output, OPENOCD, OPENOCD_VERSION)
|
|
|
|
self.assert_tool_installed(output, ESP32ULP, ESP32ULP_VERSION, ESP32ULP_ARCHIVE)
|
|
|
|
self.assert_tool_not_installed(output, RISCV_ELF, RISCV_ELF_VERSION)
|
|
|
|
self.assert_tool_not_installed(output, XTENSA_ESP32S2_ELF, XTENSA_ESP32S2_ELF_VERSION)
|
|
|
|
self.assert_tool_not_installed(output, XTENSA_ESP32S3_ELF, XTENSA_ESP32S3_ELF_VERSION)
|
|
|
|
self.assert_tool_not_installed(output, ESP32S2ULP, ESP32S2ULP_VERSION, ESP32S2ULP_ARCHIVE)
|
2021-04-26 15:34:48 -04:00
|
|
|
self.assertIn('to ' + os.path.join(self.temp_tools_dir, 'dist'), output)
|
2021-07-27 06:19:16 -04:00
|
|
|
self.assertEqual(required_tools_installed, output.count('Done'))
|
2021-04-26 15:34:48 -04:00
|
|
|
|
|
|
|
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_ESP32_ELF_VERSION, output)
|
|
|
|
self.assertIn('version installed in tools directory: ' + OPENOCD_VERSION, output)
|
|
|
|
|
|
|
|
output = self.run_idf_tools_with_action(['export'])
|
2019-04-17 03:30:30 -04:00
|
|
|
self.assertIn('%s/tools/esp32ulp-elf/%s/esp32ulp-elf-binutils/bin' %
|
2021-04-26 15:34:48 -04:00
|
|
|
(self.temp_tools_dir, ESP32ULP_VERSION), output)
|
2019-04-17 03:30:30 -04:00
|
|
|
self.assertIn('%s/tools/xtensa-esp32-elf/%s/xtensa-esp32-elf/bin' %
|
2021-04-26 15:34:48 -04:00
|
|
|
(self.temp_tools_dir, XTENSA_ESP32_ELF_VERSION), output)
|
|
|
|
self.assertIn('%s/tools/openocd-esp32/%s/openocd-esp32/bin' %
|
|
|
|
(self.temp_tools_dir, OPENOCD_VERSION), output)
|
|
|
|
self.assertNotIn('%s/tools/riscv32-esp-elf/%s/riscv32-esp-elf/bin' %
|
2021-07-27 06:19:16 -04:00
|
|
|
(self.temp_tools_dir, RISCV_ELF_VERSION), output)
|
2021-04-26 15:34:48 -04:00
|
|
|
self.assertNotIn('%s/tools/esp32s2ulp-elf/%s/esp32s2ulp-elf-binutils/bin' %
|
|
|
|
(self.temp_tools_dir, ESP32S2ULP_VERSION), output)
|
|
|
|
self.assertNotIn('%s/tools/xtensa-esp32s2-elf/%s/xtensa-esp32s2-elf/bin' %
|
|
|
|
(self.temp_tools_dir, XTENSA_ESP32S2_ELF_VERSION), output)
|
|
|
|
self.assertNotIn('%s/tools/xtensa-esp32s3-elf/%s/xtensa-esp32s3-elf/bin' %
|
|
|
|
(self.temp_tools_dir, XTENSA_ESP32S3_ELF_VERSION), output)
|
|
|
|
|
|
|
|
def test_tools_for_esp32c3(self):
|
|
|
|
required_tools_installed = 2
|
|
|
|
output = self.run_idf_tools_with_action(['install', '--targets=esp32c3'])
|
2021-07-27 06:19:16 -04:00
|
|
|
self.assert_tool_installed(output, OPENOCD, OPENOCD_VERSION)
|
|
|
|
self.assert_tool_installed(output, RISCV_ELF, RISCV_ELF_VERSION)
|
|
|
|
self.assert_tool_not_installed(output, XTENSA_ESP32_ELF, XTENSA_ESP32_ELF_VERSION)
|
|
|
|
self.assert_tool_not_installed(output, XTENSA_ESP32S2_ELF, XTENSA_ESP32S2_ELF_VERSION)
|
|
|
|
self.assert_tool_not_installed(output, XTENSA_ESP32S3_ELF, XTENSA_ESP32S3_ELF_VERSION)
|
|
|
|
self.assert_tool_not_installed(output, ESP32ULP, ESP32ULP_VERSION, ESP32ULP_ARCHIVE)
|
|
|
|
self.assert_tool_not_installed(output, ESP32S2ULP, ESP32S2ULP_VERSION, ESP32S2ULP_ARCHIVE)
|
2021-04-26 15:34:48 -04:00
|
|
|
self.assertIn('to ' + os.path.join(self.temp_tools_dir, 'dist'), output)
|
2021-07-27 06:19:16 -04:00
|
|
|
self.assertEqual(required_tools_installed, output.count('Done'))
|
2021-04-26 15:34:48 -04:00
|
|
|
|
|
|
|
output = self.run_idf_tools_with_action(['check'])
|
|
|
|
self.assertIn('version installed in tools directory: ' + OPENOCD_VERSION, output)
|
2021-07-27 06:19:16 -04:00
|
|
|
self.assertIn('version installed in tools directory: ' + RISCV_ELF_VERSION, output)
|
2021-04-26 15:34:48 -04:00
|
|
|
|
|
|
|
output = self.run_idf_tools_with_action(['export'])
|
|
|
|
self.assertIn('%s/tools/openocd-esp32/%s/openocd-esp32/bin' %
|
|
|
|
(self.temp_tools_dir, OPENOCD_VERSION), output)
|
|
|
|
self.assertIn('%s/tools/riscv32-esp-elf/%s/riscv32-esp-elf/bin' %
|
2021-07-27 06:19:16 -04:00
|
|
|
(self.temp_tools_dir, RISCV_ELF_VERSION), output)
|
2021-04-26 15:34:48 -04:00
|
|
|
self.assertNotIn('%s/tools/esp32ulp-elf/%s/esp32ulp-elf-binutils/bin' %
|
|
|
|
(self.temp_tools_dir, ESP32ULP_VERSION), output)
|
|
|
|
self.assertNotIn('%s/tools/xtensa-esp32-elf/%s/xtensa-esp32-elf/bin' %
|
|
|
|
(self.temp_tools_dir, XTENSA_ESP32_ELF_VERSION), output)
|
|
|
|
self.assertNotIn('%s/tools/esp32s2ulp-elf/%s/esp32s2ulp-elf-binutils/bin' %
|
|
|
|
(self.temp_tools_dir, ESP32S2ULP_VERSION), output)
|
|
|
|
self.assertNotIn('%s/tools/xtensa-esp32s2-elf/%s/xtensa-esp32s2-elf/bin' %
|
|
|
|
(self.temp_tools_dir, XTENSA_ESP32S2_ELF_VERSION), output)
|
|
|
|
self.assertNotIn('%s/tools/xtensa-esp32s3-elf/%s/xtensa-esp32s3-elf/bin' %
|
|
|
|
(self.temp_tools_dir, XTENSA_ESP32S3_ELF_VERSION), output)
|
|
|
|
|
|
|
|
def test_tools_for_esp32s2(self):
|
2021-07-27 06:19:16 -04:00
|
|
|
required_tools_installed = 4
|
2021-04-26 15:34:48 -04:00
|
|
|
output = self.run_idf_tools_with_action(['install', '--targets=esp32s2'])
|
2021-07-27 06:19:16 -04:00
|
|
|
self.assert_tool_installed(output, XTENSA_ESP32S2_ELF, XTENSA_ESP32S2_ELF_VERSION)
|
|
|
|
self.assert_tool_installed(output, OPENOCD, OPENOCD_VERSION)
|
|
|
|
self.assert_tool_installed(output, RISCV_ELF, RISCV_ELF_VERSION)
|
|
|
|
self.assert_tool_not_installed(output, XTENSA_ESP32_ELF, XTENSA_ESP32_ELF_VERSION)
|
|
|
|
self.assert_tool_not_installed(output, XTENSA_ESP32S3_ELF, XTENSA_ESP32S3_ELF_VERSION)
|
|
|
|
self.assert_tool_not_installed(output, ESP32ULP, ESP32ULP_VERSION, ESP32ULP_ARCHIVE)
|
|
|
|
self.assert_tool_installed(output, ESP32S2ULP, ESP32S2ULP_VERSION, ESP32S2ULP_ARCHIVE)
|
2021-04-26 15:34:48 -04:00
|
|
|
self.assertIn('to ' + os.path.join(self.temp_tools_dir, 'dist'), output)
|
2021-07-27 06:19:16 -04:00
|
|
|
self.assertEqual(required_tools_installed, output.count('Done'))
|
2021-04-26 15:34:48 -04:00
|
|
|
|
|
|
|
output = self.run_idf_tools_with_action(['check'])
|
|
|
|
self.assertIn('version installed in tools directory: ' + ESP32S2ULP_VERSION, output)
|
|
|
|
self.assertIn('version installed in tools directory: ' + OPENOCD_VERSION, output)
|
|
|
|
self.assertIn('version installed in tools directory: ' + XTENSA_ESP32S2_ELF_VERSION, output)
|
|
|
|
|
|
|
|
output = self.run_idf_tools_with_action(['export'])
|
|
|
|
self.assertIn('%s/tools/esp32s2ulp-elf/%s/esp32s2ulp-elf-binutils/bin' %
|
|
|
|
(self.temp_tools_dir, ESP32S2ULP_VERSION), output)
|
|
|
|
self.assertIn('%s/tools/xtensa-esp32s2-elf/%s/xtensa-esp32s2-elf/bin' %
|
|
|
|
(self.temp_tools_dir, XTENSA_ESP32S2_ELF_VERSION), output)
|
|
|
|
self.assertIn('%s/tools/openocd-esp32/%s/openocd-esp32/bin' %
|
|
|
|
(self.temp_tools_dir, OPENOCD_VERSION), output)
|
|
|
|
self.assertNotIn('%s/tools/esp32ulp-elf/%s/esp32ulp-elf-binutils/bin' %
|
|
|
|
(self.temp_tools_dir, ESP32ULP_VERSION), output)
|
|
|
|
self.assertNotIn('%s/tools/xtensa-esp32-elf/%s/xtensa-esp32-elf/bin' %
|
|
|
|
(self.temp_tools_dir, XTENSA_ESP32_ELF_VERSION), output)
|
2021-07-27 06:19:16 -04:00
|
|
|
self.assertIn('%s/tools/riscv32-esp-elf/%s/riscv32-esp-elf/bin' %
|
|
|
|
(self.temp_tools_dir, RISCV_ELF_VERSION), output)
|
2021-04-26 15:34:48 -04:00
|
|
|
self.assertNotIn('%s/tools/xtensa-esp32s3-elf/%s/xtensa-esp32s3-elf/bin' %
|
|
|
|
(self.temp_tools_dir, XTENSA_ESP32S3_ELF_VERSION), output)
|
|
|
|
|
|
|
|
def test_tools_for_esp32s3(self):
|
2021-07-27 06:19:16 -04:00
|
|
|
required_tools_installed = 4
|
2021-04-26 15:34:48 -04:00
|
|
|
output = self.run_idf_tools_with_action(['install', '--targets=esp32s3'])
|
2021-07-27 06:19:16 -04:00
|
|
|
self.assert_tool_installed(output, XTENSA_ESP32S3_ELF, XTENSA_ESP32S3_ELF_VERSION)
|
|
|
|
self.assert_tool_installed(output, OPENOCD, OPENOCD_VERSION)
|
|
|
|
self.assert_tool_installed(output, RISCV_ELF, RISCV_ELF_VERSION)
|
|
|
|
self.assert_tool_not_installed(output, XTENSA_ESP32_ELF, XTENSA_ESP32_ELF_VERSION)
|
|
|
|
self.assert_tool_not_installed(output, XTENSA_ESP32S2_ELF, XTENSA_ESP32S2_ELF_VERSION)
|
|
|
|
self.assert_tool_not_installed(output, ESP32ULP, ESP32ULP_VERSION, ESP32ULP_ARCHIVE)
|
|
|
|
self.assert_tool_installed(output, ESP32S2ULP, ESP32S2ULP_VERSION, ESP32S2ULP_ARCHIVE)
|
2021-04-26 15:34:48 -04:00
|
|
|
self.assertIn('to ' + os.path.join(self.temp_tools_dir, 'dist'), output)
|
2021-07-27 06:19:16 -04:00
|
|
|
self.assertEqual(required_tools_installed, output.count('Done'))
|
2021-04-26 15:34:48 -04:00
|
|
|
|
|
|
|
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_ESP32S3_ELF_VERSION, output)
|
|
|
|
|
|
|
|
output = self.run_idf_tools_with_action(['export'])
|
|
|
|
self.assertIn('%s/tools/openocd-esp32/%s/openocd-esp32/bin' %
|
|
|
|
(self.temp_tools_dir, OPENOCD_VERSION), output)
|
|
|
|
self.assertIn('%s/tools/xtensa-esp32s3-elf/%s/xtensa-esp32s3-elf/bin' %
|
|
|
|
(self.temp_tools_dir, XTENSA_ESP32S3_ELF_VERSION), output)
|
|
|
|
self.assertNotIn('%s/tools/esp32ulp-elf/%s/esp32ulp-elf-binutils/bin' %
|
|
|
|
(self.temp_tools_dir, ESP32ULP_VERSION), output)
|
|
|
|
self.assertNotIn('%s/tools/xtensa-esp32-elf/%s/xtensa-esp32-elf/bin' %
|
|
|
|
(self.temp_tools_dir, XTENSA_ESP32_ELF_VERSION), output)
|
2021-07-27 06:19:16 -04:00
|
|
|
self.assertIn('%s/tools/riscv32-esp-elf/%s/riscv32-esp-elf/bin' %
|
|
|
|
(self.temp_tools_dir, RISCV_ELF_VERSION), output)
|
|
|
|
self.assertIn('%s/tools/esp32s2ulp-elf/%s/esp32s2ulp-elf-binutils/bin' %
|
|
|
|
(self.temp_tools_dir, ESP32S2ULP_VERSION), output)
|
2021-04-26 15:34:48 -04:00
|
|
|
self.assertNotIn('%s/tools/xtensa-esp32s2-elf/%s/xtensa-esp32s2-elf/bin' %
|
|
|
|
(self.temp_tools_dir, XTENSA_ESP32S2_ELF_VERSION), output)
|
2019-04-17 03:30:30 -04:00
|
|
|
|
|
|
|
|
|
|
|
class TestMaintainer(unittest.TestCase):
|
|
|
|
|
|
|
|
def test_validation(self):
|
|
|
|
idf_tools.main(['validate'])
|
|
|
|
|
|
|
|
def test_json_rewrite(self):
|
|
|
|
idf_tools.main(['rewrite'])
|
|
|
|
idf_path = os.getenv('IDF_PATH')
|
|
|
|
if not idf_path:
|
|
|
|
self.fail('IDF_PATH needs to be set to run this test')
|
|
|
|
with open(os.path.join(idf_path, 'tools/tools.json'), 'r') as f:
|
|
|
|
json_old = f.read()
|
|
|
|
with open(os.path.join(idf_path, 'tools/tools.new.json'), 'r') as f:
|
|
|
|
json_new = f.read()
|
2021-06-05 04:59:42 -04:00
|
|
|
self.assertEqual(json_old, json_new, "Please check 'tools/tools.new.json' to find a cause!")
|
2019-04-17 03:30:30 -04:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|