This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Some testing/mocking problems/topics

HI

I still try to reconfigure my Zaphyr testing environment to NRF Unity/CMock but I've encountered more issues.

1. __syscall mocking

Is there any reason to exclude __syscall functions from the mocking process?

Currently, header_prepare.py removes all __syscall includes and removes all __syscall prefixed function signatures.

    syscall_decl_pattern = re.compile(
        r'__syscall\s+(?:\w+[*\s]+)+(.+?;)',
        re.M | re.S)
    content = syscall_decl_pattern.sub("", content)

I'm just wondering why not convert that functions to normal and mock them

syscall_decl_pattern = re.compile(
r'__syscall ([\w+\s+*\(\),]+;)',
re.M | re.S)
content = syscall_decl_pattern.sub(r"\1", content)

2. Missing support for static inline

Header_prepare is able to work correctly with inline static but if we swap static and inline then the script handles them incorrectly (they are all removed). 

3. Unity wrap_trick function works incorrectly if mocked file doesn't contain any functions

Consider the following scenario:

* We try to mock file where are no functions

* NRF/tests/unity/CMakeListsts.txt  try to do some magic for linker:

# Add --wrap linker option for each function listed in the input file.
function(cmock_linker_trick func_name_path)
  file(STRINGS ${func_name_path} contents)
  set(linker_str "-Wl")
  foreach(src ${contents})
    set(linker_str "${linker_str},--wrap=${src}")
  endforeach()
  zephyr_link_libraries(${linker_str})
endfunction()

* and 'returns' just a "-Wl" string what causes ridiculous and hard to debug error:

gcc: error: unrecognized command-line option ‘-Wl’; did you mean ‘-W’?

I understand that the mocking file without functions sounds pointless but I think it shouldn't cause unhandled errors, maybe warnings.

Parents Reply Children
No Data
Related