Merges https://github.com/espressif/esp-idf/pull/12525
Note: Most of the test cases shouldn't be run manually, but pytest should be used instead. E.g., to run all test cases on ESP32 using pytest, use:
pytest --target esp32 -m generic