Quinoa all test code coverage report
Current view: top level - UnitTest - TUTSuite.cpp (source / functions) Hit Total Coverage
Commit: -128-NOTFOUND Lines: 41 49 83.7 %
Date: 2024-04-29 14:59:56 Functions: 3 5 60.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 58 122 47.5 %

           Branch data     Line data    Source code
       1                 :            : // *****************************************************************************
       2                 :            : /*!
       3                 :            :   \file      src/UnitTest/TUTSuite.cpp
       4                 :            :   \copyright 2012-2015 J. Bakosi,
       5                 :            :              2016-2018 Los Alamos National Security, LLC.,
       6                 :            :              2019-2021 Triad National Security, LLC.
       7                 :            :              All rights reserved. See the LICENSE file for details.
       8                 :            :   \brief     Template Unit Test suite class definition
       9                 :            :   \details   Template Unit Test suite class definition. In principle there can
      10                 :            :     be unit test suites other than this one which uses the Template Unit Test
      11                 :            :     library.
      12                 :            : */
      13                 :            : // *****************************************************************************
      14                 :            : 
      15                 :            : #include <iostream>
      16                 :            : #include <utility>
      17                 :            : #include <map>
      18                 :            : 
      19                 :            : #include "NoWarning/format.hpp"
      20                 :            : 
      21                 :            : #include "NoWarning/tut_runner.hpp"
      22                 :            : 
      23                 :            : #include "Tags.hpp"
      24                 :            : #include "TUTSuite.hpp"
      25                 :            : #include "TUTTest.hpp"
      26                 :            : #include "MPIRunner.hpp"
      27                 :            : #include "Assessment.hpp"
      28                 :            : 
      29                 :            : #include "NoWarning/unittest.decl.h"
      30                 :            : 
      31                 :            : extern CProxy_Main mainProxy;
      32                 :            : 
      33                 :            : namespace unittest {
      34                 :            : 
      35                 :            : extern tut::test_runner_singleton g_runner;
      36                 :            : extern int g_maxTestsInGroup;
      37                 :            : 
      38                 :            : } // unittest::
      39                 :            : 
      40                 :            : using unittest::TUTSuite;
      41                 :            : 
      42                 :          1 : TUTSuite::TUTSuite( const ctr::CmdLine& cmdline ) :
      43                 :            :   m_cmdline( cmdline ),
      44                 :            :   m_mpirunner(),
      45                 :            :   m_nrun( 0 ),
      46                 :            :   m_ngroup( 0 ),
      47                 :            :   m_ncomplete( 0 ),
      48                 :            :   m_nfail( 0 ),
      49                 :            :   m_nskip( 0 ),
      50                 :            :   m_nwarn( 0 ),
      51                 :            :   m_nexcp( 0 ),
      52 [ +  - ][ +  - ]:         10 :   m_nspaw( 0 )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
         [ -  - ][ -  - ]
      53                 :            : // *****************************************************************************
      54                 :            : // Constructor
      55                 :            : //! \param[in] cmdline Data structure storing data from the command-line parser
      56                 :            : // *****************************************************************************
      57                 :            : {
      58         [ +  - ]:          2 :   const auto& groups = g_runner.get().list_groups();
      59                 :            : 
      60         [ +  - ]:          1 :   { auto print = printer();
      61 [ +  - ][ +  - ]:          1 :     print.part( "Factory" );
      62                 :            :     // Output registered test groups
      63 [ +  - ][ +  - ]:          1 :     print.list( "Registered test groups", groups );
      64                 :            :   } // ensure print is destructed (cannot collide with that of evaluate)
      65                 :            : 
      66                 :            :   // Get group name string passed in by -g
      67         [ +  - ]:          2 :   const auto grp = cmdline.get< tag::group >();
      68                 :            : 
      69                 :            :   // If only select groups to be run, see if there is any that will run
      70                 :          1 :   bool work = false;
      71 [ -  + ][ +  - ]:          1 :   if (grp.empty() ||
      72 [ -  - ][ -  - ]:          0 :       std::any_of( groups.cbegin(), groups.cend(),
      73                 :          0 :          [&grp]( const std::string& g )
      74                 :          0 :          { return g.find(grp) != std::string::npos; } ))
      75                 :          1 :     work = true;
      76                 :            : 
      77                 :            :   // Quit if there is no work to be done
      78         [ -  + ]:          1 :   if (!work) {
      79                 :            : 
      80 [ -  - ][ -  - ]:          0 :     printer().note( "\nNo test groups to be executed because no test group "
      81 [ -  - ][ -  - ]:          0 :                     "names match '" + grp + "'.\n" );
      82         [ -  - ]:          0 :     mainProxy.finalize( true );
      83                 :            : 
      84                 :            :   } else {
      85                 :            : 
      86         [ +  - ]:          1 :     { auto print = printer();
      87         [ +  - ]:          1 :       print.endpart();
      88 [ +  - ][ +  - ]:          1 :       print.part( "Serial, Charm++, and MPI unit test suites" );
      89 [ +  - ][ +  - ]:          1 :       print.unithead( "Unit tests computed", grp );
      90                 :            :     } // ensure print is destructed (cannot collied with that of evaluate)
      91                 :            : 
      92                 :            :     // Create MPI unit test runner nodegroup
      93 [ +  - ][ +  - ]:          1 :     m_mpirunner = CProxy_MPIRunner< CProxy_TUTSuite >::ckNew( thisProxy );
      94                 :            : 
      95                 :            :     // Fire up all tests in all groups using the Charm++ runtime system
      96         [ +  + ]:         33 :     for (const auto& g : groups) {
      97         [ +  - ]:         32 :       if (grp.empty()) {                        // consider all test groups
      98         [ +  - ]:         32 :         spawngrp( g );
      99         [ -  - ]:          0 :       } else if (g.find(grp) != std::string::npos) {
     100                 :            :         // spawn only the groups that match the string specified via -g string
     101         [ -  - ]:          0 :         spawngrp( g );
     102                 :            :       }
     103                 :            :     }
     104                 :            : 
     105                 :            :   }
     106                 :          1 : }
     107                 :            : 
     108                 :            : void
     109                 :         32 : TUTSuite::spawngrp( const std::string& g )
     110                 :            : // *****************************************************************************
     111                 :            : //  Fire up all tests in a test group
     112                 :            : //! \param[in] g Name of the test group
     113                 :            : // *****************************************************************************
     114                 :            : {
     115                 :         32 :   ++m_ngroup;         // increase number of test groups to run
     116                 :            : 
     117         [ +  + ]:         32 :   if (g.find("MPI") != std::string::npos)
     118                 :            : 
     119                 :          5 :     m_mpirunner.rungroup( g );
     120                 :            : 
     121                 :            :   else {
     122                 :            : 
     123                 :            :     // Add up number of additionally-spawned tests (this is so we know how many
     124                 :            :     // to expect results from)
     125         [ +  - ]:         27 :     const auto it = m_nspawned.find( g );
     126         [ +  + ]:         27 :     if (it != m_nspawned.end()) m_nspaw += it->second;
     127                 :            :   
     128                 :            :     // Asynchronously fire up all tests in test group
     129         [ +  + ]:       2187 :     for (int t=1; t<=g_maxTestsInGroup; ++t) {
     130         [ +  - ]:       2160 :       auto i = m_fromPE0.find( g );
     131         [ +  + ]:       2160 :       if (i != end(m_fromPE0))
     132         [ +  - ]:        320 :         CProxy_TUTTest< CProxy_TUTSuite >::ckNew( thisProxy, g, t, 0 );
     133                 :            :       else
     134         [ +  - ]:       1840 :         CProxy_TUTTest< CProxy_TUTSuite >::ckNew( thisProxy, g, t );
     135                 :            :     }
     136                 :            :   }
     137                 :         32 : }
     138                 :            : 
     139                 :            : void
     140                 :       2593 : TUTSuite::evaluate( std::vector< std::string > status )
     141                 :            : // *****************************************************************************
     142                 :            : // Evaluate a unit test
     143                 :            : //! \param[in] status Vector strings containing the test results. See
     144                 :            : //!   unittest::TUTTest constructor for the expected structure of status.
     145                 :            : // *****************************************************************************
     146                 :            : {
     147                 :            :   // Increase number tests run (including dummies)
     148                 :       2593 :   ++m_nrun;
     149                 :            : 
     150                 :            :   // Evaluate test
     151 [ +  - ][ +  - ]:       2593 :   unittest::evaluate( status, m_ncomplete, m_nwarn, m_nskip, m_nexcp, m_nfail );
     152                 :            : 
     153         [ +  - ]:       5186 :   auto print = printer();
     154                 :            : 
     155                 :            :   // Echo one-liner info on result of test
     156         [ +  - ]:       2593 :   print.test( m_ncomplete, m_nfail, status );
     157                 :            : 
     158                 :            :   // Wait for all tests to finish, then quit
     159         [ +  + ]:       2593 :   if (m_nrun == m_ngroup*static_cast<std::size_t>(g_maxTestsInGroup) + m_nspaw)
     160                 :            :   {
     161         [ +  - ]:          1 :     auto pass = assess(print, m_nfail, m_nwarn, m_nskip, m_nexcp, m_ncomplete);
     162         [ +  - ]:          1 :     mainProxy.finalize( pass );
     163                 :            :   }
     164                 :       2593 : }
     165                 :            : 
     166                 :            : #include "NoWarning/tutsuite.def.h"

Generated by: LCOV version 1.14