From e9018f80b81250fd111f97bc283016854d6e0917 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 24 Jun 2012 13:16:33 +0000 Subject: [PATCH] fixed test programs for openpgp git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-OpenPGP@5253 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/tests/pgp/Makefile | 29 +++++++++++++++++++ .../src/tests/pgp/test_pgp_handler.cc | 10 ++++--- .../tests/pgp/test_pgp_signature_parsing.cc | 13 +++++---- .../src/tests/scripts/config-linux.mk | 2 +- 4 files changed, 43 insertions(+), 11 deletions(-) create mode 100644 libretroshare/src/tests/pgp/Makefile diff --git a/libretroshare/src/tests/pgp/Makefile b/libretroshare/src/tests/pgp/Makefile new file mode 100644 index 000000000..e1e4643ff --- /dev/null +++ b/libretroshare/src/tests/pgp/Makefile @@ -0,0 +1,29 @@ + +RS_TOP_DIR = ../.. +DHT_TOP_DIR = ../../../../libbitdht/src +OPENPGP_INCLUDE_DIR = ../../../../openpgpsdk/include + +##### Define any flags that are needed for this section ####### +############################################################### + +############################################################### +include $(RS_TOP_DIR)/tests/scripts/config.mk +############################################################### + +TESTOBJ = test_pgp_handler.o test_pgp_signature_parsing.o +TESTS = test_pgp_handler test_pgp_signature_parsing + +#rsbaseitem_test + +all: tests + +test_pgp_handler : test_pgp_handler.o + $(CC) $(CFLAGS) -o test_pgp_handler test_pgp_handler.o $(OBJ) $(LIBS) -L../../../../openpgpsdk/lib/ -lops -lbz2 + +test_pgp_signature_parsing : test_pgp_signature_parsing.o + $(CC) $(CFLAGS) -o test_pgp_signature_parsing test_pgp_signature_parsing.o $(OBJ) $(LIBS) -L../../../../openpgpsdk/lib/ -lops -lbz2 + +############################################################### +include $(RS_TOP_DIR)/scripts/rules.mk +############################################################### + diff --git a/libretroshare/src/tests/pgp/test_pgp_handler.cc b/libretroshare/src/tests/pgp/test_pgp_handler.cc index 212dab512..96a4037c8 100644 --- a/libretroshare/src/tests/pgp/test_pgp_handler.cc +++ b/libretroshare/src/tests/pgp/test_pgp_handler.cc @@ -2,7 +2,7 @@ // #include #include -#include "pgphandler.h" +#include static std::string passphrase_callback(void *data,const char *uid_info,const char *what,int prev_was_bad) { @@ -39,12 +39,14 @@ int main(int argc,char *argv[]) static const std::string pubring = "pubring.gpg" ; static const std::string secring = "secring.gpg" ; + static const std::string trustdb = "trustdb.gpg" ; + static const std::string lockfile = "lock" ; PGPHandler::setPassphraseCallback(&passphrase_callback) ; - PGPHandler pgph(pubring,secring) ; + PGPHandler pgph(pubring,secring,trustdb,lockfile) ; - std::cerr << "Writing public keyring to file tmp_keyring.asc" << std::endl; - pgph.writePublicKeyring("tmp_keyring.asc") ; +// std::cerr << "Writing public keyring to file tmp_keyring.asc" << std::endl; +// pgph.writePublicKeyring("tmp_keyring.asc") ; pgph.printKeys() ; diff --git a/libretroshare/src/tests/pgp/test_pgp_signature_parsing.cc b/libretroshare/src/tests/pgp/test_pgp_signature_parsing.cc index c47b7fa37..cb0e236d2 100644 --- a/libretroshare/src/tests/pgp/test_pgp_signature_parsing.cc +++ b/libretroshare/src/tests/pgp/test_pgp_signature_parsing.cc @@ -2,7 +2,7 @@ // #include #include -#include "pgphandler.h" +#include static std::string passphrase_callback(void *data,const char *uid_info,const char *what,int prev_was_bad) { @@ -28,20 +28,21 @@ int main(int argc,char *argv[]) { // test pgp ids. // - PGPIdType id = PGPIdType::fromUserId_hex("3e5b22140ef56abb") ; + PGPIdType id("3e5b22140ef56abb") ; - std::cerr << "Id is : " << std::hex << id.toUInt64() << std::endl; std::cerr << "Id st : " << id.toStdString() << std::endl; // test PGPHandler // // 0 - init - static const std::string pubring = "globo.gpg" ; - static const std::string secring = "globo.gpg" ; + static const std::string pubring = "pubring.gpg" ; + static const std::string secring = "secring.gpg" ; + static const std::string trustdb = "trustdb.gpg" ; + static const std::string lockfil = "lock" ; PGPHandler::setPassphraseCallback(&passphrase_callback) ; - PGPHandler pgph(pubring,secring) ; + PGPHandler pgph(pubring,secring,trustdb,lockfil) ; pgph.printKeys() ; } diff --git a/libretroshare/src/tests/scripts/config-linux.mk b/libretroshare/src/tests/scripts/config-linux.mk index 3f7a297da..4d6b85893 100644 --- a/libretroshare/src/tests/scripts/config-linux.mk +++ b/libretroshare/src/tests/scripts/config-linux.mk @@ -25,7 +25,7 @@ BITDIR = $(DHT_TOP_DIR)/lib LIBRS = $(LIBDIR)/libretroshare.a BITDHT = $(BITDIR)/libbitdht.a # Unix: Linux/Cygwin -INCLUDE = -I $(RS_TOP_DIR) +INCLUDE = -I $(RS_TOP_DIR) -I$(OPENPGP_INCLUDE_DIR) CFLAGS = -Wall -g $(INCLUDE) #CFLAGS += -fprofile-arcs -ftest-coverage CFLAGS += ${DEFINES}