<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Compiling with SDK on desktop for unit testing</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/61562/compiling-with-sdk-on-desktop-for-unit-testing</link><description>Hi, 
 I am working on a product based on an nRF52832. 
 For testing purposes, I have setup the Unity testing framework (using Ceedling). 
 As soon as a module I want to test includes a file from the nrf5 SDK, I get compiler error : 
 First I had issues</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 28 May 2020 07:15:27 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/61562/compiling-with-sdk-on-desktop-for-unit-testing" /><item><title>RE: Compiling with SDK on desktop for unit testing</title><link>https://devzone.nordicsemi.com/thread/252081?ContentTypeID=1</link><pubDate>Thu, 28 May 2020 07:15:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7a8eaabb-f21d-44a1-854c-c4284bf3d846</guid><dc:creator>Krzysztof Chruscinski</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;we also use unity but we modified it to inject special defines to allow mocking static inlines. Unfortunately, it is quite coupled with test framework so I won&amp;#39;t be able to share it with you.&lt;/p&gt;
&lt;p&gt;You can take a look at how we approached this issue in nRF Connect SDK:&amp;nbsp;&amp;nbsp;&lt;a href="http://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_unity_testing.html"&gt;http://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_unity_testing.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Basically, we are first preprocessing the headers to replace or static inline functions with standard function declarations and that is passed to mock generator. I think this may work for you.&lt;/p&gt;
&lt;p&gt;Here is the script:&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/master/scripts/unity/header_prepare.py"&gt;https://github.com/nrfconnect/sdk-nrf/blob/master/scripts/unity/header_prepare.py&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Note that script contains conversions specific to zephyr (syscalls removal).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Compiling with SDK on desktop for unit testing</title><link>https://devzone.nordicsemi.com/thread/250737?ContentTypeID=1</link><pubDate>Tue, 19 May 2020 13:10:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c28a2b0-7d3b-4e6e-8714-be81378d7551</guid><dc:creator>Nathan O.</dc:creator><description>&lt;p&gt;The thing here is that I do not want to actually execute any of the driver code :&lt;/p&gt;
&lt;p&gt;If I have a module that uses the RTC for example by calling the nrf_drv_rtc driver, I would like to be able to mock the driver part and test only my module.&lt;/p&gt;
&lt;p&gt;The problem I have here is that the header file of the driver goes on including a lot of target-specific header files.&lt;/p&gt;
&lt;p&gt;The reason I&amp;#39;m asking this post here is that I have found in the nrf.h file the following section that make me think that running on Host platform should be doable :&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#if defined(_WIN32)
    /* Do not include nrf specific files when building for PC host */
#elif defined(__unix)
    /* Do not include nrf specific files when building for PC host */
#elif defined(__APPLE__)
    /* Do not include nrf specific files when building for PC host */
#else&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Compiling with SDK on desktop for unit testing</title><link>https://devzone.nordicsemi.com/thread/250668?ContentTypeID=1</link><pubDate>Tue, 19 May 2020 10:49:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b2f9434a-e2b8-4a6a-a882-e826dfabbc5c</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;Surely, you would get exactly the same issues with trying to build &lt;em&gt;&lt;strong&gt;any&lt;/strong&gt; &lt;/em&gt;microcontroller code in a desktop native compiler ?&lt;/p&gt;
[quote userid="18189" url="~/f/nordic-q-a/61562/compiling-with-sdk-on-desktop-for-unit-testing"]the Unity testing framework (using Ceedling)[/quote]
&lt;p&gt;So don&amp;#39;t they give you any guidance on how to go about abstracting the Target specifics?&lt;/p&gt;
&lt;p&gt;Perhaps it&amp;#39;d be simpler to keep doing the cross-compilation, and run in a simulator such as QEMU ... ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>