Browse Source

command line option

PYADPT-55
Volker Birk 6 years ago
parent
commit
b6e437cc68
  1. 18
      test/sync_handshake.py
  2. 43
      test/sync_test.py

18
test/sync_handshake.py

@ -18,12 +18,24 @@ def messageToSend(msg):
class UserInterface(pEp.UserInterface): class UserInterface(pEp.UserInterface):
def notifyHandshake(self, me, partner, signal): def notifyHandshake(self, me, partner, signal):
print("signal " + str(signal) + " for identities " + str(me) + " " + str(partner)) print("signal " + str(signal) + " for identities " + str(me) + " " +
str(partner))
def run(path): def run(name):
me = pEp.Identity("alice@peptest.ch", path + " Neuman") me = pEp.Identity("alice@peptest.ch", name + " Neuman")
pEp.myself(me) pEp.myself(me)
pEp.messageToSend = messageToSend pEp.messageToSend = messageToSend
ui = UserInterface() ui = UserInterface()
if __name__=="__main__":
from optparse import OptionParser
optParser = OptionParser()
optParser.add_option("-e", "--exec-for", action="store", type="string",
dest="exec_for", help="execute for name")
options, args = optParser.parse_args()
run(options.exec_for)

43
test/sync_test.py

@ -9,7 +9,6 @@
import os, pathlib, sys import os, pathlib, sys
from optparse import OptionParser
def test_for(path): def test_for(path):
@ -71,28 +70,32 @@ def waitpid(pid):
return return
optParser = OptionParser() if __name__ == "__main__":
optParser.add_option("-c", "--clean", action="store_true", dest="clean") from optparse import OptionParser
(options, args) = optParser.parse_args()
if options.clean: optParser = OptionParser()
rmrf("TestInbox") optParser.add_option("-c", "--clean", action="store_true", dest="clean",
rmrf("Alice") help="remove all generated files")
rmrf("Barbara") options, args = optParser.parse_args()
else: if options.clean:
os.makedirs("TestInbox", exist_ok=True) rmrf("TestInbox")
setup("Alice") rmrf("Alice")
setup("Barbara") rmrf("Barbara")
Alice = os.fork()
if Alice == 0:
test_for("Alice")
else: else:
Barbara = os.fork() os.makedirs("TestInbox", exist_ok=True)
if Barbara == 0: setup("Alice")
test_for("Barbara") setup("Barbara")
Alice = os.fork()
if Alice == 0:
test_for("Alice")
else: else:
waitpid(Alice) Barbara = os.fork()
waitpid(Barbara) if Barbara == 0:
test_for("Barbara")
else:
waitpid(Alice)
waitpid(Barbara)

Loading…
Cancel
Save