Added messageToSend and inject_sync_event callback caches to EngineTestSuite object so that, if desired, the args can be passed to init in set_full_env. This is kludgey and should probably be refactored, as if this needs to change between tests in the same suite, it'll be tough. (See KeyResetMessageTests for usage example) sync_and_key_reset
authorKrista Bennett <krista@pep-project.org>
Fri, 28 Sep 2018 10:22:17 +0200
branchsync_and_key_reset
changeset 29579557662f7def
parent 2956 e82181973f21
child 2958 eacaf20a6854
child 2959 8665028dc8f0
Added messageToSend and inject_sync_event callback caches to EngineTestSuite object so that, if desired, the args can be passed to init in set_full_env. This is kludgey and should probably be refactored, as if this needs to change between tests in the same suite, it'll be tough. (See KeyResetMessageTests for usage example)
test/include/EngineTestSuite.h
test/src/EngineTestSuite.cc
test/src/engine_tests/KeyResetMessageTests.cc
     1.1 --- a/test/include/EngineTestSuite.h	Fri Sep 28 10:07:05 2018 +0200
     1.2 +++ b/test/include/EngineTestSuite.h	Fri Sep 28 10:22:17 2018 +0200
     1.3 @@ -28,6 +28,9 @@
     1.4          
     1.5          string current_test_name;
     1.6  
     1.7 +        messageToSend_t cached_messageToSend;
     1.8 +        inject_sync_event_t cached_inject_sync_event;
     1.9 +
    1.10  #define TEST_FAILED_MESSAGE_BUFSIZE 1000        
    1.11          char failed_msg_buf[TEST_FAILED_MESSAGE_BUFSIZE];
    1.12          
     2.1 --- a/test/src/EngineTestSuite.cc	Fri Sep 28 10:07:05 2018 +0200
     2.2 +++ b/test/src/EngineTestSuite.cc	Fri Sep 28 10:22:17 2018 +0200
     2.3 @@ -29,6 +29,8 @@
     2.4      number_of_tests = 0;
     2.5      on_test_number = 0;
     2.6      real_home = getenv("HOME");
     2.7 +    cached_messageToSend = NULL;
     2.8 +    cached_inject_sync_event = NULL;
     2.9  }
    2.10  
    2.11  EngineTestSuite::~EngineTestSuite() {}
    2.12 @@ -194,7 +196,7 @@
    2.13      gpg_agent_conf(true);
    2.14      
    2.15  //    cout << "calling init()\n";
    2.16 -    PEP_STATUS status = init(&session, NULL, NULL);
    2.17 +    PEP_STATUS status = init(&session, cached_messageToSend, cached_inject_sync_event);
    2.18      assert(status == PEP_STATUS_OK);
    2.19      assert(session);
    2.20  //    cout << "init() completed.\n";
     3.1 --- a/test/src/engine_tests/KeyResetMessageTests.cc	Fri Sep 28 10:07:05 2018 +0200
     3.2 +++ b/test/src/engine_tests/KeyResetMessageTests.cc	Fri Sep 28 10:22:17 2018 +0200
     3.3 @@ -43,6 +43,8 @@
     3.4      add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("KeyResetMessageTests::check_receive_message_to_revoked_key_from_contact"),
     3.5                                                                        static_cast<Func>(&KeyResetMessageTests::check_receive_message_to_revoked_key_from_contact)));                                                                      
     3.6      fake_this = this;                                                                  
     3.7 +    
     3.8 +    cached_messageToSend = &KeyResetMessageTests::message_send_callback;
     3.9  }
    3.10  
    3.11  PEP_STATUS KeyResetMessageTests::message_send_callback(message* msg) {
    3.12 @@ -52,8 +54,6 @@
    3.13  
    3.14  void KeyResetMessageTests::setup() {
    3.15      EngineTestIndividualSuite::setup();
    3.16 -    session->sync_obj = this;
    3.17 -    session->messageToSend = &KeyResetMessageTests::message_send_callback;
    3.18      m_queue.clear();
    3.19  }
    3.20