aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorNils Gillmann <ng0@n0.is>2018-05-22 11:45:12 +0000
committerNils Gillmann <ng0@n0.is>2018-05-22 11:45:12 +0000
commit4cf7409d7a69e3e844c3b9ddd52f63f4c1298835 (patch)
treee5fff497686bc06c62fb94bcc3f803379ac0d046 /src/fs
parent66a93ec67a223a189bb62fe08a4e1cdc2077ad03 (diff)
downloadgnunet-4cf7409d7a69e3e844c3b9ddd52f63f4c1298835.tar.gz
gnunet-4cf7409d7a69e3e844c3b9ddd52f63f4c1298835.zip
text_gnunet_fs_psd.py.in: Fix loading pxpect + flake8'ism
Signed-off-by: Nils Gillmann <ng0@n0.is>
Diffstat (limited to 'src/fs')
-rwxr-xr-xsrc/fs/test_gnunet_fs_psd.py.in67
1 files changed, 34 insertions, 33 deletions
diff --git a/src/fs/test_gnunet_fs_psd.py.in b/src/fs/test_gnunet_fs_psd.py.in
index 601797c82..b27a24c84 100755
--- a/src/fs/test_gnunet_fs_psd.py.in
+++ b/src/fs/test_gnunet_fs_psd.py.in
@@ -29,59 +29,60 @@ except NameError:
29 # python3.4: 29 # python3.4:
30 from importlib import reload 30 from importlib import reload
31 31
32
32# Force encoding to utf-8, as this test otherwise fails 33# Force encoding to utf-8, as this test otherwise fails
33# on some systems (see #5094). 34# on some systems (see #5094).
34reload(sys) 35reload(sys)
35sys.setdefaultencoding('utf8') 36sys.setdefaultencoding('utf8')
36 37
37srcdir = "../.." 38srcdir = "../.."
38gnunet_pyexpect_dir = os.path.join (srcdir, "contrib") 39gnunet_pyexpect_dir = os.path.join (srcdir, "contrib/scripts")
39if gnunet_pyexpect_dir not in sys.path: 40if gnunet_pyexpect_dir not in sys.path:
40 sys.path.append (gnunet_pyexpect_dir) 41 sys.path.append(gnunet_pyexpect_dir)
41 42
42from gnunet_pyexpect import pexpect 43from gnunet_pyexpect import pexpect
43 44
44if os.name == 'posix': 45if os.name == 'posix':
45 download = './gnunet-download' 46 download = './gnunet-download'
46 gnunetarm = 'gnunet-arm' 47 gnunetarm = 'gnunet-arm'
47 publish = './gnunet-publish' 48 publish = './gnunet-publish'
48 unindex = './gnunet-unindex' 49 unindex = './gnunet-unindex'
49 search = './gnunet-search' 50 search = './gnunet-search'
50elif os.name == 'nt': 51elif os.name == 'nt':
51 download = './gnunet-download.exe' 52 download = './gnunet-download.exe'
52 gnunetarm = 'gnunet-arm.exe' 53 gnunetarm = 'gnunet-arm.exe'
53 publish = './gnunet-publish.exe' 54 publish = './gnunet-publish.exe'
54 unindex = './gnunet-unindex.exe' 55 unindex = './gnunet-unindex.exe'
55 search = './gnunet-search.exe' 56 search = './gnunet-search.exe'
56 57
57if os.name == "nt": 58if os.name == "nt":
58 shutil.rmtree (os.path.join (os.getenv ("TEMP"), "gnunet-test-fs-py-psd"), True) 59 shutil.rmtree(os.path.join(os.getenv("TEMP"), "gnunet-test-fs-py-psd"), True)
59else: 60else:
60 shutil.rmtree ("/tmp/gnunet-test-fs-py-psd", True) 61 shutil.rmtree("/tmp/gnunet-test-fs-py-psd", True)
61 62
62arm = subprocess.Popen ([gnunetarm, '-sq', '-c', 'test_gnunet_fs_psd_data.conf']) 63arm = subprocess.Popen([gnunetarm, '-sq', '-c', 'test_gnunet_fs_psd_data.conf'])
63arm.communicate () 64arm.communicate()
64 65
65# first, basic publish-search-download run 66# first, basic publish-search-download run
66try: 67try:
67 pub = pexpect () 68 pub = pexpect()
68 pub.spawn (None, [publish, '-c', 'test_gnunet_fs_psd_data.conf', '-n', '-m', "description:Test archive", '-k', 'tst', 'test_gnunet_fs_rec_data.tgz'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 69 pub.spawn(None, [publish, '-c', 'test_gnunet_fs_psd_data.conf', '-n', '-m', "description:Test archive", '-k', 'tst', 'test_gnunet_fs_rec_data.tgz'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
69 pub.expect ("stdout", re.compile (r"Publishing `.+test_gnunet_fs_rec_data.tgz' done\.\r?\n")) 70 pub.expect("stdout", re.compile(r"Publishing `.+test_gnunet_fs_rec_data.tgz' done\.\r?\n"))
70 pub.expect ("stdout", re.compile (r"URI is `gnunet://fs/chk/2ZMHKPV74CB6GB1GFKQRR95BXJQA2SER25FN48GAW7WSBPA0GDEM5Y74V1ZJHM0NA6919TVW376BHTFDRE3RYS0KRY92M1QJVKPHFCR\.49BT3V5C10KA1695JF71FCT8ZZG4JMJSH04BD9CT22R6KEM915A7CEST17RD0QYTHXV5M4HHEGJMEZSFRDB7JAYC0EMJAN2V781E9DG\.17822'\.\r?\n")) 71 pub.expect("stdout", re.compile(r"URI is `gnunet://fs/chk/2ZMHKPV74CB6GB1GFKQRR95BXJQA2SER25FN48GAW7WSBPA0GDEM5Y74V1ZJHM0NA6919TVW376BHTFDRE3RYS0KRY92M1QJVKPHFCR\.49BT3V5C10KA1695JF71FCT8ZZG4JMJSH04BD9CT22R6KEM915A7CEST17RD0QYTHXV5M4HHEGJMEZSFRDB7JAYC0EMJAN2V781E9DG\.17822'\.\r?\n"))
71 72
72 s = pexpect () 73 s = pexpect()
73 s.spawn (None, [search, '-V', '-t', '1000 ms', '-N', '1', '-c', 'test_gnunet_fs_psd_data.conf', 'tst'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 74 s.spawn(None, [search, '-V', '-t', '1000 ms', '-N', '1', '-c', 'test_gnunet_fs_psd_data.conf', 'tst'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
74 s.expect ("stdout", re.compile (r'gnunet-download -o "test_gnunet_fs_rec_data.tgz" gnunet://fs/chk/2ZMHKPV74CB6GB1GFKQRR95BXJQA2SER25FN48GAW7WSBPA0GDEM5Y74V1ZJHM0NA6919TVW376BHTFDRE3RYS0KRY92M1QJVKPHFCR\.49BT3V5C10KA1695JF71FCT8ZZG4JMJSH04BD9CT22R6KEM915A7CEST17RD0QYTHXV5M4HHEGJMEZSFRDB7JAYC0EMJAN2V781E9DG\.17822\r?\n')) 75 s.expect("stdout", re.compile(r'gnunet-download -o "test_gnunet_fs_rec_data.tgz" gnunet://fs/chk/2ZMHKPV74CB6GB1GFKQRR95BXJQA2SER25FN48GAW7WSBPA0GDEM5Y74V1ZJHM0NA6919TVW376BHTFDRE3RYS0KRY92M1QJVKPHFCR\.49BT3V5C10KA1695JF71FCT8ZZG4JMJSH04BD9CT22R6KEM915A7CEST17RD0QYTHXV5M4HHEGJMEZSFRDB7JAYC0EMJAN2V781E9DG\.17822\r?\n'))
75 76
76 down = pexpect () 77 down = pexpect()
77 down.spawn (None, [download, '-c', 'test_gnunet_fs_psd_data.conf', '-o', 'test_gnunet_fs_rec_data.tar.gz', 'gnunet://fs/chk/2ZMHKPV74CB6GB1GFKQRR95BXJQA2SER25FN48GAW7WSBPA0GDEM5Y74V1ZJHM0NA6919TVW376BHTFDRE3RYS0KRY92M1QJVKPHFCR.49BT3V5C10KA1695JF71FCT8ZZG4JMJSH04BD9CT22R6KEM915A7CEST17RD0QYTHXV5M4HHEGJMEZSFRDB7JAYC0EMJAN2V781E9DG.17822'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 78 down.spawn(None, [download, '-c', 'test_gnunet_fs_psd_data.conf', '-o', 'test_gnunet_fs_rec_data.tar.gz', 'gnunet://fs/chk/2ZMHKPV74CB6GB1GFKQRR95BXJQA2SER25FN48GAW7WSBPA0GDEM5Y74V1ZJHM0NA6919TVW376BHTFDRE3RYS0KRY92M1QJVKPHFCR.49BT3V5C10KA1695JF71FCT8ZZG4JMJSH04BD9CT22R6KEM915A7CEST17RD0QYTHXV5M4HHEGJMEZSFRDB7JAYC0EMJAN2V781E9DG.17822'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
78 down.expect ("stdout", re.compile (r"Downloading `test_gnunet_fs_rec_data.tar.gz' done (.*).\r?\n")) 79 down.expect("stdout", re.compile(r"Downloading `test_gnunet_fs_rec_data.tar.gz' done (.*).\r?\n"))
79 os.remove ("test_gnunet_fs_rec_data.tar.gz") 80 os.remove("test_gnunet_fs_rec_data.tar.gz")
80 81
81finally: 82finally:
82 arm = subprocess.Popen ([gnunetarm, '-eq', '-c', 'test_gnunet_fs_psd_data.conf']) 83 arm = subprocess.Popen([gnunetarm, '-eq', '-c', 'test_gnunet_fs_psd_data.conf'])
83 arm.communicate () 84 arm.communicate()
84 if os.name == "nt": 85 if os.name == "nt":
85 shutil.rmtree (os.path.join (os.getenv ("TEMP"), "gnunet-test-fs-py-psd"), True) 86 shutil.rmtree(os.path.join(os.getenv("TEMP"), "gnunet-test-fs-py-psd"), True)
86 else: 87 else:
87 shutil.rmtree ("/tmp/gnunet-test-fs-py-psd", True) 88 shutil.rmtree("/tmp/gnunet-test-fs-py-psd", True)