Question

I'm currently investigating the possibility to force the rvct compiler not to link in specific translation units and just pretend that it has linked it.

Our product is running very tight on space constraints and have trouble integrating some unit tests with it while keeping the space under control.

Basically, the memory we can leverage during run time is more than sufficient to store our unit tests, but we don't have sufficient rom space to hold them.

We have means to control exactly which segment of memory of our code goes in on our device in the scatter file, so we're thinking along the lines of defining which region the unit test codes will be located and somehow force the compiler not to link in that specific code during compile time.

Something like the following:

Result UnitTestEntryPoint (UnitTest suite) {
   if (hasTestInMemory) {
      switch (suite) {
          case EncrpytionTest:
              return EncrptyUnitTest();
          // more tests.
      }
   }
}

// Actual Tests, can we not link this code, but just pretend we link to them?
Result EncrpyUnitTest (void) {
    // Do stuff...
}

Then during runtime, we'll upload the unit test binaries to the specified memory region that we define in the scatter file, and flip the hasTestInMemory to true.

Is this possible?

Or if not, can someone point me to the right direction of looking for a solution that somehow meets our space constraint and able to load unit tests during run time.

Thanks,

Was it helpful?

Solution

You should be able to use your scatter file to place all your unit test functions into a separate load region. When you link your image you'll get one AXF but when you convert it into a binary file for loading into memory you should get two files, one for each region.

You can also have some marker in the unit test image that your ROM image can check for to verify that the binary is loaded. This check would replace your hadTestInMemory check in your code. Again you should be able to place some specific RO data at the beginning of the second binary file using your scatter file.

I can probably help out with some more details as you progress.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top