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