locked
Native unit tests not discovered when building test project with Intel Compiler 15.0 or 16.0 RRS feed

  • Question

  • To be clear, this question is specifically about NATIVE C++ unit tests, not managed unit tests.

    I've tried the following steps in both Visual Studio 2013 and 2015 and with Intel C++ Compiler 16 and 15. Building with older versions of the Microsoft Compiler seems to work fine. Running Visual Studio as administrator makes no difference to the results.

    • Create a new unit test project - New Project/Test/Native Unit Test
    • Rebuild All
    • View Test Explorer Window  - the single sample test is listed
    • Change the platform toolset of the project to build with Intel Compiler 15 or 16 (Intel compiler 15 only builds with Visual Studio 2013)
    • Rebuild All
    • View Test Explorer Window  - no tests are listed.

    If I run dumpbin on the DLLs they export the same list of exported functions with the same names in the same order.

    I realise this isn't the support forum for the Intel C++ compiler but would be grateful if someone could give me some pointers on how to diagnose this problem further. I can't figure out how to debug and step through Visual Studio's discovery of native unit tests when it's populating the test explorer window. I'm guessing Visual Studio looks at the list of named entry points and then calls some of the entry points to enumerate the tests in the DLL e.g. the function below which I haven't managed to hit when building with the Intel compiler even though it seems to be present in the list of exported functions.

    static EXPORT_METHOD const ::Microsoft::VisualStudio::CppUnitTestFramework::TestClassInfo* CALLING_CONVENTION __GetTestClassInfo()

    If the Intel C++ Compiler is truly incompatible with Microsoft's unit testing framework because the framework relies on Microsoft specific compiler features can anyone suggest an alternative NATIVE unit testing framework that works really well with Visual Studio.

    Thanks,


    Monday, April 25, 2016 11:46 AM

All replies

  • One extra piece of information. The intel build has a warning that doesn't occur in the microsoft compiler builds:

    1>unittest1.obj : warning LNK4078: multiple 'testvers' sections found with different attributes (40301040)

    The references to this section that I can see are all in CppUnitTest.h below.

    Is there a problem here because the testvers section is declared as read only but the s_version variable is not declared as const? Would the Intel compiler generate different code from the Microsoft compiler? Could this be enough to change the behaviour of the code? The other __declspec(allocate declared variables are all const and don't generate linker warnings.

    Modifying the header to add const to the variable does not fix the warning, interestingly.


    #pragma section("testvers$", read, shared)
    
    #define ALLOCATE_TESTDATA_SECTION_VERSION __declspec(allocate("testvers$"))
    
    static EXPORT_METHOD const ::Microsoft::VisualStudio::CppUnitTestFramework::TestDataVersion* CALLING_CONVENTION __GetTestVersion() 
    {
        ALLOCATE_TESTDATA_SECTION_VERSION
        static ::Microsoft::VisualStudio::CppUnitTestFramework::TestDataVersion s_version = { __CPPUNITTEST_VERSION__ };
    
        return &s_version;
    }

    Monday, April 25, 2016 7:30 PM
  • Hi Mike,

    This forum is discuss Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor.

    Your problem is more related to Intel C++ compiler, I suggest you post this problem to Intel C++ compiler support forum for a better help. Thanks for your understanding.

    https://software.intel.com/en-us/c-compilers/inde-support

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, April 26, 2016 8:02 AM
  • Yes this is related to the Intel compiler but the Intel compiler builds a valid DLL without problems with exactly the same entry points but the tests in the DLL are not discovered by Visual Studio.

    I still need to know more about the internals of the MS unit testing framework to diagnose this problem before reporting it as an Intel bug:

    e.g.how are tests discovered?

    enumerating DLL exports?

    calling entry points?

    enumerating resources in the DLL. 

    How can I step through and debug the test discovery process in Visual Studio?

    Thanks,





    Tuesday, April 26, 2016 10:39 AM
  • Hi Mike,

    Please right-click your Unit Test project and in the Properties Window -> Application, you will find its output type is Class Library.

    So the Visual Studio Unit Test Framework will import this dll and then find the test method with the order of Assembly -> Class -> Test Method based on the [TestClass] and [TestMethod] attribute.

    But I'm afraid that we could not debug this process, the Unit Test Framework is packaged by Microsoft.

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, April 27, 2016 6:01 AM
  • Hi Weiwei,

    Thanks very much for your reply.

    Unfortunately your instructions apply to managed unit tests, not native unit tests. Should I be posting this issue on a different Microsoft forum perhaps? My post on the Intel compiler forum post hasn't had any replies.

    My Intel Compiler builds are definitely building valid native DLLs. Obviously native DLLs don't provide type info usually, just entry points which may or may not be named and name mangled to contain parameter information. These all seem correct in my Intel compiler built DLL. 

    Is it possible that the Microsoft native unit testing is inspecting debugging information or intellisense information to discover detailed information about tests? That might explain why tests aren't discovered in Intel compiler built DLLs.

    My workaround at the moment is to use the Google Test framework and the third party Google Test test adapter which works fine with both Intel and Microsoft C++ compilers.





    Friday, April 29, 2016 11:25 AM
  • Hi Mike,

    The Native Unit Test project is the same with the Managed Unit Test, both of them don't have entry point to debug the project.

    Since your problem is Test doesn't be found in Test Explorer, please create a new default Native Unit Test without any custom code to check whether the tests can be found in Test Explorer.

    If the default Native Unit Test can be found, this problem is related to the Intel Compiler. Please provide some detailed steps about where I can get the Inter Compiler and how I can use it in Native Unit Test project to reproduce this issue in my side. It can help us whether the Inter Compiler is not supported in Visual Studio or the environment problem on your machine.

    If the default Native Unit Test also can't be found, this problem is related to your Visual Studio itself. Please try install the latest updates for your Visual Studio and then repair your Visual Studio to check whether this problem can be fixed.

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Weiwei Cai Wednesday, May 4, 2016 9:58 AM
    • Unproposed as answer by Weiwei Cai Thursday, May 5, 2016 1:36 AM
    Monday, May 2, 2016 2:31 AM
  • Hi Weiwei,

    Thanks for your reply.

    I've had some response to say Intel are looking into this.

    As per the steps in my original post, creating a brand new native unit test project works absolutely fine - the sample test is discovered and run. Switching to the Intel compiler stops any tests being discovered. Switching back the Microsoft compiler and the tests are discovered again. This compiler switching is done using the Visual Studio integration that the Intel compiler installs.

    The Intel C++ compiler is commercial though the problem may well be reproducible with a 30 day trial installation. It is a substantial and potentially intrusive installation though.



    • Edited by Mike C 354343 Wednesday, May 4, 2016 11:16 AM
    • Proposed as answer by Weiwei Cai Thursday, May 5, 2016 1:36 AM
    Wednesday, May 4, 2016 11:16 AM
  • Hi Mike,

    Thanks for sharing your discovery here.

    According to your description, the original reason is the intel compiler which is integrate to Visual Studio. Please mark your reply as answer, which is benefit to other communities who has the same problem. It can help them understanding what causes this issue.

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, May 5, 2016 1:36 AM