From 2910dea6fd48b33e40af86a73765bcc396ae73bf Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 5 Oct 2023 17:03:42 -0700 Subject: [PATCH] Almost fix extra_coverage test --- .gitmodules | 2 +- frozen/Adafruit_CircuitPython_asyncio | 2 +- ports/espressif/supervisor/usb_serial_jtag.c | 2 +- ports/unix/coverage.c | 15 +++++++----- py/makeversionhdr.py | 3 --- supervisor/shared/usb/host_keyboard.c | 2 +- supervisor/shared/web_workflow/websocket.c | 2 +- tests/frozen/frozentest.mpy | Bin 0 -> 196 bytes tests/frozen/frozentest.py | 7 ++++++ tests/unix/extra_coverage.py.exp | 24 +++++++------------ 10 files changed, 30 insertions(+), 29 deletions(-) create mode 100644 tests/frozen/frozentest.mpy create mode 100644 tests/frozen/frozentest.py diff --git a/.gitmodules b/.gitmodules index 17ce186acb..d013c97a4d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -293,7 +293,7 @@ url = https://github.com/adafruit/Adafruit_CircuitPython_Ticks.git [submodule "frozen/Adafruit_CircuitPython_asyncio"] path = frozen/Adafruit_CircuitPython_asyncio - url = https://github.com/adafruit/Adafruit_CircuitPython_asyncio.git + url = https://github.com/tannewt/Adafruit_CircuitPython_asyncio.git [submodule "frozen/circuitpython_ef_music"] path = frozen/circuitpython_ef_music url = https://github.com/elecfreaks/circuitpython_ef_music.git diff --git a/frozen/Adafruit_CircuitPython_asyncio b/frozen/Adafruit_CircuitPython_asyncio index 7c25d09be0..6198266eca 160000 --- a/frozen/Adafruit_CircuitPython_asyncio +++ b/frozen/Adafruit_CircuitPython_asyncio @@ -1 +1 @@ -Subproject commit 7c25d09be04a2979bcfb43b801de57594112808d +Subproject commit 6198266ecaeb1c8486a1333ee7c18bd5678d830a diff --git a/ports/espressif/supervisor/usb_serial_jtag.c b/ports/espressif/supervisor/usb_serial_jtag.c index 9350d1bf97..957ae60c91 100644 --- a/ports/espressif/supervisor/usb_serial_jtag.c +++ b/ports/espressif/supervisor/usb_serial_jtag.c @@ -89,7 +89,7 @@ static void usb_serial_jtag_isr_handler(void *arg) { } void usb_serial_jtag_init(void) { - ringbuf_init(&ringbuf, buf, sizeof(buf) - 1); + ringbuf_init(&ringbuf, buf, sizeof(buf)); usb_serial_jtag_ll_clr_intsts_mask(USB_SERIAL_JTAG_INTR_SOF | USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT | USB_SERIAL_JTAG_INTR_TOKEN_REC_IN_EP1); usb_serial_jtag_ll_ena_intr_mask(USB_SERIAL_JTAG_INTR_SOF | USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT | USB_SERIAL_JTAG_INTR_TOKEN_REC_IN_EP1); ESP_ERROR_CHECK(esp_intr_alloc(ETS_USB_SERIAL_JTAG_INTR_SOURCE, ESP_INTR_FLAG_LEVEL1, diff --git a/ports/unix/coverage.c b/ports/unix/coverage.c index 3763063870..5cc5ec6614 100644 --- a/ports/unix/coverage.c +++ b/ports/unix/coverage.c @@ -612,8 +612,11 @@ STATIC mp_obj_t extra_coverage(void) { // ringbuf { - byte buf[100]; - ringbuf_t ringbuf = {buf, sizeof(buf), 0, 0, 0}; + #define RINGBUF_SIZE 99 + + byte buf[RINGBUF_SIZE]; + ringbuf_t ringbuf; + ringbuf_init(&ringbuf, buf, sizeof(buf)); mp_printf(&mp_plat_print, "# ringbuf\n"); @@ -631,7 +634,7 @@ STATIC mp_obj_t extra_coverage(void) { mp_printf(&mp_plat_print, "%d %d\n", ringbuf_num_empty(&ringbuf), ringbuf_num_filled(&ringbuf)); // Two-byte put with full ringbuf. - for (int i = 0; i < 99; ++i) { + for (int i = 0; i < RINGBUF_SIZE; ++i) { ringbuf_put(&ringbuf, i); } mp_printf(&mp_plat_print, "%d %d\n", ringbuf_num_empty(&ringbuf), ringbuf_num_filled(&ringbuf)); @@ -643,7 +646,7 @@ STATIC mp_obj_t extra_coverage(void) { ringbuf_get(&ringbuf); mp_printf(&mp_plat_print, "%d %d\n", ringbuf_num_empty(&ringbuf), ringbuf_num_filled(&ringbuf)); mp_printf(&mp_plat_print, "%d\n", ringbuf_put16(&ringbuf, 0xcc99)); - for (int i = 0; i < 97; ++i) { + for (int i = 0; i < RINGBUF_SIZE - 2; ++i) { ringbuf_get(&ringbuf); } mp_printf(&mp_plat_print, "%04x\n", ringbuf_get16(&ringbuf)); @@ -651,7 +654,7 @@ STATIC mp_obj_t extra_coverage(void) { // Two-byte put with wrap around on first byte: ringbuf_clear(&ringbuf); - for (int i = 0; i < 99; ++i) { + for (int i = 0; i < RINGBUF_SIZE; ++i) { ringbuf_put(&ringbuf, i); ringbuf_get(&ringbuf); } @@ -660,7 +663,7 @@ STATIC mp_obj_t extra_coverage(void) { // Two-byte put with wrap around on second byte: ringbuf_clear(&ringbuf); - for (int i = 0; i < 98; ++i) { + for (int i = 0; i < RINGBUF_SIZE - 1; ++i) { ringbuf_put(&ringbuf, i); ringbuf_get(&ringbuf); } diff --git a/py/makeversionhdr.py b/py/makeversionhdr.py index e22095b89e..bc9dbdfb79 100644 --- a/py/makeversionhdr.py +++ b/py/makeversionhdr.py @@ -28,7 +28,6 @@ def get_version_info_from_git(repo_path): # Note: git describe doesn't work if no tag is available try: - print(tools_describe) git_tag = subprocess.check_output( [tools_describe], cwd=repo_path, @@ -95,10 +94,8 @@ def make_version_header(repo_path, filename): # Get version info using git (required) info = get_version_info_from_git(repo_path) if info is None: - print(info) cannot_determine_version() git_tag, git_hash, ver = info - print(git_tag, git_hash, ver) if len(ver) < 3: cannot_determine_version() else: diff --git a/supervisor/shared/usb/host_keyboard.c b/supervisor/shared/usb/host_keyboard.c index 0fd64d2662..fc74bfd33f 100644 --- a/supervisor/shared/usb/host_keyboard.c +++ b/supervisor/shared/usb/host_keyboard.c @@ -318,7 +318,7 @@ void tuh_hid_report_received_cb(uint8_t dev_addr, uint8_t instance, uint8_t cons } void usb_keyboard_init(void) { - ringbuf_init(&_incoming_ringbuf, _buf, sizeof(_buf) - 1); + ringbuf_init(&_incoming_ringbuf, _buf, sizeof(_buf)); } bool usb_keyboard_chars_available(void) { diff --git a/supervisor/shared/web_workflow/websocket.c b/supervisor/shared/web_workflow/websocket.c index 0b829bb6f8..afedf3d434 100644 --- a/supervisor/shared/web_workflow/websocket.c +++ b/supervisor/shared/web_workflow/websocket.c @@ -59,7 +59,7 @@ static _websocket cp_serial; void websocket_init(void) { socketpool_socket_reset(&cp_serial.socket); - ringbuf_init(&_incoming_ringbuf, _buf, sizeof(_buf) - 1); + ringbuf_init(&_incoming_ringbuf, _buf, sizeof(_buf)); } void websocket_handoff(socketpool_socket_obj_t *socket) { diff --git a/tests/frozen/frozentest.mpy b/tests/frozen/frozentest.mpy new file mode 100644 index 0000000000000000000000000000000000000000..7f1163956bafeacef9bda191aa3376fbf589c350 GIT binary patch literal 196 zcmZ=}V~}TMmP#wiuS(4;Ni8nXE2w1PXDbb;WN0jB%4A?wN>s?n&r4S*E-A_cQY9IQ zB?_6v3VHcJ3aFtdFExdMRV@)kJ|nSMp)@ZuIX@*;;oQb^o6c=kNX|$sDrR8gPO1c2 zqF`ubY{JOUVj#fBs15{LYJ$uHOeTzxg3QVc5Q-5(K?Id{y`Lot6lier2^V7#WENxr QavGn8w_JDDj|@x(0H%94ivR!s literal 0 HcmV?d00001 diff --git a/tests/frozen/frozentest.py b/tests/frozen/frozentest.py new file mode 100644 index 0000000000..78cdd60bf0 --- /dev/null +++ b/tests/frozen/frozentest.py @@ -0,0 +1,7 @@ +print("uPy") +print("a long string that is not interned") +print("a string that has unicode αβγ chars") +print(b"bytes 1234\x01") +print(123456789) +for i in range(4): + print(i) diff --git a/tests/unix/extra_coverage.py.exp b/tests/unix/extra_coverage.py.exp index 52b7b7d912..09e743f1b3 100644 --- a/tests/unix/extra_coverage.py.exp +++ b/tests/unix/extra_coverage.py.exp @@ -15,12 +15,12 @@ false true abc % # GC -0 -0 +0x0 +0x0 # GC part 2 pass # tracked allocation -m_tracked_head = 0 +m_tracked_head = 0x0 0 1 1 1 2 1 @@ -37,7 +37,7 @@ m_tracked_head = 0 5 1 6 1 7 1 -m_tracked_head = 0 +m_tracked_head = 0x0 # vstr tests sts @@ -55,19 +55,13 @@ _uasyncio aesio array audiocore audiomixer bitmaptools cexample cmath collections cppexample displayio gc math qrio rainbowio struct -synthio termios traceback ubinascii -uctypes uerrno uhashlib uheapq -uio ujson ulab ulab.numpy -ulab.numpy.fft ulab.numpy.linalg ulab.scipy -ulab.scipy.linalg ulab.scipy.optimize -ulab.scipy.signal ulab.scipy.special -ulab.utils uos urandom ure -uselect usys utime utimeq -uzlib zlib +synthio traceback ubinascii uctypes +uerrno uhashlib uheapq uio +ujson ulab uos uplatform +urandom ure uselect usys +utime uzlib zlib ime -utime utimeq - argv atexit byteorder exc_info executable exit getsizeof implementation maxsize modules path platform