summaryrefslogtreecommitdiff
path: root/src/fs/test_gnunet_fs_rec.py.in
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/test_gnunet_fs_rec.py.in')
-rwxr-xr-xsrc/fs/test_gnunet_fs_rec.py.in90
1 files changed, 74 insertions, 16 deletions
diff --git a/src/fs/test_gnunet_fs_rec.py.in b/src/fs/test_gnunet_fs_rec.py.in
index 0f881564f..0e1512b26 100755
--- a/src/fs/test_gnunet_fs_rec.py.in
+++ b/src/fs/test_gnunet_fs_rec.py.in
@@ -50,7 +50,9 @@ elif os.name == 'nt':
50 directory = './gnunet-directory.exe' 50 directory = './gnunet-directory.exe'
51 51
52if os.name == "nt": 52if os.name == "nt":
53 shutil.rmtree(os.path.join(os.getenv("TEMP"), "gnunet-test-fs-py-rec"), True) 53 shutil.rmtree(
54 os.path.join(os.getenv("TEMP"), "gnunet-test-fs-py-rec"), True
55 )
54else: 56else:
55 shutil.rmtree("/tmp/gnunet-test-fs-py-rec", True) 57 shutil.rmtree("/tmp/gnunet-test-fs-py-rec", True)
56 58
@@ -65,33 +67,83 @@ tar.extractall()
65# first, basic publish-search-download run 67# first, basic publish-search-download run
66try: 68try:
67 pub = pexpect() 69 pub = pexpect()
68 pub.spawn(None, [publish, '-c', 'test_gnunet_fs_rec_data.conf', '-k', 'testdir', 'dir/'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 70 pub.spawn(
71 None, [
72 publish, '-c', 'test_gnunet_fs_rec_data.conf', '-k', 'testdir',
73 'dir/'
74 ],
75 stdout=subprocess.PIPE,
76 stderr=subprocess.STDOUT
77 )
69 # Can't say much for publishing, except that the last one is the toplevel directory 78 # Can't say much for publishing, except that the last one is the toplevel directory
70 pub.expect("stdout", re.compile(r"Publishing `.+' done\.\r?\n")) 79 pub.expect("stdout", re.compile(r"Publishing `.+' done\.\r?\n"))
71 pub.expect("stdout", re.compile(r"URI is `gnunet://fs/chk/[A-Z0-9]{103}\.[A-Z0-9]{103}\.\d+'\.\r?\n")) 80 pub.expect(
81 "stdout",
82 re.compile(
83 r"URI is `gnunet://fs/chk/[A-Z0-9]{103}\.[A-Z0-9]{103}\.\d+'\.\r?\n"
84 )
85 )
72 pub.expect("stdout", re.compile(r"Publishing `.+' done\.\r?\n")) 86 pub.expect("stdout", re.compile(r"Publishing `.+' done\.\r?\n"))
73 pub.expect("stdout", re.compile(r"URI is `gnunet://fs/chk/[A-Z0-9]{103}\.[A-Z0-9]{103}\.\d+'\.\r?\n")) 87 pub.expect(
88 "stdout",
89 re.compile(
90 r"URI is `gnunet://fs/chk/[A-Z0-9]{103}\.[A-Z0-9]{103}\.\d+'\.\r?\n"
91 )
92 )
74 pub.expect("stdout", re.compile(r"Publishing `.+' done\.\r?\n")) 93 pub.expect("stdout", re.compile(r"Publishing `.+' done\.\r?\n"))
75 pub.expect("stdout", re.compile(r"URI is `gnunet://fs/chk/[A-Z0-9]{103}\.[A-Z0-9]{103}\.\d+'\.\r?\n")) 94 pub.expect(
95 "stdout",
96 re.compile(
97 r"URI is `gnunet://fs/chk/[A-Z0-9]{103}\.[A-Z0-9]{103}\.\d+'\.\r?\n"
98 )
99 )
76 pub.expect("stdout", re.compile(r"Publishing `.+' done\.\r?\n")) 100 pub.expect("stdout", re.compile(r"Publishing `.+' done\.\r?\n"))
77 pub.expect("stdout", re.compile(r"URI is `gnunet://fs/chk/[A-Z0-9]{103}\.[A-Z0-9]{103}\.\d+'\.\r?\n")) 101 pub.expect(
102 "stdout",
103 re.compile(
104 r"URI is `gnunet://fs/chk/[A-Z0-9]{103}\.[A-Z0-9]{103}\.\d+'\.\r?\n"
105 )
106 )
78 pub.expect("stdout", re.compile(r"Publishing `.+' done\.\r?\n")) 107 pub.expect("stdout", re.compile(r"Publishing `.+' done\.\r?\n"))
79 pub.expect("stdout", re.compile(r"URI is `gnunet://fs/chk/[A-Z0-9]{103}\.[A-Z0-9]{103}\.\d+'\.\r?\n")) 108 pub.expect(
109 "stdout",
110 re.compile(
111 r"URI is `gnunet://fs/chk/[A-Z0-9]{103}\.[A-Z0-9]{103}\.\d+'\.\r?\n"
112 )
113 )
80 pub.expect("stdout", re.compile(r"Publishing `.+' done\.\r?\n")) 114 pub.expect("stdout", re.compile(r"Publishing `.+' done\.\r?\n"))
81 pub.expect("stdout", re.compile(r"URI is `gnunet://fs/chk/[A-Z0-9]{103}\.[A-Z0-9]{103}\.\d+'\.\r?\n")) 115 pub.expect(
82 pub.expect("stdout", re.compile(r"Publishing `.+[\\/]dir[\\/]' done\.\r?\n")) 116 "stdout",
117 re.compile(
118 r"URI is `gnunet://fs/chk/[A-Z0-9]{103}\.[A-Z0-9]{103}\.\d+'\.\r?\n"
119 )
120 )
121 pub.expect(
122 "stdout", re.compile(r"Publishing `.+[\\/]dir[\\/]' done\.\r?\n")
123 )
83 m = pub.expect("stdout", re.compile(r".+\r?\n")) 124 m = pub.expect("stdout", re.compile(r".+\r?\n"))
84 if not m: 125 if not m:
85 sys.exit(3) 126 sys.exit(3)
86 output = m.string 127 output = m.string
87 url = output[output.find("`")+1:output.find("'")] 128 url = output[output.find("`") + 1:output.find("'")]
88 129
89 down = pexpect() 130 down = pexpect()
90 down.spawn(None, [download, '-c', 'test_gnunet_fs_rec_data.conf', '-R', '-o', 'rdir.gnd', url], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 131 down.spawn(
132 None, [
133 download, '-c', 'test_gnunet_fs_rec_data.conf', '-R', '-o',
134 'rdir.gnd', url
135 ],
136 stdout=subprocess.PIPE,
137 stderr=subprocess.STDOUT
138 )
91 down.expect("stdout", re.compile(r"Downloading `rdir.gnd' done (.*).\r?\n")) 139 down.expect("stdout", re.compile(r"Downloading `rdir.gnd' done (.*).\r?\n"))
92 140
93 d = pexpect() 141 d = pexpect()
94 d.spawn(None, [directory, '-c', 'test_gnunet_fs_rec_data.conf', 'rdir/a.gnd'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 142 d.spawn(
143 None, [directory, '-c', 'test_gnunet_fs_rec_data.conf', 'rdir/a.gnd'],
144 stdout=subprocess.PIPE,
145 stderr=subprocess.STDOUT
146 )
95 d.expect("stdout", re.compile(r"Directory `a/' meta data:\r?\n")) 147 d.expect("stdout", re.compile(r"Directory `a/' meta data:\r?\n"))
96 d.expect("stdout", re.compile(r"Directory `a/' contents:\r?\n")) 148 d.expect("stdout", re.compile(r"Directory `a/' contents:\r?\n"))
97 d.expect("stdout", re.compile(r"COPYING (.*)\r?\n")) 149 d.expect("stdout", re.compile(r"COPYING (.*)\r?\n"))
@@ -101,14 +153,20 @@ try:
101 os.remove("rdir/a.gnd") 153 os.remove("rdir/a.gnd")
102 diff = dcdiff('dir', 'rdir') 154 diff = dcdiff('dir', 'rdir')
103 if len(diff) != 0: 155 if len(diff) != 0:
104 raise Exception("Unexpected difference between source directory and downloaded result:\n{}".format(diff)) 156 raise Exception(
105 157 "Unexpected difference between source directory and downloaded result:\n{}"
158 .format(diff)
159 )
106 160
107finally: 161finally:
108 arm = subprocess.Popen([gnunetarm, '-eq', '-c', 'test_gnunet_fs_rec_data.conf']) 162 arm = subprocess.Popen([
163 gnunetarm, '-eq', '-c', 'test_gnunet_fs_rec_data.conf'
164 ])
109 arm.communicate() 165 arm.communicate()
110 if os.name == "nt": 166 if os.name == "nt":
111 shutil.rmtree(os.path.join(os.getenv("TEMP"), "gnunet-test-fs-py-rec"), True) 167 shutil.rmtree(
168 os.path.join(os.getenv("TEMP"), "gnunet-test-fs-py-rec"), True
169 )
112 else: 170 else:
113 shutil.rmtree("/tmp/gnunet-test-fs-py-rec", True) 171 shutil.rmtree("/tmp/gnunet-test-fs-py-rec", True)
114 shutil.rmtree("dir", True) 172 shutil.rmtree("dir", True)