Browse Source

src/EngineTestSuite.cc

krista-netpgp-sync
parent
commit
60511faedd
4 changed files with 31 additions and 7 deletions
  1. +2
    -2
      test/Makefile
  2. +8
    -0
      test/RUN_ONCE_AS_SUDO_FOR_TESTS.sh
  3. +8
    -0
      test/src/EngineTestSuite.cc
  4. +13
    -5
      test/src/SuiteMaker.cc

+ 2
- 2
test/Makefile View File

@ -20,7 +20,7 @@ DEPS := $(OBJS:.o=.d)
INC_DIRS := ./include /usr/local/include ../src ../sync ../asn.1
INC_FLAGS := $(addprefix -I,$(INC_DIRS)) $(GPGME_INC) $(CPPUNIT_INC)
LDFLAGS += -L/usr/local/lib
LDFLAGS += -L/usr/local/lib -L/opt/local/lib
CFLAGS += -Wno-deprecated
CXXFLAGS += -Wno-deprecated
@ -34,7 +34,7 @@ ifeq ($(BUILD_FOR),Linux)
endif
ifeq ($(OPENPGP),NETPGP)
LDLIBS+= -lnetpgp
LDLIBS+= -lnetpgp -lcrypto
CFLAGS+= -DUSE_NETPGP
ifeq ($(BUILD_FOR),Linux)
LDLIBS+= -ltre


+ 8
- 0
test/RUN_ONCE_AS_SUDO_FOR_TESTS.sh View File

@ -0,0 +1,8 @@
#!/bin/bash
if [[ $EUID > 0 ]]
then echo "This script must be run with sudo."
exit
fi
mkdir -p /run/user/$(id -u $SUDO_USER)
chown $SUDO_USER /run/user/$(id -u $SUDO_USER)

+ 8
- 0
test/src/EngineTestSuite.cc View File

