Small test fixes and changes - now with error summary at end so you can find those pesky tests and their errors
authorKrista Bennett <krista@pep-project.org>
Thu, 29 Nov 2018 09:01:36 +0100
changeset 31645c4b1bd2c638
parent 3163 9aa2a7e453c8
child 3165 0d3e23fbdaec
Small test fixes and changes - now with error summary at end so you can find those pesky tests and their errors
test/Makefile
test/include/pEpTestOutput.h
test/src/engine_tests/ReencryptPlusExtraKeysTests.cc
test/src/pEpTestOutput.cc
     1.1 --- a/test/Makefile	Wed Nov 28 15:18:49 2018 +0100
     1.2 +++ b/test/Makefile	Thu Nov 29 09:01:36 2018 +0100
     1.3 @@ -34,6 +34,9 @@
     1.4  
     1.5  ifeq ($(OPENPGP),NETPGP)
     1.6  	LDLIBS+= -lnetpgp
     1.7 +ifeq ($(BUILD_FOR),Linux)
     1.8 +	LDLIBS+= -ltre
     1.9 +endif
    1.10  endif
    1.11  
    1.12  ifdef SQLITE3_FROM_OS
     2.1 --- a/test/include/pEpTestOutput.h	Wed Nov 28 15:18:49 2018 +0100
     2.2 +++ b/test/include/pEpTestOutput.h	Thu Nov 29 09:01:36 2018 +0100
     2.3 @@ -5,6 +5,7 @@
     2.4  #include <cpptest.h>
     2.5  #include <vector>
     2.6  #include <string>
     2.7 +#include <utility>
     2.8  
     2.9  namespace Test {
    2.10      class pEpTestOutput : public Output {
    2.11 @@ -37,7 +38,7 @@
    2.12              std::string _suite_name;
    2.13              std::string _test_name;
    2.14              std::vector<Source> _test_errors;
    2.15 -            
    2.16 +            std::vector<std::pair<std::string,Source>> _all_errors;            
    2.17      };
    2.18  }
    2.19  #endif
    2.20 \ No newline at end of file
     3.1 --- a/test/src/engine_tests/ReencryptPlusExtraKeysTests.cc	Wed Nov 28 15:18:49 2018 +0100
     3.2 +++ b/test/src/engine_tests/ReencryptPlusExtraKeysTests.cc	Thu Nov 29 09:01:36 2018 +0100
     3.3 @@ -109,11 +109,10 @@
     3.4      cout << decrypted_text << endl;
     3.5  
     3.6      cout << "Status is " << tl_status_string(status) << endl;
     3.7 -    TEST_ASSERT_MSG(decrypted_text, "No decrypted test");
     3.8 -    TEST_ASSERT_MSG(rating, "No rating. FIXME: what???");
     3.9 +    TEST_ASSERT_MSG(decrypted_text != NULL, "No decrypted test");
    3.10      TEST_ASSERT_MSG((flags & PEP_decrypt_flag_src_modified) == 0, "Source was modified, but shouldn't have been.");
    3.11      
    3.12 -    TEST_ASSERT_MSG(!modified_src, "Modified source was returned, but should not have been generated");
    3.13 +    TEST_ASSERT_MSG(modified_src == NULL, "Modified source was returned, but should not have been generated");
    3.14      //cout << modified_src << endl;
    3.15      
    3.16      free(decrypted_text);
    3.17 @@ -143,8 +142,7 @@
    3.18      cout << "Status is " << tl_status_string(status) << endl;
    3.19  
    3.20  
    3.21 -    TEST_ASSERT_MSG(decrypted_text, "No decrypted text");
    3.22 -    TEST_ASSERT_MSG(rating, "No rating. FIXME: what???");
    3.23 +    TEST_ASSERT_MSG(decrypted_text != NULL, "No decrypted text");
    3.24      TEST_ASSERT_MSG(modified_src != NULL, "No reeencrypted text!");
    3.25      
    3.26      free(decrypted_text);
    3.27 @@ -228,15 +226,9 @@
    3.28      cout << (decrypted_text ? decrypted_text : "No decrypted text") << endl;
    3.29      cout << "Status is " << tl_status_string(status) << endl;
    3.30  
    3.31 -    cout << "1";
    3.32      TEST_ASSERT_MSG(decrypted_text != NULL, "No decrypted test");
    3.33 -    cout << "2";
    3.34 -    TEST_ASSERT_MSG(rating, "No rating. FIXME: what???");
    3.35 -    cout << "3";
    3.36      TEST_ASSERT_MSG((flags & PEP_decrypt_flag_src_modified) == 0, "Source was modified, but shouldn't have been.");
    3.37 -    cout << "4";    
    3.38 -    TEST_ASSERT_MSG(!modified_src, "Modified source was returned, but should not have been generated");
    3.39 -    cout << "5";
    3.40 +    TEST_ASSERT_MSG(modified_src == NULL, "Modified source was returned, but should not have been generated");
    3.41  
    3.42      free(decrypted_text);
    3.43      decrypted_text = nullptr;
    3.44 @@ -265,7 +257,7 @@
    3.45      cout << "Status is " << tl_status_string(status) << endl;
    3.46  
    3.47      TEST_ASSERT_MSG(decrypted_text != NULL, "No decrypted test");
    3.48 -    TEST_ASSERT_MSG(rating, "No rating. FIXME: what???");
    3.49 +    TEST_ASSERT_MSG(modified_src != NULL, "No reeencrypted text!");
    3.50  
    3.51      free(decrypted_text);
    3.52      decrypted_text = nullptr;
    3.53 @@ -351,10 +343,9 @@
    3.54      cout << decrypted_text << endl;
    3.55      cout << "Status is " << tl_status_string(status) << endl;
    3.56  
    3.57 -    TEST_ASSERT_MSG(decrypted_text, "No decrypted test");
    3.58 -    TEST_ASSERT_MSG(rating, "No rating. FIXME: what???");
    3.59 +    TEST_ASSERT_MSG(decrypted_text != NULL, "No decrypted test");
    3.60      TEST_ASSERT_MSG((flags & PEP_decrypt_flag_src_modified) == 0, "Source was modified, but shouldn't have been.");    
    3.61 -    TEST_ASSERT_MSG(!modified_src, "Modified source was returned, but should not have been generated");
    3.62 +    TEST_ASSERT_MSG(modified_src == NULL, "Modified source was returned, but should not have been generated");
    3.63  
    3.64      free(decrypted_text);
    3.65      decrypted_text = nullptr;
    3.66 @@ -382,8 +373,7 @@
    3.67      cout << decrypted_text << endl;
    3.68      cout << "Status is " << tl_status_string(status) << endl;
    3.69  
    3.70 -    TEST_ASSERT_MSG(decrypted_text, "No decrypted test");
    3.71 -    TEST_ASSERT_MSG(rating, "No rating. FIXME: what???");
    3.72 +    TEST_ASSERT_MSG(decrypted_text != NULL, "No decrypted test");
    3.73  
    3.74      free(decrypted_text);
    3.75      decrypted_text = nullptr;
     4.1 --- a/test/src/pEpTestOutput.cc	Wed Nov 28 15:18:49 2018 +0100
     4.2 +++ b/test/src/pEpTestOutput.cc	Thu Nov 29 09:01:36 2018 +0100
     4.3 @@ -4,6 +4,7 @@
     4.4  #include <vector>
     4.5  #include <string>
     4.6  #include <cstring>
     4.7 +#include <utility>
     4.8  
     4.9  #include "pEpTestOutput.h"
    4.10  using namespace std;
    4.11 @@ -36,6 +37,18 @@
    4.12          int remlen = 56 - finalstr.size();
    4.13          cout << left << setw(finalstr.size()) << finalstr << right << setw(remlen) << "+" << endl;
    4.14          cout << alt_sepline << endl;
    4.15 +        cout << med_sepline;        
    4.16 +        cout << "Error recap:" << endl;
    4.17 +        vector<std::pair<string,Source>>::iterator it;
    4.18 +        for (it = _all_errors.begin(); it != _all_errors.end(); it++) {
    4.19 +            std::pair<string,Source> err = *it;
    4.20 +            cout << lil_sepline;
    4.21 +            cout << left << setw(10) << "Test name: " << err.first << endl;
    4.22 +            Source src = err.second;
    4.23 +            cout << left << setw(25) << "*** Assert location: " << src.file() << ":" << src.line() << endl;
    4.24 +            cout << left << setw(25) << "*** Message: " << src.message() << endl;
    4.25 +        }
    4.26 +        cout << med_sepline << endl << endl;        
    4.27  	}
    4.28  	
    4.29  	void pEpTestOutput::suite_start(int tests, const string& name) {
    4.30 @@ -72,6 +85,7 @@
    4.31      }
    4.32      void pEpTestOutput::test_end(const string& name, bool ok, const Test::Time&) {
    4.33  	    if (!ok) {
    4.34 +            std::pair<string,Source> test_error_set;
    4.35              _suite_failed++;
    4.36              _total_failed++;
    4.37              cout << endl << endl << alt_sepline;
    4.38 @@ -81,7 +95,10 @@
    4.39                  Source src = *it;
    4.40                  cout << lil_sepline;
    4.41                  cout << left << setw(25) << "*** Assert location: " << src.file() << ":" << src.line() << endl;
    4.42 -                cout << left << setw(25) << "*** Message: " << src.message() << endl;                
    4.43 +                cout << left << setw(25) << "*** Message: " << src.message() << endl;
    4.44 +                test_error_set.first = name;
    4.45 +                test_error_set.second = src;
    4.46 +                _all_errors.push_back(test_error_set);                
    4.47              }
    4.48              cout << alt_sepline << endl;
    4.49          }