diff --git a/docs/conf_common.py b/docs/conf_common.py index 907bd7a65c..787f117c92 100644 --- a/docs/conf_common.py +++ b/docs/conf_common.py @@ -16,77 +16,84 @@ from esp_docs.conf_docs import * # noqa: F403,F401 if os.environ.get('IDF_PATH') is None: raise RuntimeError('IDF_PATH should be set, run export.sh before building docs') -BT_DOCS = ['api-reference/bluetooth/esp_bt_defs.rst', - 'api-reference/bluetooth/esp_bt_device.rst', - 'api-reference/bluetooth/esp_bt_main.rst', - 'api-reference/bluetooth/bt_common.rst', - 'api-reference/bluetooth/bt_vhci.rst', - 'api-reference/bluetooth/controller_vhci.rst', - 'api-reference/bluetooth/index.rst'] +BT_DOCS = [ + 'api-reference/bluetooth/esp_bt_defs.rst', + 'api-reference/bluetooth/esp_bt_device.rst', + 'api-reference/bluetooth/esp_bt_main.rst', + 'api-reference/bluetooth/bt_common.rst', + 'api-reference/bluetooth/bt_vhci.rst', + 'api-reference/bluetooth/controller_vhci.rst', + 'api-reference/bluetooth/index.rst', +] -BLE_DOCS = ['api-guides/ble/index.rst', - 'api-guides/ble/overview.rst', - 'api-guides/ble/ble-feature-support-status.rst', - 'api-guides/ble/host-feature-support-status.rst', - 'api-guides/ble/ble-qualification.rst', - 'api-guides/ble/get-started/ble-introduction.rst', - 'api-guides/ble/get-started/ble-device-discovery.rst', - 'api-guides/ble/get-started/ble-connection.rst', - 'api-guides/ble/get-started/ble-data-exchange.rst', - 'api-reference/bluetooth/bt_le.rst', - 'api-reference/bluetooth/esp_gap_ble.rst', - 'api-reference/bluetooth/esp_gatt_defs.rst', - 'api-reference/bluetooth/esp_gatts.rst', - 'api-reference/bluetooth/esp_gattc.rst', - 'api-reference/bluetooth/nimble/index.rst', - 'migration-guides/release-5.x/5.0/bluetooth-low-energy.rst'] +BLE_DOCS = [ + 'api-guides/ble/index.rst', + 'api-guides/ble/overview.rst', + 'api-guides/ble/ble-feature-support-status.rst', + 'api-guides/ble/host-feature-support-status.rst', + 'api-guides/ble/ble-qualification.rst', + 'api-guides/ble/get-started/ble-introduction.rst', + 'api-guides/ble/get-started/ble-device-discovery.rst', + 'api-guides/ble/get-started/ble-connection.rst', + 'api-guides/ble/get-started/ble-data-exchange.rst', + 'api-reference/bluetooth/bt_le.rst', + 'api-reference/bluetooth/esp_gap_ble.rst', + 'api-reference/bluetooth/esp_gatt_defs.rst', + 'api-reference/bluetooth/esp_gatts.rst', + 'api-reference/bluetooth/esp_gattc.rst', + 'api-reference/bluetooth/nimble/index.rst', + 'migration-guides/release-5.x/5.0/bluetooth-low-energy.rst', +] -BLE_MESH_DOCS = ['api-guides/esp-ble-mesh/ble-mesh-index.rst', - 'api-guides/esp-ble-mesh/ble-mesh-feature-list.rst', - 'api-guides/esp-ble-mesh/ble-mesh-terminology.rst', - 'api-guides/esp-ble-mesh/ble-mesh-architecture.rst', - 'api-guides/esp-ble-mesh/ble-mesh-faq.rst', - 'api-reference/bluetooth/esp-ble-mesh.rst'] +BLE_MESH_DOCS = [ + 'api-guides/esp-ble-mesh/ble-mesh-index.rst', + 'api-guides/esp-ble-mesh/ble-mesh-feature-list.rst', + 'api-guides/esp-ble-mesh/ble-mesh-terminology.rst', + 'api-guides/esp-ble-mesh/ble-mesh-architecture.rst', + 'api-guides/esp-ble-mesh/ble-mesh-faq.rst', + 'api-reference/bluetooth/esp-ble-mesh.rst', +] -CLASSIC_BT_DOCS = ['api-guides/classic-bt/index.rst', - 'api-guides/classic-bt/overview.rst', - 'api-reference/bluetooth/classic_bt.rst', - 'api-reference/bluetooth/esp_a2dp.rst', - 'api-reference/bluetooth/esp_avrc.rst', - 'api-reference/bluetooth/esp_hidd.rst', - 'api-reference/bluetooth/esp_hidh.rst', - 'api-reference/bluetooth/esp_l2cap_bt.rst', - 'api-reference/bluetooth/esp_sdp.rst', - 'api-reference/bluetooth/esp_hf_defs.rst', - 'api-reference/bluetooth/esp_hf_client.rst', - 'api-reference/bluetooth/esp_hf_ag.rst', - 'api-reference/bluetooth/esp_spp.rst', - 'api-reference/bluetooth/esp_gap_bt.rst', - 'migration-guides/release-5.x/5.0/bluetooth-classic.rst'] +CLASSIC_BT_DOCS = [ + 'api-guides/classic-bt/index.rst', + 'api-guides/classic-bt/overview.rst', + 'api-reference/bluetooth/classic_bt.rst', + 'api-reference/bluetooth/esp_a2dp.rst', + 'api-reference/bluetooth/esp_avrc.rst', + 'api-reference/bluetooth/esp_hidd.rst', + 'api-reference/bluetooth/esp_hidh.rst', + 'api-reference/bluetooth/esp_l2cap_bt.rst', + 'api-reference/bluetooth/esp_sdp.rst', + 'api-reference/bluetooth/esp_hf_defs.rst', + 'api-reference/bluetooth/esp_hf_client.rst', + 'api-reference/bluetooth/esp_hf_ag.rst', + 'api-reference/bluetooth/esp_spp.rst', + 'api-reference/bluetooth/esp_gap_bt.rst', + 'migration-guides/release-5.x/5.0/bluetooth-classic.rst', +] -BLUFI_DOCS = ['api-guides/ble/blufi.rst', - 'api-reference/bluetooth/esp_blufi.rst'] +BLUFI_DOCS = ['api-guides/ble/blufi.rst', 'api-reference/bluetooth/esp_blufi.rst'] -WIFI_DOCS = ['api-guides/low-power-mode/low-power-mode-wifi.rst', - 'api-guides/wifi.rst', - 'api-guides/wifi-security.rst', - 'api-guides/wireshark-user-guide.rst', - 'api-reference/network/esp_now.rst', - 'api-reference/network/esp_smartconfig.rst', - 'api-reference/network/esp_wifi.rst', - 'api-reference/network/esp_dpp.rst', - 'api-reference/provisioning/provisioning.rst', - 'api-reference/provisioning/wifi_provisioning.rst', - 'migration-guides/release-5.x/5.2/wifi.rst'] +WIFI_DOCS = [ + 'api-guides/low-power-mode/low-power-mode-wifi.rst', + 'api-guides/wifi.rst', + 'api-guides/wifi-security.rst', + 'api-guides/wireshark-user-guide.rst', + 'api-reference/network/esp_now.rst', + 'api-reference/network/esp_smartconfig.rst', + 'api-reference/network/esp_wifi.rst', + 'api-reference/network/esp_dpp.rst', + 'api-reference/provisioning/provisioning.rst', + 'api-reference/provisioning/wifi_provisioning.rst', + 'migration-guides/release-5.x/5.2/wifi.rst', +] -IEEE802154_DOCS = ['migration-guides/release-5.x/5.1/ieee802154.rst', - 'migration-guides/release-5.x/5.2/ieee802154.rst'] +IEEE802154_DOCS = ['migration-guides/release-5.x/5.1/ieee802154.rst', 'migration-guides/release-5.x/5.2/ieee802154.rst'] NAN_DOCS = ['api-reference/network/esp_nan.rst'] -WIFI_MESH_DOCS = ['api-guides/esp-wifi-mesh.rst', - 'api-reference/network/esp-wifi-mesh.rst'] +WIFI_MESH_DOCS = ['api-guides/esp-wifi-mesh.rst', 'api-reference/network/esp-wifi-mesh.rst'] COEXISTENCE_DOCS = ['api-guides/coexist.rst'] @@ -102,8 +109,7 @@ UART_DOCS = ['api-reference/peripherals/uart.rst'] SDMMC_DOCS = ['api-reference/peripherals/sdmmc_host.rst'] -SDIO_SLAVE_DOCS = ['api-reference/peripherals/sdio_slave.rst', - 'api-reference/protocols/esp_sdio_slave_protocol.rst'] +SDIO_SLAVE_DOCS = ['api-reference/peripherals/sdio_slave.rst', 'api-reference/protocols/esp_sdio_slave_protocol.rst'] MCPWM_DOCS = ['api-reference/peripherals/mcpwm.rst'] @@ -127,16 +133,18 @@ TOUCH_SENSOR_DOCS = ['api-reference/peripherals/cap_touch_sens.rst'] SPIRAM_DOCS = ['api-guides/external-ram.rst'] -USB_DOCS = ['api-reference/peripherals/usb_device.rst', - 'api-reference/peripherals/usb_host.rst', - 'api-reference/peripherals/usb_host/usb_host_notes_arch.rst', - 'api-reference/peripherals/usb_host/usb_host_notes_design.rst', - 'api-reference/peripherals/usb_host/usb_host_notes_dwc_otg.rst', - 'api-reference/peripherals/usb_host/usb_host_notes_index.rst', - 'api-reference/peripherals/usb_host/usb_host_notes_usbh.rst', - 'api-reference/peripherals/usb_host/usb_host_notes_enum.rst', - 'api-reference/peripherals/usb_host/usb_host_notes_ext_hub.rst', - 'api-reference/peripherals/usb_host/usb_host_notes_ext_port.rst'] +USB_DOCS = [ + 'api-reference/peripherals/usb_device.rst', + 'api-reference/peripherals/usb_host.rst', + 'api-reference/peripherals/usb_host/usb_host_notes_arch.rst', + 'api-reference/peripherals/usb_host/usb_host_notes_design.rst', + 'api-reference/peripherals/usb_host/usb_host_notes_dwc_otg.rst', + 'api-reference/peripherals/usb_host/usb_host_notes_index.rst', + 'api-reference/peripherals/usb_host/usb_host_notes_usbh.rst', + 'api-reference/peripherals/usb_host/usb_host_notes_enum.rst', + 'api-reference/peripherals/usb_host/usb_host_notes_ext_hub.rst', + 'api-reference/peripherals/usb_host/usb_host_notes_ext_port.rst', +] I80_LCD_DOCS = ['api-reference/peripherals/lcd/i80_lcd.rst'] RGB_LCD_DOCS = ['api-reference/peripherals/lcd/rgb_lcd.rst'] @@ -149,19 +157,24 @@ USB_OTG_CONSOLE_DOCS = ['api-guides/usb-otg-console.rst'] FTDI_JTAG_DOCS = ['api-guides/jtag-debugging/configure-ft2232h-jtag.rst'] -USB_SERIAL_JTAG_DOCS = ['api-guides/jtag-debugging/configure-builtin-jtag.rst', - 'api-guides/usb-serial-jtag-console.rst'] +USB_SERIAL_JTAG_DOCS = [ + 'api-guides/jtag-debugging/configure-builtin-jtag.rst', + 'api-guides/usb-serial-jtag-console.rst', +] -ULP_FSM_DOCS = ['api-reference/system/ulp.rst', - 'api-reference/system/ulp_macros.rst', - 'api-reference/system/ulp_instruction_set.rst'] +ULP_FSM_DOCS = [ + 'api-reference/system/ulp.rst', + 'api-reference/system/ulp_macros.rst', + 'api-reference/system/ulp_instruction_set.rst', +] -RISCV_COPROC_DOCS = ['api-reference/system/ulp-risc-v.rst',] +RISCV_COPROC_DOCS = [ + 'api-reference/system/ulp-risc-v.rst', +] LP_CORE_DOCS = ['api-reference/system/ulp-lp-core.rst'] -XTENSA_DOCS = ['api-guides/hlinterrupts.rst', - 'api-reference/system/perfmon.rst'] +XTENSA_DOCS = ['api-guides/hlinterrupts.rst', 'api-reference/system/perfmon.rst'] RISCV_DOCS = [] # type: list[str] @@ -169,15 +182,19 @@ TWAI_DOCS = ['api-reference/peripherals/twai.rst'] SDM_DOCS = ['api-reference/peripherals/sdm.rst'] -I2C_DOCS = ['api-reference/peripherals/i2c.rst', - 'api-reference/peripherals/lcd/i2c_lcd.rst', - 'api-reference/peripherals/i2c_slave_v1.rst'] +I2C_DOCS = [ + 'api-reference/peripherals/i2c.rst', + 'api-reference/peripherals/lcd/i2c_lcd.rst', + 'api-reference/peripherals/i2c_slave_v1.rst', +] -SPI_DOCS = ['api-reference/peripherals/spi_master.rst', - 'api-reference/peripherals/spi_slave.rst', - 'api-reference/peripherals/sdspi_host.rst', - 'api-reference/peripherals/sdspi_share.rst', - 'api-reference/peripherals/lcd/spi_lcd.rst'] +SPI_DOCS = [ + 'api-reference/peripherals/spi_master.rst', + 'api-reference/peripherals/spi_slave.rst', + 'api-reference/peripherals/sdspi_host.rst', + 'api-reference/peripherals/sdspi_share.rst', + 'api-reference/peripherals/lcd/spi_lcd.rst', +] I2S_DOCS = ['api-reference/peripherals/i2s.rst'] @@ -189,8 +206,7 @@ ISP_DOCS = ['api-reference/peripherals/isp.rst'] DSLP_STUB_DOCS = ['api-guides/deep-sleep-stub.rst'] -ADC_DOCS = ['api-reference/peripherals/adc_oneshot.rst', - 'api-reference/peripherals/adc_calibration.rst'] +ADC_DOCS = ['api-reference/peripherals/adc_oneshot.rst', 'api-reference/peripherals/adc_calibration.rst'] ADC_DMA_DOCS = ['api-reference/peripherals/adc_continuous.rst'] ANA_CMPR_DOCS = ['api-reference/peripherals/ana_cmpr.rst'] @@ -203,148 +219,173 @@ PPA_DOCS = ['api-reference/peripherals/ppa.rst'] QEMU_DOCS = ['api-guides/tools/qemu.rst'] -ESP_TEE_DOCS = ['security/tee/index.rst', - 'security/tee/tee.rst', - 'security/tee/tee-advanced.rst', - 'security/tee/tee-attestation.rst', - 'security/tee/tee-ota.rst', - 'security/tee/tee-sec-storage.rst'] +ESP_TEE_DOCS = [ + 'security/tee/index.rst', + 'security/tee/tee.rst', + 'security/tee/tee-advanced.rst', + 'security/tee/tee-attestation.rst', + 'security/tee/tee-ota.rst', + 'security/tee/tee-sec-storage.rst', +] -ESP32_DOCS = ['api-reference/system/himem.rst', - 'api-guides/romconsole.rst', - 'api-reference/system/ipc.rst', - 'security/secure-boot-v1.rst', - 'api-reference/peripherals/dac.rst', - 'api-reference/peripherals/sd_pullup_requirements.rst', - 'hw-reference/esp32/**', - 'api-guides/RF_calibration.rst', - 'api-guides/phy.rst'] + FTDI_JTAG_DOCS + QEMU_DOCS +ESP32_DOCS = ( + [ + 'api-reference/system/himem.rst', + 'api-guides/romconsole.rst', + 'api-reference/system/ipc.rst', + 'security/secure-boot-v1.rst', + 'api-reference/peripherals/dac.rst', + 'api-reference/peripherals/sd_pullup_requirements.rst', + 'hw-reference/esp32/**', + 'api-guides/RF_calibration.rst', + 'api-guides/phy.rst', + ] + + FTDI_JTAG_DOCS + + QEMU_DOCS +) -ESP32S2_DOCS = ['hw-reference/esp32s2/**', - 'api-guides/usb-console.rst', - 'api-reference/peripherals/ds.rst', - 'api-reference/peripherals/temp_sensor.rst', - 'api-reference/system/async_memcpy.rst', - 'api-reference/peripherals/touch_element.rst', - 'api-guides/RF_calibration.rst', - 'api-guides/phy.rst'] + FTDI_JTAG_DOCS + USB_OTG_DFU_DOCS + USB_OTG_CONSOLE_DOCS +ESP32S2_DOCS = ( + [ + 'hw-reference/esp32s2/**', + 'api-guides/usb-console.rst', + 'api-reference/peripherals/ds.rst', + 'api-reference/peripherals/temp_sensor.rst', + 'api-reference/system/async_memcpy.rst', + 'api-reference/peripherals/touch_element.rst', + 'api-guides/RF_calibration.rst', + 'api-guides/phy.rst', + ] + + FTDI_JTAG_DOCS + + USB_OTG_DFU_DOCS + + USB_OTG_CONSOLE_DOCS +) -ESP32S3_DOCS = ['hw-reference/esp32s3/**', - 'api-reference/system/ipc.rst', - 'api-guides/flash_psram_config.rst', - 'api-reference/peripherals/sd_pullup_requirements.rst', - 'api-guides/RF_calibration.rst', - 'api-guides/phy.rst'] + USB_OTG_DFU_DOCS + USB_OTG_CONSOLE_DOCS + QEMU_DOCS +ESP32S3_DOCS = ( + [ + 'hw-reference/esp32s3/**', + 'api-reference/system/ipc.rst', + 'api-guides/flash_psram_config.rst', + 'api-reference/peripherals/sd_pullup_requirements.rst', + 'api-guides/RF_calibration.rst', + 'api-guides/phy.rst', + ] + + USB_OTG_DFU_DOCS + + USB_OTG_CONSOLE_DOCS + + QEMU_DOCS +) # No JTAG docs for this one as it gets gated on SOC_USB_SERIAL_JTAG_SUPPORTED down below. -ESP32C3_DOCS = ['hw-reference/esp32c3/**', - 'api-guides/RF_calibration.rst', - 'api-guides/phy.rst'] + QEMU_DOCS +ESP32C3_DOCS = ['hw-reference/esp32c3/**', 'api-guides/RF_calibration.rst', 'api-guides/phy.rst'] + QEMU_DOCS -ESP32C2_DOCS = ['api-guides/RF_calibration.rst', - 'api-guides/phy.rst'] +ESP32C2_DOCS = ['api-guides/RF_calibration.rst', 'api-guides/phy.rst'] ESP32C5_DOCS = ['api-guides/phy.rst'] ESP32C61_DOCS = ['api-guides/phy.rst'] -ESP32C6_DOCS = ['api-guides/RF_calibration.rst', - 'api-reference/peripherals/sd_pullup_requirements.rst', - 'api-guides/phy.rst'] + ESP_TEE_DOCS +ESP32C6_DOCS = [ + 'api-guides/RF_calibration.rst', + 'api-reference/peripherals/sd_pullup_requirements.rst', + 'api-guides/phy.rst', +] + ESP_TEE_DOCS -ESP32H2_DOCS = ['api-guides/RF_calibration.rst', - 'api-guides/phy.rst'] +ESP32H2_DOCS = ['api-guides/RF_calibration.rst', 'api-guides/phy.rst'] -ESP32P4_DOCS = ['api-reference/system/ipc.rst', - 'api-reference/peripherals/cap_touch_sens.rst', - 'api-reference/peripherals/sd_pullup_requirements.rst'] + USB_OTG_DFU_DOCS +ESP32P4_DOCS = [ + 'api-reference/system/ipc.rst', + 'api-reference/peripherals/cap_touch_sens.rst', + 'api-reference/peripherals/sd_pullup_requirements.rst', +] + USB_OTG_DFU_DOCS # format: {tag needed to include: documents to included}, tags are parsed from sdkconfig and peripheral_caps.h headers -conditional_include_dict = {'SOC_BT_SUPPORTED':BT_DOCS, - 'SOC_BLE_SUPPORTED':BLE_DOCS, - 'SOC_BLE_MESH_SUPPORTED':BLE_MESH_DOCS, - 'SOC_BLUFI_SUPPORTED':BLUFI_DOCS, - 'SOC_WIFI_SUPPORTED':WIFI_DOCS, - 'SOC_BT_CLASSIC_SUPPORTED':CLASSIC_BT_DOCS, - 'SOC_IEEE802154_SUPPORTED':IEEE802154_DOCS, - 'SOC_SUPPORT_COEXISTENCE':COEXISTENCE_DOCS, - 'SOC_PSRAM_DMA_CAPABLE':MM_SYNC_DOCS, - 'SOC_CACHE_INTERNAL_MEM_VIA_L1CACHE':MM_SYNC_DOCS, - 'SOC_CLK_TREE_SUPPORTED':CLK_TREE_DOCS, - 'SOC_UART_SUPPORTED':UART_DOCS, - 'SOC_SDMMC_HOST_SUPPORTED':SDMMC_DOCS, - 'SOC_SDIO_SLAVE_SUPPORTED':SDIO_SLAVE_DOCS, - 'SOC_MCPWM_SUPPORTED':MCPWM_DOCS, - 'SOC_USB_OTG_SUPPORTED':USB_DOCS, - 'SOC_USB_SERIAL_JTAG_SUPPORTED':USB_SERIAL_JTAG_DOCS, - 'SOC_DEDICATED_GPIO_SUPPORTED':DEDIC_GPIO_DOCS, - 'SOC_LCD_I80_SUPPORTED':I80_LCD_DOCS, - 'SOC_LCD_RGB_SUPPORTED':RGB_LCD_DOCS, - 'SOC_PARLIO_SUPPORT_SPI_LCD':PARLIO_LCD_DOCS, - 'SOC_MIPI_DSI_SUPPORTED':DSI_LCD_DOCS, - 'SOC_SPIRAM_SUPPORTED':SPIRAM_DOCS, - 'SOC_PARLIO_SUPPORTED':PARLIO_DOCS, - 'SOC_PCNT_SUPPORTED':PCNT_DOCS, - 'SOC_RMT_SUPPORTED':RMT_DOCS, - 'SOC_DAC_SUPPORTED':DAC_DOCS, - 'SOC_ETM_SUPPORTED':ETM_DOCS, - 'SOC_ULP_FSM_SUPPORTED':ULP_FSM_DOCS, - 'SOC_RISCV_COPROC_SUPPORTED':RISCV_COPROC_DOCS, - 'SOC_LP_CORE_SUPPORTED':LP_CORE_DOCS, - 'SOC_DIG_SIGN_SUPPORTED':['api-reference/peripherals/ds.rst'], - 'SOC_ECDSA_SUPPORTED':['api-reference/peripherals/ecdsa.rst'], - 'SOC_HMAC_SUPPORTED':['api-reference/peripherals/hmac.rst'], - 'SOC_ASYNC_MEMCPY_SUPPORTED':['api-reference/system/async_memcpy.rst'], - 'CONFIG_IDF_TARGET_ARCH_XTENSA':XTENSA_DOCS, - 'CONFIG_IDF_TARGET_ARCH_RISCV':RISCV_DOCS, - 'SOC_TEMP_SENSOR_SUPPORTED':TEMP_SENSOR_DOCS, - 'SOC_TOUCH_SENSOR_SUPPORTED':TOUCH_SENSOR_DOCS, - 'SOC_TWAI_SUPPORTED':TWAI_DOCS, - 'SOC_I2C_SUPPORTED':I2C_DOCS, - 'SOC_GPSPI_SUPPORTED':SPI_DOCS, - 'SOC_I2S_SUPPORTED':I2S_DOCS, - 'SOC_LP_I2S_SUPPORTED':LP_I2S_DOCS, - 'SOC_LP_VAD_SUPPORTED':VAD_DOCS, - 'SOC_ISP_SUPPORTED':ISP_DOCS, - 'ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB': DSLP_STUB_DOCS, - 'SOC_ADC_SUPPORTED':ADC_DOCS, - 'SOC_ADC_DMA_SUPPORTED':ADC_DMA_DOCS, - 'SOC_ANA_CMPR_SUPPORTED': ANA_CMPR_DOCS, - 'SOC_SDM_SUPPORTED':SDM_DOCS, - 'SOC_WIFI_MESH_SUPPORT':WIFI_MESH_DOCS, - 'SOC_MIPI_CSI_SUPPORTED':CAMERA_DOCS, - 'SOC_BITSCRAMBLER_SUPPORTED':BITSCRAMBLER_DOCS, - 'SOC_SPI_SUPPORT_SLAVE_HD_VER2':SPI_SLAVE_HD_DOCS, - 'SOC_WIFI_NAN_SUPPORT':NAN_DOCS, - 'SOC_JPEG_CODEC_SUPPORTED':JPEG_DOCS, - 'SOC_PPA_SUPPORTED':PPA_DOCS, - 'SOC_GP_LDO_SUPPORTED':LDO_DOCS, - 'esp32':ESP32_DOCS, - 'esp32s2':ESP32S2_DOCS, - 'esp32s3':ESP32S3_DOCS, - 'esp32c2':ESP32C2_DOCS, - 'esp32c3':ESP32C3_DOCS, - 'esp32c5':ESP32C5_DOCS, - 'esp32c6':ESP32C6_DOCS, - 'esp32c61':ESP32C61_DOCS, - 'esp32h2':ESP32H2_DOCS, - 'esp32p4':ESP32P4_DOCS} +conditional_include_dict = { + 'SOC_BT_SUPPORTED': BT_DOCS, + 'SOC_BLE_SUPPORTED': BLE_DOCS, + 'SOC_BLE_MESH_SUPPORTED': BLE_MESH_DOCS, + 'SOC_BLUFI_SUPPORTED': BLUFI_DOCS, + 'SOC_WIFI_SUPPORTED': WIFI_DOCS, + 'SOC_BT_CLASSIC_SUPPORTED': CLASSIC_BT_DOCS, + 'SOC_IEEE802154_SUPPORTED': IEEE802154_DOCS, + 'SOC_SUPPORT_COEXISTENCE': COEXISTENCE_DOCS, + 'SOC_PSRAM_DMA_CAPABLE': MM_SYNC_DOCS, + 'SOC_CACHE_INTERNAL_MEM_VIA_L1CACHE': MM_SYNC_DOCS, + 'SOC_CLK_TREE_SUPPORTED': CLK_TREE_DOCS, + 'SOC_UART_SUPPORTED': UART_DOCS, + 'SOC_SDMMC_HOST_SUPPORTED': SDMMC_DOCS, + 'SOC_SDIO_SLAVE_SUPPORTED': SDIO_SLAVE_DOCS, + 'SOC_MCPWM_SUPPORTED': MCPWM_DOCS, + 'SOC_USB_OTG_SUPPORTED': USB_DOCS, + 'SOC_USB_SERIAL_JTAG_SUPPORTED': USB_SERIAL_JTAG_DOCS, + 'SOC_DEDICATED_GPIO_SUPPORTED': DEDIC_GPIO_DOCS, + 'SOC_LCD_I80_SUPPORTED': I80_LCD_DOCS, + 'SOC_LCD_RGB_SUPPORTED': RGB_LCD_DOCS, + 'SOC_PARLIO_SUPPORT_SPI_LCD': PARLIO_LCD_DOCS, + 'SOC_MIPI_DSI_SUPPORTED': DSI_LCD_DOCS, + 'SOC_SPIRAM_SUPPORTED': SPIRAM_DOCS, + 'SOC_PARLIO_SUPPORTED': PARLIO_DOCS, + 'SOC_PCNT_SUPPORTED': PCNT_DOCS, + 'SOC_RMT_SUPPORTED': RMT_DOCS, + 'SOC_DAC_SUPPORTED': DAC_DOCS, + 'SOC_ETM_SUPPORTED': ETM_DOCS, + 'SOC_ULP_FSM_SUPPORTED': ULP_FSM_DOCS, + 'SOC_RISCV_COPROC_SUPPORTED': RISCV_COPROC_DOCS, + 'SOC_LP_CORE_SUPPORTED': LP_CORE_DOCS, + 'SOC_DIG_SIGN_SUPPORTED': ['api-reference/peripherals/ds.rst'], + 'SOC_ECDSA_SUPPORTED': ['api-reference/peripherals/ecdsa.rst'], + 'SOC_HMAC_SUPPORTED': ['api-reference/peripherals/hmac.rst'], + 'SOC_ASYNC_MEMCPY_SUPPORTED': ['api-reference/system/async_memcpy.rst'], + 'CONFIG_IDF_TARGET_ARCH_XTENSA': XTENSA_DOCS, + 'CONFIG_IDF_TARGET_ARCH_RISCV': RISCV_DOCS, + 'SOC_TEMP_SENSOR_SUPPORTED': TEMP_SENSOR_DOCS, + 'SOC_TOUCH_SENSOR_SUPPORTED': TOUCH_SENSOR_DOCS, + 'SOC_TWAI_SUPPORTED': TWAI_DOCS, + 'SOC_I2C_SUPPORTED': I2C_DOCS, + 'SOC_GPSPI_SUPPORTED': SPI_DOCS, + 'SOC_I2S_SUPPORTED': I2S_DOCS, + 'SOC_LP_I2S_SUPPORTED': LP_I2S_DOCS, + 'SOC_LP_VAD_SUPPORTED': VAD_DOCS, + 'SOC_ISP_SUPPORTED': ISP_DOCS, + 'ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB': DSLP_STUB_DOCS, + 'SOC_ADC_SUPPORTED': ADC_DOCS, + 'SOC_ADC_DMA_SUPPORTED': ADC_DMA_DOCS, + 'SOC_ANA_CMPR_SUPPORTED': ANA_CMPR_DOCS, + 'SOC_SDM_SUPPORTED': SDM_DOCS, + 'SOC_WIFI_MESH_SUPPORT': WIFI_MESH_DOCS, + 'SOC_MIPI_CSI_SUPPORTED': CAMERA_DOCS, + 'SOC_BITSCRAMBLER_SUPPORTED': BITSCRAMBLER_DOCS, + 'SOC_SPI_SUPPORT_SLAVE_HD_VER2': SPI_SLAVE_HD_DOCS, + 'SOC_WIFI_NAN_SUPPORT': NAN_DOCS, + 'SOC_JPEG_CODEC_SUPPORTED': JPEG_DOCS, + 'SOC_PPA_SUPPORTED': PPA_DOCS, + 'SOC_GP_LDO_SUPPORTED': LDO_DOCS, + 'esp32': ESP32_DOCS, + 'esp32s2': ESP32S2_DOCS, + 'esp32s3': ESP32S3_DOCS, + 'esp32c2': ESP32C2_DOCS, + 'esp32c3': ESP32C3_DOCS, + 'esp32c5': ESP32C5_DOCS, + 'esp32c6': ESP32C6_DOCS, + 'esp32c61': ESP32C61_DOCS, + 'esp32h2': ESP32H2_DOCS, + 'esp32p4': ESP32P4_DOCS, +} -extensions += ['sphinx_copybutton', - 'sphinxcontrib.wavedrom', - # Note: order is important here, events must - # be registered by one extension before they can be - # connected to another extension - 'esp_docs.idf_extensions.build_system', - 'esp_docs.idf_extensions.esp_err_definitions', - 'esp_docs.idf_extensions.gen_defines', - 'esp_docs.idf_extensions.gen_version_specific_includes', - 'esp_docs.idf_extensions.kconfig_reference', - 'esp_docs.idf_extensions.gen_idf_tools_links', - 'esp_docs.esp_extensions.run_doxygen', - 'esp_docs.esp_extensions.add_html_zip', - 'linuxdoc.rstFlatTable', # https://return42.github.io/linuxdoc/linuxdoc-howto/table-markup.html#flat-table - ] +extensions += [ # noqa: F405 + 'sphinx_copybutton', + 'sphinxcontrib.wavedrom', + # Note: order is important here, events must + # be registered by one extension before they can be + # connected to another extension + 'esp_docs.idf_extensions.build_system', + 'esp_docs.idf_extensions.esp_err_definitions', + 'esp_docs.idf_extensions.gen_defines', + 'esp_docs.idf_extensions.gen_version_specific_includes', + 'esp_docs.idf_extensions.kconfig_reference', + 'esp_docs.idf_extensions.gen_idf_tools_links', + 'esp_docs.esp_extensions.run_doxygen', + 'esp_docs.esp_extensions.add_html_zip', + 'linuxdoc.rstFlatTable', # https://return42.github.io/linuxdoc/linuxdoc-howto/table-markup.html#flat-table +] # Use wavedrompy as backend, instead of wavedrom-cli render_using_wavedrompy = True @@ -355,8 +396,8 @@ smartquotes = False github_repo = 'espressif/esp-idf' # context used by sphinx_idf_theme -html_context['github_user'] = 'espressif' -html_context['github_repo'] = 'esp-idf' +html_context['github_user'] = 'espressif' # noqa: F405 +html_context['github_repo'] = 'esp-idf' # noqa: F405 # Extra options required by sphinx_idf_theme @@ -372,26 +413,33 @@ project_homepage = 'https://github.com/espressif/esp-idf' linkcheck_anchors = False -linkcheck_exclude_documents = ['index', # several false positives due to the way we link to different sections - 'api-reference/protocols/esp_local_ctrl', # Fails due to `https://.local` - 'api-reference/provisioning/wifi_provisioning', # Fails due to `https://.local` - ] +linkcheck_exclude_documents = [ + 'index', # several false positives due to the way we link to different sections + 'api-reference/protocols/esp_local_ctrl', # Fails due to `https://.local` + 'api-reference/provisioning/wifi_provisioning', # Fails due to `https://.local` +] -linkcheck_ignore = ['https://webhome.phy.duke.edu/~rgb/General/dieharder.php', # Certificate error - 'https://docs.espressif.com/projects/esptool/en/latest/esp32c2/espefuse/index.html', # Not published - 'https://docs.espressif.com/projects/esptool/en/latest/esp32c2/espsecure/index.html#remote-signing-using-an-external-hs', # Not published - 'https://docs.espressif.com/projects/esptool/en/latest/esp32c6/espefuse/index.html', # Not published - 'https://docs.espressif.com/projects/esptool/en/latest/esp32c6/espsecure/index.html#remote-signing-using-an-external-hs', # Not published - 'https://docs.espressif.com/projects/esptool/en/latest/esp32h2/espefuse/index.html', # Not published - 'https://docs.espressif.com/projects/esptool/en/latest/esp32h2/espsecure/index.html#remote-signing-using-an-external-hs', # Not published - 'https://www.cadence.com/content/dam/cadence-www/global/en_US/documents/tools/ip/tensilica-ip/isa-summary.pdf', # Rejects user-agent - ] - +# URLs to ignore during linkcheck +linkcheck_ignore = [ + # Certificate error + 'https://webhome.phy.duke.edu/~rgb/General/dieharder.php', + # Not published docs + 'https://docs.espressif.com/projects/esptool/en/latest/esp32c2/espefuse/index.html', + 'https://docs.espressif.com/projects/esptool/en/latest/esp32c2/espsecure/index.html#remote-signing-using-an-external-hs', + 'https://docs.espressif.com/projects/esptool/en/latest/esp32c6/espefuse/index.html', + 'https://docs.espressif.com/projects/esptool/en/latest/esp32c6/espsecure/index.html#remote-signing-using-an-external-hs', + 'https://docs.espressif.com/projects/esptool/en/latest/esp32h2/espefuse/index.html', + 'https://docs.espressif.com/projects/esptool/en/latest/esp32h2/espsecure/index.html#remote-signing-using-an-external-hs', + # Rejects user-agent + 'https://www.cadence.com/content/dam/cadence-www/global/en_US/documents/tools/ip/tensilica-ip/isa-summary.pdf', +] # Custom added feature to allow redirecting old URLs with open('../page_redirects.txt') as f: - lines = [re.sub(' +', ' ', line.strip()) for line in f.readlines() if line.strip() != '' and not line.startswith('#')] + lines = [ + re.sub(' +', ' ', line.strip()) for line in f.readlines() if line.strip() != '' and not line.startswith('#') + ] for line in lines: # check for well-formed entries if len(line.split(' ')) != 2: raise RuntimeError('Invalid line in page_redirects.txt: %s' % line) @@ -399,7 +447,10 @@ html_redirect_pages = [tuple(line.split(' ')) for line in lines] html_static_path = ['../_static'] -idf_build_system = {'doxygen_component_info': True, 'component_info_ignore_file': Path(os.environ['IDF_PATH']) / 'docs' / 'component_info_ignore_file.txt'} +idf_build_system = { + 'doxygen_component_info': True, + 'component_info_ignore_file': Path(os.environ['IDF_PATH']) / 'docs' / 'component_info_ignore_file.txt', +} # Please update following list to enable Qemu doc guide (and cross references) for a new target QEMU_TARGETS = ['esp32', 'esp32c3', 'esp32s3'] @@ -408,7 +459,9 @@ QEMU_TARGETS = ['esp32', 'esp32c3', 'esp32s3'] # Callback function for user setup that needs be done after `config-init`-event # config.idf_target is not available at the initial config stage def conf_setup(app, config): - config.add_warnings_content = 'This document is not updated for {} yet, so some of the content may not be correct.'.format(config.idf_target.upper()) + config.add_warnings_content = ( + f'This document is not updated for {config.idf_target.upper()} yet, so some of the content may not be correct.' + ) add_warnings_file = '{}/../docs_not_updated/{}.txt'.format(app.confdir, config.idf_target) diff --git a/tools/check_python_dependencies.py b/tools/check_python_dependencies.py index 1c290b4b7c..da7bb4f47b 100755 --- a/tools/check_python_dependencies.py +++ b/tools/check_python_dependencies.py @@ -12,20 +12,23 @@ try: from packaging.requirements import Requirement from packaging.version import Version except ImportError: - print('packaging cannot be imported. ' - 'If you\'ve installed a custom Python then this package is provided separately and have to be installed as well. ' - 'Please refer to the Get Started section of the ESP-IDF Programming Guide for setting up the required packages.') + print( + 'packaging cannot be imported. ' + "If you've installed a custom Python then this package is provided separately and have to be installed as " + 'well. Please refer to the Get Started section of the ESP-IDF Programming Guide for setting up the required ' + 'packages.' + ) sys.exit(1) try: + from importlib.metadata import PackageNotFoundError from importlib.metadata import requires as _requires from importlib.metadata import version as _version - from importlib.metadata import PackageNotFoundError except ImportError: # compatibility for python <=3.7 + from importlib_metadata import PackageNotFoundError # type: ignore from importlib_metadata import requires as _requires # type: ignore from importlib_metadata import version as _version # type: ignore - from importlib_metadata import PackageNotFoundError # type: ignore try: from typing import Set @@ -66,12 +69,20 @@ def get_requires(name: str) -> Optional[list]: if __name__ == '__main__': parser = argparse.ArgumentParser(description='ESP-IDF Python package dependency checker') - parser.add_argument('--requirements', '-r', - help='Path to a requirements file (can be used multiple times)', - action='append', default=[]) - parser.add_argument('--constraints', '-c', default=[], - help='Path to a constraints file (can be used multiple times)', - action='append') + parser.add_argument( + '--requirements', + '-r', + help='Path to a requirements file (can be used multiple times)', + action='append', + default=[], + ) + parser.add_argument( + '--constraints', + '-c', + default=[], + help='Path to a constraints file (can be used multiple times)', + action='append', + ) args = parser.parse_args() required_set = set() @@ -87,7 +98,8 @@ if __name__ == '__main__': con = os.path.basename(con) elif con.startswith('--only-binary'): continue - elif con.startswith('-e') and '#egg=' in con: # version control URLs, take the egg= part at the end only + # version control URLs, take the egg= part at the end only + elif con.startswith('-e') and '#egg=' in con: con_m = re.search(r'#egg=([^\s]+)', con) if not con_m: print('Malformed input. Cannot find name in {}'.format(con)) @@ -103,7 +115,7 @@ if __name__ == '__main__': not_satisfied = [] # in string form which will be printed # already_checked set is used in order to avoid circular checks which would cause looping. - already_checked = set() # type: Set[Requirement] + already_checked: Set[Requirement] = set() # required_set contains package names in string form without version constraints. If the package has a constraint # specification (package name + version requirement) then use that instead. new_req_list is used to store @@ -125,7 +137,10 @@ if __name__ == '__main__': except Exception as e: # Catch general exception, because get_version may return None (https://github.com/python/cpython/issues/91216) # log package name alongside the error message for easier debugging - not_satisfied.append(f"Error while checking requirement '{req}'. Package was not found and is required by the application: {e}") + not_satisfied.append( + f"Error while checking requirement '{req}'. Package was not found and is required by the " + f'application: {e}' + ) new_req_list.remove(req) else: new_req_list.remove(req) @@ -138,7 +153,7 @@ if __name__ == '__main__': try: dependency_requirements = set() extras = list(requirement.extras) or [''] - # `requires` returns all sub-requirements including all extras - we need to filter out just required ones + # `requires` returns all sub-requirements including all extras; we need to filter out just required ones for name in get_requires(requirement.name) or []: sub_req = Requirement(name) # check extras e.g. esptool[hsm] @@ -155,7 +170,10 @@ if __name__ == '__main__': except Exception as e: # Catch general exception, because get_version may return None (https://github.com/python/cpython/issues/91216) # log package name alongside the error message for easier debugging - not_satisfied.append(f"Error while checking requirement '{req}'. Package was not found and is required by the application: {e}") + not_satisfied.append( + f"Error while checking requirement '{req}'. Package was not found and is required by the " + f'application: {e}' + ) if len(not_satisfied) > 0: print('The following Python requirements are not satisfied:') @@ -166,8 +184,10 @@ if __name__ == '__main__': install_script = 'install.bat' if sys.platform == 'win32' else 'install.sh' print('To install the missing packages, please run "{}"'.format(install_script)) else: - print('Please follow the instructions found in the "Set up the tools" section of ' - 'ESP-IDF Getting Started Guide.') + print( + 'Please follow the instructions found in the "Set up the tools" section of ' + 'ESP-IDF Getting Started Guide.' + ) print('Diagnostic information:') idf_python_env_path = os.environ.get('IDF_PYTHON_ENV_PATH') diff --git a/tools/mkdfu.py b/tools/mkdfu.py index 0fe4000e5e..aac138c7a3 100755 --- a/tools/mkdfu.py +++ b/tools/mkdfu.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD +# SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Apache-2.0 # # This program creates archives compatible with ESP32-S* ROM DFU implementation. @@ -19,13 +19,13 @@ from collections import namedtuple from functools import partial try: - import typing + import typing # noqa: F401 except ImportError: # Only used for type annotations pass try: - from itertools import izip as zip # type: ignore + from itertools import izip as zip # type: ignore # noqa: A004 except ImportError: # Python 3 pass @@ -55,10 +55,8 @@ CPIOHeader = namedtuple( CPIO_TRAILER = 'TRAILER!!!' -def make_cpio_header( - filename_len, file_len, is_trailer=False -): # type: (int, int, bool) -> CPIOHeader - """ Returns CPIOHeader for the given file name and file size """ +def make_cpio_header(filename_len, file_len, is_trailer=False): # type: (int, int, bool) -> CPIOHeader + """Returns CPIOHeader for the given file name and file size""" def as_hex(val): # type: (int) -> bytes return '{:08x}'.format(val).encode('ascii') @@ -91,9 +89,7 @@ DFUInfo = namedtuple('DFUInfo', ['address', 'flags', 'name', 'md5']) DFUINFO_FILE = 'dfuinfo0.dat' # Structure which gets added at the end of the entire DFU file DFUSUFFIX_STRUCT = b' int - """ Calculate CRC32/JAMCRC of data, with an optional initial value """ + """Calculate CRC32/JAMCRC of data, with an optional initial value""" uint32_max = 0xFFFFFFFF return uint32_max - (zlib.crc32(data, crc) & uint32_max) def pad_bytes(b, multiple, padding=b'\x00'): # type: (bytes, int, bytes) -> bytes - """ Pad 'b' to a length divisible by 'multiple' """ + """Pad 'b' to a length divisible by 'multiple'""" padded_len = (len(b) + multiple - 1) // multiple * multiple return b + padding * (padded_len - len(b)) @@ -150,7 +146,7 @@ class EspDfuWriter(object): self.entries = [] # type: typing.List[bytes] self.index = [] # type: typing.List[DFUInfo] - def add_flash_params_file(self, flash_size): # type: (str) -> None + def add_flash_params_file(self, flash_size): # type: (str) -> None """ Add a file containing flash chip parameters @@ -167,7 +163,7 @@ class EspDfuWriter(object): block_size=64 * 1024, sector_size=4 * 1024, page_size=256, - status_mask=0xffff, + status_mask=0xFFFF, ) data = struct.pack(FLASH_PARAMS_STRUCT, *flash_params) flags = DFU_INFO_FLAG_PARAM | DFU_INFO_FLAG_NOERASE | DFU_INFO_FLAG_IGNORE_MD5 @@ -193,7 +189,7 @@ class EspDfuWriter(object): flash_addr += len(chunk) def finish(self): # type: () -> None - """ Write DFU file """ + """Write DFU file""" # Prepare and add dfuinfo0.dat file dfuinfo = b''.join([struct.pack(DFUINFO_STRUCT, *item) for item in self.index]) self._add_cpio_entry(DFUINFO_FILE, dfuinfo, first=True) @@ -214,9 +210,7 @@ class EspDfuWriter(object): # Finally write the entire binary self.dest.write(out_data) - def _add_cpio_flash_entry( - self, filename, flash_addr, data, flags=0 - ): # type: (str, int, bytes, int) -> None + def _add_cpio_flash_entry(self, filename, flash_addr, data, flags=0): # type: (str, int, bytes, int) -> None md5 = hashlib.md5() md5.update(data) self.index.append( @@ -229,14 +223,10 @@ class EspDfuWriter(object): ) self._add_cpio_entry(filename, data) - def _add_cpio_entry( - self, filename, data, first=False, trailer=False - ): # type: (str, bytes, bool, bool) -> None + def _add_cpio_entry(self, filename, data, first=False, trailer=False): # type: (str, bytes, bool, bool) -> None filename_b = filename.encode('utf-8') + b'\x00' cpio_header = make_cpio_header(len(filename_b), len(data), is_trailer=trailer) - entry = pad_bytes( - struct.pack(CPIO_STRUCT, *cpio_header) + filename_b, 4 - ) + pad_bytes(data, 4) + entry = pad_bytes(struct.pack(CPIO_STRUCT, *cpio_header) + filename_b, 4) + pad_bytes(data, 4) if not first: self.entries.append(entry) else: @@ -262,27 +252,33 @@ def main(): # type: () -> None # Provision to add "info" command subparsers = parser.add_subparsers(dest='command') write_parser = subparsers.add_parser('write') - write_parser.add_argument('-o', '--output-file', - help='Filename for storing the output DFU image', - required=True, - type=argparse.FileType('wb')) - write_parser.add_argument('--pid', - required=True, - type=lambda h: int(h, 16), - help='Hexa-decimal product indentificator') - write_parser.add_argument('--json', - help='Optional file for loading "flash_files" dictionary with
items') - write_parser.add_argument('--part-size', - default=os.environ.get('ESP_DFU_PART_SIZE', 512 * 1024), - type=lambda x: int(x, 0), - help='Larger files are split-up into smaller partitions of this size') - write_parser.add_argument('files', - metavar='
', help='Add at
', - nargs='*') - write_parser.add_argument('-fs', '--flash-size', - help='SPI Flash size in MegaBytes (1MB, 2MB, 4MB, 8MB, 16MB, 32MB, 64MB, 128MB)', - choices=['1MB', '2MB', '4MB', '8MB', '16MB', '32MB', '64MB', '128MB'], - default='2MB') + write_parser.add_argument( + '-o', + '--output-file', + help='Filename for storing the output DFU image', + required=True, + type=argparse.FileType('wb'), + ) + write_parser.add_argument( + '--pid', required=True, type=lambda h: int(h, 16), help='Hexa-decimal product indentificator' + ) + write_parser.add_argument( + '--json', help='Optional file for loading "flash_files" dictionary with
items' + ) + write_parser.add_argument( + '--part-size', + default=os.environ.get('ESP_DFU_PART_SIZE', 512 * 1024), + type=lambda x: int(x, 0), + help='Larger files are split-up into smaller partitions of this size', + ) + write_parser.add_argument('files', metavar='
', help='Add at
', nargs='*') + write_parser.add_argument( + '-fs', + '--flash-size', + help='SPI Flash size in MegaBytes (1MB, 2MB, 4MB, 8MB, 16MB, 32MB, 64MB, 128MB)', + choices=['1MB', '2MB', '4MB', '8MB', '16MB', '32MB', '64MB', '128MB'], + default='2MB', + ) args = parser.parse_args() @@ -299,28 +295,28 @@ def main(): # type: () -> None json_dir = os.path.dirname(os.path.abspath(args.json)) def process_json_file(path): # type: (str) -> str - ''' + """ The input path is relative to json_dir. This function makes it relative to the current working directory. - ''' + """ return check_file(os.path.relpath(os.path.join(json_dir, path), start=os.curdir)) with open(args.json, encoding='utf-8') as f: - files += [(int(addr, 0), - process_json_file(f_name)) for addr, f_name in json.load(f)['flash_files'].items()] + files += [(int(addr, 0), process_json_file(f_name)) for addr, f_name in json.load(f)['flash_files'].items()] - files = sorted([(addr, f_name) for addr, f_name in dict(files).items()], - key=lambda x: x[0]) # remove possible duplicates and sort based on the address + files = sorted( + [(addr, f_name) for addr, f_name in dict(files).items()], key=lambda x: x[0] + ) # remove possible duplicates and sort based on the address - cmd_args = {'output_file': args.output_file, - 'files': files, - 'pid': args.pid, - 'part_size': args.part_size, - 'flash_size': args.flash_size, - } + cmd_args = { + 'output_file': args.output_file, + 'files': files, + 'pid': args.pid, + 'part_size': args.part_size, + 'flash_size': args.flash_size, + } - {'write': action_write - }[args.command](cmd_args) + {'write': action_write}[args.command](cmd_args) if __name__ == '__main__': diff --git a/tools/test_idf_tools/test_idf_tools.py b/tools/test_idf_tools/test_idf_tools.py index 00a82635d3..d7a713244e 100755 --- a/tools/test_idf_tools/test_idf_tools.py +++ b/tools/test_idf_tools/test_idf_tools.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD +# SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Apache-2.0 import json import os @@ -9,12 +9,13 @@ import shutil import sys import tempfile import unittest -from subprocess import check_call from subprocess import STDOUT +from subprocess import check_call from unittest.mock import patch try: - from contextlib import redirect_stdout, redirect_stderr + from contextlib import redirect_stderr + from contextlib import redirect_stdout except ImportError: import contextlib @@ -32,6 +33,7 @@ except ImportError: yield sys.stderr = original + try: from cStringIO import StringIO except ImportError: @@ -64,12 +66,12 @@ DFU_UTIL = 'dfu-util' 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()) @@ -98,17 +100,20 @@ DFU_UTIL_VERSION = version_dict[DFU_UTIL] # Avoiding an ambiguity with a substring 'riscv32-esp-elf' in the `riscv32-esp-elf-gdb` # (removing esp- prefix from version) -RISCV_ELF_ARCHIVE_PATTERN = RISCV_ELF + '-' \ - + (RISCV_ELF_VERSION[len('esp-'):] if RISCV_ELF_VERSION.startswith('esp-') else RISCV_ELF_VERSION) +RISCV_ELF_ARCHIVE_PATTERN = ( + RISCV_ELF + '-' + (RISCV_ELF_VERSION[len('esp-') :] if RISCV_ELF_VERSION.startswith('esp-') else RISCV_ELF_VERSION) +) # The same like above -XTENSA_ELF_ARCHIVE_PATTERN = XTENSA_ELF + '-' \ - + (XTENSA_ELF_VERSION[len('esp-'):] if XTENSA_ELF_VERSION.startswith('esp-') else XTENSA_ELF_VERSION) +XTENSA_ELF_ARCHIVE_PATTERN = ( + XTENSA_ELF + + '-' + + (XTENSA_ELF_VERSION[len('esp-') :] if XTENSA_ELF_VERSION.startswith('esp-') else XTENSA_ELF_VERSION) +) # TestUsageBase takes care of general test setup to use the idf_tools commands class TestUsageBase(unittest.TestCase): - @classmethod def setUpClass(cls): with open(os.path.join(os.getenv('IDF_PATH'), 'tools/tools.json'), 'r') as json_file: @@ -122,8 +127,12 @@ class TestUsageBase(unittest.TestCase): # These are are all mapping to filesystem. Windows cannot download from there not even if file:// is omitted local = ''.join(['file://', os.path.join(old_tools_dir, 'dist', '')]) - mirror_prefix_map = ';'.join([f'https://dl.espressif.com/dl,{local}', - f'https://github.com/.*/.*/releases/download/.*/,{local}']) + mirror_prefix_map = ';'.join( + [ + f'https://dl.espressif.com/dl,{local}', + f'https://github.com/.*/.*/releases/download/.*/,{local}', + ] + ) # Windows will keep downloading the tools from default location or IDF_MIRROR_PREFIX_MAP if set globally @@ -193,12 +202,11 @@ class TestUsageBase(unittest.TestCase): # TestUsage executes tests that behaves the same on both platforms # TestUsage class serves as a parent for classes TestUsageUnix and TestUsageWin class TestUsage(TestUsageBase): - 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_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) @@ -251,19 +259,24 @@ class TestUsage(TestUsageBase): '--checksum-file', 'add_version/checksum.sha256', '--output', - tools_json_new - ]) + 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(['--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') + 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)) @@ -276,10 +289,7 @@ class TestUsage(TestUsageBase): for version in tool['versions']: if version['status'] != 'recommended': continue - always_install_and_recommended_tools.append({ - 'name': tool['name'], - 'version': version['name'] - }) + 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']) @@ -322,15 +332,15 @@ class TestUsage(TestUsageBase): self.run_idf_tools_with_action(['install', OPENOCD]) 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', 'openocd-esp32', OPENOCD_VERSION, 'openocd-esp32', 'bin'), + 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) @@ -355,25 +365,35 @@ class TestUsageUnix(TestUsage): 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]: + 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' % - (self.temp_tools_dir, ESP32ULP_VERSION), output) - self.assertIn('%s/tools/xtensa-esp-elf/%s/xtensa-esp-elf/bin' % - (self.temp_tools_dir, XTENSA_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, RISCV_ELF_VERSION), output) - self.assertIn('%s/tools/xtensa-esp-elf-gdb/%s/xtensa-esp-elf-gdb/bin' % - (self.temp_tools_dir, XTENSA_ESP_GDB_VERSION), output) - self.assertIn('%s/tools/riscv32-esp-elf-gdb/%s/riscv32-esp-elf-gdb/bin' % - (self.temp_tools_dir, RISCV_ESP_GDB_VERSION), output) - self.assertIn('%s/tools/esp-rom-elfs/%s/' % - (self.temp_tools_dir, ESP_ROM_ELFS_VERSION), output) + self.assertIn('%s/tools/esp32ulp-elf/%s/esp32ulp-elf/bin' % (self.temp_tools_dir, ESP32ULP_VERSION), output) + self.assertIn( + '%s/tools/xtensa-esp-elf/%s/xtensa-esp-elf/bin' % (self.temp_tools_dir, XTENSA_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, RISCV_ELF_VERSION), output + ) + self.assertIn( + '%s/tools/xtensa-esp-elf-gdb/%s/xtensa-esp-elf-gdb/bin' % (self.temp_tools_dir, XTENSA_ESP_GDB_VERSION), + output, + ) + self.assertIn( + '%s/tools/riscv32-esp-elf-gdb/%s/riscv32-esp-elf-gdb/bin' % (self.temp_tools_dir, RISCV_ESP_GDB_VERSION), + output, + ) + self.assertIn('%s/tools/esp-rom-elfs/%s/' % (self.temp_tools_dir, ESP_ROM_ELFS_VERSION), output) output = self.run_idf_tools_with_action(['list', '--outdated']) self.assertEqual('', output) @@ -393,18 +413,12 @@ class TestUsageUnix(TestUsage): '--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) + ] + ) + + output = self.run_idf_tools_with_action(['--tools-json', tools_json_outdated, 'list', '--outdated']) + self.assertIn((f'{XTENSA_ELF}: version {XTENSA_ELF_VERSION} is outdated by {new_version}'), output) def test_tools_for_esp32(self): required_tools_installed = 5 @@ -420,25 +434,33 @@ class TestUsageUnix(TestUsage): 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]: + 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' % - (self.temp_tools_dir, ESP32ULP_VERSION), output) - self.assertIn('%s/tools/xtensa-esp-elf/%s/xtensa-esp-elf/bin' % - (self.temp_tools_dir, XTENSA_ELF_VERSION), output) - self.assertIn('%s/tools/openocd-esp32/%s/openocd-esp32/bin' % - (self.temp_tools_dir, OPENOCD_VERSION), output) - self.assertIn('%s/tools/xtensa-esp-elf-gdb/%s/xtensa-esp-elf-gdb/bin' % - (self.temp_tools_dir, XTENSA_ESP_GDB_VERSION), output) - self.assertNotIn('%s/tools/riscv32-esp-elf/%s/riscv32-esp-elf/bin' % - (self.temp_tools_dir, RISCV_ELF_VERSION), output) - self.assertNotIn('%s/tools/riscv32-esp-elf-gdb/%s/riscv32-esp-elf-gdb/bin' % - (self.temp_tools_dir, RISCV_ESP_GDB_VERSION), output) - self.assertIn('%s/tools/esp-rom-elfs/%s/' % - (self.temp_tools_dir, ESP_ROM_ELFS_VERSION), output) + self.assertIn('%s/tools/esp32ulp-elf/%s/esp32ulp-elf/bin' % (self.temp_tools_dir, ESP32ULP_VERSION), output) + self.assertIn( + '%s/tools/xtensa-esp-elf/%s/xtensa-esp-elf/bin' % (self.temp_tools_dir, XTENSA_ELF_VERSION), output + ) + self.assertIn('%s/tools/openocd-esp32/%s/openocd-esp32/bin' % (self.temp_tools_dir, OPENOCD_VERSION), output) + self.assertIn( + '%s/tools/xtensa-esp-elf-gdb/%s/xtensa-esp-elf-gdb/bin' % (self.temp_tools_dir, XTENSA_ESP_GDB_VERSION), + output, + ) + self.assertNotIn( + '%s/tools/riscv32-esp-elf/%s/riscv32-esp-elf/bin' % (self.temp_tools_dir, RISCV_ELF_VERSION), output + ) + self.assertNotIn( + '%s/tools/riscv32-esp-elf-gdb/%s/riscv32-esp-elf-gdb/bin' % (self.temp_tools_dir, RISCV_ESP_GDB_VERSION), + output, + ) + self.assertIn('%s/tools/esp-rom-elfs/%s/' % (self.temp_tools_dir, ESP_ROM_ELFS_VERSION), output) def test_tools_for_esp32c3(self): required_tools_installed = 4 @@ -458,18 +480,19 @@ class TestUsageUnix(TestUsage): 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' % - (self.temp_tools_dir, OPENOCD_VERSION), output) - self.assertIn('%s/tools/riscv32-esp-elf/%s/riscv32-esp-elf/bin' % - (self.temp_tools_dir, RISCV_ELF_VERSION), output) - self.assertNotIn('%s/tools/esp32ulp-elf/%s/esp32ulp-elf/bin' % - (self.temp_tools_dir, ESP32ULP_VERSION), output) - self.assertNotIn('%s/tools/xtensa-esp-elf/%s/xtensa-esp-elf/bin' % - (self.temp_tools_dir, XTENSA_ELF_VERSION), output) - self.assertNotIn('%s/tools/xtensa-esp-elf-gdb/%s/xtensa-esp-elf-gdb/bin' % - (self.temp_tools_dir, XTENSA_ESP_GDB_VERSION), output) - self.assertIn('%s/tools/esp-rom-elfs/%s/' % - (self.temp_tools_dir, ESP_ROM_ELFS_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, RISCV_ELF_VERSION), output + ) + self.assertNotIn('%s/tools/esp32ulp-elf/%s/esp32ulp-elf/bin' % (self.temp_tools_dir, ESP32ULP_VERSION), output) + self.assertNotIn( + '%s/tools/xtensa-esp-elf/%s/xtensa-esp-elf/bin' % (self.temp_tools_dir, XTENSA_ELF_VERSION), output + ) + self.assertNotIn( + '%s/tools/xtensa-esp-elf-gdb/%s/xtensa-esp-elf-gdb/bin' % (self.temp_tools_dir, XTENSA_ESP_GDB_VERSION), + output, + ) + self.assertIn('%s/tools/esp-rom-elfs/%s/' % (self.temp_tools_dir, ESP_ROM_ELFS_VERSION), output) def test_tools_for_esp32s2(self): required_tools_installed = 6 @@ -489,20 +512,23 @@ class TestUsageUnix(TestUsage): 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' % - (self.temp_tools_dir, XTENSA_ELF_VERSION), output) - self.assertIn('%s/tools/openocd-esp32/%s/openocd-esp32/bin' % - (self.temp_tools_dir, OPENOCD_VERSION), output) - self.assertIn('%s/tools/esp32ulp-elf/%s/esp32ulp-elf/bin' % - (self.temp_tools_dir, ESP32ULP_VERSION), output) - self.assertIn('%s/tools/riscv32-esp-elf/%s/riscv32-esp-elf/bin' % - (self.temp_tools_dir, RISCV_ELF_VERSION), output) - self.assertIn('%s/tools/xtensa-esp-elf-gdb/%s/xtensa-esp-elf-gdb/bin' % - (self.temp_tools_dir, XTENSA_ESP_GDB_VERSION), output) - self.assertNotIn('%s/tools/riscv32-esp-elf-gdb/%s/riscv32-esp-elf-gdb/bin' % - (self.temp_tools_dir, RISCV_ESP_GDB_VERSION), output) - self.assertIn('%s/tools/esp-rom-elfs/%s/' % - (self.temp_tools_dir, ESP_ROM_ELFS_VERSION), output) + self.assertIn( + '%s/tools/xtensa-esp-elf/%s/xtensa-esp-elf/bin' % (self.temp_tools_dir, XTENSA_ELF_VERSION), output + ) + self.assertIn('%s/tools/openocd-esp32/%s/openocd-esp32/bin' % (self.temp_tools_dir, OPENOCD_VERSION), output) + self.assertIn('%s/tools/esp32ulp-elf/%s/esp32ulp-elf/bin' % (self.temp_tools_dir, ESP32ULP_VERSION), output) + self.assertIn( + '%s/tools/riscv32-esp-elf/%s/riscv32-esp-elf/bin' % (self.temp_tools_dir, RISCV_ELF_VERSION), output + ) + self.assertIn( + '%s/tools/xtensa-esp-elf-gdb/%s/xtensa-esp-elf-gdb/bin' % (self.temp_tools_dir, XTENSA_ESP_GDB_VERSION), + output, + ) + self.assertNotIn( + '%s/tools/riscv32-esp-elf-gdb/%s/riscv32-esp-elf-gdb/bin' % (self.temp_tools_dir, RISCV_ESP_GDB_VERSION), + output, + ) + self.assertIn('%s/tools/esp-rom-elfs/%s/' % (self.temp_tools_dir, ESP_ROM_ELFS_VERSION), output) def test_tools_for_esp32s3(self): required_tools_installed = 6 @@ -518,25 +544,33 @@ class TestUsageUnix(TestUsage): 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, ESP_ROM_ELFS_VERSION]: + 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' % - (self.temp_tools_dir, OPENOCD_VERSION), output) - self.assertIn('%s/tools/xtensa-esp-elf/%s/xtensa-esp-elf/bin' % - (self.temp_tools_dir, XTENSA_ELF_VERSION), output) - self.assertIn('%s/tools/esp32ulp-elf/%s/esp32ulp-elf/bin' % - (self.temp_tools_dir, ESP32ULP_VERSION), output) - self.assertIn('%s/tools/riscv32-esp-elf/%s/riscv32-esp-elf/bin' % - (self.temp_tools_dir, RISCV_ELF_VERSION), output) - self.assertIn('%s/tools/xtensa-esp-elf-gdb/%s/xtensa-esp-elf-gdb/bin' % - (self.temp_tools_dir, XTENSA_ESP_GDB_VERSION), output) - self.assertNotIn('%s/tools/riscv32-esp-elf-gdb/%s/riscv32-esp-elf-gdb/bin' % - (self.temp_tools_dir, RISCV_ESP_GDB_VERSION), output) - self.assertIn('%s/tools/esp-rom-elfs/%s/' % - (self.temp_tools_dir, ESP_ROM_ELFS_VERSION), output) + self.assertIn('%s/tools/openocd-esp32/%s/openocd-esp32/bin' % (self.temp_tools_dir, OPENOCD_VERSION), output) + self.assertIn( + '%s/tools/xtensa-esp-elf/%s/xtensa-esp-elf/bin' % (self.temp_tools_dir, XTENSA_ELF_VERSION), output + ) + self.assertIn('%s/tools/esp32ulp-elf/%s/esp32ulp-elf/bin' % (self.temp_tools_dir, ESP32ULP_VERSION), output) + self.assertIn( + '%s/tools/riscv32-esp-elf/%s/riscv32-esp-elf/bin' % (self.temp_tools_dir, RISCV_ELF_VERSION), output + ) + self.assertIn( + '%s/tools/xtensa-esp-elf-gdb/%s/xtensa-esp-elf-gdb/bin' % (self.temp_tools_dir, XTENSA_ESP_GDB_VERSION), + output, + ) + self.assertNotIn( + '%s/tools/riscv32-esp-elf-gdb/%s/riscv32-esp-elf-gdb/bin' % (self.temp_tools_dir, RISCV_ESP_GDB_VERSION), + output, + ) + self.assertIn('%s/tools/esp-rom-elfs/%s/' % (self.temp_tools_dir, ESP_ROM_ELFS_VERSION), output) def test_tools_for_esp32p4(self): required_tools_installed = 4 @@ -556,12 +590,24 @@ class TestUsageUnix(TestUsage): output = self.run_idf_tools_with_action(['export']) self.assertIn(os.path.join(self.temp_tools_dir, 'tools', OPENOCD, OPENOCD_VERSION, OPENOCD, 'bin'), output) - self.assertIn(os.path.join(self.temp_tools_dir, 'tools', RISCV_ELF, RISCV_ELF_VERSION, RISCV_ELF, 'bin'), output) + self.assertIn( + os.path.join(self.temp_tools_dir, 'tools', RISCV_ELF, RISCV_ELF_VERSION, RISCV_ELF, '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', RISCV_ESP_GDB, RISCV_ESP_GDB_VERSION, RISCV_ESP_GDB, 'bin'), output) - self.assertNotIn(os.path.join(self.temp_tools_dir, 'tools', ESP32ULP, ESP32ULP_VERSION, ESP32ULP, 'bin'), output) - self.assertNotIn(os.path.join(self.temp_tools_dir, 'tools', XTENSA_ELF, XTENSA_ELF_VERSION, XTENSA_ELF, 'bin'), output) - self.assertNotIn(os.path.join(self.temp_tools_dir, 'tools', XTENSA_ESP_GDB, XTENSA_ESP_GDB_VERSION, XTENSA_ESP_GDB, 'bin'), output) + self.assertIn( + os.path.join(self.temp_tools_dir, 'tools', RISCV_ESP_GDB, RISCV_ESP_GDB_VERSION, RISCV_ESP_GDB, 'bin'), + output, + ) + self.assertNotIn( + os.path.join(self.temp_tools_dir, 'tools', ESP32ULP, ESP32ULP_VERSION, ESP32ULP, 'bin'), output + ) + self.assertNotIn( + os.path.join(self.temp_tools_dir, 'tools', XTENSA_ELF, XTENSA_ELF_VERSION, XTENSA_ELF, 'bin'), output + ) + self.assertNotIn( + os.path.join(self.temp_tools_dir, 'tools', XTENSA_ESP_GDB, XTENSA_ESP_GDB_VERSION, XTENSA_ESP_GDB, 'bin'), + output, + ) # a different test for qemu because of "on_request" def test_tools_for_qemu_with_required(self): @@ -590,7 +636,6 @@ class TestUsageUnix(TestUsage): # 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) @@ -620,48 +665,59 @@ class TestUsageWin(TestUsage): 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]: + 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.10.2-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) + 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.10.2-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) @@ -681,18 +737,12 @@ class TestUsageWin(TestUsage): '--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) + ] + ) + + output = self.run_idf_tools_with_action(['--tools-json', tools_json_outdated, 'list', '--outdated']) + self.assertIn((f'{XTENSA_ELF}: version {XTENSA_ELF_VERSION} is outdated by {new_version}'), output) def test_tools_for_esp32_win(self): required_tools_installed = 9 @@ -713,48 +763,65 @@ class TestUsageWin(TestUsage): 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]: + 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.10.2-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) + 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.10.2-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 @@ -775,45 +842,58 @@ class TestUsageWin(TestUsage): 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]: + 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.10.2-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) + 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.10.2-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 @@ -834,47 +914,64 @@ class TestUsageWin(TestUsage): 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]: + 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.10.2-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) + 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.10.2-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 @@ -896,48 +993,65 @@ class TestUsageWin(TestUsage): 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]: + 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.10.2-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) + 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.10.2-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_esp32p4_win(self): required_tools_installed = 8 @@ -957,23 +1071,47 @@ class TestUsageWin(TestUsage): self.assertEqual(required_tools_installed, output.count('Done')) output = self.run_idf_tools_with_action(['check']) - for tool_version in [RISCV_ELF_VERSION, RISCV_ESP_GDB_VERSION, ESP_ROM_ELFS_VERSION, OPENOCD_VERSION, - CMAKE_VERSION, NINJA_VERSION, IDF_EXE_VERSION, CCACHE_VERSION]: + for tool_version in [ + RISCV_ELF_VERSION, + RISCV_ESP_GDB_VERSION, + ESP_ROM_ELFS_VERSION, + OPENOCD_VERSION, + CMAKE_VERSION, + NINJA_VERSION, + IDF_EXE_VERSION, + CCACHE_VERSION, + ]: self.assertIn(f'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', RISCV_ELF, RISCV_ELF_VERSION, RISCV_ELF, 'bin'), output) - self.assertIn(os.path.join(self.temp_tools_dir, 'tools', RISCV_ESP_GDB, RISCV_ESP_GDB_VERSION, RISCV_ESP_GDB, 'bin'), output) + self.assertIn( + os.path.join(self.temp_tools_dir, 'tools', RISCV_ELF, RISCV_ELF_VERSION, RISCV_ELF, 'bin'), output + ) + self.assertIn( + os.path.join(self.temp_tools_dir, 'tools', RISCV_ESP_GDB, RISCV_ESP_GDB_VERSION, RISCV_ESP_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', OPENOCD, OPENOCD_VERSION, OPENOCD, 'bin'), 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.10.2-windows-x86_64'), output) - self.assertNotIn(os.path.join(self.temp_tools_dir, 'tools', XTENSA_ELF, XTENSA_ELF_VERSION, XTENSA_ELF, 'bin'), output) - self.assertNotIn(os.path.join(self.temp_tools_dir, 'tools', ESP32ULP, ESP32ULP_VERSION, ESP32ULP, 'bin'), output) - self.assertNotIn(os.path.join(self.temp_tools_dir, 'tools', XTENSA_ESP_GDB, XTENSA_ESP_GDB_VERSION, XTENSA_ESP_GDB, 'bin'), output) - self.assertNotIn(os.path.join(self.temp_tools_dir, 'tools', DFU_UTIL, DFU_UTIL_VERSION, 'dfu-util-0.11-win64'), output) + self.assertIn( + os.path.join(self.temp_tools_dir, 'tools', CCACHE, CCACHE_VERSION, 'ccache-4.10.2-windows-x86_64'), output + ) + self.assertNotIn( + os.path.join(self.temp_tools_dir, 'tools', XTENSA_ELF, XTENSA_ELF_VERSION, XTENSA_ELF, 'bin'), output + ) + self.assertNotIn( + os.path.join(self.temp_tools_dir, 'tools', ESP32ULP, ESP32ULP_VERSION, ESP32ULP, 'bin'), output + ) + self.assertNotIn( + os.path.join(self.temp_tools_dir, 'tools', XTENSA_ESP_GDB, XTENSA_ESP_GDB_VERSION, XTENSA_ESP_GDB, 'bin'), + output, + ) + self.assertNotIn( + 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): @@ -998,7 +1136,6 @@ class TestUsageWin(TestUsage): class TestMaintainer(unittest.TestCase): - @classmethod def setUpClass(cls): idf_path = os.getenv('IDF_PATH') @@ -1050,8 +1187,9 @@ class TestMaintainer(unittest.TestCase): 'http://test.com', '--version', 'test', - '--artifact-file' - ] + filenames + '--artifact-file', + ] + + filenames ) expected_json = self.add_version_get_expected_json('add_version/artifact_expected_addition.json') with open(self.tools_new, 'r') as f1: @@ -1087,7 +1225,7 @@ class TestMaintainer(unittest.TestCase): 'test', '--override', '--checksum-file', - 'add_version/checksum.sha256' + 'add_version/checksum.sha256', ] ) expected_json = self.add_version_get_expected_json('add_version/checksum_expected_override.json', True) @@ -1096,7 +1234,6 @@ class TestMaintainer(unittest.TestCase): class TestArmDetection(unittest.TestCase): - ELF_HEADERS = { idf_tools.PLATFORM_LINUX_ARM64: 'platform_detection/arm64_header.elf', idf_tools.PLATFORM_LINUX_ARMHF: 'platform_detection/armhf_header.elf', @@ -1111,10 +1248,12 @@ class TestArmDetection(unittest.TestCase): def test_arm_detection(self): for platform in idf_tools.Platforms.PLATFORM_FROM_NAME.values(): - with patch('sys.executable', __file__): # use invalid ELF as executable. In this case passed parameter must return + # use invalid ELF as executable. In this case passed parameter must return + with patch('sys.executable', __file__): self.assertEqual(idf_tools.Platforms.detect_linux_arm_platform(platform), platform) # detect_linux_arm_platform() intended to return arch that detected in sys.executable ELF - for exec_platform in (idf_tools.PLATFORM_LINUX_ARM64, idf_tools.PLATFORM_LINUX_ARMHF, idf_tools.PLATFORM_LINUX_ARM32): + arm_platforms = (idf_tools.PLATFORM_LINUX_ARM64, idf_tools.PLATFORM_LINUX_ARMHF, idf_tools.PLATFORM_LINUX_ARM32) + for exec_platform in arm_platforms: with patch('sys.executable', TestArmDetection.ELF_HEADERS[exec_platform]): for platform in TestArmDetection.ARM_PLATFORMS: self.assertEqual(idf_tools.Platforms.detect_linux_arm_platform(platform), exec_platform) @@ -1122,13 +1261,18 @@ class TestArmDetection(unittest.TestCase): # TestSystemDependencies tests behaviour when system dependencies had been broken, on linux @unittest.skipUnless(sys.platform == 'linux', reason='Tools for LINUX differ') -@unittest.skipUnless(int(os.getenv('IDF_TEST_MAY_BREAK_DEPENDENCIES', 0)) == 1, reason='Do not run destructive tests by default') +@unittest.skipUnless( + int(os.getenv('IDF_TEST_MAY_BREAK_DEPENDENCIES', 0)) == 1, reason='Do not run destructive tests by default' +) class TestSystemDependencies(TestUsageBase): - @classmethod def tearDownClass(cls): - # We won't restore dependencies because `apt-get update` and `apt-get install` require network access and take a lot of time on the runners - print('\nINFO: System dependencies have been modified for TestSystemDependencies. Other tests may not work correctly') + # We won't restore dependencies because `apt-get update` and `apt-get install` require network access and take + # a lot of time on the runners + print( + '\nINFO: System dependencies have been modified for TestSystemDependencies. ' + 'Other tests may not work correctly' + ) super(TestSystemDependencies, cls).tearDownClass() def test_commands_when_nodeps(self): @@ -1142,17 +1286,25 @@ class TestSystemDependencies(TestUsageBase): # Tests _, err_output = self.run_idf_tools_with_error(['list']) - self.assertIn(f'ERROR: tool {QEMU_XTENSA} version {QEMU_XTENSA_VERSION} is installed, but cannot be run', err_output) + self.assertIn( + f'ERROR: tool {QEMU_XTENSA} version {QEMU_XTENSA_VERSION} is installed, but cannot be run', err_output + ) _, err_output = self.run_idf_tools_with_error(['export']) - self.assertIn(f'ERROR: tool {QEMU_XTENSA} version {QEMU_XTENSA_VERSION} is installed, but cannot be run', err_output) + self.assertIn( + f'ERROR: tool {QEMU_XTENSA} version {QEMU_XTENSA_VERSION} is installed, but cannot be run', err_output + ) - _,err_output = self.run_idf_tools_with_error(['check'], assertError=True) - self.assertIn(f'ERROR: tool {QEMU_XTENSA} version {QEMU_XTENSA_VERSION} is installed, but cannot be run', err_output) + _, err_output = self.run_idf_tools_with_error(['check'], assertError=True) + self.assertIn( + f'ERROR: tool {QEMU_XTENSA} version {QEMU_XTENSA_VERSION} is installed, but cannot be run', err_output + ) - _,err_output = self.run_idf_tools_with_error(['install', 'qemu-xtensa'], assertError=True) - self.assertIn(f'ERROR: tool {QEMU_XTENSA} version {QEMU_XTENSA_VERSION} is installed, but getting error', err_output) - self.assertIn(f'ERROR: Failed to check the tool while installed', err_output) + _, err_output = self.run_idf_tools_with_error(['install', 'qemu-xtensa'], assertError=True) + self.assertIn( + f'ERROR: tool {QEMU_XTENSA} version {QEMU_XTENSA_VERSION} is installed, but getting error', err_output + ) + self.assertIn('ERROR: Failed to check the tool while installed', err_output) if __name__ == '__main__': diff --git a/tools/test_idf_tools/test_idf_tools_python_env.py b/tools/test_idf_tools/test_idf_tools_python_env.py index 370a30a341..f3005a8505 100644 --- a/tools/test_idf_tools/test_idf_tools_python_env.py +++ b/tools/test_idf_tools/test_idf_tools_python_env.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD +# SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Apache-2.0 # NOTE: unittest is by default sorting tests based on their names, # so the order if which the tests are started may be different from @@ -15,7 +15,7 @@ import subprocess import sys import tempfile import unittest -from typing import List +from typing import List # noqa: F401 try: import idf_tools @@ -85,7 +85,7 @@ class BasePythonInstall(unittest.TestCase): # Wheel for foopackage-0.99-py3-none-any.whl # This is dummy package for testing purposes created with # python -m build --wheel for the following package - ''' + """ ├── foopackage │   └── __init__.py └── setup.py @@ -101,79 +101,82 @@ class BasePythonInstall(unittest.TestCase): __init__.py if __name__ == '__main__': return - ''' + """ - whl = (b'PK\x03\x04\x14\x00\x00\x00\x08\x00\x07fqVz|E\t&\x00\x00\x00&\x00\x00\x00\x16\x00\x00\x00' - b'foopackage/__init__.py\xcbLS\x88\x8f\xcfK\xccM\x8d\x8fW\xb0\xb5UP\x8f\x8f\xcfM\xcc\xcc\x8b\x8fW' - b'\xb7\xe2R\x00\x82\xa2\xd4\x92\xd2\xa2<.\x00PK\x03\x04\x14\x00\x00\x00\x08\x00%fqV\x8d\x90\x81\x05' - b'1\x00\x00\x006\x00\x00\x00"\x00\x00\x00foopackage-0.99.dist-info/METADATA\xf3M-ILI,I\xd4\rK-*\xce' - b'\xcc\xcf\xb3R0\xd23\xe4\xf2K\xccM\xb5RH\xcb\xcf/HL\xceNLO\xe5\x82\xcb\x1a\xe8YZrq\x01\x00PK\x03\x04' - b'\x14\x00\x00\x00\x08\x00%fqVI\xa2!\xcb\\\x00\x00\x00\\\x00\x00\x00\x1f\x00\x00\x00foopackage-0.99' - b'.dist-info/WHEEL\x0b\xcfHM\xcd\xd1\rK-*\xce\xcc\xcf\xb3R0\xd43\xe0rO\xcdK-J,\xc9/\xb2RHJ\xc9,.\x89/' - b'\x07\xa9Q\xd00\xd031\xd03\xd0\xe4\n\xca\xcf/\xd1\xf5,\xd6\r(-J\xcd\xc9L\xb2R()*M\xe5\nIL\xb7R(\xa84' - b'\xd6\xcd\xcb\xcfK\xd5M\xcc\xab\xe4\xe2\x02\x00PK\x03\x04\x14\x00\x00\x00\x08\x00%fqVI*\x9e\xa7\r\x00' - b'\x00\x00\x0b\x00\x00\x00\'\x00\x00\x00foopackage-0.99.dist-info/top_level.txtK\xcb\xcf/HL\xceNLO\xe5' - b'\x02\x00PK\x03\x04\x14\x00\x00\x00\x08\x00%fqV&\xdc\x9b\x88\xfd\x00\x00\x00}\x01\x00\x00 \x00\x00\x00' - b'foopackage-0.99.dist-info/RECORD}\xcc;\x92\x820\x00\x00\xd0\xde\xb3\x04\xe4#\xbfb\x8b\xac\xb0\x0b,' - b'\xa8\x83\x02#M&\x08\x81\x80\x02c\x02\x82\xa7\xb7rK\xdf\x01\x1e\xe9\xfb\x01_Z\\\x95k\x84hG9B\xe2\xb0' - b'\x00VcE\xd3\xbf\xf4\xe6\xe1\t6a2\xc3\x16N\x06]1Bm\xb7\x17\xc2Z\xef\xaa\xed\xf6\x9c\xdaQ \xd0\xf6\xc6' - b':\xec\x00\xd5\\\x91\xffL\x90D\xcb\x12\x0b\xca\xb8@;\xd2\xafC\xe7\x04mx\x82\xef\xb8\xf2\xc6"\xd9\xdd' - b'\r\x18\xe4\xcd\xef=\xf7\n7\x9eg4?\xa7\x04V*gXI\xff\xcanD\xc1\xf1\xc0\x80\xb6\xf9\x10\xa7\xae\xe3\x04' - b'\xefuh/<;?\xe3\xe3\x06\x9e\x93N/|\xc1Puc\xefgt\xfaQJ3\x82V\x8e\xb2\xef\x86\x12\xd9\x04\x96\xf2a\xe5' - b'\xfd\x80\xae\xe5T^E>\xf3\xf7\x1eW\x122\xe4\x91\xfbi\x1f\xd6\xeem\x99\xd4\xec\x11Ju\x9d\'R\xc83R\x19>' - b'jbO:\xb8\x8b\td\xf9\xc3\x1e9\xdb}d\x03\xb0z\x01PK\x01\x02\x14\x03\x14\x00\x00\x00\x08\x00\x07fqVz|E\t' - b'&\x00\x00\x00&\x00\x00\x00\x16\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81\x00\x00\x00\x00' - b'foopackage/__init__.pyPK\x01\x02\x14\x03\x14\x00\x00\x00\x08\x00%fqV\x8d\x90\x81\x051\x00\x00\x006\x00' - b'\x00\x00"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81Z\x00\x00\x00foopackage-0.99.dist-info' - b'/METADATAPK\x01\x02\x14\x03\x14\x00\x00\x00\x08\x00%fqVI\xa2!\xcb\\\x00\x00\x00\\\x00\x00\x00\x1f\x00' - b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81\xcb\x00\x00\x00foopackage-0.99.dist-info/WHEELPK\x01' - b'\x02\x14\x03\x14\x00\x00\x00\x08\x00%fqVI*\x9e\xa7\r\x00\x00\x00\x0b\x00\x00\x00\'\x00\x00\x00\x00\x00' - b'\x00\x00\x00\x00\x00\x00\xa4\x81d\x01\x00\x00foopackage-0.99.dist-info/top_level.txtPK\x01\x02\x14\x03' - b'\x14\x00\x00\x00\x08\x00%fqV&\xdc\x9b\x88\xfd\x00\x00\x00}\x01\x00\x00 \x00\x00\x00\x00\x00\x00\x00' - b'\x00\x00\x00\x00\xb4\x81\xb6\x01\x00\x00foopackage-0.99.dist-info/RECORDPK\x05\x06\x00\x00\x00\x00\x05' - b'\x00\x05\x00\x84\x01\x00\x00\xf1\x02\x00\x00\x00\x00') + whl = ( + b'PK\x03\x04\x14\x00\x00\x00\x08\x00\x07fqVz|E\t&\x00\x00\x00&\x00\x00\x00\x16\x00\x00\x00' + b'foopackage/__init__.py\xcbLS\x88\x8f\xcfK\xccM\x8d\x8fW\xb0\xb5UP\x8f\x8f\xcfM\xcc\xcc\x8b\x8fW' + b'\xb7\xe2R\x00\x82\xa2\xd4\x92\xd2\xa2<.\x00PK\x03\x04\x14\x00\x00\x00\x08\x00%fqV\x8d\x90\x81\x05' + b'1\x00\x00\x006\x00\x00\x00"\x00\x00\x00foopackage-0.99.dist-info/METADATA\xf3M-ILI,I\xd4\rK-*\xce' + b'\xcc\xcf\xb3R0\xd23\xe4\xf2K\xccM\xb5RH\xcb\xcf/HL\xceNLO\xe5\x82\xcb\x1a\xe8YZrq\x01\x00PK\x03\x04' + b'\x14\x00\x00\x00\x08\x00%fqVI\xa2!\xcb\\\x00\x00\x00\\\x00\x00\x00\x1f\x00\x00\x00foopackage-0.99' + b'.dist-info/WHEEL\x0b\xcfHM\xcd\xd1\rK-*\xce\xcc\xcf\xb3R0\xd43\xe0rO\xcdK-J,\xc9/\xb2RHJ\xc9,.\x89/' + b'\x07\xa9Q\xd00\xd031\xd03\xd0\xe4\n\xca\xcf/\xd1\xf5,\xd6\r(-J\xcd\xc9L\xb2R()*M\xe5\nIL\xb7R(\xa84' + b'\xd6\xcd\xcb\xcfK\xd5M\xcc\xab\xe4\xe2\x02\x00PK\x03\x04\x14\x00\x00\x00\x08\x00%fqVI*\x9e\xa7\r\x00' + b"\x00\x00\x0b\x00\x00\x00'\x00\x00\x00foopackage-0.99.dist-info/top_level.txtK\xcb\xcf/HL\xceNLO\xe5" + b'\x02\x00PK\x03\x04\x14\x00\x00\x00\x08\x00%fqV&\xdc\x9b\x88\xfd\x00\x00\x00}\x01\x00\x00 \x00\x00\x00' + b'foopackage-0.99.dist-info/RECORD}\xcc;\x92\x820\x00\x00\xd0\xde\xb3\x04\xe4#\xbfb\x8b\xac\xb0\x0b,' + b'\xa8\x83\x02#M&\x08\x81\x80\x02c\x02\x82\xa7\xb7rK\xdf\x01\x1e\xe9\xfb\x01_Z\\\x95k\x84hG9B\xe2\xb0' + b'\x00VcE\xd3\xbf\xf4\xe6\xe1\t6a2\xc3\x16N\x06]1Bm\xb7\x17\xc2Z\xef\xaa\xed\xf6\x9c\xdaQ \xd0\xf6\xc6' + b':\xec\x00\xd5\\\x91\xffL\x90D\xcb\x12\x0b\xca\xb8@;\xd2\xafC\xe7\x04mx\x82\xef\xb8\xf2\xc6"\xd9\xdd' + b'\r\x18\xe4\xcd\xef=\xf7\n7\x9eg4?\xa7\x04V*gXI\xff\xcanD\xc1\xf1\xc0\x80\xb6\xf9\x10\xa7\xae\xe3\x04' + b'\xefuh/<;?\xe3\xe3\x06\x9e\x93N/|\xc1Puc\xefgt\xfaQJ3\x82V\x8e\xb2\xef\x86\x12\xd9\x04\x96\xf2a\xe5' + b"\xfd\x80\xae\xe5T^E>\xf3\xf7\x1eW\x122\xe4\x91\xfbi\x1f\xd6\xeem\x99\xd4\xec\x11Ju\x9d'R\xc83R\x19>" + b'jbO:\xb8\x8b\td\xf9\xc3\x1e9\xdb}d\x03\xb0z\x01PK\x01\x02\x14\x03\x14\x00\x00\x00\x08\x00\x07fqVz|E\t' + b'&\x00\x00\x00&\x00\x00\x00\x16\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81\x00\x00\x00\x00' + b'foopackage/__init__.pyPK\x01\x02\x14\x03\x14\x00\x00\x00\x08\x00%fqV\x8d\x90\x81\x051\x00\x00\x006\x00' + b'\x00\x00"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81Z\x00\x00\x00foopackage-0.99.dist-info' + b'/METADATAPK\x01\x02\x14\x03\x14\x00\x00\x00\x08\x00%fqVI\xa2!\xcb\\\x00\x00\x00\\\x00\x00\x00\x1f\x00' + b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81\xcb\x00\x00\x00foopackage-0.99.dist-info/WHEELPK\x01' + b"\x02\x14\x03\x14\x00\x00\x00\x08\x00%fqVI*\x9e\xa7\r\x00\x00\x00\x0b\x00\x00\x00'\x00\x00\x00\x00\x00" + b'\x00\x00\x00\x00\x00\x00\xa4\x81d\x01\x00\x00foopackage-0.99.dist-info/top_level.txtPK\x01\x02\x14\x03' + b'\x14\x00\x00\x00\x08\x00%fqV&\xdc\x9b\x88\xfd\x00\x00\x00}\x01\x00\x00 \x00\x00\x00\x00\x00\x00\x00' + b'\x00\x00\x00\x00\xb4\x81\xb6\x01\x00\x00foopackage-0.99.dist-info/RECORDPK\x05\x06\x00\x00\x00\x00\x05' + b'\x00\x05\x00\x84\x01\x00\x00\xf1\x02\x00\x00\x00\x00' + ) return self.dump_package(whl, 'foopackage-0.99-py3-none-any.whl') def dump_foopackage_dev(self): # type: () -> str # similar to dump_foopackage, but using dev release version - whl = (b'PK\x03\x04\x14\x00\x00\x00\x08\x00\nl\x03W !Z\xfc%\x00\x00\x00%\x00\x00\x00\x16\x00\x00\x00' - b'foopackage/__init__.py\xcbLS\x88\x8f\xcfK\xccM\x8d\x8fW\xb0\xb5UP\x8f\x8f\xcfM\xcc\xcc\x8b\x8fW\xb7' - b'\xe2R\x00\x82\xa2\xd4\x92\xd2\xa2<\x00PK\x03\x04\x14\x00\x00\x00\x08\x00Jl\x03W\xb4wO\x876\x00\x00' - b'\x00;\x00\x00\x00\'\x00\x00\x00foopackage-0.99.dev0.dist-info/METADATA\xf3M-ILI,I\xd4\rK-*\xce\xcc' - b'\xcf\xb3R0\xd23\xe4\xf2K\xccM\xb5RH\xcb\xcf/HL\xceNLO\xe5\x82\xcb\x1a\xe8YZ\xea\xa5\xa4\x96\x19pq' - b'\x01\x00PK\x03\x04\x14\x00\x00\x00\x08\x00Jl\x03W\xda9\xe8\xb4[\x00\x00\x00\\\x00\x00\x00$\x00\x00' - b'\x00foopackage-0.99.dev0.dist-info/WHEEL\x0b\xcfHM\xcd\xd1\rK-*\xce\xcc\xcf\xb3R0\xd43\xe0rO\xcdK-J,' - b'\xc9/\xb2RHJ\xc9,.\x89/\x07\xa9Q\xd00\xd03\x01Jkr\x05\xe5\xe7\x97\xe8z\x16\xeb\x06\x94\x16\xa5\xe6' - b'd&Y)\x94\x14\x95\xa6r\x85$\xa6[)\x14T\x1a\xeb\xe6\xe5\xe7\xa5\xea&\xe6Urq\x01\x00PK\x03\x04\x14\x00' - b'\x00\x00\x08\x00Jl\x03WI*\x9e\xa7\r\x00\x00\x00\x0b\x00\x00\x00,\x00\x00\x00foopackage-0.99.dev0' - b'.dist-info/top_level.txtK\xcb\xcf/HL\xceNLO\xe5\x02\x00PK\x03\x04\x14\x00\x00\x00\x08\x00Jl\x03W' - b'\x1e\xbaW\xb5\x00\x01\x00\x00\x91\x01\x00\x00%\x00\x00\x00foopackage-0.99.dev0.dist-info/RECORD\x85' - b'\xcd\xbbv\x820\x00\x00\xd0\xddo\t\x18\xe4\x08d\xe8\x80\x88"\xf2\xb0T\xe4\xb1\xe4\x08\x06B\xa1\x064F' - b'\xe8\xd7w\xb2\xab?po\xc5X\x7f.\xdbsM\xe6\x187\xd7\x86c,\xf7\x13\xb8\xd3\xf3b\xa9}d\x98\x90\xc1\n\xbc' - b'[m\xea\x0fI\x848\xda\xb1\x80)\xf5-D\xc7&\xcc\x9d\xe8\xa1\x1f\nj\x97\xbdZ\x02U\x9fU\xff\x98\x04e\x84' - b'\xe4\x0b\x11P\xbe4w.5\xd7\x8a\xcd}\xfbh\xae\xcd\xa3\xf9\xd2]\xb1jQ4$^?\xe6\xd9\xe4C\xb6\xdfdE3\x89' - b'\xb1m\x8dt0\xb2.6s[B\xbb_-\x03K\xf4NO\x1c\xdb\xf6^\xb4\xc9W[\xed+\xf5\xd4\xfd\x06\x0b\x18\x8c^\x05' - b'\t\x9dN!\x85%\xeb.\x92[\xb8Y\x1al\xd9\xcd\xd2>\x01Z\xbc\xa39\xebqG\x04\xe9d>\xf2W\x11\xd7\x10\xeb' - b'\xca\x83\xbb\t\xf3\xa9\xf33\t5\x7f\xfa\x90\xd2\xe2\x04}\x9eW\xb5\xee\xe2\xefx\x07\x0f\xced\x00EyWD' - b'\xb6\x15Fk\x00f\x7fPK\x01\x02\x14\x03\x14\x00\x00\x00\x08\x00\nl\x03W !Z\xfc%\x00\x00\x00%\x00\x00' - b'\x00\x16\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81\x00\x00\x00\x00foopackage/__init__.py' - b'PK\x01\x02\x14\x03\x14\x00\x00\x00\x08\x00Jl\x03W\xb4wO\x876\x00\x00\x00;\x00\x00\x00\'\x00\x00\x00' - b'\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81Y\x00\x00\x00foopackage-0.99.dev0.dist-info/METADATAPK\x01' - b'\x02\x14\x03\x14\x00\x00\x00\x08\x00Jl\x03W\xda9\xe8\xb4[\x00\x00\x00\\\x00\x00\x00$\x00\x00\x00\x00' - b'\x00\x00\x00\x00\x00\x00\x00\xa4\x81\xd4\x00\x00\x00foopackage-0.99.dev0.dist-info/WHEELPK\x01\x02' - b'\x14\x03\x14\x00\x00\x00\x08\x00Jl\x03WI*\x9e\xa7\r\x00\x00\x00\x0b\x00\x00\x00,\x00\x00\x00\x00' - b'\x00\x00\x00\x00\x00\x00\x00\xa4\x81q\x01\x00\x00foopackage-0.99.dev0.dist-info/top_level.txtPK\x01' - b'\x02\x14\x03\x14\x00\x00\x00\x08\x00Jl\x03W\x1e\xbaW\xb5\x00\x01\x00\x00\x91\x01\x00\x00%\x00\x00' - b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\xb4\x81\xc8\x01\x00\x00foopackage-0.99.dev0.dist-info/RECORDPK' - b'\x05\x06\x00\x00\x00\x00\x05\x00\x05\x00\x98\x01\x00\x00\x0b\x03\x00\x00\x00\x00') + whl = ( + b'PK\x03\x04\x14\x00\x00\x00\x08\x00\nl\x03W !Z\xfc%\x00\x00\x00%\x00\x00\x00\x16\x00\x00\x00' + b'foopackage/__init__.py\xcbLS\x88\x8f\xcfK\xccM\x8d\x8fW\xb0\xb5UP\x8f\x8f\xcfM\xcc\xcc\x8b\x8fW\xb7' + b'\xe2R\x00\x82\xa2\xd4\x92\xd2\xa2<\x00PK\x03\x04\x14\x00\x00\x00\x08\x00Jl\x03W\xb4wO\x876\x00\x00' + b"\x00;\x00\x00\x00'\x00\x00\x00foopackage-0.99.dev0.dist-info/METADATA\xf3M-ILI,I\xd4\rK-*\xce\xcc" + b'\xcf\xb3R0\xd23\xe4\xf2K\xccM\xb5RH\xcb\xcf/HL\xceNLO\xe5\x82\xcb\x1a\xe8YZ\xea\xa5\xa4\x96\x19pq' + b'\x01\x00PK\x03\x04\x14\x00\x00\x00\x08\x00Jl\x03W\xda9\xe8\xb4[\x00\x00\x00\\\x00\x00\x00$\x00\x00' + b'\x00foopackage-0.99.dev0.dist-info/WHEEL\x0b\xcfHM\xcd\xd1\rK-*\xce\xcc\xcf\xb3R0\xd43\xe0rO\xcdK-J,' + b'\xc9/\xb2RHJ\xc9,.\x89/\x07\xa9Q\xd00\xd03\x01Jkr\x05\xe5\xe7\x97\xe8z\x16\xeb\x06\x94\x16\xa5\xe6' + b'd&Y)\x94\x14\x95\xa6r\x85$\xa6[)\x14T\x1a\xeb\xe6\xe5\xe7\xa5\xea&\xe6Urq\x01\x00PK\x03\x04\x14\x00' + b'\x00\x00\x08\x00Jl\x03WI*\x9e\xa7\r\x00\x00\x00\x0b\x00\x00\x00,\x00\x00\x00foopackage-0.99.dev0' + b'.dist-info/top_level.txtK\xcb\xcf/HL\xceNLO\xe5\x02\x00PK\x03\x04\x14\x00\x00\x00\x08\x00Jl\x03W' + b'\x1e\xbaW\xb5\x00\x01\x00\x00\x91\x01\x00\x00%\x00\x00\x00foopackage-0.99.dev0.dist-info/RECORD\x85' + b'\xcd\xbbv\x820\x00\x00\xd0\xddo\t\x18\xe4\x08d\xe8\x80\x88"\xf2\xb0T\xe4\xb1\xe4\x08\x06B\xa1\x064F' + b'\xe8\xd7w\xb2\xab?po\xc5X\x7f.\xdbsM\xe6\x187\xd7\x86c,\xf7\x13\xb8\xd3\xf3b\xa9}d\x98\x90\xc1\n\xbc' + b'[m\xea\x0fI\x848\xda\xb1\x80)\xf5-D\xc7&\xcc\x9d\xe8\xa1\x1f\nj\x97\xbdZ\x02U\x9fU\xff\x98\x04e\x84' + b'\xe4\x0b\x11P\xbe4w.5\xd7\x8a\xcd}\xfbh\xae\xcd\xa3\xf9\xd2]\xb1jQ4$^?\xe6\xd9\xe4C\xb6\xdfdE3\x89' + b'\xb1m\x8dt0\xb2.6s[B\xbb_-\x03K\xf4NO\x1c\xdb\xf6^\xb4\xc9W[\xed+\xf5\xd4\xfd\x06\x0b\x18\x8c^\x05' + b'\t\x9dN!\x85%\xeb.\x92[\xb8Y\x1al\xd9\xcd\xd2>\x01Z\xbc\xa39\xebqG\x04\xe9d>\xf2W\x11\xd7\x10\xeb' + b'\xca\x83\xbb\t\xf3\xa9\xf33\t5\x7f\xfa\x90\xd2\xe2\x04}\x9eW\xb5\xee\xe2\xefx\x07\x0f\xced\x00EyWD' + b'\xb6\x15Fk\x00f\x7fPK\x01\x02\x14\x03\x14\x00\x00\x00\x08\x00\nl\x03W !Z\xfc%\x00\x00\x00%\x00\x00' + b'\x00\x16\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81\x00\x00\x00\x00foopackage/__init__.py' + b"PK\x01\x02\x14\x03\x14\x00\x00\x00\x08\x00Jl\x03W\xb4wO\x876\x00\x00\x00;\x00\x00\x00'\x00\x00\x00" + b'\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81Y\x00\x00\x00foopackage-0.99.dev0.dist-info/METADATAPK\x01' + b'\x02\x14\x03\x14\x00\x00\x00\x08\x00Jl\x03W\xda9\xe8\xb4[\x00\x00\x00\\\x00\x00\x00$\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00\x00\xa4\x81\xd4\x00\x00\x00foopackage-0.99.dev0.dist-info/WHEELPK\x01\x02' + b'\x14\x03\x14\x00\x00\x00\x08\x00Jl\x03WI*\x9e\xa7\r\x00\x00\x00\x0b\x00\x00\x00,\x00\x00\x00\x00' + b'\x00\x00\x00\x00\x00\x00\x00\xa4\x81q\x01\x00\x00foopackage-0.99.dev0.dist-info/top_level.txtPK\x01' + b'\x02\x14\x03\x14\x00\x00\x00\x08\x00Jl\x03W\x1e\xbaW\xb5\x00\x01\x00\x00\x91\x01\x00\x00%\x00\x00' + b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\xb4\x81\xc8\x01\x00\x00foopackage-0.99.dev0.dist-info/RECORDPK' + b'\x05\x06\x00\x00\x00\x00\x05\x00\x05\x00\x98\x01\x00\x00\x0b\x03\x00\x00\x00\x00' + ) return self.dump_package(whl, 'foopackage-0.99.dev0-py3-none-any.whl') class TestPythonInstall(BasePythonInstall): - def setUp(self): # type: () -> None if os.path.isdir(PYTHON_DIR): shutil.rmtree(PYTHON_DIR) @@ -183,7 +186,7 @@ class TestPythonInstall(BasePythonInstall): def test_default_arguments(self): # type: () -> None output = self.run_idf_tools(['check-python-dependencies']) self.assertNotIn(REQ_SATISFIED, output) - self.assertIn(f'{PYTHON_BINARY} doesn\'t exist', output) + self.assertIn(f"{PYTHON_BINARY} doesn't exist", output) output = self.run_idf_tools(['install-python-env']) self.assertIn(CONSTR, output) @@ -219,7 +222,6 @@ class TestPythonInstall(BasePythonInstall): class TestCustomPythonPathInstall(BasePythonInstall): - def setUp(self): # type: () -> None self.CUSTOM_PYTHON_DIR = tempfile.mkdtemp() self.environ_old = os.environ.copy() @@ -244,7 +246,6 @@ class TestCustomPythonPathInstall(BasePythonInstall): class TestCheckPythonDependencies(BasePythonInstall): - """ The constraint file name is available as the constraint_file attribute. The content of the file is changed by these tests. The backup_constraint_file is a temporary file with the content of the original constraint file. This is @@ -252,6 +253,7 @@ class TestCheckPythonDependencies(BasePythonInstall): important for consequent tests which should not download a new one especially when the test was run with a custom constraint file different from the one on dl.espressif.com. """ + constraint_file: str backup_constraint_file: str