embeddedartistry / libc

libc targeted for embedded systems usage. Reduced set of functionality (due to embedded nature). Chosen for portability and quick bringup.
MIT License
504 stars 67 forks source link

Add unittests for memmove() #185

Closed eriols closed 1 year ago

eriols commented 1 year ago

The approach taken here is relying quite a bit on the corresponding memmove tests in the coreboot repo. I liked this setup/teardown approach as it reduced the boilerplate of manually restoring the buffer in between runs. But if it's a too deviant change from the other unit tests just let me know.

Fixes # 184

phillipjohnston commented 1 year ago

The CI server reports a test failure for the new test:

difference at offset 30 0x0d 0x11
difference at offset 31 0x0e 0x12
difference at offset 32 0x0f 0x13
difference at offset 33 0x10 0x14
difference at offset 34 0x11 0x15
difference at offset 35 0x12 0x16
difference at offset 36 0x13 0x17
difference at offset 37 0x14 0x18
difference at offset 38 0x15 0x19
difference at offset 39 0x16 0x00
difference at offset 40 0x17 0x01
difference at offset 41 0x18 0x02
difference at offset 42 0x19 0x03
difference at offset 43 0x00 0x04
difference at offset 44 0x01 0x05
difference at offset 45 0x02 0x06
...
34 bytes of 0x7f8d67405c70 and 0x7f8d67405c30 differ
../test/string/memmove.c:82: error: Failure!
eriols commented 1 year ago

Regarding the failure - I can help you dig into that, I'm guessing that your local tests are not failing :). What OS is being used?

Oops, it does fail because I rewrote this a bit and then forgot about it. Squashing in a fix quite soon I hope.

phillipjohnston commented 1 year ago

Thanks for the contribution!