diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-05 21:16:35 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-05 21:16:35 +0000 |
commit | cb41db74f56afaa480d834c4756ecb6ac6bf8258 (patch) | |
tree | 421f628248ad91624dd900b664a2dd86eeea519c /src/fs | |
parent | 00082097a2f6c54166d4308b65bde7ef0bbed1bd (diff) | |
download | gnunet-cb41db74f56afaa480d834c4756ecb6ac6bf8258.tar.gz gnunet-cb41db74f56afaa480d834c4756ecb6ac6bf8258.zip |
LRN: 0005-Port-old-pexpect-tests-to-gnunet_pyexpect.patch
Diffstat (limited to 'src/fs')
-rwxr-xr-x | src/fs/test_gnunet_fs_idx.py.in | 63 | ||||
-rwxr-xr-x | src/fs/test_gnunet_fs_ns.py.in | 72 | ||||
-rwxr-xr-x | src/fs/test_gnunet_fs_psd.py.in | 73 | ||||
-rwxr-xr-x | src/fs/test_gnunet_fs_rec.py.in | 89 |
4 files changed, 213 insertions, 84 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) |
21 | import pexpect | 21 | import sys |
22 | import os | 22 | import os |
23 | import signal | 23 | import subprocess |
24 | import re | 24 | import re |
25 | import shutil | ||
26 | |||
27 | srcdir = "../.." | ||
28 | gnunet_pyexpect_dir = os.path.join (srcdir, "contrib", "gnunet_pyexpect") | ||
29 | if gnunet_pyexpect_dir not in sys.path: | ||
30 | sys.path.append (gnunet_pyexpect_dir) | ||
31 | |||
32 | from gnunet_pyexpect import pexpect | ||
33 | |||
34 | if os.name == 'posix': | ||
35 | download = 'gnunet-download' | ||
36 | gnunetarm = 'gnunet-arm' | ||
37 | publish = 'gnunet-publish' | ||
38 | unindex = 'gnunet-unindex' | ||
39 | elif os.name == 'nt': | ||
40 | download = 'gnunet-download.exe' | ||
41 | gnunetarm = 'gnunet-arm.exe' | ||
42 | publish = 'gnunet-publish.exe' | ||
43 | unindex = 'gnunet-unindex.exe' | ||
44 | |||
45 | if os.name == "nt": | ||
46 | shutil.rmtree (os.path.join (os.getenv ("TEMP"), "gnunet-test-fs-py-idx"), True) | ||
47 | else: | ||
48 | shutil.rmtree ("/tmp/gnunet-test-fs-py-idx", True) | ||
49 | |||
50 | arm = subprocess.Popen ([gnunetarm, '-sq', '-c', 'test_gnunet_fs_idx_data.conf']) | ||
51 | arm.communicate () | ||
25 | 52 | ||
26 | os.system ('rm -rf /tmp/gnunet-test-fs-py-idx/') | ||
27 | os.system ('gnunet-arm -sq -c test_gnunet_fs_idx_data.conf') | ||
28 | try: | 53 | try: |
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 | ||
43 | finally: | 68 | finally: |
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) | ||
diff --git a/src/fs/test_gnunet_fs_ns.py.in b/src/fs/test_gnunet_fs_ns.py.in index b72bc9062..b6a695c7f 100755 --- a/src/fs/test_gnunet_fs_ns.py.in +++ b/src/fs/test_gnunet_fs_ns.py.in | |||
@@ -18,33 +18,63 @@ | |||
18 | # Boston, MA 02111-1307, USA. | 18 | # Boston, MA 02111-1307, USA. |
19 | # | 19 | # |
20 | # Testcase for file-sharing command-line tools (namespaces) | 20 | # Testcase for file-sharing command-line tools (namespaces) |
21 | import pexpect | 21 | import sys |
22 | import os | 22 | import os |
23 | import signal | 23 | import subprocess |
24 | import re | 24 | import re |
25 | import shutil | ||
26 | |||
27 | srcdir = "../.." | ||
28 | gnunet_pyexpect_dir = os.path.join (srcdir, "contrib", "gnunet_pyexpect") | ||
29 | if gnunet_pyexpect_dir not in sys.path: | ||
30 | sys.path.append (gnunet_pyexpect_dir) | ||
31 | |||
32 | from gnunet_pyexpect import pexpect | ||
33 | |||
34 | if os.name == 'posix': | ||
35 | pseudonym = 'gnunet-pseudonym' | ||
36 | gnunetarm = 'gnunet-arm' | ||
37 | publish = 'gnunet-publish' | ||
38 | unindex = 'gnunet-unindex' | ||
39 | search = 'gnunet-search' | ||
40 | elif os.name == 'nt': | ||
41 | pseudonym = 'gnunet-pseudonym.exe' | ||
42 | gnunetarm = 'gnunet-arm.exe' | ||
43 | publish = 'gnunet-publish.exe' | ||
44 | unindex = 'gnunet-unindex.exe' | ||
45 | search = 'gnunet-search.exe' | ||
46 | |||
47 | if os.name == "nt": | ||
48 | shutil.rmtree (os.path.join (os.getenv ("TEMP"), "gnunet-test-fs-py-ns"), True) | ||
49 | else: | ||
50 | shutil.rmtree ("/tmp/gnunet-test-fs-py-ns", True) | ||
51 | |||
52 | arm = subprocess.Popen ([gnunetarm, '-sq', '-c', 'test_gnunet_fs_ns_data.conf']) | ||
53 | arm.communicate () | ||
25 | 54 | ||
26 | os.system ('rm -rf /tmp/gnunet-test-fs-py-ns/') | ||
27 | os.system ('gnunet-arm -sq -c test_gnunet_fs_ns_data.conf') | ||
28 | try: | 55 | try: |
29 | pseu = pexpect.spawn ('gnunet-pseudonym -c test_gnunet_fs_ns_data.conf -C licenses -k gplad -m "description:Free Software Licenses" -R myroot') | 56 | pseu = pexpect () |
30 | pseu.expect (pexpect.EOF) | 57 | pseu.spawn (None, [pseudonym, '-c', 'test_gnunet_fs_ns_data.conf', '-C', 'licenses', '-k', 'gplad', '-m', 'description:Free Software Licenses', '-R', 'myroot'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
31 | pseu = pexpect.spawn ('gnunet-pseudonym -c test_gnunet_fs_ns_data.conf -o') | 58 | pseu.spawn (None, [pseudonym, '-c', 'test_gnunet_fs_ns_data.conf', '-o'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
32 | pseu.expect (re.compile("licenses \(.*\)\r")) | 59 | pseu.expect ("stdout", re.compile (r"licenses (.*)\r?\n")) |
33 | pseu.expect (pexpect.EOF) | ||
34 | 60 | ||
35 | pub = pexpect.spawn ('gnunet-publish -c test_gnunet_fs_ns_data.conf -k licenses -P licenses -u gnunet://fs/chk/PC0M19QMQC0BPSHR6BGA228PP6INER1D610MGEMOMEM87222FN8HVUO7PQGO0O9HD2GVLHF2N5IDHEQUNK6LKE428FPO96SKQEA486O.PG7K85JGQ6N599MD5HEP3CHEVFPKQD9JB6NPSLVA3T1SKDS66CFI499VS6MGQ88B0QUAVT1282TCRD4GGFVUKDLGI8F0SPIANA3J2LG.35147 -t gpl -N gpl3') | 61 | pub = pexpect () |
36 | pub.expect (pexpect.EOF) | 62 | pub.spawn (None, [publish, '-c', 'test_gnunet_fs_ns_data.conf', '-k', 'licenses', '-P', 'licenses', '-u', 'gnunet://fs/chk/PC0M19QMQC0BPSHR6BGA228PP6INER1D610MGEMOMEM87222FN8HVUO7PQGO0O9HD2GVLHF2N5IDHEQUNK6LKE428FPO96SKQEA486O.PG7K85JGQ6N599MD5HEP3CHEVFPKQD9JB6NPSLVA3T1SKDS66CFI499VS6MGQ88B0QUAVT1282TCRD4GGFVUKDLGI8F0SPIANA3J2LG.35147', '-t', 'gpl', '-N', 'gpl3'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
37 | 63 | ||
38 | search = pexpect.spawn ('gnunet-search -V -c test_gnunet_fs_ns_data.conf gplad') | 64 | s = pexpect () |
39 | search.expect (re.compile ("gnunet-download gnunet://fs/sks/.*/myroot\r")) | 65 | s.spawn (None, [search, '-V', '-t', '1000', '-N', '1', '-c', 'test_gnunet_fs_ns_data.conf', 'gplad'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
40 | search.expect (re.compile (" *description: Free Software Licenses\r")) | 66 | s.expect ("stdout", re.compile (r'#0:\r?\n')) |
41 | search.kill (signal.SIGTERM) | 67 | s.expect ("stdout", re.compile (r'gnunet-download gnunet://fs/sks/.*/myroot\r?\n')) |
42 | search.expect (pexpect.EOF) | 68 | s.expect ("stdout", re.compile (r'\s*description: Free Software Licenses\r?\n')) |
43 | 69 | ||
44 | pseu = pexpect.spawn ('gnunet-pseudonym -c test_gnunet_fs_ns_data.conf') | 70 | pseu = pexpect () |
45 | pseu.expect (re.compile ("Free Software Licenses.*:\r")) | 71 | pseu.spawn (None, [pseudonym, '-c', 'test_gnunet_fs_ns_data.conf'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
46 | pseu.expect (pexpect.EOF) | 72 | pseu.expect ("stdout", re.compile (r'Free Software Licenses.*:\r?\n')) |
47 | 73 | ||
48 | finally: | 74 | finally: |
49 | os.system ('gnunet-arm -c test_gnunet_fs_ns_data.conf -eq') | 75 | arm = subprocess.Popen ([gnunetarm, '-eq', '-c', 'test_gnunet_fs_ns_data.conf']) |
50 | os.system ('rm -rf /tmp/gnunet-test-fs-py-ns/') | 76 | arm.communicate () |
77 | if os.name == "nt": | ||
78 | shutil.rmtree (os.path.join (os.getenv ("TEMP"), "gnunet-test-fs-py-ns"), True) | ||
79 | else: | ||
80 | shutil.rmtree ("/tmp/gnunet-test-fs-py-ns", True) | ||
diff --git a/src/fs/test_gnunet_fs_psd.py.in b/src/fs/test_gnunet_fs_psd.py.in index d66b8b994..aac10f2de 100755 --- a/src/fs/test_gnunet_fs_psd.py.in +++ b/src/fs/test_gnunet_fs_psd.py.in | |||
@@ -18,31 +18,62 @@ | |||
18 | # Boston, MA 02111-1307, USA. | 18 | # Boston, MA 02111-1307, USA. |
19 | # | 19 | # |
20 | # Testcase for file-sharing command-line tools (publish, search, download) | 20 | # Testcase for file-sharing command-line tools (publish, search, download) |
21 | import pexpect | 21 | import sys |
22 | import os | 22 | import os |
23 | import signal | 23 | import subprocess |
24 | import re | 24 | import re |
25 | import shutil | ||
26 | |||
27 | srcdir = "../.." | ||
28 | gnunet_pyexpect_dir = os.path.join (srcdir, "contrib", "gnunet_pyexpect") | ||
29 | if gnunet_pyexpect_dir not in sys.path: | ||
30 | sys.path.append (gnunet_pyexpect_dir) | ||
31 | |||
32 | from gnunet_pyexpect import pexpect | ||
33 | |||
34 | if os.name == 'posix': | ||
35 | download = 'gnunet-download' | ||
36 | gnunetarm = 'gnunet-arm' | ||
37 | publish = 'gnunet-publish' | ||
38 | unindex = 'gnunet-unindex' | ||
39 | search = 'gnunet-search' | ||
40 | elif os.name == 'nt': | ||
41 | download = 'gnunet-download.exe' | ||
42 | gnunetarm = 'gnunet-arm.exe' | ||
43 | publish = 'gnunet-publish.exe' | ||
44 | unindex = 'gnunet-unindex.exe' | ||
45 | search = 'gnunet-search.exe' | ||
46 | |||
47 | if os.name == "nt": | ||
48 | shutil.rmtree (os.path.join (os.getenv ("TEMP"), "gnunet-test-fs-py-psd"), True) | ||
49 | else: | ||
50 | shutil.rmtree ("/tmp/gnunet-test-fs-py-psd", True) | ||
51 | |||
52 | arm = subprocess.Popen ([gnunetarm, '-sq', '-c', 'test_gnunet_fs_psd_data.conf']) | ||
53 | arm.communicate () | ||
25 | 54 | ||
26 | os.system ('rm -rf /tmp/gnunet-test-fs-py-psd/') | ||
27 | os.system ('gnunet-arm -sq -c test_gnunet_fs_psd_data.conf') | ||
28 | try: | ||
29 | # first, basic publish-search-download run | 55 | # first, basic publish-search-download run |
30 | pub = pexpect.spawn ('gnunet-publish -n -c test_gnunet_fs_psd_data.conf -m "description:The GNU Public License" -k gpl ../../COPYING') | 56 | try: |
31 | pub.expect ('Publishing `../../COPYING\' done.\r') | 57 | pub = pexpect () |
32 | pub.expect ("URI is `gnunet://fs/chk/PC0M19QMQC0BPSHR6BGA228PP6INER1D610MGEMOMEM87222FN8HVUO7PQGO0O9HD2GVLHF2N5IDHEQUNK6LKE428FPO96SKQEA486O.PG7K85JGQ6N599MD5HEP3CHEVFPKQD9JB6NPSLVA3T1SKDS66CFI499VS6MGQ88B0QUAVT1282TCRD4GGFVUKDLGI8F0SPIANA3J2LG.35147'.\r") | 58 | pub.spawn (None, [publish, '-c', 'test_gnunet_fs_psd_data.conf', '-n', '-m', "description:The GNU Public License", '-k', 'gpl', '../../COPYING'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
33 | pub.expect (pexpect.EOF) | 59 | pub.expect ("stdout", re.compile (r"Publishing `\.\./\.\./COPYING' done\.\r?\n")) |
34 | 60 | pub.expect ("stdout", re.compile (r"URI is `gnunet://fs/chk/PC0M19QMQC0BPSHR6BGA228PP6INER1D610MGEMOMEM87222FN8HVUO7PQGO0O9HD2GVLHF2N5IDHEQUNK6LKE428FPO96SKQEA486O\.PG7K85JGQ6N599MD5HEP3CHEVFPKQD9JB6NPSLVA3T1SKDS66CFI499VS6MGQ88B0QUAVT1282TCRD4GGFVUKDLGI8F0SPIANA3J2LG\.35147'\.\r?\n")) | |
35 | search = pexpect.spawn ('gnunet-search -V -c test_gnunet_fs_psd_data.conf gpl') | 61 | |
36 | search.expect ("gnunet-download -o \"COPYING\" gnunet://fs/chk/PC0M19QMQC0BPSHR6BGA228PP6INER1D610MGEMOMEM87222FN8HVUO7PQGO0O9HD2GVLHF2N5IDHEQUNK6LKE428FPO96SKQEA486O.PG7K85JGQ6N599MD5HEP3CHEVFPKQD9JB6NPSLVA3T1SKDS66CFI499VS6MGQ88B0QUAVT1282TCRD4GGFVUKDLGI8F0SPIANA3J2LG.35147\r") | 62 | s = pexpect () |
37 | search.expect (re.compile (" *description: The GNU Public License\r")); | 63 | s.spawn (None, [search, '-V', '-t', '1000', '-N', '1', '-c', 'test_gnunet_fs_psd_data.conf', 'gpl'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
38 | search.kill (signal.SIGTERM) | 64 | s.expect ("stdout", re.compile (r'#0:\r?\n')) |
39 | search.expect (pexpect.EOF) | 65 | s.expect ("stdout", re.compile (r'gnunet-download -o "COPYING" gnunet://fs/chk/PC0M19QMQC0BPSHR6BGA228PP6INER1D610MGEMOMEM87222FN8HVUO7PQGO0O9HD2GVLHF2N5IDHEQUNK6LKE428FPO96SKQEA486O\.PG7K85JGQ6N599MD5HEP3CHEVFPKQD9JB6NPSLVA3T1SKDS66CFI499VS6MGQ88B0QUAVT1282TCRD4GGFVUKDLGI8F0SPIANA3J2LG\.35147\r?\n')) |
66 | s.expect ("stdout", re.compile (r"\s*description: The GNU Public License\r?\n")) | ||
40 | 67 | ||
41 | down = pexpect.spawn ('gnunet-download -c test_gnunet_fs_psd_data.conf -o \"COPYING\" gnunet://fs/chk/PC0M19QMQC0BPSHR6BGA228PP6INER1D610MGEMOMEM87222FN8HVUO7PQGO0O9HD2GVLHF2N5IDHEQUNK6LKE428FPO96SKQEA486O.PG7K85JGQ6N599MD5HEP3CHEVFPKQD9JB6NPSLVA3T1SKDS66CFI499VS6MGQ88B0QUAVT1282TCRD4GGFVUKDLGI8F0SPIANA3J2LG.35147') | 68 | down = pexpect () |
42 | down.expect (re.compile ("Downloading `COPYING\' done \(.*\).\r")); | 69 | down.spawn (None, [download, '-c', 'test_gnunet_fs_psd_data.conf', '-o', 'COPYING', 'gnunet://fs/chk/PC0M19QMQC0BPSHR6BGA228PP6INER1D610MGEMOMEM87222FN8HVUO7PQGO0O9HD2GVLHF2N5IDHEQUNK6LKE428FPO96SKQEA486O.PG7K85JGQ6N599MD5HEP3CHEVFPKQD9JB6NPSLVA3T1SKDS66CFI499VS6MGQ88B0QUAVT1282TCRD4GGFVUKDLGI8F0SPIANA3J2LG.35147'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
43 | down.expect (pexpect.EOF); | 70 | down.expect ("stdout", re.compile (r"Downloading `COPYING' done (.*).\r?\n")) |
44 | os.system ('rm COPYING'); | 71 | os.remove ("COPYING") |
45 | 72 | ||
46 | finally: | 73 | finally: |
47 | os.system ('gnunet-arm -c test_gnunet_fs_psd_data.conf -eq') | 74 | arm = subprocess.Popen ([gnunetarm, '-eq', '-c', 'test_gnunet_fs_psd_data.conf']) |
48 | os.system ('rm -rf /tmp/gnunet-test-fs-py-psd/') | 75 | arm.communicate () |
76 | if os.name == "nt": | ||
77 | shutil.rmtree (os.path.join (os.getenv ("TEMP"), "gnunet-test-fs-py-psd"), True) | ||
78 | else: | ||
79 | shutil.rmtree ("/tmp/gnunet-test-fs-py-psd", True) | ||
diff --git a/src/fs/test_gnunet_fs_rec.py.in b/src/fs/test_gnunet_fs_rec.py.in index 3c990b35b..5b1b7f0e6 100755 --- a/src/fs/test_gnunet_fs_rec.py.in +++ b/src/fs/test_gnunet_fs_rec.py.in | |||
@@ -18,36 +18,75 @@ | |||
18 | # Boston, MA 02111-1307, USA. | 18 | # Boston, MA 02111-1307, USA. |
19 | # | 19 | # |
20 | # Testcase for file-sharing command-line tools (recursive publishing & download) | 20 | # Testcase for file-sharing command-line tools (recursive publishing & download) |
21 | import pexpect | 21 | import sys |
22 | import os | 22 | import os |
23 | import signal | 23 | import subprocess |
24 | import re | 24 | import re |
25 | import shutil | ||
25 | 26 | ||
26 | os.system ('rm -rf /tmp/gnunet-test-fs-py-rec/') | 27 | srcdir = "../.." |
27 | os.system ('gnunet-arm -sq -c test_gnunet_fs_rec_data.conf') | 28 | gnunet_pyexpect_dir = os.path.join (srcdir, "contrib", "gnunet_pyexpect") |
29 | if gnunet_pyexpect_dir not in sys.path: | ||
30 | sys.path.append (gnunet_pyexpect_dir) | ||
31 | |||
32 | from gnunet_pyexpect import pexpect | ||
33 | |||
34 | if os.name == 'posix': | ||
35 | download = 'gnunet-download' | ||
36 | gnunetarm = 'gnunet-arm' | ||
37 | publish = 'gnunet-publish' | ||
38 | unindex = 'gnunet-unindex' | ||
39 | search = 'gnunet-search' | ||
40 | directory = 'gnunet-directory' | ||
41 | elif os.name == 'nt': | ||
42 | download = 'gnunet-download.exe' | ||
43 | gnunetarm = 'gnunet-arm.exe' | ||
44 | publish = 'gnunet-publish.exe' | ||
45 | unindex = 'gnunet-unindex.exe' | ||
46 | search = 'gnunet-search.exe' | ||
47 | directory = 'gnunet-directory.exe' | ||
48 | |||
49 | if os.name == "nt": | ||
50 | shutil.rmtree (os.path.join (os.getenv ("TEMP"), "gnunet-test-fs-py-rec"), True) | ||
51 | else: | ||
52 | shutil.rmtree ("/tmp/gnunet-test-fs-py-rec", True) | ||
53 | |||
54 | arm = subprocess.Popen ([gnunetarm, '-sq', '-c', 'test_gnunet_fs_rec_data.conf']) | ||
55 | arm.communicate () | ||
56 | |||
57 | # pray that `tar' is in PATH | ||
28 | os.system ('tar xfz test_gnunet_fs_rec_data.tgz') | 58 | os.system ('tar xfz test_gnunet_fs_rec_data.tgz') |
59 | # first, basic publish-search-download run | ||
29 | try: | 60 | try: |
30 | pub = pexpect.spawn ('gnunet-publish -c test_gnunet_fs_rec_data.conf -d -k testdir dir/') | 61 | pub = pexpect () |
31 | pub.expect ('Publishing `dir/\' done.\r') | 62 | pub.spawn (None, [publish, '-c', 'test_gnunet_fs_rec_data.conf', '-d', '-k', 'testdir', 'dir/'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
32 | pub.expect ("URI is `gnunet://fs/chk/M2I80IUI2DM4L6G93KL15AHAO7MIMS5JKP1L3LQFVN50CT7AKRQDSF594BC9TD97JJIT3COF6B5O524CMIOG9EJO8UK1560M54JRI70.GBRE5M4QJ7NA0QIN88FMSC78NNOQMVT5DH8FP37OIR5SGGHFEB9ESDNBRKT9PFE9N2GOI81UN8GGBR6KH9GRTV1T04JFSJURF2U0VE8.20182'.") | 63 | pub.expect ("stdout", re.compile (r"Publishing `dir/' done\.\r?\n")) |
33 | pub.expect (pexpect.EOF) | 64 | pub.expect ("stdout", re.compile (r"URI is `gnunet://fs/chk/M2I80IUI2DM4L6G93KL15AHAO7MIMS5JKP1L3LQFVN50CT7AKRQDSF594BC9TD97JJIT3COF6B5O524CMIOG9EJO8UK1560M54JRI70\.GBRE5M4QJ7NA0QIN88FMSC78NNOQMVT5DH8FP37OIR5SGGHFEB9ESDNBRKT9PFE9N2GOI81UN8GGBR6KH9GRTV1T04JFSJURF2U0VE8\.20182'\.\r?\n")) |
34 | 65 | ||
35 | down = pexpect.spawn ('gnunet-download -c test_gnunet_fs_rec_data.conf -R -o rdir.gnd gnunet://fs/chk/M2I80IUI2DM4L6G93KL15AHAO7MIMS5JKP1L3LQFVN50CT7AKRQDSF594BC9TD97JJIT3COF6B5O524CMIOG9EJO8UK1560M54JRI70.GBRE5M4QJ7NA0QIN88FMSC78NNOQMVT5DH8FP37OIR5SGGHFEB9ESDNBRKT9PFE9N2GOI81UN8GGBR6KH9GRTV1T04JFSJURF2U0VE8.20182') | 66 | down = pexpect () |
36 | down.expect (re.compile ("Downloading `rdir.gnd\' done \(.*\).\r")); | 67 | down.spawn (None, [download, '-c', 'test_gnunet_fs_rec_data.conf', '-R', '-o', 'rdir.gnd', 'gnunet://fs/chk/M2I80IUI2DM4L6G93KL15AHAO7MIMS5JKP1L3LQFVN50CT7AKRQDSF594BC9TD97JJIT3COF6B5O524CMIOG9EJO8UK1560M54JRI70.GBRE5M4QJ7NA0QIN88FMSC78NNOQMVT5DH8FP37OIR5SGGHFEB9ESDNBRKT9PFE9N2GOI81UN8GGBR6KH9GRTV1T04JFSJURF2U0VE8.20182'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
37 | down.expect (pexpect.EOF); | 68 | down.expect ("stdout", re.compile (r"Downloading `rdir.gnd' done (.*).\r?\n")) |
38 | 69 | ||
39 | dir = pexpect.spawn ('gnunet-directory -c test_gnunet_fs_rec_data.conf rdir/a.gnd') | 70 | d = pexpect () |
40 | dir.expect (re.compile ("Directory `a/' meta data:")); | 71 | d.spawn (None, [directory, '-c', 'test_gnunet_fs_rec_data.conf', 'rdir/a.gnd'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
41 | dir.expect (re.compile ("Directory `a/' contents:")); | 72 | d.expect ("stdout", re.compile (r"Directory `a/' meta data:\r?\n")) |
42 | dir.expect (re.compile ("COPYING (.*)")); | 73 | d.expect ("stdout", re.compile (r"Directory `a/' contents:\r?\n")) |
43 | dir.expect (re.compile ("INSTALL (.*)")); | 74 | d.expect ("stdout", re.compile (r"COPYING (.*)\r?\n")) |
44 | dir.expect (pexpect.EOF) | 75 | d.expect ("stdout", re.compile (r"INSTALL (.*)\r?\n")) |
45 | 76 | ||
46 | os.system ('rm -r rdir/b.gnd rdir/a.gnd') | 77 | os.remove ("rdir/b.gnd") |
47 | if (0 != os.system ("diff -r dir rdir")): | 78 | os.remove ("rdir/a.gnd") |
79 | if 0 != os.system ("diff -r dir rdir"): | ||
48 | raise Exception ("Unexpected difference between source directory and downloaded result") | 80 | raise Exception ("Unexpected difference between source directory and downloaded result") |
49 | 81 | ||
82 | |||
50 | finally: | 83 | finally: |
51 | os.system ('gnunet-arm -c test_gnunet_fs_rec_data.conf -eq') | 84 | arm = subprocess.Popen ([gnunetarm, '-eq', '-c', 'test_gnunet_fs_rec_data.conf']) |
52 | os.system ('rm -r dir rdir rdir.gnd') | 85 | arm.communicate () |
53 | os.system ('rm -rf /tmp/gnunet-test-fs-py-rec/') | 86 | if os.name == "nt": |
87 | shutil.rmtree (os.path.join (os.getenv ("TEMP"), "gnunet-test-fs-py-rec"), True) | ||
88 | else: | ||
89 | shutil.rmtree ("/tmp/gnunet-test-fs-py-rec", True) | ||
90 | shutil.rmtree ("dir", True) | ||
91 | shutil.rmtree ("rdir", True) | ||
92 | shutil.rmtree ("rdir.gnd", True) | ||