LCOV - code coverage report
Current view: top level - tests/harness - testrunner.h (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core 954b5873a738 Lines: 7 7 100.0 %
Date: 2019-06-30 05:20:33 Functions: 3 3 100.0 %
Branches: 1 2 50.0 %

           Branch data     Line data    Source code
       1                 :            : /** @file testrunner.h
       2                 :            :  * @brief Run multiple tests for different backends.
       3                 :            :  */
       4                 :            : /* Copyright 2008 Lemur Consulting Ltd
       5                 :            :  * Copyright 2008,2009,2014,2015,2017,2018 Olly Betts
       6                 :            :  *
       7                 :            :  * This program is free software; you can redistribute it and/or
       8                 :            :  * modify it under the terms of the GNU General Public License as
       9                 :            :  * published by the Free Software Foundation; either version 2 of the
      10                 :            :  * License, or (at your option) any later version.
      11                 :            :  *
      12                 :            :  * This program is distributed in the hope that it will be useful,
      13                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15                 :            :  * GNU General Public License for more details.
      16                 :            :  *
      17                 :            :  * You should have received a copy of the GNU General Public License
      18                 :            :  * along with this program; if not, write to the Free Software
      19                 :            :  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
      20                 :            :  * USA
      21                 :            :  */
      22                 :            : 
      23                 :            : #ifndef XAPIAN_INCLUDED_TESTRUNNER_H
      24                 :            : #define XAPIAN_INCLUDED_TESTRUNNER_H
      25                 :            : 
      26                 :            : #include <string>
      27                 :            : 
      28                 :            : class BackendManager;
      29                 :            : 
      30                 :            : /// backendmanager is global so that it can be accessed by individual tests.
      31                 :            : extern BackendManager * backendmanager;
      32                 :            : 
      33                 :            : /** A test runner, which runs the tests (implemented by subclassing it) with
      34                 :            :  *  a variety of backends.
      35                 :            :  */
      36         [ +  - ]:          1 : class TestRunner {
      37                 :            :     /** Backend specified by the user (or empty if none was specified).
      38                 :            :      */
      39                 :            :     std::string user_backend;
      40                 :            : 
      41                 :            :     /** Result of running tests so far.
      42                 :            :      *
      43                 :            :      *  Actually, the maximum value returned by run() so far.
      44                 :            :      */
      45                 :            :     int result_so_far;
      46                 :            : 
      47                 :            :     /** The source directory, read from the test driver.
      48                 :            :      */
      49                 :            :     std::string srcdir;
      50                 :            : 
      51                 :            :     /** Return true iff we should use the named backend.
      52                 :            :      */
      53                 :            :     bool use_backend(const std::string & backend_name);
      54                 :            : 
      55                 :            :     /** Set the property flags to those for the named backend.
      56                 :            :      */
      57                 :            :     void set_properties_for_backend(const std::string & backend_name);
      58                 :            : 
      59                 :            :     void do_tests_for_backend_(BackendManager* manager);
      60                 :            : 
      61                 :            :     /** Run the tests with the specified backend.
      62                 :            :      */
      63                 :          7 :     void do_tests_for_backend(BackendManager&& manager) {
      64                 :          7 :         do_tests_for_backend_(&manager);
      65                 :          7 :     }
      66                 :            : 
      67                 :          1 :     void do_tests_for_backend(BackendManager& manager) {
      68                 :          1 :         do_tests_for_backend_(&manager);
      69                 :          1 :     }
      70                 :            : 
      71                 :            :   protected:
      72                 :            :     enum {
      73                 :            :         BACKEND         = 0x00000001,
      74                 :            :         REMOTE          = 0x00000002,
      75                 :            :         TRANSACTIONS    = 0x00000004,
      76                 :            :         POSITIONAL      = 0x00000008,
      77                 :            :         WRITABLE        = 0x00000010,
      78                 :            :         SPELLING        = 0x00000020,
      79                 :            :         METADATA        = 0x00000040,
      80                 :            :         SYNONYMS        = 0x00000080,
      81                 :            :         REPLICAS        = 0x00000100,
      82                 :            :         VALUESTATS      = 0x00000200,
      83                 :            :         GENERATED       = 0x00000400,
      84                 :            :         MULTI           = 0x00000800,
      85                 :            :         SINGLEFILE      = 0x00001000,
      86                 :            :         INMEMORY        = 0x00002000,
      87                 :            :         GLASS           = 0x00004000,
      88                 :            :         COMPACT         = 0x00008000,
      89                 :            :         HONEY           = 0x00010000,
      90                 :            :         /// Requires get_database_path() or similar.
      91                 :            :         PATH            = 0x00020000,
      92                 :            :     };
      93                 :            : 
      94                 :            :   public:
      95                 :            :     /// Property bitmask.
      96                 :            :     unsigned properties;
      97                 :            : 
      98                 :            :     /// Virtual destructor - needed for abstract class.
      99                 :            :     virtual ~TestRunner();
     100                 :            : 
     101                 :            :     /** Run all the tests.
     102                 :            :      *
     103                 :            :      *  This should be passed the command line arguments supplied to main,
     104                 :            :      *  and will parse them for options.
     105                 :            :      */
     106                 :            :     int run_tests(int argc, char ** argv);
     107                 :            : 
     108                 :            :     /** Run the tests with a particular backend.
     109                 :            :      *
     110                 :            :      *  Properties of the backend can be determined by checking the settings of
     111                 :            :      *  the flags.
     112                 :            :      */
     113                 :            :     virtual int run() const = 0;
     114                 :            : };
     115                 :            : 
     116                 :            : #endif // XAPIAN_INCLUDED_TESTRUNNER_H

Generated by: LCOV version 1.11