aboutsummaryrefslogtreecommitdiff
path: root/src/fs/test_gnunet_fs_idx.py.in
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-05 21:16:35 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-05 21:16:35 +0000
commitcb41db74f56afaa480d834c4756ecb6ac6bf8258 (patch)
tree421f628248ad91624dd900b664a2dd86eeea519c /src/fs/test_gnunet_fs_idx.py.in
parent00082097a2f6c54166d4308b65bde7ef0bbed1bd (diff)
downloadgnunet-cb41db74f56afaa480d834c4756ecb6ac6bf8258.tar.gz
gnunet-cb41db74f56afaa480d834c4756ecb6ac6bf8258.zip
LRN: 0005-Port-old-pexpect-tests-to-gnunet_pyexpect.patch
Diffstat (limited to 'src/fs/test_gnunet_fs_idx.py.in')
-rwxr-xr-xsrc/fs/test_gnunet_fs_idx.py.in63
1 files changed, 46 insertions, 17 deletions
diff --git a/src/fs/test_gnunet_fs_idx.py.in b/src/fs/test_gnunet_fs_idx.py.in
index c97ffd883..b579ab863 100755
--- a/src/fs/test_gnunet_fs_idx.py.in
+++ b/src/fs/test_gnunet_fs_idx.py.in
@@ -18,28 +18,57 @@
18# Boston, MA 02111-1307, USA. 18# Boston, MA 02111-1307, USA.
19# 19#
20# Testcase for file-sharing command-line tools (indexing and unindexing) 20# Testcase for file-sharing command-line tools (indexing and unindexing)
21import pexpect 21import sys
22import os 22import os
23import signal 23import subprocess
24import re 24import re
25import shutil
26
27srcdir = "../.."
28gnunet_pyexpect_dir = os.path.join (srcdir, "contrib", "gnunet_pyexpect")
29if gnunet_pyexpect_dir not in sys.path:
30 sys.path.append (gnunet_pyexpect_dir)
31
32from gnunet_pyexpect import pexpect
33
34if os.name == 'posix':
35 download = 'gnunet-download'
36 gnunetarm = 'gnunet-arm'
37 publish = 'gnunet-publish'
38 unindex = 'gnunet-unindex'
39elif os.name == 'nt':
40 download = 'gnunet-download.exe'
41 gnunetarm = 'gnunet-arm.exe'
42 publish = 'gnunet-publish.exe'
43 unindex = 'gnunet-unindex.exe'
44
45if os.name == "nt":
46 shutil.rmtree (os.path.join (os.getenv ("TEMP"), "gnunet-test-fs-py-idx"), True)
47else:
48 shutil.rmtree ("/tmp/gnunet-test-fs-py-idx", True)
49
50arm = subprocess.Popen ([gnunetarm, '-sq', '-c', 'test_gnunet_fs_idx_data.conf'])
51arm.communicate ()
25 52
26os.system ('rm -rf /tmp/gnunet-test-fs-py-idx/')
27os.system ('gnunet-arm -sq -c test_gnunet_fs_idx_data.conf')
28try: 53try:
29 pub = pexpect.spawn ('gnunet-publish -c test_gnunet_fs_idx_data.conf -m "description:The GNU Public License" -k gpl ../../COPYING') 54 pub = pexpect ()
30 pub.expect ('Publishing `../../COPYING\' done.\r') 55 pub.spawn (None, [publish, '-c', 'test_gnunet_fs_idx_data.conf', '-m', "description:The GNU Public License", '-k', 'gpl', '../../COPYING'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
31 pub.expect ("URI is `gnunet://fs/chk/PC0M19QMQC0BPSHR6BGA228PP6INER1D610MGEMOMEM87222FN8HVUO7PQGO0O9HD2GVLHF2N5IDHEQUNK6LKE428FPO96SKQEA486O.PG7K85JGQ6N599MD5HEP3CHEVFPKQD9JB6NPSLVA3T1SKDS66CFI499VS6MGQ88B0QUAVT1282TCRD4GGFVUKDLGI8F0SPIANA3J2LG.35147'.\r") 56 pub.expect ("stdout", re.compile (r"Publishing `\.\./\.\./COPYING' done\.\r?\n"))
32 pub.expect (pexpect.EOF) 57 pub.expect ("stdout", re.compile (r"URI is `gnunet://fs/chk/PC0M19QMQC0BPSHR6BGA228PP6INER1D610MGEMOMEM87222FN8HVUO7PQGO0O9HD2GVLHF2N5IDHEQUNK6LKE428FPO96SKQEA486O\.PG7K85JGQ6N599MD5HEP3CHEVFPKQD9JB6NPSLVA3T1SKDS66CFI499VS6MGQ88B0QUAVT1282TCRD4GGFVUKDLGI8F0SPIANA3J2LG\.35147'\.\r?\n"))
33 58
34 down = pexpect.spawn ('gnunet-download -c test_gnunet_fs_idx_data.conf -o COPYING gnunet://fs/chk/PC0M19QMQC0BPSHR6BGA228PP6INER1D610MGEMOMEM87222FN8HVUO7PQGO0O9HD2GVLHF2N5IDHEQUNK6LKE428FPO96SKQEA486O.PG7K85JGQ6N599MD5HEP3CHEVFPKQD9JB6NPSLVA3T1SKDS66CFI499VS6MGQ88B0QUAVT1282TCRD4GGFVUKDLGI8F0SPIANA3J2LG.35147') 59 down = pexpect ()
35 down.expect (re.compile ("Downloading `COPYING\' done \(.*\).\r")); 60 down.spawn (None, [download, '-c', 'test_gnunet_fs_idx_data.conf', '-o', 'COPYING', 'gnunet://fs/chk/PC0M19QMQC0BPSHR6BGA228PP6INER1D610MGEMOMEM87222FN8HVUO7PQGO0O9HD2GVLHF2N5IDHEQUNK6LKE428FPO96SKQEA486O.PG7K85JGQ6N599MD5HEP3CHEVFPKQD9JB6NPSLVA3T1SKDS66CFI499VS6MGQ88B0QUAVT1282TCRD4GGFVUKDLGI8F0SPIANA3J2LG.35147'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
36 down.expect (pexpect.EOF); 61 down.expect ("stdout", re.compile (r"Downloading `COPYING' done (.*).\r?\n"))
37 os.system ('rm COPYING'); 62 os.remove ("COPYING")
38 63
39 unindex = pexpect.spawn ('gnunet-unindex -c test_gnunet_fs_idx_data.conf ../../COPYING') 64 un = pexpect ()
40 unindex.expect ('Unindexing done.\r') 65 un.spawn (None, [unindex, '-c', 'test_gnunet_fs_idx_data.conf', '../../COPYING'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
41 unindex.expect (pexpect.EOF) 66 un.expect ("stdout", re.compile (r'Unindexing done\.\r?\n'))
42 67
43finally: 68finally:
44 os.system ('gnunet-arm -c test_gnunet_fs_idx_data.conf -eq') 69 arm = subprocess.Popen ([gnunetarm, '-eq', '-c', 'test_gnunet_fs_idx_data.conf'])
45 os.system ('rm -rf /tmp/gnunet-test-fs-py-idx/') 70 arm.communicate ()
71 if os.name == "nt":
72 shutil.rmtree (os.path.join (os.getenv ("TEMP"), "gnunet-test-fs-py-idx"), True)
73 else:
74 shutil.rmtree ("/tmp/gnunet-test-fs-py-idx", True)