just checkin in to switch tracks googletest
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Tue, 20 Aug 2019 09:59:36 +0200
branchgoogletest
changeset 39994c4a87d520eb
parent 3998 687546abfd88
child 4004 ef7ff8fa3ead
just checkin in to switch tracks
gtest/gtest_firstpass.py
gtest/src/engine_tests/ExportKeyTest.cc
test/include/test_util.h
test/src/SuiteMaker.cc
test/src/engine_tests/ExportKeyTests.cc
test/src/util/test_util.cc
     1.1 --- a/gtest/gtest_firstpass.py	Thu Aug 15 12:45:34 2019 +0200
     1.2 +++ b/gtest/gtest_firstpass.py	Tue Aug 20 09:59:36 2019 +0200
     1.3 @@ -1,8 +1,299 @@
     1.4  import re 
     1.5 +import sys
     1.6  
     1.7 -#*Tests::*Tests(string suitename, string test_home_dir)
     1.8 -# Put in fixture blob
     1.9 -# - delete through first }
    1.10 +fixture_in = False 
    1.11 +removing_old_constructor = False
    1.12 +constructor_done = False
    1.13 +modline = None
    1.14 +filename = sys.argv[1]
    1.15 +outfile = sys.argv[2]
    1.16  
    1.17 -#void *Tests::check*() {
    1.18 -# -> TEST_F(*Test, check*);
    1.19 +newfile = open(outfile,'w')
    1.20 +
    1.21 +with open(filename) as fp: 
    1.22 +    for line in fp:
    1.23 +        line = line.rstrip();
    1.24 +        
    1.25 +        if not fixture_in:
    1.26 +            if (removing_old_constructor):
    1.27 +                if "}" in line:
    1.28 +                    removing_old_constructor = False  
    1.29 +                    constructor_done = True 
    1.30 +                continue
    1.31 +            else:        
    1.32 +                if (line.find("namespace") >= 0):
    1.33 +                    continue
    1.34 +                if (line.find("Tests.h") >= 0):
    1.35 +                    continue
    1.36 +                if (line.find("cpptest") >= 0):
    1.37 +                    continue 
    1.38 +                if (line.find("EngineTestSuite.h") >= 0 or line.find("EngineTestIndividualSuite.h") >= 0 or line.find("EngineTestSessionSuite.h") >= 0):
    1.39 +                    continue
    1.40 +                
    1.41 +                if (modline == None):                
    1.42 +                    modline = re.sub(r'(.*)Tests::(.*)Tests\(string suitename, string test_home_dir\) :', r'\1Test', line)                
    1.43 +                    
    1.44 +                if(modline == line):
    1.45 +                    newfile.write(line)
    1.46 +                    modline = None
    1.47 +                    continue
    1.48 +                else:
    1.49 +                    if not (constructor_done):
    1.50 +                        removing_old_constructor = True
    1.51 +                        continue    
    1.52 +                    #*Tests::*Tests(string suitename, string test_home_dir)
    1.53 +                    # Put in fixture blob
    1.54 +                    # - delete through first }
    1.55 +                    #print(modline) 
    1.56 +                    newfile.write("#include <gtest/gtest.h>\n\n\n")
    1.57 +                    newfile.write("namespace {\n\n\t//The fixture for " + modline + "\n")
    1.58 +                    newfile.write("\tclass " + modline + " public ::testing::Test {\n")
    1.59 +                    newfile.write("\t\tpublic:\n")
    1.60 +                    newfile.write("\t\t\tEngine engine;\n")
    1.61 +                    newfile.write("\t\t\tPEP_SESSION session;\n\n")
    1.62 +                    newfile.write("\t\tprotected:\n")
    1.63 +                    newfile.write("\t\t\t// You can remove any or all of the following functions if its body\n")
    1.64 +                    newfile.write("\t\t\t// is empty.\n")
    1.65 +                    newfile.write("\t\t\t" + modline + "() {\n")
    1.66 +                    newfile.write("\t\t\t\t// You can do set-up work for each test here.\n")
    1.67 +                    newfile.write("\t\t\t\ttest_suite_name = ::testing::UnitTest::GetInstance()->current_test_info()->test_suite_name();\n")
    1.68 +                    newfile.write("\t\t\t\ttest_name = ::testing::UnitTest::GetInstance()->current_test_info()->name();\n")
    1.69 +                    newfile.write("\t\t\t\t")
    1.70 +                    newfile.write("\t\t\t\t")
    1.71 +                    newfile.write("\t\t\t\t")
    1.72 +                    newfile.write("\t\t\t\t")                    
    1.73 +                    newfile.write("\t\t\t}\n\n")
    1.74 +                    newfile.write("\t\t\t~" + modline + "() override {\n")
    1.75 +                    newfile.write("\t\t\t\t// You can do clean-up work that doesn't throw exceptions here.\n")
    1.76 +                    newfile.write("\t\t\t}\n\n")
    1.77 +                    newfile.write("\t\t\t// If the constructor and destructor are not enough for setting up\n")
    1.78 +                    newfile.write("\t\t\t// and cleaning up each test, you can define the following methods:\n\n")
    1.79 +                    newfile.write("\t\t\tvoid SetUp() override {\n")
    1.80 +                    newfile.write("\t\t\t\t// Code here will be called immediately after the constructor (right\n")
    1.81 +                    newfile.write("\t\t\t\t// before each test).\n")
    1.82 +                    newfile.write("\t\t\t}\n\n")
    1.83 +                    newfile.write("\t\t\tvoid TearDown() override {\n")
    1.84 +                    newfile.write("\t\t\t\t// Code here will be called immediately after each test (right\n")
    1.85 +                    newfile.write("\t\t\t}\n\n")
    1.86 +                    newfile.write("\t\tprivate:\n");
    1.87 +                    newfile.write("\t\t\tconst char* test_suite_name;\n")
    1.88 +                    newfile.write("\t\t\tconst char* test_name;\n")                                        
    1.89 +                    newfile.write("\t\t\t// Objects declared here can be used by all tests in the " + modline + " suite.\n\n")
    1.90 +                    newfile.write("\t};\n\n")
    1.91 +                    newfile.write("}  // namespace\n\n\n")
    1.92 +
    1.93 +                    fixture_in = True
    1.94 +        else:
    1.95 +            #void *Tests::check*() {
    1.96 +            # -> TEST_F(*Test, check*) {
    1.97 +            modline = re.sub(r'void\s*(.*)Tests::check(.*)\(\);', r'TEST_F(\1Test, check\2);', line)
    1.98 +            if (line != modline):
    1.99 +                newfile.write(modline + "\n")
   1.100 +                continue
   1.101 +                
   1.102 +            #TEST_ASSERT(true)
   1.103 +            # -> <nothing>                
   1.104 +            if (line.find("TEST_ASSERT(true)") >= 0):
   1.105 +                continue
   1.106 +                
   1.107 +            #TEST_ASSERT_MSG(strcmp(blah,blah) == 0, *)
   1.108 +            #TEST_ASSERT(strcmp(blah,blah == 0))
   1.109 +            # -> ASSERT_STREQ(blah,blah)
   1.110 +            modline = re.sub(r'TEST_ASSERT_MSG\(\s*strcmp\(\s*(.*),\s*(.*)\)\s*==\s*0\s*,.*\);', r'ASSERT_STREQ(\1, \2);', line)
   1.111 +            if (line != modline):
   1.112 +                newfile.write(modline + "\n")
   1.113 +                continue
   1.114 +            modline = re.sub(r'TEST_ASSERT\(\s*strcmp\(\s*(.*),\s*(.*)\)\s*==\s*0\);', r'ASSERT_STREQ(\1, \2);', line)
   1.115 +            if (line != modline):
   1.116 +                newfile.write(modline + "\n")
   1.117 +                continue
   1.118 +
   1.119 +            #TEST_ASSERT_MSG(strcmp(blah,blah) != 0, *)
   1.120 +            #TEST_ASSERT(strcmp(blah,blah != 0))
   1.121 +            # -> ASSERT_STREQ(blah,blah)
   1.122 +            modline = re.sub(r'TEST_ASSERT_MSG\(\s*strcmp\(\s*(.*),\s*(.*)\)\s*!=\s*0\s*,.*\);', r'ASSERT_STRNE(\1, \2);', line)
   1.123 +            if (line != modline):
   1.124 +                newfile.write(modline + "\n")
   1.125 +                continue
   1.126 +            modline = re.sub(r'TEST_ASSERT\(\s*strcmp\(\s*(.*),\s*(.*)\)\s*!=\s*0\);', r'ASSERT_STRNE(\1, \2);', line)
   1.127 +            if (line != modline):
   1.128 +                newfile.write(modline + "\n")
   1.129 +                continue
   1.130 +                
   1.131 +            #TEST_ASSERT_MSG(<x> == NULL, *);
   1.132 +            #TEST_ASSERT(<x> == NULL);
   1.133 +            # -> ASSERT_EQ(<x>, nullptr);
   1.134 +            modline = re.sub(r'TEST_ASSERT_MSG\((.*)\s*==\s*NULL,.*\);',r'ASSERT_EQ(\1, nullptr);', line)
   1.135 +            if (line != modline):
   1.136 +                newfile.write(modline + "\n")
   1.137 +                continue
   1.138 +            modline = re.sub(r'TEST_ASSERT\((.*)\s*==\s*NULL\);', r'ASSERT_EQ(\1, nullptr);',line)
   1.139 +            if (line != modline):
   1.140 +                newfile.write(modline + "\n")
   1.141 +                continue
   1.142 +            
   1.143 +            #TEST_ASSERT_MSG(<x> != NULL, *);
   1.144 +            #TEST_ASSERT(<x> != NULL);
   1.145 +            # -> ASSERT_NE(<x>, nullptr);
   1.146 +            modline = re.sub(r'TEST_ASSERT_MSG\((.*)\s*!=\s*NULL,.*\);',r'ASSERT_NE(\1, nullptr);', line)
   1.147 +            if (line != modline):
   1.148 +                newfile.write(modline + "\n")
   1.149 +                continue
   1.150 +            modline = re.sub(r'TEST_ASSERT\((.*)\s*!=\s*NULL\);', r'ASSERT_NE(\1, nullptr);',line)
   1.151 +            if (line != modline):
   1.152 +                newfile.write(modline + "\n")
   1.153 +                continue
   1.154 +            
   1.155 +            #TEST_ASSERT_MSG(<x> == <y>, *);
   1.156 +            #TEST_ASSERT(<x> == <y>);
   1.157 +            # -> ASSERT_EQ(<x>, <y>);
   1.158 +            modline = re.sub(r'TEST_ASSERT_MSG\((.*)\s*==\s*(.*),.*\);', r'ASSERT_EQ(\1, \2);',line)
   1.159 +            if (line != modline):
   1.160 +                newfile.write(modline + "\n")
   1.161 +                continue
   1.162 +            modline = re.sub(r'TEST_ASSERT\((.*)\s*==\s*(.*)\);', r'ASSERT_EQ(\1, \2);',line)
   1.163 +            if (line != modline):
   1.164 +                newfile.write(modline + "\n")
   1.165 +                continue
   1.166 +            
   1.167 +            #TEST_ASSERT_MSG(<x> != <y>, *);
   1.168 +            #TEST_ASSERT(<x> != <y>);
   1.169 +            # -> ASSERT_NE(<x>, <y>);
   1.170 +            modline = re.sub(r'TEST_ASSERT_MSG\((.*)\s*!=\s*(.*),.*\);', r'ASSERT_NE(\1, \2);',line)
   1.171 +            if (line != modline):
   1.172 +                newfile.write(modline + "\n")
   1.173 +                continue
   1.174 +            modline = re.sub(r'TEST_ASSERT\((.*)\s*!=\s*(.*)\);', r'ASSERT_NE(\1, \2);',line)
   1.175 +            if (line != modline):
   1.176 +                newfile.write(modline + "\n")
   1.177 +                continue
   1.178 +            
   1.179 +            #TEST_ASSERT_MSG(<x> >= <y>, *);
   1.180 +            #TEST_ASSERT(<x> >= <y>);
   1.181 +            # -> ASSERT_GE(<x>, <y>);
   1.182 +            modline = re.sub(r'TEST_ASSERT_MSG\((.*)\s*[^-]>=\s*(.*),.*\);', r'ASSERT_GE(\1, \2);',line)
   1.183 +            if (line != modline):
   1.184 +                newfile.write(modline + "\n")
   1.185 +                continue
   1.186 +            modline = re.sub(r'TEST_ASSERT\((.*)\s*[^-]>=\s*(.*)\);', r'ASSERT_GE(\1, \2);',line)
   1.187 +            if (line != modline):
   1.188 +                newfile.write(modline + "\n")
   1.189 +                continue
   1.190 +            
   1.191 +            #TEST_ASSERT_MSG(<x> > <y>, *);
   1.192 +            #TEST_ASSERT(<x> > <y>);
   1.193 +            # -> ASSERT_GT(<x>, <y>);
   1.194 +            modline = re.sub(r'TEST_ASSERT_MSG\((.*)\s*[^-]>\s*(.*),.*\);', r'ASSERT_GT(\1, \2);',line)
   1.195 +            if (line != modline):
   1.196 +                newfile.write(modline + "\n")
   1.197 +                continue
   1.198 +            modline = re.sub(r'TEST_ASSERT\((.*)\s*[^-]>\s*(.*)\);', r'ASSERT_GT(\1, \2);',line)
   1.199 +            if (line != modline):
   1.200 +                newfile.write(modline + "\n")
   1.201 +                continue
   1.202 +            
   1.203 +            #TEST_ASSERT_MSG(<x> <= <y>, *);
   1.204 +            #TEST_ASSERT(<x> <= <y>);
   1.205 +            # -> ASSERT_LE(<x>, <y>);
   1.206 +            modline = re.sub(r'TEST_ASSERT_MSG\((.*)\s*<=\s*(.*),.*\);', r'ASSERT_LE(\1, \2);',line)
   1.207 +            if (line != modline):
   1.208 +                newfile.write(modline + "\n")
   1.209 +                continue
   1.210 +            modline = re.sub(r'TEST_ASSERT\((.*)\s*<=\s*(.*)\);', r'ASSERT_LE(\1, \2);',line)
   1.211 +            if (line != modline):
   1.212 +                newfile.write(modline + "\n")
   1.213 +                continue
   1.214 +            
   1.215 +            #TEST_ASSERT_MSG(<x> < <y>, *);
   1.216 +            #TEST_ASSERT(<x> < <y>);
   1.217 +            # -> ASSERT_LT(<x>, <y>);
   1.218 +            modline = re.sub(r'TEST_ASSERT_MSG\((.*)\s*<\s*(.*),.*\);', r'ASSERT_LT(\1, \2);',line)
   1.219 +            if (line != modline):
   1.220 +                newfile.write(modline + "\n")
   1.221 +                continue
   1.222 +            modline = re.sub(r'TEST_ASSERT\((.*)\s*<\s*(.*)\);', r'ASSERT_LT(\1, \2);',line)
   1.223 +            if (line != modline):
   1.224 +                newfile.write(modline + "\n")
   1.225 +                continue
   1.226 +            
   1.227 +            # FIXME: either assume ptr or ask about it?
   1.228 +            #TEST_ASSERT_MSG(!<x>, *);
   1.229 +            #TEST_ASSERT(!<x>);
   1.230 +            # -> ASSERT_FALSE(<x>);
   1.231 +            mgroup = re.match(r'TEST_ASSERT_MSG\(!(.*),.*\);', line.lstrip());
   1.232 +            if (mgroup == None):
   1.233 +                mgroup = re.match(r'TEST_ASSERT\(!(.*)\);', line.lstrip());
   1.234 +            
   1.235 +            if (mgroup != None):
   1.236 +                matchphrase = mgroup.group(0)
   1.237 +                is_pointer = False
   1.238 +                while True:
   1.239 +                    answer = input("ATTENTION: INPUT REQUIRED: In line " + line.lstrip() + ", is " + matchphrase + " a pointer? (y/n)")
   1.240 +                    if (answer == "y" or answer == "Y"):
   1.241 +                        is_pointer = True
   1.242 +                        break
   1.243 +                    elif (answer != "n" and answer != 'N'):
   1.244 +                        print("\'" + answer + "\' is not a valid answer. Please answer with 'y' or 'n'.") 
   1.245 +                        continue
   1.246 +                    break;       
   1.247 +                
   1.248 +                if (is_pointer):
   1.249 +                    modline = re.sub(r'TEST_ASSERT_MSG\(!(.*),.*\);',r'ASSERT_NE(\1, nullptr);', line)
   1.250 +                    if (line != modline):
   1.251 +                        newfile.write(modline + "\n")
   1.252 +                        continue
   1.253 +                    modline = re.sub(r'TEST_ASSERT\(!(.*)\);', r'ASSERT_NE(\1, nullptr);',line)
   1.254 +                    if (line != modline):
   1.255 +                        newfile.write(modline + "\n")
   1.256 +                        continue
   1.257 +                else:        
   1.258 +                    modline = re.sub(r'TEST_ASSERT_MSG\(!(.*),.*\);',r'ASSERT_FALSE(\1);', line)
   1.259 +                    if (line != modline):
   1.260 +                        newfile.write(modline + "\n")
   1.261 +                        continue
   1.262 +                    modline = re.sub(r'TEST_ASSERT\(!(.*)\);', r'ASSERT_FALSE(\1);',line)
   1.263 +                    if (line != modline):
   1.264 +                        newfile.write(modline + "\n")
   1.265 +                        continue
   1.266 +                                            
   1.267 +            #TEST_ASSERT_MSG(<x>, *);
   1.268 +            #TEST_ASSERT(<x>);
   1.269 +            # -> ASSERT_TRUE(<x>);
   1.270 +            mgroup = re.match(r'TEST_ASSERT_MSG\((.*),.*\);', line.lstrip());
   1.271 +            if (mgroup == None):
   1.272 +                mgroup = re.match(r'TEST_ASSERT\((.*)\);', line.lstrip());
   1.273 +            
   1.274 +            if (mgroup != None):
   1.275 +                matchphrase = mgroup.group(1)
   1.276 +                is_pointer = False
   1.277 +                while True:
   1.278 +                    answer = input("ATTENTION: INPUT REQUIRED: In line " + line.lstrip() + ", is " + matchphrase + " a pointer? (y/n)")
   1.279 +                    if (answer == "y" or answer == "Y"):
   1.280 +                        is_pointer = True
   1.281 +                        break
   1.282 +                    elif (answer != "n" and answer != 'N'):
   1.283 +                        print("\'" + answer + "\' is not a valid answer. Please answer with 'y' or 'n'.") 
   1.284 +                        continue
   1.285 +                    break;       
   1.286 +                
   1.287 +                if (is_pointer):
   1.288 +                    modline = re.sub(r'TEST_ASSERT_MSG\((.*),.*\);',r'ASSERT_NE(\1, nullptr);', line)
   1.289 +                    if (line != modline):
   1.290 +                        newfile.write(modline + "\n")
   1.291 +                        continue
   1.292 +                    modline = re.sub(r'TEST_ASSERT\((.*)\);', r'ASSERT_NE(\1, nullptr);',line)
   1.293 +                    if (line != modline):
   1.294 +                        newfile.write(modline + "\n")
   1.295 +                        continue
   1.296 +                else:        
   1.297 +                    modline = re.sub(r'TEST_ASSERT_MSG\((.*),.*\);',r'ASSERT_TRUE(\1);', line)
   1.298 +                    if (line != modline):
   1.299 +                        newfile.write(modline + "\n")
   1.300 +                        continue
   1.301 +                    modline = re.sub(r'TEST_ASSERT\((.*)\);', r'ASSERT_TRUE(\1);',line)
   1.302 +                    if (line != modline):
   1.303 +                        newfile.write(modline + "\n")
   1.304 +                        continue
   1.305 +            
   1.306 +            #Ok, it's something else. Print line and go.
   1.307 +            newfile.write(line + "\n")
     2.1 --- a/gtest/src/engine_tests/ExportKeyTest.cc	Thu Aug 15 12:45:34 2019 +0200
     2.2 +++ b/gtest/src/engine_tests/ExportKeyTest.cc	Tue Aug 20 09:59:36 2019 +0200
     2.3 @@ -1,47 +1,57 @@
     2.4 -// This file is under GNU General Public License 3.0
     2.5 -// see LICENSE.txt
     2.6 +// This file is under GNU General Public License 3.0// see LICENSE.txt#include <stdlib.h>#include <cstring>#include <string>#include "test_util.h"#include "pEpEngine.h"#include <gtest/gtest.h>
     2.7  
     2.8 -#include <stdlib.h>
     2.9 -#include <cstring>
    2.10 -#include <string>
    2.11  
    2.12 -#include <cpptest.h>
    2.13 -#include "test_util.h"
    2.14 +namespace {
    2.15  
    2.16 -#include "pEpEngine.h"
    2.17 +    //The fixture for ExportKeyTest
    2.18 +    class ExportKeyTest public ::testing::Test {
    2.19 +        public:
    2.20 +            Engine engine;
    2.21 +            PEP_SESSION session;
    2.22  
    2.23 -#include "EngineTestIndividualSuite.h"
    2.24 -#include "ExportKeyTests.h"
    2.25 +        protected:
    2.26 +            // You can remove any or all of the following functions if its body
    2.27 +            // is empty.
    2.28 +            ExportKeyTest() {
    2.29 +                // You can do set-up work for each test here.
    2.30 +            }
    2.31  
    2.32 -using namespace std;
    2.33 +            ~ExportKeyTest() override {
    2.34 +                // You can do clean-up work that doesn't throw exceptions here.
    2.35 +            }
    2.36  
    2.37 -ExportKeyTests::ExportKeyTests(string suitename, string test_home_dir) :
    2.38 -    EngineTestIndividualSuite::EngineTestIndividualSuite(suitename, test_home_dir) {
    2.39 -    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("ExportKeyTests::check_export_key_no_key"),
    2.40 -                                                                      static_cast<Func>(&ExportKeyTests::check_export_key_no_key)));
    2.41 -    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("ExportKeyTests::check_export_key_pubkey"),
    2.42 -                                                                      static_cast<Func>(&ExportKeyTests::check_export_key_pubkey)));
    2.43 -    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("ExportKeyTests::check_export_key_no_secret_key"),
    2.44 -                                                                      static_cast<Func>(&ExportKeyTests::check_export_key_no_secret_key)));
    2.45 -    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("ExportKeyTests::check_export_key_no_secret_key"),
    2.46 -                                                                      static_cast<Func>(&ExportKeyTests::check_export_key_no_secret_key)));
    2.47 -}
    2.48 +            // If the constructor and destructor are not enough for setting up
    2.49 +            // and cleaning up each test, you can define the following methods:
    2.50 +
    2.51 +            void SetUp() override {
    2.52 +                // Code here will be called immediately after the constructor (right
    2.53 +                // before each test).
    2.54 +            }
    2.55 +
    2.56 +            void TearDown() override {
    2.57 +                // Code here will be called immediately after each test (right
    2.58 +            }
    2.59 +
    2.60 +            // Objects declared here can be used by all tests in the ExportKeyTest suite.
    2.61 +    };
    2.62 +
    2.63 +}  // namespace
    2.64 +
    2.65  
    2.66  void ExportKeyTests::check_export_key_no_key() {
    2.67      char* keydata = NULL;
    2.68      size_t keysize = 0;
    2.69 -    PEP_STATUS status = export_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39", 
    2.70 +    PEP_STATUS status = export_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39",
    2.71                                     &keydata, &keysize);
    2.72 -    TEST_ASSERT_MSG(status == PEP_KEY_NOT_FOUND, tl_status_string(status));
    2.73 +    ASSERT_EQ(status , PEP_KEY_NOT_FOUND);
    2.74      free(keydata);
    2.75      keydata = NULL;
    2.76      keysize = 0;
    2.77 -    status = export_secret_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39", 
    2.78 +    status = export_secret_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39",
    2.79                                     &keydata, &keysize);
    2.80 -    TEST_ASSERT_MSG(status == PEP_KEY_NOT_FOUND, tl_status_string(status));
    2.81 +    ASSERT_EQ(status , PEP_KEY_NOT_FOUND);
    2.82      free(keydata);
    2.83  
    2.84 -    TEST_ASSERT(true);
    2.85  }
    2.86  
    2.87  void ExportKeyTests::check_export_key_pubkey() {
    2.88 @@ -53,16 +63,16 @@
    2.89      size_t keysize = 0;
    2.90      stringlist_t* keylist = NULL;
    2.91      PEP_STATUS status = find_keys(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39", &keylist);
    2.92 -    TEST_ASSERT(keylist && keylist->value);
    2.93 -    TEST_ASSERT(strcmp(keylist->value, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39") == 0);
    2.94 +    ASSERT_TRUE(keylist && keylist->value);
    2.95 +    ASSERT_STREQ(keylist->value, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39");
    2.96      free_stringlist(keylist);
    2.97  
    2.98 -    status = export_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39", 
    2.99 +    status = export_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39",
   2.100                                     &keydata, &keysize);
   2.101 -    TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
   2.102 -    TEST_ASSERT(keydata);
   2.103 -    TEST_ASSERT(keysize > 0);
   2.104 -    
   2.105 +    ASSERT_EQ(status , PEP_STATUS_OK);
   2.106 +    ASSERT_NE(keydata, nullptr);
   2.107 +    ASSERT_GT(keysize, 0);
   2.108 +
   2.109      free(keydata);
   2.110  }
   2.111  
   2.112 @@ -75,30 +85,29 @@
   2.113      size_t keysize = 0;
   2.114      stringlist_t* keylist = NULL;
   2.115      PEP_STATUS status = find_keys(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39", &keylist);
   2.116 -    TEST_ASSERT(keylist && keylist->value);
   2.117 -    TEST_ASSERT(strcmp(keylist->value, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39") == 0);
   2.118 +    ASSERT_TRUE(keylist && keylist->value);
   2.119 +    ASSERT_STREQ(keylist->value, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39");
   2.120      free_stringlist(keylist);
   2.121      keylist = NULL;
   2.122 -    
   2.123 +
   2.124      bool has_private = false;
   2.125      contains_priv_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39", &has_private);
   2.126 -    TEST_ASSERT_MSG(has_private, "Secret key not found.")
   2.127 -    
   2.128 -    status = export_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39", 
   2.129 +    ASSERT_TRUE(has_private);
   2.130 +
   2.131 +    status = export_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39",
   2.132                                     &keydata, &keysize);
   2.133 -    TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
   2.134 -    TEST_ASSERT(keydata);
   2.135 -    TEST_ASSERT(keysize > 0);
   2.136 +    ASSERT_EQ(status , PEP_STATUS_OK);
   2.137 +    ASSERT_NE(keydata, nullptr);
   2.138 +    ASSERT_GT(keysize, 0);
   2.139  
   2.140      free(keydata);
   2.141      keydata = NULL;
   2.142      keysize = 0;
   2.143 -    status = export_secret_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39", 
   2.144 +    status = export_secret_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39",
   2.145                                     &keydata, &keysize);
   2.146 -    TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
   2.147 +    ASSERT_EQ(status , PEP_STATUS_OK);
   2.148  
   2.149      free(keydata);
   2.150 -    TEST_ASSERT(true);
   2.151  }
   2.152  
   2.153  
   2.154 @@ -111,18 +120,17 @@
   2.155      size_t keysize = 0;
   2.156      stringlist_t* keylist = NULL;
   2.157      PEP_STATUS status = find_keys(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39", &keylist);
   2.158 -    TEST_ASSERT(keylist && keylist->value);
   2.159 -    TEST_ASSERT(strcmp(keylist->value, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39") == 0);
   2.160 +    ASSERT_TRUE(keylist && keylist->value);
   2.161 +    ASSERT_STREQ(keylist->value, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39");
   2.162  
   2.163 -    status = export_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39", 
   2.164 +    status = export_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39",
   2.165                                     &keydata, &keysize);
   2.166 -    TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
   2.167 +    ASSERT_EQ(status , PEP_STATUS_OK);
   2.168      free(keydata);
   2.169      keydata = NULL;
   2.170      keysize = 0;
   2.171 -    status = export_secret_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39", 
   2.172 +    status = export_secret_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39",
   2.173                                     &keydata, &keysize);
   2.174 -    TEST_ASSERT_MSG(status == PEP_KEY_NOT_FOUND, tl_status_string(status));
   2.175 +    ASSERT_EQ(status , PEP_KEY_NOT_FOUND);
   2.176      free(keydata);
   2.177 -    TEST_ASSERT(true);
   2.178  }
     3.1 --- a/test/include/test_util.h	Thu Aug 15 12:45:34 2019 +0200
     3.2 +++ b/test/include/test_util.h	Tue Aug 20 09:59:36 2019 +0200
     3.3 @@ -14,6 +14,8 @@
     3.4  
     3.5  bool file_exists(std::string filename);
     3.6  
     3.7 +extern std::string _main_test_home_dir;
     3.8 +
     3.9  typedef enum _pEp_test_ident_preset {
    3.10      ALICE,
    3.11      APPLE,
     4.1 --- a/test/src/SuiteMaker.cc	Thu Aug 15 12:45:34 2019 +0200
     4.2 +++ b/test/src/SuiteMaker.cc	Tue Aug 20 09:59:36 2019 +0200
     4.3 @@ -30,7 +30,6 @@
     4.4  #include "PgpBinaryTests.h"
     4.5  #include "SubkeyRatingEvalTests.h"
     4.6  #include "MessageNullFromTests.h"
     4.7 -#include "Engine587Tests.h"
     4.8  #include "ExportKeyTests.h"
     4.9  #include "LeastCommonDenomColorTests.h"
    4.10  #include "StringlistTests.h"
    4.11 @@ -100,7 +99,6 @@
    4.12      "PgpBinaryTests",
    4.13      "SubkeyRatingEvalTests",
    4.14      "MessageNullFromTests",
    4.15 -    "Engine587Tests",
    4.16      "ExportKeyTests",
    4.17      "LeastCommonDenomColorTests",
    4.18      "StringlistTests",
    4.19 @@ -152,7 +150,7 @@
    4.20  };
    4.21  
    4.22  // This file is generated, so magic constants are ok.
    4.23 -int SuiteMaker::num_suites = 67;
    4.24 +int SuiteMaker::num_suites = 66;
    4.25  
    4.26  void SuiteMaker::suitemaker_build(const char* test_class_name, const char* test_home, Test::Suite** test_suite) {
    4.27      if (strcmp(test_class_name, "URIAddressTests") == 0)
    4.28 @@ -191,8 +189,6 @@
    4.29          *test_suite = new SubkeyRatingEvalTests(test_class_name, test_home);
    4.30      else if (strcmp(test_class_name, "MessageNullFromTests") == 0)
    4.31          *test_suite = new MessageNullFromTests(test_class_name, test_home);
    4.32 -    else if (strcmp(test_class_name, "Engine587Tests") == 0)
    4.33 -        *test_suite = new Engine587Tests(test_class_name, test_home);
    4.34      else if (strcmp(test_class_name, "ExportKeyTests") == 0)
    4.35          *test_suite = new ExportKeyTests(test_class_name, test_home);
    4.36      else if (strcmp(test_class_name, "LeastCommonDenomColorTests") == 0)
     5.1 --- a/test/src/engine_tests/ExportKeyTests.cc	Thu Aug 15 12:45:34 2019 +0200
     5.2 +++ b/test/src/engine_tests/ExportKeyTests.cc	Tue Aug 20 09:59:36 2019 +0200
     5.3 @@ -21,8 +21,8 @@
     5.4                                                                        static_cast<Func>(&ExportKeyTests::check_export_key_no_key)));
     5.5      add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("ExportKeyTests::check_export_key_pubkey"),
     5.6                                                                        static_cast<Func>(&ExportKeyTests::check_export_key_pubkey)));
     5.7 -    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("ExportKeyTests::check_export_key_no_secret_key"),
     5.8 -                                                                      static_cast<Func>(&ExportKeyTests::check_export_key_no_secret_key)));
     5.9 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("ExportKeyTests::check_export_key_secret_key"),
    5.10 +                                                                      static_cast<Func>(&ExportKeyTests::check_export_key_secret_key)));
    5.11      add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("ExportKeyTests::check_export_key_no_secret_key"),
    5.12                                                                        static_cast<Func>(&ExportKeyTests::check_export_key_no_secret_key)));
    5.13  }
    5.14 @@ -82,7 +82,7 @@
    5.15      
    5.16      bool has_private = false;
    5.17      contains_priv_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39", &has_private);
    5.18 -    TEST_ASSERT_MSG(has_private, "Secret key not found.")
    5.19 +    TEST_ASSERT_MSG(has_private, "Secret key not found.");
    5.20      
    5.21      status = export_key(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39", 
    5.22                                     &keydata, &keysize);
     6.1 --- a/test/src/util/test_util.cc	Thu Aug 15 12:45:34 2019 +0200
     6.2 +++ b/test/src/util/test_util.cc	Tue Aug 20 09:59:36 2019 +0200
     6.3 @@ -20,6 +20,23 @@
     6.4  
     6.5  using namespace std;
     6.6  
     6.7 +std::string _main_test_home_dir;
     6.8 +
     6.9 +std::string get_main_test_home_dir() {
    6.10 +    size_t BUF_MAX_PATHLEN = 4097; 
    6.11 +    char buf[BUF_MAX_PATHLEN];// Linux max path size...
    6.12 +
    6.13 +    if (_main_test_home_dir.empty()) {
    6.14 +        string curr_wd = getcwd(buf, BUF_MAX_PATHLEN);
    6.15 +    
    6.16 +        if (curr_wd.empty())
    6.17 +            throw std::runtime_error("Error grabbing current working directory"); 
    6.18 +
    6.19 +        _main_test_home_dir = curr_wd + "/pEp_test_home";
    6.20 +    }
    6.21 +    return _main_test_home_dir;        
    6.22 +}
    6.23 +
    6.24  PEP_STATUS read_file_and_import_key(PEP_SESSION session, const char* fname) {
    6.25      const std::string key = slurp(fname);
    6.26      PEP_STATUS status = (key.empty() ? PEP_KEY_NOT_FOUND : PEP_STATUS_OK);