2019-04-17 03:30:30 -04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
2021-09-09 03:01:14 -04:00
|
|
|
# SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
2019-04-17 03:30:30 -04:00
|
|
|
|
2021-12-21 11:06:05 -05:00
|
|
|
import json
|
2019-04-17 03:30:30 -04:00
|
|
|
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'
|
|
|
|
ESP32S2ULP = 'esp32s2ulp-elf'
|
|
|
|
OPENOCD = 'openocd-esp32'
|
|
|
|
RISC = 'riscv32-esp-elf'
|
|
|
|
XTENSA_ESP32_ELF = 'xtensa-esp32-elf'
|
|
|
|
XTENSA_ESP32S2_ELF = 'xtensa-esp32s2-elf'
|
|
|
|
XTENSA_ESP32S3_ELF = 'xtensa-esp32s3-elf'
|
|
|
|
|
2021-12-21 11:06:05 -05:00
|
|
|
|
|
|
|
def get_version_dict():
|
|
|
|
'''
|
|
|
|
Return a dictionary with tool name to tool version mapping.
|
|
|
|
|
|
|
|
It works with tools.json directly and not through idf_tools.py in order to bypass the script under test. This is
|
|
|
|
a little hacky but thanks to this, versions are not required to be updated here every time a tool is updated.
|
|
|
|
'''
|
|
|
|
with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'tools.json')) as f:
|
|
|
|
tools_obj = json.loads(f.read())
|
|
|
|
|
|
|
|
return dict((tool['name'], tool['versions'][0]['name']) for tool in tools_obj['tools'])
|
|
|
|
|
|
|
|
|
|
|
|
version_dict = get_version_dict()
|
|
|
|
|
|
|
|
ESP32ULP_VERSION = version_dict[ESP32ULP]
|
|
|
|
ESP32S2ULP_VERSION = version_dict[ESP32S2ULP]
|
|
|
|
OPENOCD_VERSION = version_dict[OPENOCD]
|
|
|
|
RISC_VERSION = version_dict[RISC]
|
|
|
|
XTENSA_ESP32_ELF_VERSION = version_dict[XTENSA_ESP32_ELF]
|
|
|
|
XTENSA_ESP32S2_ELF_VERSION = version_dict[XTENSA_ESP32S2_ELF]
|
|
|
|
XTENSA_ESP32S3_ELF_VERSION = version_dict[XTENSA_ESP32S3_ELF]
|
2021-04-26 15:34:48 -04:00
|
|
|
|
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):
|
2019-07-07 21:16:06 -04:00
|
|
|
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')
|
2019-04-17 03:30:30 -04:00
|
|
|
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))
|
|
|
|
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-04-26 15:34:48 -04:00
|
|
|
def check_install_tool(self,tool,tool_version,output,assertIn=True):
|
|
|
|
if assertIn:
|
|
|
|
self.assertIn('Installing %s@' % tool + tool_version, output)
|
|
|
|
self.assertIn('Downloading %s' % tool, output)
|
|
|
|
else:
|
|
|
|
self.assertNotIn('Installing %s@' % tool + tool_version, output)
|
|
|
|
self.assertNotIn('Downloading %s' % tool, output)
|
2019-04-17 03:30:30 -04:00
|
|
|
|
2021-04-26 15:34:48 -04:00
|
|
|
def check_install_esp32_ulp(self,output,assertIn=True):
|
|
|
|
if assertIn:
|
|
|
|
self.assertIn('Installing esp32ulp-elf@' + ESP32ULP_VERSION, output)
|
|
|
|
self.assertIn('Downloading binutils-esp32ulp', output)
|
|
|
|
else:
|
|
|
|
self.assertNotIn('Installing esp32ulp-elf@' + ESP32ULP_VERSION, output)
|
|
|
|
self.assertNotIn('Downloading binutils-esp32ulp', output)
|
2019-04-17 03:30:30 -04:00
|
|
|
|
2021-04-26 15:34:48 -04:00
|
|
|
def check_install_esp32s2_ulp(self,output,assertIn=True):
|
|
|
|
if assertIn:
|
|
|
|
self.assertIn('Installing esp32s2ulp-elf@' + ESP32S2ULP_VERSION, output)
|
|
|
|
self.assertIn('Downloading binutils-esp32s2ulp', output)
|
|
|
|
else:
|
|
|
|
self.assertNotIn('Installing esp32s2ulp-elf@' + ESP32S2ULP_VERSION, output)
|
|
|
|
self.assertNotIn('Downloading binutils-esp32s2ulp', output)
|
2019-04-17 03:30:30 -04:00
|
|
|
|
2021-04-26 15:34:48 -04:00
|
|
|
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-04-26 15:34:48 -04:00
|
|
|
idf_tools.main(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)
|
|
|
|
self.assertIn('* %s:' % RISC, output)
|
|
|
|
self.assertIn('- %s (recommended)' % RISC_VERSION, output)
|
|
|
|
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'])
|
|
|
|
self.check_install_tool(OPENOCD,OPENOCD_VERSION,output)
|
|
|
|
self.check_install_tool(RISC,RISC_VERSION,output)
|
|
|
|
self.check_install_tool(XTENSA_ESP32_ELF,XTENSA_ESP32_ELF_VERSION,output)
|
|
|
|
self.check_install_tool(XTENSA_ESP32S2_ELF,XTENSA_ESP32S2_ELF_VERSION,output)
|
|
|
|
self.check_install_tool(XTENSA_ESP32S3_ELF,XTENSA_ESP32S3_ELF_VERSION,output)
|
|
|
|
self.check_install_esp32_ulp(output)
|
|
|
|
self.check_install_esp32s2_ulp(output)
|
|
|
|
self.assertIn('to ' + os.path.join(self.temp_tools_dir, 'dist'), output)
|
|
|
|
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)
|
|
|
|
self.assertIn('version installed in tools directory: ' + RISC_VERSION, output)
|
|
|
|
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' %
|
|
|
|
(self.temp_tools_dir, RISC_VERSION), output)
|
|
|
|
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'])
|
|
|
|
self.check_install_tool(XTENSA_ESP32_ELF,XTENSA_ESP32_ELF_VERSION,output)
|
|
|
|
self.check_install_tool(OPENOCD,OPENOCD_VERSION,output)
|
|
|
|
self.check_install_esp32_ulp(output)
|
|
|
|
self.check_install_tool(RISC,RISC_VERSION,output,assertIn=False)
|
|
|
|
self.check_install_tool(XTENSA_ESP32S2_ELF,XTENSA_ESP32S2_ELF_VERSION,output,assertIn=False)
|
|
|
|
self.check_install_tool(XTENSA_ESP32S3_ELF,XTENSA_ESP32S3_ELF_VERSION,output,assertIn=False)
|
|
|
|
self.check_install_esp32s2_ulp(output,assertIn=False)
|
|
|
|
self.assertIn('to ' + 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: ' + 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' %
|
|
|
|
(self.temp_tools_dir, RISC_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_esp32c3(self):
|
|
|
|
required_tools_installed = 2
|
|
|
|
output = self.run_idf_tools_with_action(['install', '--targets=esp32c3'])
|
|
|
|
self.check_install_tool(OPENOCD,OPENOCD_VERSION,output)
|
|
|
|
self.check_install_tool(RISC,RISC_VERSION,output)
|
|
|
|
self.check_install_tool(XTENSA_ESP32_ELF,XTENSA_ESP32_ELF_VERSION,output,assertIn=False)
|
|
|
|
self.check_install_tool(XTENSA_ESP32S2_ELF,XTENSA_ESP32S2_ELF_VERSION,output,assertIn=False)
|
|
|
|
self.check_install_tool(XTENSA_ESP32S3_ELF,XTENSA_ESP32S3_ELF_VERSION,output,assertIn=False)
|
|
|
|
self.check_install_esp32_ulp(output,assertIn=False)
|
|
|
|
self.check_install_esp32s2_ulp(output,assertIn=False)
|
|
|
|
self.assertIn('to ' + 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: ' + RISC_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/riscv32-esp-elf/%s/riscv32-esp-elf/bin' %
|
|
|
|
(self.temp_tools_dir, RISC_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)
|
|
|
|
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):
|
|
|
|
required_tools_installed = 3
|
|
|
|
output = self.run_idf_tools_with_action(['install', '--targets=esp32s2'])
|
|
|
|
self.check_install_tool(XTENSA_ESP32S2_ELF,XTENSA_ESP32S2_ELF_VERSION,output)
|
|
|
|
self.check_install_tool(OPENOCD,OPENOCD_VERSION,output)
|
|
|
|
self.check_install_esp32s2_ulp(output)
|
|
|
|
self.check_install_tool(RISC,RISC_VERSION,output,assertIn=False)
|
|
|
|
self.check_install_tool(XTENSA_ESP32_ELF,XTENSA_ESP32_ELF_VERSION,output,assertIn=False)
|
|
|
|
self.check_install_tool(XTENSA_ESP32S3_ELF,XTENSA_ESP32S3_ELF_VERSION,output,assertIn=False)
|
|
|
|
self.check_install_esp32_ulp(output,assertIn=False)
|
|
|
|
self.assertIn('to ' + 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: ' + 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)
|
|
|
|
self.assertNotIn('%s/tools/riscv32-esp-elf/%s/riscv32-esp-elf/bin' %
|
|
|
|
(self.temp_tools_dir, RISC_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_esp32s3(self):
|
|
|
|
required_tools_installed = 2
|
|
|
|
output = self.run_idf_tools_with_action(['install', '--targets=esp32s3'])
|
|
|
|
self.check_install_tool(OPENOCD,OPENOCD_VERSION,output)
|
|
|
|
self.check_install_tool(XTENSA_ESP32S3_ELF,XTENSA_ESP32S3_ELF_VERSION,output)
|
|
|
|
self.check_install_tool(RISC,RISC_VERSION,output,assertIn=False)
|
|
|
|
self.check_install_tool(XTENSA_ESP32_ELF,XTENSA_ESP32_ELF_VERSION,output,assertIn=False)
|
|
|
|
self.check_install_tool(XTENSA_ESP32S2_ELF,XTENSA_ESP32S2_ELF_VERSION,output,assertIn=False)
|
|
|
|
self.check_install_esp32_ulp(output,assertIn=False)
|
|
|
|
self.check_install_esp32s2_ulp(output,assertIn=False)
|
|
|
|
self.assertIn('to ' + 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: ' + 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)
|
|
|
|
self.assertNotIn('%s/tools/riscv32-esp-elf/%s/riscv32-esp-elf/bin' %
|
|
|
|
(self.temp_tools_dir, RISC_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)
|
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()
|