If the byte order of the host environment and the target environment is different, the test fails because the host output value and the target output value are different.

When the output value of host/target is different

If the source code directly controls memory, the output value may vary depending on the byte order of the host environment and the target environment. Testing with the same expected values will cause either the host test or the target test to fail. In this case, you can run host/target tests with the same test case by using vertical bar(|) for the expected value.

  • Example
    • Host output value : 0x1122
    • Target output value : 0x2211
    • Expected value to be entered : 0x1122|0x2211

When the source code logic is completely dependent on byte order

In host test, logic that depends on how the memory is used will not have normal results. The following cases are dependent on how the memory is used.

  • When using union to directly access and use memory details.
  • Packing for bitfields that may have different implementations depending on the compiler.

The above type of code should be avoided in consideration of portability. Even when checking the test result, it is better to design to check the value of the data type rather than check the memory value directly.

If it is difficult to modify the source code, tests for such code should be performed in an actual target environment or host and target tests should be designed and managed separately.

Need more help with this?
Don’t hesitate to contact us here.

Thanks for your feedback.