Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing/libc/wcstombs: Add testing application for wcstombs #2986

Merged
merged 1 commit into from
Feb 6, 2025

Conversation

tmedicci
Copy link
Contributor

@tmedicci tmedicci commented Feb 5, 2025

Summary

  • testing/libc/wcstombs: Add testing application for wcstombs

This application tests the libc's wcstombs function for different len sizes (bigger than the converted string, exactly the size of it and smaller than it).

Impact

Enabling testing the libc's wcstombs()function. No impact on existing applications. This application is used to test a bugfix regarding wcstombs behavior.

Testing

Internal CI testing + rv-virt:nsh:

Build with:

make -j distclean && ./tools/configure.sh rv-virt:nsh && kconfig-tweak -e LIBC_LOCALE && kconfig-tweak -e TESTING_WCSTOMBS && make olddefconfig && make

Run with:

$ qemu-system-riscv32 -semihosting -M virt,aclint=on -cpu rv32 -smp 1 -bios none -kernel nuttx -nographic
ABC
NuttShell (NSH) NuttX-10.4.0
nsh> help
help usage:  help [-v] [<cmd>]

    .           cmp         false       mount       set         uptime      
    [           dirname     fdinfo      mv          sleep       usleep      
    ?           dd          free        pidof       source      watch       
    alias       df          help        poweroff    test        xd          
    unalias     dmesg       hexdump     quit        time        wait        
    basename    echo        kill        printf      true        
    break       env         pkill       ps          truncate    
    cat         exec        ls          pwd         uname       
    cd          exit        mkdir       rm          umount      
    cp          expr        mkrd        rmdir       unset       

Builtin Apps:
    getprime    hello       nsh         ostest      sh          wcstombs    
nsh> wcstombs
wcstombs Test application:

Test Scenario: len is bigger than the size of the converted string. Expected the null-terminator at the end of the converted string.
Return code: 13
dst buffer (as uint8_t array): 48 65 6c 6c 6f 2c 20 77 6f 72 6c 64 21 aa 
The character just after the return value is not the expected null-terminator (value: aa). This is a bug!
nsh> QEMU: Terminated

This application test the libc's `wcstombs` function for different
len sizes (bigger than the converted string, exactly the size of
it and smaller than it).
Copy link

@cederom cederom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @tmedicci :-)

@cederom cederom merged commit f139e56 into apache:master Feb 6, 2025
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants