Browse Source

throw away tests, new ones are needed

PYADPT-55
Volker Birk 7 years ago
parent
commit
21bd48145b
  1. 2
      src/identity.cc
  2. 11
      src/message.cc
  3. 4
      test/basic_doctest.py
  4. 247
      test/mp_sync_test.py
  5. 537
      test/multipEp.py
  6. BIN
      test/profiling/5k_pubring.gpg
  7. 15
      test/profiling/README
  8. 68
      test/profiling/mp_load_test.py
  9. 29
      test/profiling/profile.d
  10. 603
      test/profiling/results.txt
  11. 50
      test/profiling/trace_analysis.py
  12. 31
      test/sync_test.py

2
src/identity.cc

@ -42,7 +42,7 @@ namespace pEp {
Identity::~Identity()
{
}
}
Identity::operator pEp_identity *()
{

11
src/message.cc

@ -131,6 +131,7 @@ namespace pEp {
{
if (!_msg)
throw bad_alloc();
if (from) {
_msg->from = ::identity_dup(*from);
if (!_msg->from)
@ -147,14 +148,14 @@ namespace pEp {
mimetext.size(), &_cpy);
switch (status) {
case PEP_STATUS_OK:
if (_cpy) {
if (_cpy)
_cpy->dir = PEP_dir_outgoing;
_msg = shared_ptr< message >(_cpy);
return;
}
_cpy = new_message(PEP_dir_outgoing);
else
_cpy = new_message(PEP_dir_outgoing);
if (!_cpy)
throw bad_alloc();
_msg = shared_ptr< message >(_cpy);
break;

4
test/basic_doctest.py

@ -1,7 +1,7 @@
"""
>>> from pEp import *
>>> m = outgoing_message(Identity("vb@dingens.org", "Volker Birk"))
>>> m.to = [Identity("trischa@dingens.org", "Patricia Bednar")]
>>> m = outgoing_message(Identity("vb@dingens.org", "23", "Volker Birk"))
>>> m.to = [Identity("trischa@dingens.org", "42", "Patricia Bednar")]
>>> m.shortmsg = "Hello"
>>> m.longmsg = "Something\\n"
>>> print(str(m).replace('\\r', ''))

247
test/mp_sync_test.py

@ -1,247 +0,0 @@
"""
= Tests for keysync =
See multipEp.py for command line switches.
* Example to launch with latest built pEp Python Adapter (no install):
PYTHONPATH=`pwd`/build/lib.macosx-10.12-x86_64-3.4 \
python3.4 test/mp_sync_test.py
* Example to debug at a particular step in "group_of_3_members"
python3.4 test/mp_sync_test.py only_group_of_3_members debug_GroupA3_3
* Example test with both GPG and NetPGP :
In that example only GroupA1 is using NetPGP, others use GPG
- In pEpEngine :
hg clean --all
make install DEBUG=YES OPENPGP=GPG PREFIX=$HOME/pep_gpg
hg clean --all
make install DEBUG=YES OPENPGP=NETPGP PREFIX=$HOME/pep_netpgp
- In pEpPythonAdapter :
DYLD_LIBRARY_PATH=$HOME/pep_gpg/lib \
PYTHONPATH=`pwd`/build/lib.macosx-10.12-x86_64-3.4 \
python3.4 test/mp_sync_test.py libs_GroupA1=$HOME/pep_netpgp/lib
"""
from multipEp import *
#("instance name", [instance_action_func, [args], {kwargs}], result_func),
#(manager_action_func, [args], {kwargs}, result_func),
def message_to_self():
yield ("GroupA1", [create_account, ["first@group.a", "GroupA First"]])
self_msg = yield ("GroupA1", [encrypted_message, ["first@group.a",
"first@group.a",
"GroupA First to GroupA First -- encrypted",
"GroupA First to GroupA First -- long encrypted"]])
yield ("GroupA1", [decrypt_message, [self_msg]], expect(pEp.PEP_rating.PEP_rating_trusted_and_anonymized))
def pre_existing_peers_with_encrypted_mail():
for action in [
("GroupA1", [create_account, ["first@group.a", "GroupA First"]]),
("SoloA", [create_account, ["first@solo.a", "First SoloA"]]),
(flush_all_mails,),
# key exchange
("SoloA", [send_message, ["first@solo.a",
"first@group.a",
"SoloA First to GroupA First",
"SoloA First to GroupA First -- long"]]),
("GroupA1", [send_message, ["first@group.a",
"first@solo.a",
"GroupA First to SoloA First",
"GroupA First to SoloA First -- long"]])
] : yield action
enc_msg = yield ("SoloA", [encrypted_message, ["first@solo.a",
"first@group.a",
"SoloA First to GroupA First -- encrypted",
"SoloA First to GroupA First -- long encrypted"]])
for action in [
(flush_all_mails,),
("GroupA1", [decrypt_message, [enc_msg]], expect(pEp.PEP_rating.PEP_rating_reliable)),
] : yield action
return enc_msg
def group_on_keygen():
enc_msg = yield from pre_existing_peers_with_encrypted_mail()
for action in [
("GroupA2", [create_account, ["first@group.a", "GroupA First"]]),
(cycle_until_no_change, ["GroupA1", "GroupA2"], expect(3)),
("GroupA2", [decrypt_message, [enc_msg]], expect(pEp.PEP_rating.PEP_rating_reliable))
] : yield action
return enc_msg
def message_to_self_after_sync():
yield from group_on_keygen()
yield (flush_all_mails,)
self_msg = yield ("GroupA2", [encrypted_message, ["first@group.a",
"first@group.a",
"GroupA First to GroupA First -- encrypted",
"GroupA First to GroupA First -- long encrypted"]])
for action in [
("GroupA1", [decrypt_message, [self_msg]], expect(pEp.PEP_rating.PEP_rating_trusted_and_anonymized)),
("GroupA2", [decrypt_message, [self_msg]], expect(pEp.PEP_rating.PEP_rating_trusted_and_anonymized))
] : yield action
self_msg = yield ("GroupA1", [encrypted_message, ["first@group.a",
"first@group.a",
"GroupA First to GroupA First -- encrypted",
"GroupA First to GroupA First -- long encrypted"]])
for action in [
("GroupA1", [decrypt_message, [self_msg]], expect(pEp.PEP_rating.PEP_rating_trusted_and_anonymized)),
("GroupA2", [decrypt_message, [self_msg]], expect(pEp.PEP_rating.PEP_rating_trusted_and_anonymized))
] : yield action
def group_on_cannotdecrypt():
enc_msg = yield from pre_existing_peers_with_encrypted_mail()
for action in [
("GroupA2", [create_account, ["first@group.a", "GroupA First"]]),
(flush_all_mails,),
("GroupA2", [decrypt_message, [enc_msg]], expect(pEp.PEP_rating.PEP_rating_have_no_key)),
(cycle_until_no_change, ["GroupA1", "GroupA2"], expect(3)),
("GroupA2", [decrypt_message, [enc_msg]], expect(pEp.PEP_rating.PEP_rating_reliable)),
] : yield action
def group_gets_losing_key():
yield from group_on_keygen()
# device losing key election is the youngest one, last created, GroupA2
self_msg = yield ("GroupA2", [encrypted_message, ["first@group.a",
"first@group.a",
"GroupA First to GroupA First -- encrypted",
"GroupA First to GroupA First -- long encrypted"]])
for action in [
(flush_all_mails,),
("GroupA1", [decrypt_message, [self_msg]], expect(pEp.PEP_rating.PEP_rating_trusted_and_anonymized)),
] : yield action
def group_of_3_members():
enc_msg = yield from group_on_keygen()
for action in [
("GroupA3", [create_account, ["first@group.a", "GroupA First"]]),
(cycle_until_no_change, ["GroupA1", "GroupA2", "GroupA3"], expect(3)),
("GroupA3", [decrypt_message, [enc_msg]], expect(pEp.PEP_rating.PEP_rating_reliable))
] : yield action
return enc_msg
def new_address_peer_and_mail(identity_flag = None):
for action in [
("SoloB", [create_account, ["first@solo.b", "First SoloB"]]),
("GroupA3", [create_account, ["second@group.a", "GroupA Second", identity_flag]]),
# key exchange
("SoloB", [send_message, ["first@solo.b",
"second@group.a",
"SoloB First to GroupA second",
"SoloB First to GroupA second -- long"]]),
("GroupA3", [send_message, ["second@group.a",
"first@solo.b",
"GroupA second to SoloB First",
"GroupA second to SoloB First"]]),
] : yield action
enc_msg = yield ("SoloB", [encrypted_message, ["first@solo.b",
"second@group.a",
"SoloB First to GroupA Second -- encrypted",
"SoloB First to GroupA Second -- long encrypted"]])
for action in [
("GroupA3", [decrypt_message, [enc_msg]], expect(pEp.PEP_rating.PEP_rating_reliable)),
] : yield action
return enc_msg
def keygen_in_a_group_of_3_members(pre_actions=[]):
yield from group_of_3_members()
enc_msg = yield from new_address_peer_and_mail()
for action in pre_actions + [
(cycle_until_no_change, ["GroupA1", "GroupA2", "GroupA3"], expect(1)),
(flush_all_mails,),
("GroupA1", [create_account, ["second@group.a", "GroupA Second"]]),
(flush_all_mails, expect(0)),
("GroupA2", [create_account, ["second@group.a", "GroupA Second"]]),
(flush_all_mails, expect(0)),
("GroupA2", [decrypt_message, [enc_msg]], expect(pEp.PEP_rating.PEP_rating_reliable)),
("GroupA1", [decrypt_message, [enc_msg]], expect(pEp.PEP_rating.PEP_rating_reliable)),
] : yield action
def group_survives_restart():
yield from keygen_in_a_group_of_3_members([
(restart_instance, ["GroupA1"]),
(restart_instance, ["GroupA2"]),
(restart_instance, ["GroupA3"])
])
def nokey_in_a_group_of_3_members():
yield from group_of_3_members()
enc_msg = yield from new_address_peer_and_mail()
for action in [
(flush_all_mails,),
("GroupA1", [create_account, ["second@group.a", "GroupA Second"]]),
(flush_all_mails,),
("GroupA1", [decrypt_message, [enc_msg]], expect(pEp.PEP_rating.PEP_rating_have_no_key)),
(cycle_until_no_change, ["GroupA1", "GroupA2", "GroupA3"], expect(3)),
("GroupA1", [decrypt_message, [enc_msg]], expect(pEp.PEP_rating.PEP_rating_reliable)),
("GroupA2", [create_account, ["second@group.a", "GroupA Second"]]),
("GroupA2", [decrypt_message, [enc_msg]], expect(pEp.PEP_rating.PEP_rating_reliable)),
] : yield action
def not_for_sync_in_a_group_of_3_members(pre_actions=[]):
yield from group_of_3_members()
enc_msg = yield from new_address_peer_and_mail(pEp.identity_flags.PEP_idf_not_for_sync)
for action in pre_actions + [
(cycle_until_no_change, ["GroupA1", "GroupA2", "GroupA3"], expect(1)),
(flush_all_mails,),
("GroupA1", [create_account, ["second@group.a", "GroupA Second", pEp.identity_flags.PEP_idf_not_for_sync]]),
(flush_all_mails,),
("GroupA2", [create_account, ["second@group.a", "GroupA Second", pEp.identity_flags.PEP_idf_not_for_sync]]),
(flush_all_mails,),
("GroupA2", [decrypt_message, [enc_msg]], expect(pEp.PEP_rating.PEP_rating_have_no_key)),
("GroupA1", [decrypt_message, [enc_msg]], expect(pEp.PEP_rating.PEP_rating_have_no_key)),
] : yield action
def timeout_while_group_on_keygen():
for action in [
(disable_auto_handshake,),
] : yield action
enc_msg = yield from pre_existing_peers_with_encrypted_mail()
for action in [
("GroupA2", [create_account, ["first@group.a", "GroupA First"]]),
(cycle_until_no_change, ["GroupA1", "GroupA2"], expect(3)),
("GroupA1", [simulate_timeout, []]),
("GroupA2", [simulate_timeout, []]),
(flush_all_mails,),
(enable_auto_handshake,),
("GroupA2", [decrypt_message, [enc_msg]], expect(pEp.PEP_rating.PEP_rating_have_no_key)),
(cycle_until_no_change, ["GroupA1", "GroupA2"], expect(3)),
("GroupA2", [decrypt_message, [enc_msg]], expect(pEp.PEP_rating.PEP_rating_reliable))
] : yield action
return enc_msg
if __name__ == "__main__":
run_scenario(message_to_self)
run_scenario(group_on_keygen)
run_scenario(group_on_cannotdecrypt)
run_scenario(group_gets_losing_key)
run_scenario(message_to_self_after_sync)
run_scenario(group_of_3_members)
run_scenario(keygen_in_a_group_of_3_members)
run_scenario(group_survives_restart)
run_scenario(nokey_in_a_group_of_3_members)
run_scenario(not_for_sync_in_a_group_of_3_members)
run_scenario(timeout_while_group_on_keygen)

537
test/multipEp.py

@ -1,537 +0,0 @@
"""
multipEp.py : multiple process python testing framework for pEp
= Command line switches =
wait_for_debug
Block and ask if debugger should be attached each time an instance
is started
debug_${instance_name}
Launch lldb in another terminal, and attach it to given intsance
immediately after instance startup.
debug_${instance_name}_${execution_number}
Launch lldb in another terminal, and attach it to given intsance
when instance is at some particular step in the test.
${execution_number} is found by reading test output.
only_${test_scenario_name}
Execute only given test scenario. Scenario with different name
are skipped.
libs_${instance_name}=/path/to/libs
Set LD_LIBRARY_PATH to given path before launching instance,
meant to allow selection of per-instance pEpEngines flavors
wait_for_cleanup
Block at the end of each test scenario, before deleting temporary
directory. It is meant to be able to examine keyring and DBs after
test finished or crashed.
"""
import os
import sys
import multiprocessing
import importlib
import tempfile
import time
import types
import itertools
from copy import deepcopy
from collections import OrderedDict
# ----------------------------------------------------------------------------
# GLOBALS
# ----------------------------------------------------------------------------
# per-instance globals
sync_handler = None
own_addresses = []
indent = 0
i_name = ""
handshakes_pending = None
pEp = None
# manager globals
instances = None
if(multiprocessing.current_process().name == "MainProcess"):
ctx = multiprocessing.get_context('spawn')
# import pEp in main process to get enums
pEp = importlib.import_module("pEp")
# both side globals (managed by MP)
handshakes_seen = None
test_config = None
msgs_folders = None
# both side globals (not managed)
disable_sync = False
# ----------------------------------------------------------------------------
# INSTANCE ACTIONS
# ----------------------------------------------------------------------------
def create_account(address, name, flags=None):
global own_addresses
i = pEp.Identity(address, name)
if flags is not None:
i.flags = flags
pEp.myself(i)
own_addresses.append(address)
def _send_message(address, msg):
global msgs_folders
# list inside dict from MP manager are not proxified.
msgs = msgs_folders.get(address,[])
msg.sent = int(time.time())
msgs.append(str(msg))
msgs_folders[address] = msgs
def _encrypted_message(from_address, to_address, shortmsg, longmsg):
m = pEp.outgoing_message(pEp.Identity(from_address, from_address))
if type(to_address) != list :
to_address = [to_address]
m.to = [ pEp.Identity(address, address) for address in to_address ]
m.shortmsg = shortmsg
m.longmsg = longmsg
begin = time.time()
ret = m.encrypt()
end = time.time()
printi("ENCRYPTION TIME:", end - begin)
return ret
def encrypted_message(from_address, to_address, shortmsg, longmsg):
return str(_encrypted_message(from_address, to_address, shortmsg, longmsg))
def send_message(from_address, to_address, shortmsg, longmsg):
msg = _encrypted_message(from_address, to_address, shortmsg, longmsg)
if type(to_address) != list :
to_address = [to_address]
for address in to_address:
_send_message(address, msg)
def decrypt_message(msgstr):
msg = pEp.incoming_message(msgstr)
printi("--- decrypt()")
msg.recv = int(time.time())
printmsg(msg)
msg2, keys, rating, consumed, flags = msg.decrypt()
printi("->-", rating, "->-")
printmsg(msg2)
printi("---")
return rating
def simulate_timeout():
global sync_handler
sync_handler.onTimeout()
no_inbox_decrypt = [simulate_timeout, create_account]
# ----------------------------------------------------------------------------
# MANAGER ACTIONS
# ----------------------------------------------------------------------------
def flush_all_mails():
global msgs_folders
count = sum(map(len,msgs_folders.values()))
msgs_folders.clear()
return count
def restart_instance(iname):
tmpdir, instance_addresses = stop_instance(iname)
instances[iname] = start_instance(iname, tmpdir, instance_addresses)
def cycle_until_no_change(*instancelist, maxcycles=20):
count = 0
while True:
global msgs_folders
tmp = deepcopy(dict(msgs_folders))
for iname in instancelist:
action = (iname, [])
run_instance_action(action)
count += 1
if dict(msgs_folders) == tmp:
return count
if count >= maxcycles:
raise Exception("Too many cycles waiting for stability")
def disable_auto_handshake():
global test_config
test_config.disable_handshake = True
def enable_auto_handshake():
global test_config
test_config.disable_handshake = False
def expect(expectation):
def _expect(res, action):
if(expectation != res):
raise Exception("Expected " + str(expectation) + ", got " + str(res))
return _expect
# ----------------------------------------------------------------------------
# "PRETTY" PRINTING
# ----------------------------------------------------------------------------
def printi(*args):
global indent
print(i_name + ">" * indent, *args)
def printheader(blah=None):
global indent
if blah is None:
printi("-" * 80)
indent = indent - 1
else:
indent = indent + 1
printi("-" * (39 - int(len(blah)/2)) +
" " + blah + " " +
"-" * (39 - len(blah) + int(len(blah)/2)))
def printmsg(msg):
printi("from :", repr(msg.from_))
printi("to :", repr(msg.to))
printi("recv :", msg.recv)
printi("sent :", msg.sent)
printi("short :", msg.shortmsg)
printi("opt_fields :", msg.opt_fields)
lng = msg.longmsg.splitlines()
lngcut = lng[:40]+["[...]"] if len(lng)>40 else lng
pfx = "long : "
for l in lngcut :
printi(pfx + l)
pfx = " "
printi("attachments : ", msg.attachments)
# ----------------------------------------------------------------------------
# INSTANCE TEST EXECUTION
# ----------------------------------------------------------------------------
def execute_order(order):
global handshakes_pending, hanshakes_seen
global test_config, msgs_folders, own_addresses, sync_handler
func, args, kwargs, timeoff = order[0:] + [None, [], {}, 0][len(order):]
printheader("DECRYPT messages")
# decrypt every non-consumed message for all instance accounts
if func not in no_inbox_decrypt :
for own_address in own_addresses :
msgs_for_me = msgs_folders.get(own_address, [])
for msgstr in msgs_for_me:
msg = pEp.incoming_message(msgstr)
printi("--- decrypt()")
msg.recv = int(time.time() + timeoff)
printmsg(msg)
msg2, keys, rating, consumed, flags = msg.decrypt()
if consumed == "MESSAGE_CONSUME":
printi("--- PEP_MESSAGE_CONSUMED")
# folder may have changed in the meantime,
# remove item directly from latest version of it.
folder = msgs_folders[own_address]
folder.remove(msgstr)
msgs_folders[own_address] = folder
elif consumed == "MESSAGE_IGNORE":
printi("--- PEP_MESSAGE_DISCARDED")
else :
printi("->-", rating, "->-")
printmsg(msg2)
printi("---")
printheader()
res = None
if func is not None:
printheader("Executing instance function " + func.__name__)
printi("args :", args)
printi("kwargs :", kwargs)
res = func(*args,**kwargs)
printi("function " + func.__name__ + " returned :", res)
printheader()
if handshakes_pending and not test_config.disable_handshake :
printheader("check pending handshakes accepted on other device")
tw, partner, nth_seen = handshakes_pending
if handshakes_seen[tw] >= test_config.handshake_count_to_accept :
if nth_seen in [1, test_config.handshake_count_to_accept]:
# equiv to close dialog
handshakes_pending = None
printi("ACCEPT pending handshake : "+ tw)
sync_handler.deliverHandshakeResult(partner, 0)
# else dialog closed later by OVERTAKEN notification
printheader()
return res
def pEp_instance_run(iname, _own_addresses, conn, _msgs_folders, _handshakes_seen, _test_config):
global pEp, sync_handler, own_addresses, i_name, msgs_folders
global handshakes_pending
global handshakes_seen, test_config
# assign instance globals
own_addresses = _own_addresses
msgs_folders = _msgs_folders
handshakes_seen = _handshakes_seen
test_config = _test_config
i_name = iname
pEp = importlib.import_module("pEp")
class Handler(pEp.SyncMixIn):
def messageToSend(self, msg):
printheader("SYNC MESSAGE to send")
printmsg(msg)
printheader()
for rcpt in msg.to + msg.cc + msg.bcc:
_send_message(rcpt.address, msg)
def notifyHandshake(self, me, partner, signal):
global handshakes_pending
if test_config.disable_handshake :
printheader("HANDSHAKE disabled. Notification ignored")
printi(signal)
printheader()
return
if signal in [
pEp.sync_handshake_signal.SYNC_NOTIFY_INIT_ADD_OUR_DEVICE,
pEp.sync_handshake_signal.SYNC_NOTIFY_INIT_ADD_OTHER_DEVICE,
pEp.sync_handshake_signal.SYNC_NOTIFY_INIT_FORM_GROUP,
pEp.sync_handshake_signal.SYNC_NOTIFY_INIT_MOVE_OUR_DEVICE]:
printheader("show HANDSHAKE dialog")
printi(signal)
printi("handshake needed between " + repr(me) + " and " + repr(partner))
tw = pEp.trustwords(me, partner, 'en', True)
printi(tw)
# This is an error from pEpEngine if asked to open handshake dialog twice
if handshakes_pending:
raise Exception("Asked to open a second Sync Handshake Dialog !")
if tw in handshakes_seen :
handshakes_seen[tw] += 1
else:
handshakes_seen[tw] = 1
handshakes_pending = (tw,partner,handshakes_seen[tw])
printheader()
elif signal == pEp.sync_handshake_signal.SYNC_NOTIFY_OVERTAKEN:
if handshakes_pending:
tw, partner, nth_seen = handshakes_pending
printi("OVERTAKEN handshake : "+ tw)
handshakes_pending = None
else:
raise Exception("Asked to close a non existing Sync Handshake Dialog !")
else :
printheader("other HANDSHAKE notification - ignored")
printi(signal)
printheader()
def setTimeout(self, timeout):
printi("SET TIMEOUT :", timeout)
def cancelTimeout(self):
printi("CANCEL TIMEOUT")
return 42
if not disable_sync:
sync_handler = Handler()
while True:
order = conn.recv()
if order is None:
break
res = execute_order(order)
conn.send(res)
conn.send(own_addresses)
msgs_folders = None
def pEp_instance_main(iname, tmpdirname, *args):
# run with a dispensable $HOME to get fresh DB and PGP keyrings
print("Instance " + iname + " runs into " + tmpdirname)
os.environ['HOME'] = tmpdirname
pEp_instance_run(iname, *args)
print(iname + " exiting")
# ----------------------------------------------------------------------------
# MANAGER TEST EXECUTION
# ----------------------------------------------------------------------------
def start_debug(iname, proc):
print("#"*80 + "\n" +
"INSTANCE " + iname + "\n" +
"launching debugger attaching to process " +
str(proc.pid) + "\n" +
"#"*80 + "\n")
# TODO : linux terminal support
#import subprocess
#subprocess.call(['xterm', '-e', 'lldb', '-p', str(proc.pid)])
import appscript
appscript.app('Terminal').do_script('lldb -p ' + str(proc.pid))
time.sleep(2)
def start_instance(iname, tmpdir=None, instance_addresses = []):
global handshakes_seen, test_config, msgs_folders
given_libs = None
for a in sys.argv:
if a.startswith("libs_"+iname+"="):
given_libs = a.split("=")[1]
break
if tmpdir is None:
tmpdir = tempfile.TemporaryDirectory()
if given_libs is not None:
os.symlink(given_libs, os.path.join(tmpdir.name, "libs"))
if sys.platform.startswith('darwin'):
ld_env_name = 'DYLD_LIBRARY_PATH'
else:
ld_env_name = 'LD_LIBRARY_PATH'
orig_ld_env_val = None
if given_libs is not None:
orig_ld_env_val = os.environ.pop(ld_env_name, None)
os.environ[ld_env_name] = os.path.join(tmpdir.name, "libs")
conn, child_conn = ctx.Pipe()
proc = ctx.Process(
target=pEp_instance_main,
args=(iname, tmpdir.name, instance_addresses,
child_conn, msgs_folders,
handshakes_seen, test_config))
proc.start()
if orig_ld_env_val is not None:
os.environ[ld_env_name] = orig_ld_env_val
elif given_libs is not None:
os.environ.pop(ld_env_name)
debug = False
if "debug_"+iname in sys.argv :
debug = True
if not debug and "wait_for_debug" in sys.argv :
yes = input("#"*80 + "\n" +
"INSTANCE " + iname + "\n" +
"Enter y/yes/Y/YES to attach debugger to process " +
str(proc.pid) + "\nor just press ENTER\n" +
"#"*80 + "\n")
if yes in ["y", "Y", "yes" "YES"]:
debug = True
if debug :
start_debug(iname, proc)
return (proc, conn, tmpdir, 0)
def get_instance(iname):
global instances
if iname not in instances:
res = start_instance(iname)
instances[iname] = res
return res
else:
return instances[iname]
def stop_instance(iname):
proc, conn, tmpdir, execnt = instances.pop(iname)
# tell process to terminate
conn.send(None)
instance_addresses = conn.recv()
proc.join()
return tmpdir, instance_addresses
def purge_instances():
global instances
for iname in list(instances.keys()):
stop_instance(iname)
def run_instance_action(action):
iname, order = action
proc, conn, tmpdir, execnt = get_instance(iname)
execnt = execnt + 1
instances[iname] = (proc, conn, tmpdir, execnt)
debug_here_arg = "debug_"+iname+"_"+str(execnt)
print(iname, ": execution number :", execnt , "(add", debug_here_arg, "to args to debug from here)")
if debug_here_arg in sys.argv :
start_debug(iname, proc)
conn.send(order)
return conn.recv()
def run_manager_action(action):
func, args, kwargs = action[0:] + (None, [], {})[len(action):]
print("------------------------- Executing manager function -----------------------------")
print("function name :", func.__name__)
print("args :", args)
print("kwargs :", kwargs)
res = func(*args, **kwargs)
print("manager function " + func.__name__ + " returned :", res)
print("-" * 80)
return res
def run_scenario(scenario):
global pEp
for a in sys.argv:
if a.startswith("only_") and a != "only_" + scenario.__name__ :
print("IGNORING: " + scenario.__name__)
return
print("RUNNING: " + scenario.__name__)
global handshakes_seen, test_config, msgs_folders, instances
instances = OrderedDict()
with ctx.Manager() as manager:
msgs_folders = manager.dict()
handshakes_seen = manager.dict()
test_config = manager.Namespace(
disable_handshake=False,
handshake_count_to_accept=2)
sc = scenario()
t = None
try:
action = next(sc)
while True:
res = None
output = None
if len(action) > 1 and type(action[-1]) == types.FunctionType:
output = action[-1]
action = action[:-1]
if type(action[0]) == str:
res = run_instance_action(action)
else:
res = run_manager_action(action)
if output is not None:
output(res, action)
action = sc.send(res)
except StopIteration:
pass
except :
t,v,tv = sys.exc_info()
import traceback
print("EXCEPTION IN: " + scenario.__name__)
traceback.print_exc()
if "wait_for_cleanup" in sys.argv:
for iname,(proc, conn, tmpdir, execnt) in instances.items():
print("Instance " + iname + " waits into " + tmpdir.name)
input("#"*80 + "\n" +
"Press ENTER to cleanup\n" +
"#"*80 + "\n")
purge_instances()
if t:
raise t(v).with_traceback(tv)

BIN
test/profiling/5k_pubring.gpg

Binary file not shown.

15
test/profiling/README

@ -1,15 +0,0 @@
Tool to profile pEpEngine with dtrace.
To profile :
LC_ALL=en_US.UTF-8 PYTHONPATH=`pwd`/build/lib.macosx-10.11-x86_64-3.4:`pwd`/test python3.4 mp_load_test.py wait_for_debug
wait for Alice instance to respawn after loading 5k keyring, and pass PID to dtrace script
$ sudo dtrace -s profile.d 12345 > log.dtrace
dtrace script does no processing, but just stores event, otherwise it is too slow and drops some events. Events are the analysed with a python script :
$ cat log.dtrace | python3.4 trace_analysis.py > results.txt

68
test/profiling/mp_load_test.py

@ -1,68 +0,0 @@
"""
load tests
Launch it with something like :
LC_ALL=en_US.UTF-8 \
DYLD_LIBRARY_PATH=/Users/ed/lib/ \
PYTHONPATH=`pwd`/../build/lib.macosx-10.11-x86_64-3.4 \
python3.4 mp_load_test.py
"""
import multipEp
from multipEp import *
from os import system, path, environ
from shutil import copyfile
curpath = path.dirname(path.abspath(__file__))
#("instance name", [instance_action_func, [args], {kwargs}], result_func),
#(manager_action_func, [args], {kwargs}, result_func),
multipEp.disable_sync = True
def import_5k_keys():
copyfile(path.join(curpath, "5k_pubring.gpg"),
path.join(environ["HOME"], ".gnupg", "pubring.gpg") )
def handshake_with_heavy_ring():
for action in [
("Alice", [import_5k_keys]),
#("Bob", [import_5k_keys]),
(restart_instance, ["Alice"]),
#(restart_instance, ["Bob"]),
("Alice", [create_account, ["mail@alice.a", "Alice mail"]]),
("Bob", [create_account, ["mail@bob.a", "mail Bob"]]),
(flush_all_mails,),
# key exchange
("Bob", [send_message, ["mail@bob.a",
"mail@alice.a",
"Bob mail to Alice mail",
"Bob mail to Alice mail -- long"]]),
("Alice", [send_message, ["mail@alice.a",
["mail@bob.a",
"test1@peptest.ch",
"test2@peptest.ch",
"test3@peptest.ch",
"test4@peptest.ch",
"test5@peptest.ch",
"test6@peptest.ch",
"test7@peptest.ch",
"test8@peptest.ch",
"test9@peptest.ch",
"test10@peptest.ch"
],
"Alice mail to Bob mail",
"Alice mail to Bob mail -- long"]])
] : yield action
# enc_msg = yield ("Bob", [encrypted_message, ["mail@bob.a",
#  "mail@alice.a",
#  "Bob mail to Alice mail -- encrypted",
#  "Bob mail to Alice mail -- long encrypted"]])
# for action in [
#  ("Alice", [decrypt_message, [enc_msg]], expect(pEp.PEP_rating.PEP_rating_reliable))
# ] : yield action
if __name__ == "__main__":
run_scenario(handshake_with_heavy_ring)

29
test/profiling/profile.d

@ -1,29 +0,0 @@
self int rec;
self uint64_t st;
pid$1:libpEpEngine:encrypt_message:entry
{
self->rec = 1;
self->st = timestamp;
}
pid$1:libpEpEngine:encrypt_message:return
{
self->rec = 0;
printf("%d", timestamp - self->st);
}
pid$1:libgpgme::entry,
pid$1:libpEpEngine::entry
/self->rec == 1/
{
printf("%d", timestamp - self->st);
}
pid$1:libgpgme::return,
pid$1:libpEpEngine::return
/self->rec == 1/
{
printf("%d", timestamp - self->st);
}

603
test/profiling/results.txt

@ -1,603 +0,0 @@
gpgme_key_release 1   0.00 0.00
_rating 1   0.00 0.00
computeJD 1   0.00 0.00
unixCurrentTimeInt64 1   0.00 0.00
sqlite3_value_type 1   0.00 0.00
computeYMD 1   0.00 0.00
sqlite3PagerGetData 1   0.00 0.00
stringlist_append 1   0.00 0.00
decodeFlags 1   0.00 0.00
sqlite3AtoF 1   0.00 0.00
sqlite3HeapNearlyFull 1   0.00 0.00
new_stringpair_list 1   0.00 0.00
sqlite3StrICmp 1   0.00 0.00
free_stringpair_list 1   0.00 0.00
parse_sec_field15 2   0.00 0.00
_gpgme_wait_one 2   0.00 0.00
getDigits 2   0.00 0.00
free_timestamp 2   0.00 0.00
_gpgme_op_sign_init_result 1   0.00 0.00
new_stringpair 1   0.00 0.00
parseHhMmSs 1   0.00 0.00
_gpgme_op_encrypt_init_result 1   0.00 0.00
is_whitespace 2   0.00 0.00
sqlite3OsCurrentTimeInt64 1   0.00 0.00
applyNumericAffinity 1   0.00 0.00
mem_release 3   0.00 0.00
computeHMS 1   0.00 0.00
free_identity_list 4   0.00 0.00
combine_short_and_long 1   0.00 0.00
parseYyyyMmDd 1   0.00 0.00
export_status_handler 1   0.00 0.00
get_file_part 1   0.00 0.00
_gpgme_data_new 3   0.00 0.00
pcacheFetchFinishWithInit 1   0.00 0.00
btreeInitPage 1   0.00 0.00
stringpair_list_add 1   0.00 0.00
pcache1UnderMemoryPressure 1   0.00 0.00
sqlite3StmtCurrentTime 1   0.00 0.00
gpgme_data_get_file_name 1   0.00 0.00
gpgme_signers_clear 1   0.00 0.00
pcache1AllocPage 1   0.00 0.00
gpgme_sig_notation_get 1   0.00 0.00
determine_encryption_format 1   0.00 0.00
mime_attachment 1   0.00 0.00
export_common 1   0.00 0.00
setDateTimeToCurrent 1   0.00 0.00
generate_boundary 1   0.00 0.00
computeYMD_HMS 1   0.00 0.00
new_bloblist 3   0.00 0.00
append_args_from_sig_notations 1   0.00 0.00
_gpgme_io_set_nonblocking 1   0.00 0.00
is_PGP_message_text 2   0.00 0.00
new_identity_list 11   0.00 0.00
bloblist_add 2   0.00 0.00
add_opt_field 1   0.00 0.00
_gpgme_progress_status_handler 10   0.00 0.00
free_stringlist 4   0.00 0.00
part_multiple_new 1   0.00 0.00
gpg_export 1   0.00 0.00
gpgme_signers_enum 2   0.00 0.00
part_new_empty 3   0.00 0.00
gpgme_key_ref 2   0.00 0.00
gpgme_data_new_from_mem 1   0.00 0.00
_gpgme_ath_write 12   0.00 0.00
_gpgme_fd_table_init 13   0.00 0.00
get_text_part 1   0.00 0.00
gpgme_strsource 13   0.00 0.00
gpgme_strerror 13   0.00 0.00
pcache1FetchStage2 1   0.00 0.00
_gpgme_fd_table_deinit 13   0.00 0.00
stringlist_length 15   0.00 0.00
_gpgme_signers_clear 13   0.00 0.00
gpg_get_version 13   0.00 0.00
_gpgme_ath_mutex_destroy 13   0.00 0.00
gpgme_signers_add 1   0.00 0.00
gpgme_data_new 2   0.00 0.00
readDbPage 1   0.00 0.00
parseDateOrTime 1   0.00 0.00
gpgme_data_release 3   0.00 0.00
append_args_from_signers 1   0.00 0.00
new_stringlist 12   0.00 0.00
pager_error 24   0.00 0.00
pcache1Truncate 24   0.00 0.00
writeMasterJournal 24   0.00 0.00
sqlite3PagerGetJournalMode 24   0.00 0.00
unixUnmapfile 24   0.00 0.00
isDate 1   0.00 0.00
mem_read 15   0.00 0.00
_gpgme_encrypt_status_handler 10   0.00 0.00
sqlite3TempInMemory 24   0.00 0.00
sqlite3FaultSim 24   0.00 0.00
verifyDbFile 24   0.00 0.00
sqlite3_uri_parameter 24   0.00 0.00
sqlite3_initialize 24   0.00 0.00
sqlite3JournalIsInMemory 24   0.00 0.00
sqlite3StrAccumFinish 25   0.00 0.00
sqlite3StrAccumInit 25   0.00 0.00
gpg_set_pinentry_mode 39   0.00 0.00
_gpgme_io_fd2str 40   0.00 0.00
mime_encode_message_plain 1   0.00 0.00
gpg_set_io_cbs 39   0.00 0.00
_gpgme_sema_cs_destroy 13   0.00 0.00
robustFchown 24   0.00 0.00
status_cmp 57   0.00 0.00
_gpgme_get_basename 39   0.00 0.00
gpg_set_status_handler 39   0.00 0.00
sqlite3BtreeNext 48   0.00 0.00
stringlist_add 11   0.00 0.00
sqlite3CloseSavepoints 46   0.00 0.00
sqlite3VtabUnlockList 46   0.00 0.00
sqlite3DeleteTable 46   0.00 0.00
render_mime 1   0.00 0.00
_gpgme_engine_info_release 13   0.00 0.00
sqlite3VdbeMemSetNull 46   0.00 0.00
sqlite3VdbeDeletePriorOpcode 46   0.00 0.00
sqlite3DeleteTrigger 46   0.00 0.00
identity_list_dup 1   0.00 0.00
saveAllCursors 46   0.00 0.00
sqlite3StrAccumAppend 35   0.00 0.00
sqlite3AuthCheck 46   0.00 0.00
pagerFlushOnCommit 48   0.00 0.00
storeLastErrno 48   0.00 0.00
_gpgme_passphrase_status_handler 10   0.00 0.00
journalHdrOffset 48   0.00 0.00
sqlite3VdbeAddOp1 23   0.00 0.00
sqlite3PcacheClearSyncFlags 24   0.00 0.00
btreeClearHasContent 24   0.00 0.00
sqlite3_column_count 46   0.00 0.00
sqlite3ExprListDelete 46   0.00 0.00
_gpgme_sign_status_handler 10   0.00 0.00
gpgme_ctx_get_engine_info 13   0.00 0.00
gpgme_get_keylist_mode 13   0.00 0.00
gpgme_set_keylist_mode 13   0.00 0.00
keywordCode 46   0.00 0.00
encrypt_sign_status_handler 10   0.00 0.00
parse_user_id 37   0.00 0.00
newDatabase 71   0.00 0.00
datetimeFunc 1   0.00 0.00
mem_seek 4   0.00 0.00
copy_fields 1   0.00 0.00
sqlite3CommitInternalChanges 94   0.00 0.00
gpg_encrypt_sign 1   0.00 0.00
sqlite3_uri_boolean 24   0.00 0.00
clone_to_empty_message 1   0.00 0.00
gpg_set_locale 78   0.00 0.00
sqlite3BtreeFirst 1   0.00 0.00
sqlite3PcacheTruncate 24   0.00 0.00
_gpgme_map_pk_algo 75   0.00 0.00
closePendingFds 94   0.00 0.00
sqlite3SafetyCheckOk 92   0.00 0.00
yy_shift 92   0.00 0.00
mem_write 32   0.00 0.00
callFinaliser 94   0.00 0.00
_gpgme_parse_status 9   0.00 0.00
sqlite3VdbeSetChanges 94   0.00 0.00
clearAllSharedCacheTableLocks 94   0.00 0.00
gpg_cancel 39   0.00 0.00
sqlite3VtabSavepoint 94   0.00 0.00
keylist_status_handler 37   0.00 0.00
sqlite3VtabSync 94   0.00 0.00
sqlite3PagerPagecount 94   0.00 0.00
sqlite3PagerFilename 94   0.00 0.00
sqlite3BtreeEnterAll 46   0.00 0.00
_gpgme_key_add_subkey 74   0.00 0.00
moveToRightmost 94   0.00 0.00
sqlite3VdbeIntValue 138   0.00 0.00
gpgme_data_seek 4   0.00 0.00
sqlite3DbStrNDup 46   0.00 0.00
sqlite3BtreeLeaveAll 46   0.00 0.00
identity_dup 34   0.00 0.00
gpgme_op_keylist_end 24   0.00 0.00
sqlite3_result_int64 46   0.00 0.00
gpgme_key_unref 16   0.00 0.00
_gpgme_ath_read 168   0.00 0.00
binCollFunc 162   0.00 0.00
_gpgme_parse_timestamp 149   0.00 0.00
querySharedCacheTableLock 140   0.00 0.00
_gpgme_engine_set_io_cbs 39   0.00 0.00
free_identity 47   0.00 0.00
new_identity 57   0.00 0.00
_gpgme_engine_info_copy 13   0.00 0.00
_gpgme_wait_private_event_cb 128   0.00 0.00
yy_destructor 184   0.00 0.00
createAggContext 46   0.00 0.00
_gpgme_getenv 78   0.00 0.00
_gpgme_op_keylist_event_cb 37   0.00 0.00
_gpgme_decode_c_string 37   0.00 0.00
unixDeviceCharacteristics 142   0.00 0.00
sqlite3BtreePager 165   0.00 0.00
invalidateIncrblobCursors 187   0.00 0.00
sqlite3BtreeCursorHasHint 184   0.00 0.00
pageFindSlot 189   0.00 0.00
allocSpace 230   0.00 0.00
sqlite3BtreeIsInTrans 188   0.00 0.00
sqlite3PagerUnref 24   0.00 0.00
sqlite3BackupUpdate 235   0.00 0.00
findCreateFileMode 24   0.00 0.00
sqlite3WalCallback 141   0.00 0.00
sqlite3VdbeMemSetInt64 186   0.00 0.00
allocateTempSpace 211   0.00 0.00
yy_find_reduce_action 207   0.00 0.00
balance 209   0.00 0.00
sqlite3_value_int 92   0.00 0.00
sqlite3VdbeSetSql 46   0.00 0.00
_gpgme_key_append_name 37   0.00 0.00
_gpgme_key_new 37   0.00 0.00
gpgme_data_read 15   0.00 0.00
sqlite3PutVarint 211   0.00 0.00
sqlite3WalDbsize 282   0.00 0.00
sqlite3VdbeMemInit 231   0.00 0.00
sqlite3VdbeMemMakeWriteable 69   0.00 0.00
sqlite3_aggregate_context 46   0.00 0.00
sqlite3BtreeLockTable 233   0.00 0.00
sqlite3ParserReset 46   0.00 0.00
sqlite3_context_db_handle 257   0.00 0.00
sqlite3VtabCommit 94   0.00 0.00
get_gpgconf_item 39   0.00 0.00
sqlite3VXPrintf 25   0.00 0.00
sqlite3BtreeSchemaLocked 46   0.00 0.00
btreePageFromDbPage 95   0.00 0.00
pager_cksum 235   0.00 0.00
yy_pop_parser_stack 184   0.00 0.00
_gpgme_engine_set_pinentry_mode 39   0.00 0.00
_gpgme_debug_end 319   0.00 0.00
fillInUnixFile 24   0.00 0.00
yy_find_shift_action 299   0.00 0.00
sqlite3BitvecSet 329   0.00 0.00
sqlite3_bind_null 23   0.00 0.00
gpgme_data_write 32   0.00 0.00
sqlite3VdbeRewind 374   0.00 0.00
_gpgme_in_gpg_one_mode 39   0.00 0.00
btreeParseCellPtrIndex 347   0.00 0.00
gpgme_new 13   0.00 0.00
addToSavepointBitvecs 235   0.00 0.00
freeSpace 209   0.00 0.00
robust_close 48   0.00 0.00
sqlite3BtreeGetFilename 94   0.00 0.00
sqlite3VarintLen 406   0.00 0.00
fileHasMoved 24   0.00 0.00
sqlite3_randomness 24   0.00 0.00
sqlite3VdbeLeave 420   0.00 0.00
sqlite3VdbeEnter 420   0.00 0.00
sqlite3VdbeCheckFk 419   0.00 0.00
sqlite3BitvecTestNotNull 423   0.00 0.00
btreeParseCellPtr 373   0.00 0.00
sqlite3VdbeRecordUnpack 117   0.00 0.00
_gpgme_release_result 39   0.00 0.00
sqlite3_vsnprintf 25   0.00 0.00
gpg_keylist_build_options 37   0.00 0.00
seekAndRead 119   0.00 0.00
vdbeCompareMemString 162   0.00 0.00
closeUnixFile 24   0.00 0.00
pager_write_changecounter 48   0.00 0.00
subjRequiresPage 188   0.00 0.00
sqlite3BtreeCursorHintFlags 534   0.00 0.00
sqlite3_snprintf 25   0.00 0.00
_gpgme_op_data_lookup 453   0.00 0.00
pthreadMutexAlloc 544   0.00 0.00
sqlite3BtreeCursorZero 534   0.00 0.00
sqlite3OsDeviceCharacteristics 142   0.00 0.00
pagerUseWal 522   0.00 0.00
nolockClose 24   0.00 0.00
sqlite3VdbeFindCompare 510   0.00 0.00
sqlite3VdbeSerialTypeLen 592   0.00 0.00
fetchPayload 554   0.00 0.00
sqlite3BtreeCursorSize 534   0.00 0.00
btreePagecount 534   0.00 0.00
unixFileControl 72   0.00 0.00
sqlite3Strlen30 451   0.00 0.00
vdbeSafety 585   0.00 0.00
sqlite3Get4byte 565   0.00 0.00
sqlite3PagerWalCallback 141   0.00 0.00
vdbeRecordDecodeInt 243   0.00 0.00
countFinalize 46   0.00 0.00
pcache1Unpin 582   0.00 0.00
pcacheManageDirtyList 587   0.00 0.00
unixFileSize 282   0.00 0.00
_gpgme_remove_io_cb 79   0.00 0.00
sqlite3PcacheRefCount 652   0.00 0.00
allocateSpace 211   0.00 0.00
sqlite3BtreeDataFetch 231   0.00 0.00
sqlite3VdbeChangeEncoding 610   0.00 0.00
databaseIsUnmoved 24   0.00 0.00
sqlite3BtreeCursorHasMoved 625   0.00 0.00
applyAffinity 606   0.00 0.00
sqlite3PagerGetExtra 629   0.00 0.00
_gpgme_sema_cs_leave 671   0.00 0.00
resolveP2Values 46   0.00 0.00
sqlite3OsFileControl 72   0.00 0.00
clearCell 209   0.00 0.00
columnMem 161   0.00 0.00
gpgme_result_unref 39   0.00 0.00
sqlite3PagerBegin 24   0.00 0.00
sqlite3PcacheFetchFinish 653   0.00 0.00
_gpgme_debug_begin 625   0.00 0.00
sqlite3VdbeSerialType 749   0.00 0.00
_gpgme_sema_cs_enter 671   0.00 0.00
_gpgme_debug_add 741   0.00 0.00
sqlite3VdbeTransferError 210   0.00 0.00
sqlite3GetVarint 726   0.00 0.00
sqlite3VdbeMakeReady 46   0.00 0.00
sqlite3VdbeMemFinalize 46   0.00 0.00
sqlite3MemCompare 162   0.00 0.00
gpg_keylist 37   0.00 0.00
sqlite3PcacheMakeDirty 235   0.00 0.00
sqlite3Put4byte 734   0.00 0.00
unixRead 119   0.00 0.00
sqlite3VdbeSerialPut 749   0.00 0.00
sqlite3VdbeMemTooBig 748   0.00 0.00
sqlite3Realloc 47   0.00 0.00
pcacheMergeDirtyList 931   0.00 0.00
gpgme_release 13   0.00 0.00
sqlite3OsClose 236   0.00 0.00
sqlite3_bind_int64 46   0.00 0.00
_gpgme_add_io_cb 79   0.00 0.00
sqlite3VdbeMemShallowCopy 792   0.00 0.00
subjournalPageIfRequired 188   0.00 0.00
sqlite3VdbeOneByteSerialTypeLen 923   0.00 0.00
_gpgme_ath_mutex_unlock 671   0.00 0.00
columnMallocFailure 161   0.00 0.00
dropCell 209   0.00 0.00
sqlite3VdbeAllocUnpackedRecord 117   0.00 0.00
sqlite3_bind_int 46   0.00 0.00
sqlite3VdbeCursorRestore 301   0.00 0.00
sqlite3PagerSavepoint 47   0.00 0.00
sqlite3BtreeKeyFetch 323   0.00 0.00
sqlite3ValueBytes 537   0.00 0.00
sqlite3Error 983   0.00 0.00
_gpgme_io_write 12   0.00 0.00
vdbeFreeOpArray 46   0.00 0.00
close_notify_handler 158   0.00 0.00
gpg_release 39   0.00 0.00
Cleanup 374   0.00 0.00
btreeCursor 534   0.00 0.00
sqlite3BtreeGetMeta 164   0.00 0.00
sqlite3OsRead 119   0.00 0.00
_gpgme_io_pipe 92   0.00 0.00
_gpgme_engine_set_locale 78   0.00 0.00
sqlite3StatusHighwater 1093   0.00 0.00
sqlite3_column_text 69   0.00 0.00
sqlite3MemRoundup 1117   0.00 0.00
sqlite3OsFileSize 282   0.00 0.00
sqlite3PagerExclusiveLock 48   0.00 0.00
unixFileLock 496   0.00 0.00
_gpgme_engine_release 39   0.00 0.00
sqlite3DbRealloc 46   0.00 0.00
_add_arg 921   0.00 0.00
pcache1PinPage 581   0.00 0.00
sqlite3FinishCoding 46   0.00 0.00
sqlite3ApiExit 1307   0.00 0.00
sqlite3VdbeMemFromBtree 231   0.00 0.00
releaseAllSavepoints 118   0.00 0.00
out2Prerelease 1331   0.00 0.00
fillInCell 211   0.00 0.00
setResultStrOrError 258   0.00 0.00
get_revoked 1   0.00 0.00
sqlite3BtreeDataSize 231   0.00 0.00
sqlite3VdbeRecordCompare 173   0.00 0.00
sqlite3ParserAlloc 46   0.00 0.00
sqlite3PcacheMakeClean 235   0.00 0.00
_gpgme_ath_mutex_lock 671   0.00 0.00
sqlite3VdbeCreate 46   0.00 0.00
openDirectory 24   0.00 0.00
sqlite3ParserFree 46   0.00 0.00
unixAccess 188   0.00 0.00
sqlite3BitvecDestroy 189   0.00 0.00
pagerOpenWalIfPresent 94   0.00 0.00
_gpgme_data_outbound_handler 13   0.00 0.00
sqlite3BtreeClearCursor 534   0.00 0.00
sqlite3MemFree 1093   0.00 0.00
hasHotJournal 94   0.00 0.00
sqlite3BtreeSavepoint 47   0.00 0.00
sqlite3_column_int 92   0.00 0.00
sqlite3MutexAlloc 544   0.00 0.00
growOpArray 46   0.00 0.00
pcacheSortDirtyList 24   0.00 0.00
sqlite3PcacheCleanAll 48   0.00 0.00
sqlite3VdbeClearObject 46   0.00 0.00
pcacheUnpin 582   0.00 0.00
vdbeSafetyNotNull 585   0.00 0.00
sqlite3PcacheDirtyList 24   0.00 0.00
writeJournalHdr 24   0.00 0.00
btreeParseCell 511   0.00 0.00
sqlite3BtreeLeave 1865   0.00 0.00
sqlite3BtreeEnter 1865   0.00 0.00
growOp3 46   0.00 0.00
sqlite3OsAccess 188   0.00 0.00
gpg_set_colon_line_handler 37   0.00 0.00
sqlite3_result_text 258   0.00 0.00
sqlite3MallocZero 71   0.00 0.00
doWalCallbacks 141   0.00 0.00
sqlite3MemMalloc 1093   0.00 0.00
sqlite3StatusDown 2186   0.00 0.00
unixLeaveMutex 260   0.00 0.00
sqlite3VdbeCloseStatement 185   0.00 0.00
gpg_io_event 89   0.00 0.00
sqlite3VdbeAddOp3 184   0.00 0.00
sqlite3_value_bytes 537   0.00 0.00
sqlite3CommitTransaction 23   0.00 0.00
btreeGetPage 94   0.00 0.00
sqlite3StatusUp 2186   0.00 0.00
_gpgme_engine_io_event 89   0.00 0.00
_gpgme_debug_frame_end 2203   0.00 0.00
sqlite3BitvecCreate 71   0.00 0.00
log_event 1   0.00 0.00
insertCell 211   0.00 0.00
sqlite3VdbeAddOp0 115   0.00 0.00
sqlite3BeginTransaction 23   0.00 0.00
pager_incr_changecounter 24   0.00 0.00
sqlite3VdbeMemSetStr 564   0.00 0.00
sqlite3PcacheRelease 652   0.00 0.00
pagerPagecount 282   0.00 0.00
_gpgme_debug_frame_begin 2204   0.00 0.00
unixEnterMutex 260   0.00 0.00
_gpgme_io_set_close_notify 158   0.00 0.00
isLookaside 2674   0.00 0.00
pagerOpenSavepoint 47   0.00 0.00
sqlite3VdbeRecordCompareWithSkip 359   0.00 0.00
unixDelete 24   0.00 0.00
vdbeMemClearExternAndSetNull 140   0.00 0.00
pcache1FetchNoMutex 652   0.00 0.00
sqlite3OsDelete 24   0.00 0.00
sqlite3DbMallocZero 92   0.00 0.00
sqlite3VdbeDelete 46   0.00 0.00
pager_write_pagelist 24   0.00 0.00
sqlite3PagerOpenSavepoint 141   0.00 0.00
status_handler 47   0.00 0.00
_gpgme_data_inbound_handler 34   0.00 0.00
getCellInfo 718   0.00 0.00
sqlite3MemSize 2790   0.00 0.00
sqlite3BtreeBeginStmt 47   0.00 0.00
posixUnlock 118   0.00 0.00
vdbeMemClear 140   0.00 0.00
sqlite3BtreeLast 94   0.00 0.00
sqlite3BtreeKeySize 487   0.00 0.00
vdbeRecordCompareString 1421   0.00 0.00
unixUnlock 118   0.00 0.00
vdbeMemAddTerminator 117   0.00 0.00
pthreadMutexLeave 3636   0.00 0.00
sqlite3OsUnlock 118   0.00 0.00
pthreadMutexEnter 3636   0.00 0.00
handleDeferredMoveto 138   0.00 0.00
allocVdbe 46   0.00 0.00
pagerUnlockDb 118   0.00 0.00
sqlite3VdbeFinalize 46   0.00 0.00
sqlite3VdbeMemNulTerminate 278   0.00 0.00
sqlite3GetVdbe 92   0.00 0.00
sqlite3BtreeCursor 534   0.00 0.00
sqlite3PagerSync 24   0.00 0.00
pcache1Fetch 652   0.00 0.00
valueToText 117   0.00 0.00
posixOpen 48   0.00 0.00
unixLock 142   0.00 0.00
robust_open 48   0.00 0.00
sqlite3DbMallocSize 1256   0.00 0.00
btreeMoveto 117   0.00 0.00
sqlite3VdbeMemRelease 1309   0.00 0.00
_gpgme_debug_buffer 180   0.00 0.00
sqlite3OsLock 142   0.00 0.00
pager_unlock 94   0.00 0.00
pager_wait_on_lock 142   0.00 0.00
vdbeUnbind 375   0.00 0.00
unixOpen 24   0.00 0.00
sqlite3OsOpen 24   0.00 0.00
sqlite3ValueText 607   0.00 0.00
sqlite3JournalOpen 24   0.00 0.00
sqlite3VdbeCursorMoveto 462   0.00 0.00
pagerLockDb 166   0.00 0.00
pagerUnlockAndRollback 94   0.00 0.00
sqlite3VdbeIdxRowid 231   0.00 0.00
sqlite3PcacheFetch 652   0.01 0.00
seekAndWriteFd 988   0.01 0.01
sqlite3_value_text 607   0.01 0.00
sqlite3MallocSize 2210   0.01 0.00
pager_end_transaction 118   0.01 0.00
write32bits 470   0.01 0.00
sqlite3PagerCommitPhaseTwo 24   0.01 0.00
_gpgme_io_close 184   0.01 0.00
btreeEndTransaction 94   0.01 0.00
pagerUnlockIfUnused 652   0.01 0.00
unlockBtreeIfUnused 628   0.01 0.00
_gpgme_debug 7075   0.01 0.01
releasePage 745   0.01 0.00
sqlite3Parser 92   0.01 0.00
seekAndWrite 988   0.01 0.00
contextMalloc 257   0.01 0.00
closeCursorsInFrame 515   0.01 0.00
sqlite3PagerGet 652   0.01 0.00
pager_open_journal 24   0.01 0.00
colon_line_handler 74   0.01 0.00
bindText 306   0.01 0.00
unixWrite 988   0.01 0.00
sqlite3BtreeInsert 211   0.01 0.00
getAndInitPage 534   0.01 0.00
replaceFunc 140   0.01 0.00
sqlite3_bind_text 306   0.01 0.00
sqlite3_mutex_enter 3636   0.01 0.01
sqlite3_mutex_leave 3636   0.01 0.01
upperFunc 117   0.01 0.00
sqlite3PagerSharedLock 94   0.01 0.00
sqlite3OsWrite 988   0.01 0.00
moveToRoot 1093   0.01 0.00
sqlite3PagerUnrefNotNull 652   0.01 0.00
sqlite3RunParser 46   0.01 0.00
releasePageNotNull 628   0.01 0.00
pagerAddPageToRollbackJournal 235   0.01 0.00
keylist_colon_handler 258   0.01 0.00
lockBtree 94   0.01 0.00
sqlite3BtreeCloseCursor 534   0.01 0.00
sqlite3BtreeCommitPhaseTwo 94   0.01 0.00
sqlite3VdbeFreeCursor 534   0.01 0.00
sqlite3Prepare 46   0.01 0.00
mallocWithAlarm 1093   0.01 0.01
sqlite3BtreeBeginTrans 164   0.01 0.00
sqlite3LockAndPrepare 46   0.02 0.00
sqlite3_prepare_v2 46   0.02 0.00
dbMallocRawFinish 696   0.02 0.00
sqlite3DbFree 2509   0.02 0.00
releaseMemArray 607   0.02 0.00
yy_reduce 207   0.02 0.00
sqlite3BtreeMovetoUnpacked 834   0.02 0.00
sqlite3DbMallocRawNN 1420   0.02 0.00
sqlite3DbMallocRaw 1326   0.02 0.00
sqlite3_free 2326   0.02 0.01
sqlite3VdbeMemClearAndResize 746   0.02 0.00
allocateCursor 534   0.02 0.00
pager_write 235   0.02 0.00
_gpgme_run_io_cb 168   0.02 0.00
sqlite3PagerWrite 444   0.02 0.00
_gpgme_engine_reset 26   0.02 0.00
sqlite3Malloc 1093   0.02 0.00
sqlite3VdbeReset 374   0.02 0.00
sqlite3BtreeDelete 209   0.02 0.00
sqlite3VdbeMemGrow 1210   0.02 0.00
closeAllCursors 515   0.03 0.00
sqlite3GetToken 138   0.03 0.00
sqlite3_reset 328   0.03 0.00
syncJournal 24   0.03 0.00
full_fsync 96   0.03 0.03
unixSync 72   0.03 0.00
sqlite3OsSync 72   0.03 0.00
gpg_new 39   0.03 0.03
_gpgme_engine_new 39   0.03 0.00
blacklist_is_listed 46   0.03 0.00
_gpgme_op_reset 39   0.04 0.00
sqlite3PagerCommitPhaseOne 24   0.04 0.00
sqlite3BtreeCommitPhaseOne 94   0.04 0.00
get_identity 23   0.04 0.00
sqlite3VdbeSerialGet 650   0.05 0.00
_gpgme_engine_op_encrypt_sign 1   0.05 0.00
encrypt_sign_start 1   0.05 0.00
vdbeCommit 94   0.06 0.00
_gpgme_engine_op_export 1   0.06 0.00
export_start 1   0.06 0.00
gpgme_op_export 1   0.06 0.00
sqlite3_exec 46   0.07 0.00
sqlite3VdbeHalt 515   0.09 0.00
pgp_key_expired 1   0.20 0.00
key_expired 1   0.20 0.00
pgp_key_revoked 1   0.20 0.00
key_revoked 1   0.20 0.00
pgp_export_keydata 1   0.22 0.00
export_key 1   0.22 0.00
_attach_key 1   0.22 0.00
attach_own_key 1   0.22 0.00
sqlite3VdbeExec 210   0.23 0.01
sqlite3Step 210   0.23 0.00
sqlite3_step 210   0.23 0.00
set_identity 23   0.23 0.00
pgp_contains_priv_key 1   0.31 0.00
contains_priv_key 1   0.31 0.00
_has_usable_priv_key 1   0.31 0.00
find_single_key 2   0.40 0.00
_gpgme_io_read 168   0.70 0.70
_myself 1   0.73 0.00
myself 1   0.73 0.00
_gpgme_ath_waitpid 52   0.95 0.95
gpgme_op_encrypt_sign 1   0.99 0.00
_gpgme_get_program_version 13   1.41 0.00
_gpgme_set_engine_info 13   1.41 0.00
_gpgme_engine_op_keylist 37   2.01 0.00
_gpgme_engine_set_colon_line_handler 37   2.01 0.00
gpgme_op_keylist_start 37   2.05 0.00
start 39   2.12 0.00
_gpgme_engine_set_status_handler 39   2.13 0.00
_get_comm_type 11   2.34 0.00
_gpgme_io_spawn 52   2.84 1.88
gpgme_ctx_set_engine_info 13   4.05 0.00
gpgme_set_protocol 13   4.05 0.00
gpgme_get_protocol 13   4.05 0.00
gpgme_get_key 13   4.05 0.00
pgp_get_key_rating 22   4.44 0.00
get_key_rating 22   4.44 0.00
update_identity 22   4.72 0.00
pgp_encrypt_and_sign 1   4.73 0.00
encrypt_and_sign 1   4.73 0.00
mime_encode_message 1   4.73 0.00
encrypt_PGP_MIME 1   4.73 0.00
gpgme_op_keylist_next 50   5.43 0.00
_gpgme_ath_select 306   6.49 6.49
_gpgme_io_select 319   6.50 0.00
_gpgme_wait_on_condition 52   6.52 0.00
encrypt_message 1   10.40 0.00

50
test/profiling/trace_analysis.py

@ -1,50 +0,0 @@
import sys
first = True
funcs = {}
prevtime = 0
stack=[]
for line in sys.stdin:
if first:
first = False
continue
try:
_cpu, _id, probe, time = line.split()
except:
break
time = int(time)
func,point = probe.split(':')
entry = point == "entry"
fs = funcs.setdefault(func,[0,0,0,[]])
if entry:
if len(stack) > 0:
prevfunc, prevfs = stack[-1]
prevfs[2] = prevfs[2] + time - prevtime
fs[0] = fs[0] + 1
fs[3].append(time)
stack.append((func,fs))
else:
while len(stack) > 0 :
prevfunc, prevfs=stack.pop()
if func != prevfunc:
print(prevfunc, ": NO RETURN, unwinded in", func, file=sys.stderr)
# in case unwinding from non returning func, cannot guess time spent
# spent time is then (abusively) added to all unwinded, worst case.
prevfs[2] = prevfs[2] + time - prevtime
prevfs[1] = prevfs[1] + time - prevfs[3].pop()
else:
break
fs[2] = fs[2] + time - prevtime
fs[1] = fs[1] + time - fs[3].pop()
prevtime = time
#print(_cpu, _id, func,point, time)
for func in sorted(funcs.items(), key=lambda fs: fs[1][1]):
name,(count, totaltime, insidetime, entries) = func
print("{:<40} {:<6} {:>6.2f} {:>6.2f}".format( name, count, totaltime/1000000000, insidetime/1000000000))

31
test/sync_test.py

@ -1,31 +0,0 @@
import codecs
from pEp import *
_msg = []
_me = None
_partner = None
class Handler(SyncMixIn):
def messageToSend(self, msg):
global _msg
print("-" * 80)
print(str(msg).replace("\r", ""))
_msg.append(msg)
def showHandshake(self, me, partner):
print("handshake needed between " + repr(me) + " and " + repr(partner))
global _me, _partner
_me, _partner = (me, partner)
handler = Handler()
def process(path):
with open(path, 'r') as f:
text = f.read()
return Message(text)
# this is an interactive test, so start it with python -i
Loading…
Cancel
Save