merged in default ENGINE-9
authorKrista Bennett <krista@pep-project.org>
Mon, 12 Jun 2017 09:30:39 +0200
branchENGINE-9
changeset 18498b7bed853a1f
parent 1843 d56e2234b665
parent 1848 7400c532bb36
child 1870 4334908a5f9f
merged in default
test/encrypt_for_identity_test.cc
     1.1 --- a/.hgignore	Fri Jun 09 14:37:34 2017 +0200
     1.2 +++ b/.hgignore	Mon Jun 12 09:30:39 2017 +0200
     1.3 @@ -47,10 +47,10 @@
     1.4  *.xml
     1.5  *.dot
     1.6  *.svg
     1.7 -.imported
     1.8  gpg-agent.conf
     1.9  gpg.conf
    1.10  pubring.gpg
    1.11  random_seed
    1.12  secring.gpg
    1.13  trustdb.gpg
    1.14 +.pEp_management.db
     2.1 --- a/test/Makefile	Fri Jun 09 14:37:34 2017 +0200
     2.2 +++ b/test/Makefile	Mon Jun 12 09:30:39 2017 +0200
     2.3 @@ -2,10 +2,10 @@
     2.4  # This file is under GNU General Public License 3.0
     2.5  # see LICENSE.txt
     2.6  
     2.7 +HERE := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
     2.8 +
     2.9  include ../Makefile.conf
    2.10  
    2.11 -export GNUPGHOME=.
    2.12 -
    2.13  CC?=g++ -std=gnu++11 -pthread
    2.14  CXX?=g++ -std=gnu++11 -pthread
    2.15  LD?=$(CXX)
    2.16 @@ -34,32 +34,48 @@
    2.17  # don't delete .o files!
    2.18  .PRECIOUS: %.o
    2.19  
    2.20 +unexport GNUPGHOME;
    2.21 +TEST_HOME=$(HERE)/test_home
    2.22 +TEST_HOME_SKEL=$(TEST_HOME)_skel
    2.23 +TEST_GNUPGHOME_SKEL=$(TEST_HOME)_skel/.gnupg
    2.24 +
    2.25 +ifeq ($(shell uname), Darwin)
    2.26 +    LIBPATH = DYLD_LIBRARY_PATH
    2.27 +else
    2.28 +    LIBPATH = LD_LIBRARY_PATH
    2.29 +endif
    2.30 +
    2.31 +TEST_CMD_PFX = $(LIBPATH)=$(HOME)/lib:../src HOME=$(TEST_HOME)
    2.32 +
    2.33 +test_home_skel:
    2.34 +	mkdir -p test_home_skel
    2.35 +	-cat 0x*.asc *_sec.asc | gpg2 --import --homedir $(TEST_GNUPGHOME_SKEL)
    2.36 +
    2.37 +test_home_: test_home_skel
    2.38 +	rm -rf test_home
    2.39 +	cp -a test_home_skel test_home
    2.40 +
    2.41  clean:
    2.42  	rm -f *.o $(TARGET) *.a *~ $(UNIT_TESTS) pep_Dokument_Titel.pdf msg4.asc
    2.43 -	rm -Rf *.dSYM .imported pubring.gpg secring.gpg random_seed *.conf trustdb.gpg
    2.44 +	rm -Rf *.dSYM test_home test_home_skel pubring.gpg secring.gpg random_seed *.conf trustdb.gpg
    2.45  
    2.46 -.imported:
    2.47 -	-cat 0x*.asc *_sec.asc | gpg2 --import
    2.48 -	touch .imported
    2.49 -
    2.50 -test: pEpEngineTest .imported
    2.51 -	LD_LIBRARY_PATH=~/lib:../src ./pEpEngineTest
    2.52 +test: pEpEngineTest test_home_
    2.53 +	$(TEST_CMD_PFX) ./pEpEngineTest
    2.54  
    2.55  %_test : %_test.o test_util.o
    2.56  	 $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)
    2.57  
    2.58 -%_run : %
    2.59 -	LD_LIBRARY_PATH=~/lib:../src ./$<
    2.60 +%_run : % test_home_
    2.61 +	$(TEST_CMD_PFX) ./$<
    2.62  
    2.63 +%_lldb : % test_home_
    2.64 +	$(TEST_CMD_PFX) lldb ./$<
    2.65  
    2.66 -%_lldb : %
    2.67 -	LD_LIBRARY_PATH=~/lib:../src lldb ./$<
    2.68 +%_valgrind : % test_home_
    2.69 +	$(TEST_CMD_PFX) valgrind --leak-check=yes ./$<
    2.70  
    2.71 -%_valgrind : %
    2.72 -	LD_LIBRARY_PATH=~/lib:../src valgrind --leak-check=yes ./$<
    2.73 -
    2.74 -%_gdb : %
    2.75 -	LD_LIBRARY_PATH=~/lib:../src gdb ./$<
    2.76 +%_gdb : % test_home_
    2.77 +	$(TEST_CMD_PFX) gdb ./$<
    2.78  
    2.79  unit_tests: $(UNIT_TESTS) $(UNIT_TESTS_RUN)
    2.80  
     3.1 --- a/test/encrypt_for_identity_test.cc	Fri Jun 09 14:37:34 2017 +0200
     3.2 +++ b/test/encrypt_for_identity_test.cc	Mon Jun 12 09:30:39 2017 +0200
     3.3 @@ -9,6 +9,7 @@
     3.4  #include <assert.h>
     3.5  #include "mime.h"
     3.6  #include "message_api.h"
     3.7 +#include "keymanagement.h"
     3.8  #include "test_util.h"
     3.9  
    3.10  using namespace std;
    3.11 @@ -35,9 +36,13 @@
    3.12      assert(statuspriv == PEP_STATUS_OK);
    3.13  
    3.14      cout << "creating message…\n";
    3.15 -    pEp_identity* alice = new_identity("pep.test.alice@pep-project.org", NULL, PEP_OWN_USERID, "Alice Test");
    3.16 +    pEp_identity* alice = new_identity("pep.test.alice@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97", PEP_OWN_USERID, "Alice Test");
    3.17      pEp_identity* bob = new_identity("pep.test.bob@pep-project.org", NULL, "42", "Bob Test");
    3.18      alice->me = true;
    3.19 +
    3.20 +    PEP_STATUS mystatus = myself(session, alice);
    3.21 +    assert(mystatus == PEP_STATUS_OK);
    3.22 +
    3.23      identity_list* to_list = new_identity_list(bob); // to bob
    3.24      message* outgoing_message = new_message(PEP_dir_outgoing);
    3.25      assert(outgoing_message);
     4.1 --- a/test/least_color_group_test.cc	Fri Jun 09 14:37:34 2017 +0200
     4.2 +++ b/test/least_color_group_test.cc	Mon Jun 12 09:30:39 2017 +0200
     4.3 @@ -43,7 +43,8 @@
     4.4      const string mailtext = slurp(mailfile);
     4.5      cout << "\t All files read successfully." << std::endl;
     4.6  
     4.7 -    pEp_identity * me1 = new_identity("pep.color.test.P@kgrothoff.org", NULL, 
     4.8 +    pEp_identity * me1 = new_identity("pep.color.test.P@kgrothoff.org", 
     4.9 +                                      "7EE6C60C68851954E1797F81EA59715E3EBE215C", 
    4.10                                        PEP_OWN_USERID, "Pep Color Test P (recip)");
    4.11      me1->me = true;
    4.12      PEP_STATUS status = update_identity(session, me1);