Empty report following Unity tests

Jul 22, 2016 at 10:03 AM
Edited Jul 25, 2016 at 8:12 AM
Hello,

I am sorry if this discussion is a duplicate of this.

I am trying to generate a coverage report after performing tests with Unity. The files I have are very basic:

Source file
#include "MyExampleHeader.h"

int8_t AverageThreeBytes(int8_t a, int8_t b, int8_t c)
{
    return (int8_t)(((int16_t)a + (int16_t)b + (int16_t)c) / 3);
}

int8_t FindMaximum(int8_t a, int8_t b, int8_t c)
{
    uint8_t tmax = a;
    if (tmax < b)
    {
        tmax = b;
    }
    if (tmax < c)
    {
        tmax = c;
    }
    return tmax;
}
Test file
#include "C:\Projects\CUnitTests\Unity-master\src\unity.h"
#include "MyExampleHeader.h"

void setUp(void)
{

}

void tearDown(void)
{

}

void test_FindMaximum(void)
{
    TEST_ASSERT_EQUAL_HEX8(50, FindMaximum(20, 30, 50));
}

int main(void)
{
    UNITY_BEGIN();
    RUN_TEST(test_FindMaximum);
    return UNITY_END();
}
I compile the two using MSVC2015 in the command line:
C:\Projects\CUnitTests\Files\Project1\Project1>cl TestExample.c Source.c C
:\Projects\CUnitTests\Unity-master\src\unity.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24210 for x86
Copyright (C) Microsoft Corporation. All rights reserved.

TestExample.c
Source.c
unity.c
Generating Code...
Microsoft (R) Incremental Linker Version 14.00.24210.0
Copyright (C) Microsoft Corporation. All rights reserved.

/out:TestExample.exe
TestExample.obj
Source.obj
unity.obj
After running OpenCppCoverage from the command line, I get an empty HTML report.

The output also has some peculiar lines:
[2016-07-22 10:42:57] [info] Start Program:
Path:"C:\Projects\CUnitTests\Files\Project1\Project1\TestExample.exe"
Arguments:
Working directory: not set.
Modules: Selected: * Excluded:
Sources: Selected: C:\Projects\CUnitTests\Files\Project1\Project1\Debug Excluded:
Log Level: Normal
Cover Children: 1
Aggregate by file: 1
Continue after C++ exception: 1
Export: Html
Input coverage:
Unified diff:
[2016-07-22 10:42:57] [info] Module: C:\Projects\CUnitTests\Files\Project1\Project1\TestExample.exe is selected because it matches selected pattern: *
[2016-07-22 10:42:58] [info] Module: C:\Windows\System32\ntdll.dll is selected because it matches selected pattern: *
[2016-07-22 10:42:58] [warning] Cannot find pdb for C:\Windows\System32\ntdll.dll
[2016-07-22 10:42:58] [info] Module: C:\Windows\SysWOW64\ntdll.dll is selected because it matches selected pattern: *
[2016-07-22 10:42:58] [warning] Cannot find pdb for C:\Windows\SysWOW64\ntdll.dll
[2016-07-22 10:42:58] [info] Module: C:\Windows\System32\wow64.dll is selected because it matches selected pattern: *
[2016-07-22 10:42:58] [warning] Cannot find pdb for C:\Windows\System32\wow64.dll
[2016-07-22 10:42:58] [info] Module: C:\Windows\System32\wow64win.dll is selected because it matches selected pattern: *
[2016-07-22 10:42:58] [warning] Cannot find pdb for C:\Windows\System32\wow64win.dll
[2016-07-22 10:42:58] [info] Module: C:\Windows\System32\wow64cpu.dll is selected because it matches selected pattern: *
[2016-07-22 10:42:58] [warning] Cannot find pdb for C:\Windows\System32\wow64cpu.dll
[2016-07-22 10:42:58] [info] Module: C:\Windows\System32\kernel32.dll is selected because it matches selected pattern: *
[2016-07-22 10:42:58] [warning] Cannot find pdb for C:\Windows\System32\kernel32.dll
[2016-07-22 10:42:58] [info] Module: C:\Windows\SysWOW64\kernel32.dll is selected because it matches selected pattern: *
[2016-07-22 10:42:58] [warning] Cannot find pdb for C:\Windows\SysWOW64\kernel32.dll
[2016-07-22 10:42:58] [info] Module: C:\Windows\System32\kernel32.dll is selected because it matches selected pattern: *
[2016-07-22 10:42:58] [warning] Cannot find pdb for C:\Windows\System32\kernel32.dll
[2016-07-22 10:42:58] [info] Module: C:\Windows\System32\user32.dll is selected because it matches selected pattern: *
[2016-07-22 10:42:58] [warning] Cannot find pdb for C:\Windows\System32\user32.dll
[2016-07-22 10:42:58] [info] Module: C:\Windows\SysWOW64\kernel32.dll is selected because it matches selected pattern: *
[2016-07-22 10:42:58] [warning] Cannot find pdb for C:\Windows\SysWOW64\kernel32.dll
[2016-07-22 10:42:58] [info] Module: C:\Windows\SysWOW64\KernelBase.dll is selected because it matches selected pattern: *
[2016-07-22 10:42:58] [warning] Cannot find pdb for C:\Windows\SysWOW64\KernelBase.dll
[2016-07-22 10:42:58] [info] Module: C:\Windows\SysWOW64\api-ms-win-core-synch-l1-2-0.dll is selected because it matches selected pattern: *
[2016-07-22 10:42:58] [warning] Cannot find pdb for C:\Windows\SysWOW64\api-ms-win-core-synch-l1-2-0.dll
[2016-07-22 10:42:58] [info] ----------------------------------------------------
[2016-07-22 10:42:58] [info] Coverage generated in Folder C:\Program Files\OpenCppCoverage\CoverageReport-2016-07-22-10h42m58s
[2016-07-22 10:42:58] [info] ----------------------------------------------------
I can see that the .exe is tested, however, I do not understand why are the dlls tested and why the report is empty. Any suggestions will be greatly appreciated.

Thanks
Radoslav
Coordinator
Jul 23, 2016 at 12:17 PM
Hello,

It seems your --sources pattern is not correct (Sources: Selected: C:\Projects\CUnitTests\Files\Project1\Project1\Debug ) except if your source files are located in Debug folder. You do not need to have full path and probably --sources Project1 does the job.

Let me know if it solves your problem,

OpenCppCoverage
Jul 25, 2016 at 8:16 AM
Hello,

It turned out that I was just being silly and forgot to add '/Zi' as an argument in Visual C++, which actually generates the .pdb file. I got it to work and generate a coverage report, it's a fantastic tool!

Thank you for the support!

Best regards

Radoslav
Marked as answer by OpenCppCoverage on 7/27/2016 at 1:27 PM