Browse Source

Small test fixes and changes - now with error summary at end so you can find those pesky tests and their errors

doc_update_sequoia
Krista Bennett 3 years ago
parent
commit
6fbddd2ab3
4 changed files with 31 additions and 20 deletions
  1. +3
    -0
      test/Makefile
  2. +2
    -1
      test/include/pEpTestOutput.h
  3. +8
    -18
      test/src/engine_tests/ReencryptPlusExtraKeysTests.cc
  4. +18
    -1
      test/src/pEpTestOutput.cc

+ 3
- 0
test/Makefile View File

@ -34,6 +34,9 @@ endif
ifeq ($(OPENPGP),NETPGP)
LDLIBS+= -lnetpgp
ifeq ($(BUILD_FOR),Linux)
LDLIBS+= -ltre
endif
endif
ifdef SQLITE3_FROM_OS


+ 2
- 1
test/include/pEpTestOutput.h View File

@ -5,6 +5,7 @@
#include <cpptest.h>
#include <vector>
#include <string>
#include <utility>
namespace Test {
class pEpTestOutput : public Output {
@ -37,7 +38,7 @@ namespace Test {
std::string _suite_name;
std::string _test_name;
std::vector<Source> _test_errors;
std::vector<std::pair<std::string,Source>> _all_errors;
};
}
#endif

+ 8
- 18
test/src/engine_tests/ReencryptPlusExtraKeysTests.cc View File

@ -109,11 +109,10 @@ void ReencryptPlusExtraKeysTests::check_reencrypt_plus_extra_keys() {
cout << decrypted_text << endl;
cout << "Status is " << tl_status_string(status) << endl;
TEST_ASSERT_MSG(decrypted_text, "No decrypted test");
TEST_ASSERT_MSG(rating, "No rating. FIXME: what???");
TEST_ASSERT_MSG(decrypted_text != NULL, "No decrypted test");
TEST_ASSERT_MSG((flags & PEP_decrypt_flag_src_modified) == 0, "Source was modified, but shouldn't have been.");
TEST_ASSERT_MSG(!modified_src, "Modified source was returned, but should not have been generated");
TEST_ASSERT_MSG(modified_src == NULL, "Modified source was returned, but should not have been generated");
//cout << modified_src << endl;
free(decrypted_text);
@ -143,8 +142,7 @@ void ReencryptPlusExtraKeysTests::check_reencrypt_plus_extra_keys() {
cout << "Status is " << tl_status_string(status) << endl;
TEST_ASSERT_MSG(decrypted_text, "No decrypted text");
TEST_ASSERT_MSG(rating, "No rating. FIXME: what???");
TEST_ASSERT_MSG(decrypted_text != NULL, "No decrypted text");
TEST_ASSERT_MSG(modified_src != NULL, "No reeencrypted text!");
free(decrypted_text);
@ -228,15 +226,9 @@ void ReencryptPlusExtraKeysTests::check_reencrypt_plus_extra_keys() {
cout << (decrypted_text ? decrypted_text : "No decrypted text") << endl;
cout << "Status is " << tl_status_string(status) << endl;
cout << "1";
TEST_ASSERT_MSG(decrypted_text != NULL, "No decrypted test");
cout << "2";
TEST_ASSERT_MSG(rating, "No rating. FIXME: what???");
cout << "3";
TEST_ASSERT_MSG((flags & PEP_decrypt_flag_src_modified) == 0, "Source was modified, but shouldn't have been.");
cout << "4";
TEST_ASSERT_MSG(!modified_src, "Modified source was returned, but should not have been generated");
cout << "5";
TEST_ASSERT_MSG(modified_src == NULL, "Modified source was returned, but should not have been generated");
free(decrypted_text);
decrypted_text = nullptr;
@ -265,7 +257,7 @@ void ReencryptPlusExtraKeysTests::check_reencrypt_plus_extra_keys() {
cout << "Status is " << tl_status_string(status) << endl;
TEST_ASSERT_MSG(decrypted_text != NULL, "No decrypted test");
TEST_ASSERT_MSG(rating, "No rating. FIXME: what???");
TEST_ASSERT_MSG(modified_src != NULL, "No reeencrypted text!");
free(decrypted_text);
decrypted_text = nullptr;
@ -351,10 +343,9 @@ void ReencryptPlusExtraKeysTests::check_reencrypt_plus_extra_keys() {
cout << decrypted_text << endl;
cout << "Status is " << tl_status_string(status) << endl;
TEST_ASSERT_MSG(decrypted_text, "No decrypted test");
TEST_ASSERT_MSG(rating, "No rating. FIXME: what???");
TEST_ASSERT_MSG(decrypted_text != NULL, "No decrypted test");
TEST_ASSERT_MSG((flags & PEP_decrypt_flag_src_modified) == 0, "Source was modified, but shouldn't have been.");
TEST_ASSERT_MSG(!modified_src, "Modified source was returned, but should not have been generated");
TEST_ASSERT_MSG(modified_src == NULL, "Modified source was returned, but should not have been generated");
free(decrypted_text);
decrypted_text = nullptr;
@ -382,8 +373,7 @@ void ReencryptPlusExtraKeysTests::check_reencrypt_plus_extra_keys() {
cout << decrypted_text << endl;
cout << "Status is " << tl_status_string(status) << endl;
TEST_ASSERT_MSG(decrypted_text, "No decrypted test");
TEST_ASSERT_MSG(rating, "No rating. FIXME: what???");
TEST_ASSERT_MSG(decrypted_text != NULL, "No decrypted test");
free(decrypted_text);
decrypted_text = nullptr;


+ 18
- 1
test/src/pEpTestOutput.cc View File

@ -4,6 +4,7 @@
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include "pEpTestOutput.h"
using namespace std;
@ -36,6 +37,18 @@ namespace Test {
int remlen = 56 - finalstr.size();
cout << left << setw(finalstr.size()) << finalstr << right << setw(remlen) << "+" << endl;
cout << alt_sepline << endl;
cout << med_sepline;
cout << "Error recap:" << endl;
vector<std::pair<string,Source>>::iterator it;
for (it = _all_errors.begin(); it != _all_errors.end(); it++) {
std::pair<string,Source> err = *it;
cout << lil_sepline;
cout << left << setw(10) << "Test name: " << err.first << endl;
Source src = err.second;
cout << left << setw(25) << "*** Assert location: " << src.file() << ":" << src.line() << endl;
cout << left << setw(25) << "*** Message: " << src.message() << endl;
}
cout << med_sepline << endl << endl;
}
void pEpTestOutput::suite_start(int tests, const string& name) {
@ -72,6 +85,7 @@ namespace Test {
}
void pEpTestOutput::test_end(const string& name, bool ok, const Test::Time&) {
if (!ok) {
std::pair<string,Source> test_error_set;
_suite_failed++;
_total_failed++;
cout << endl << endl << alt_sepline;
@ -81,7 +95,10 @@ namespace Test {
Source src = *it;
cout << lil_sepline;
cout << left << setw(25) << "*** Assert location: " << src.file() << ":" << src.line() << endl;
cout << left << setw(25) << "*** Message: " << src.message() << endl;
cout << left << setw(25) << "*** Message: " << src.message() << endl;
test_error_set.first = name;
test_error_set.second = src;
_all_errors.push_back(test_error_set);
}
cout << alt_sepline << endl;
}


Loading…
Cancel
Save