test/include/EngineTestSuite.h
author Krista Bennett <krista@pep-project.org>
Tue, 14 Aug 2018 10:01:15 +0200
branchENGINE-451
changeset 2824 34863e77a260
parent 2822 a33bdd73952a
parent 2823 f56e57460c61
permissions -rw-r--r--
Merged in 427 fixes
krista@2633
     1
#ifndef ENGINE_TEST_SUITE_H
krista@2633
     2
#define ENGINE_TEST_SUITE_H
krista@2628
     3
krista@2637
     4
#include <cpptest.h>
krista@2628
     5
#include <string>
krista@2653
     6
#include <map>
krista@2823
     7
#include <vector>
krista@2823
     8
#include <utility>
krista@2628
     9
#include "pEpEngine.h"
krista@2628
    10
krista@2628
    11
using namespace std;
krista@2628
    12
krista@2633
    13
class EngineTestSuite : public Test::Suite {
krista@2628
    14
    public:
krista@2633
    15
        EngineTestSuite(string suitename, string test_home_dir);
krista@2645
    16
        virtual ~EngineTestSuite();
krista@2632
    17
        
krista@2653
    18
        void add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()> test_func);
krista@2653
    19
        
krista@2628
    20
    protected:
krista@2628
    21
        PEP_SESSION session;
krista@2628
    22
        string test_home;
krista@2703
    23
        string real_home;
krista@2628
    24
        string prev_gpg_home;
krista@2628
    25
        string name;
krista@2632
    26
        
krista@2652
    27
        string current_test_name;
krista@2653
    28
krista@2703
    29
#define TEST_FAILED_MESSAGE_BUFSIZE 1000        
krista@2703
    30
        char failed_msg_buf[TEST_FAILED_MESSAGE_BUFSIZE];
krista@2703
    31
        
krista@2653
    32
        std::map<std::string, void (Test::Suite::*)()> test_map;                
krista@2652
    33
        
krista@2703
    34
        string my_name;
krista@2703
    35
        
krista@2652
    36
        unsigned int number_of_tests;
krista@2652
    37
        unsigned int on_test_number;
krista@2652
    38
        
krista@2789
    39
        string temp_test_home;
krista@2789
    40
        
krista@2628
    41
        virtual void setup();
krista@2628
    42
        virtual void tear_down();
krista@2653
    43
        
krista@2628
    44
        void set_full_env();
krista@2823
    45
        void set_full_env(const char* gpg_conf_copy_path, const char* gpg_agent_conf_file_copy_path, const char* db_conf_file_copy_path);
krista@2632
    46
        void restore_full_env();
krista@2632
    47
        void initialise_test_home();
krista@2703
    48
        void set_my_name();    
krista@2789
    49
	
krista@2823
    50
        void copy_conf_file_to_test_dir(const char* dest_path, const char* conf_orig_path, const char* conf_dest_name);
krista@2823
    51
        
krista@2823
    52
        std::vector<std::pair<std::string, std::string>> gpgdir_fileadd_queue;
krista@2823
    53
        std::vector<std::pair<std::string, std::string>> homedir_fileadd_queue;
krista@2823
    54
        void add_file_to_gpg_dir_queue(std::string copy_from, std::string dst_fname);    
krista@2823
    55
        void add_file_to_home_dir_queue(std::string copy_from, std::string dst_fname);
krista@2823
    56
        void process_file_queue(std::string dirname, std::vector<std::pair<std::string, std::string>> file_queue);
krista@2823
    57
krista@2628
    58
};
krista@2628
    59
#endif