@ -216,7 +216,12 @@ void EngineTestSuite::set_full_env(const char* gpg_conf_copy_path, const char* g
// cout << "calling init()\n";
PEP_STATUS status = init(&session, cached_messageToSend, cached_inject_sync_event);
#ifndef USE_NETPGP
success = system("gpgconf --create-socketdir");
if (success != 0)
throw std::runtime_error("RESTORE: Error when executing 'gpgconf --create-socketdir'.");
system("gpg-connect-agent /bye"); // Just in case - otherwise, we die on MacOS sometimes. Is this enough??
#endif
assert(status == PEP_STATUS_OK);
assert(session);
@ -234,6 +239,9 @@ void EngineTestSuite::restore_full_env() {
success = system("gpgconf --kill all");
if (success != 0)
throw std::runtime_error("RESTORE: Error when executing 'gpgconf --kill all'.");
success = system("gpgconf --remove-socketdir");
if (success != 0)
throw std::runtime_error("RESTORE: Error when executing 'gpgconf --remove-socketdir'.");
#endif
success = setenv("GNUPGHOME", prev_pgp_home.c_str(), 1);


+ 13
- 5
test/src/SuiteMaker.cc View File

@ -21,7 +21,6 @@
#include "I18nTests.h"
#include "IdentityListTests.h"
#include "PgpBinaryTests.h"
#include "MistrustUndoTests.h"
#include "SubkeyRatingEvalTests.h"
#include "MessageNullFromTests.h"
#include "LeastCommonDenomColorTests.h"
@ -29,8 +28,10 @@
#include "PgpListKeysTests.h"
#include "MessageApiTests.h"
#include "EncryptMissingPrivateKeyTests.h"
#include "NetPGPPlaygroundTests.h"
#include "CaseAndDotAddressTests.h"
#include "UserIDAliasTests.h"
#include "SignOnlyTests.h"
#include "BCCTests.h"
#include "Engine358Tests.h"
#include "BlacklistAcceptNewKeyTests.h"
@ -55,6 +56,7 @@
#include "CrashdumpTests.h"
#include "StringpairListTests.h"
#include "EncryptForIdentityTests.h"
#include "KeyResetMessageTests.h"
#include "TrustManipulationTests.h"
#include "AppleMailTests.h"
@ -69,7 +71,6 @@ const char* SuiteMaker::all_suites[] = {
"I18nTests",
"IdentityListTests",
"PgpBinaryTests",
"MistrustUndoTests",
"SubkeyRatingEvalTests",
"MessageNullFromTests",
"LeastCommonDenomColorTests",
@ -77,8 +78,10 @@ const char* SuiteMaker::all_suites[] = {
"PgpListKeysTests",
"MessageApiTests",
"EncryptMissingPrivateKeyTests",
"NetPGPPlaygroundTests",
"CaseAndDotAddressTests",
"UserIDAliasTests",
"SignOnlyTests",
"BCCTests",
"Engine358Tests",
"BlacklistAcceptNewKeyTests",
@ -103,12 +106,13 @@ const char* SuiteMaker::all_suites[] = {
"CrashdumpTests",
"StringpairListTests",
"EncryptForIdentityTests",
"KeyResetMessageTests",
"TrustManipulationTests",
"AppleMailTests",
};
// This file is generated, so magic constants are ok.
int SuiteMaker::num_suites = 45;
int SuiteMaker::num_suites = 47;
void SuiteMaker::suitemaker_build(const char* test_class_name, const char* test_home, Test::Suite** test_suite) {
if (strcmp(test_class_name, "MimeTests") == 0)
@ -129,8 +133,6 @@ void SuiteMaker::suitemaker_build(const char* test_class_name, const char* test_
*test_suite = new IdentityListTests(test_class_name, test_home);
else if (strcmp(test_class_name, "PgpBinaryTests") == 0)
*test_suite = new PgpBinaryTests(test_class_name, test_home);
else if (strcmp(test_class_name, "MistrustUndoTests") == 0)
*test_suite = new MistrustUndoTests(test_class_name, test_home);
else if (strcmp(test_class_name, "SubkeyRatingEvalTests") == 0)
*test_suite = new SubkeyRatingEvalTests(test_class_name, test_home);
else if (strcmp(test_class_name, "MessageNullFromTests") == 0)
@ -145,10 +147,14 @@ void SuiteMaker::suitemaker_build(const char* test_class_name, const char* test_
*test_suite = new MessageApiTests(test_class_name, test_home);
else if (strcmp(test_class_name, "EncryptMissingPrivateKeyTests") == 0)
*test_suite = new EncryptMissingPrivateKeyTests(test_class_name, test_home);
else if (strcmp(test_class_name, "NetPGPPlaygroundTests") == 0)
*test_suite = new NetPGPPlaygroundTests(test_class_name, test_home);
else if (strcmp(test_class_name, "CaseAndDotAddressTests") == 0)
*test_suite = new CaseAndDotAddressTests(test_class_name, test_home);
else if (strcmp(test_class_name, "UserIDAliasTests") == 0)
*test_suite = new UserIDAliasTests(test_class_name, test_home);
else if (strcmp(test_class_name, "SignOnlyTests") == 0)
*test_suite = new SignOnlyTests(test_class_name, test_home);
else if (strcmp(test_class_name, "BCCTests") == 0)
*test_suite = new BCCTests(test_class_name, test_home);
else if (strcmp(test_class_name, "Engine358Tests") == 0)
@ -197,6 +203,8 @@ void SuiteMaker::suitemaker_build(const char* test_class_name, const char* test_
*test_suite = new StringpairListTests(test_class_name, test_home);
else if (strcmp(test_class_name, "EncryptForIdentityTests") == 0)
*test_suite = new EncryptForIdentityTests(test_class_name, test_home);
else if (strcmp(test_class_name, "KeyResetMessageTests") == 0)
*test_suite = new KeyResetMessageTests(test_class_name, test_home);
else if (strcmp(test_class_name, "TrustManipulationTests") == 0)
*test_suite = new TrustManipulationTests(test_class_name, test_home);
else if (strcmp(test_class_name, "AppleMailTests") == 0)


Loading…
Cancel
Save