diff options
Diffstat (limited to 'src/peerinfo-tool/test_gnunet_peerinfo.py.in')
-rwxr-xr-x | src/peerinfo-tool/test_gnunet_peerinfo.py.in | 75 |
1 files changed, 58 insertions, 17 deletions
diff --git a/src/peerinfo-tool/test_gnunet_peerinfo.py.in b/src/peerinfo-tool/test_gnunet_peerinfo.py.in index d07224b14..5d9daa930 100755 --- a/src/peerinfo-tool/test_gnunet_peerinfo.py.in +++ b/src/peerinfo-tool/test_gnunet_peerinfo.py.in | |||
@@ -11,7 +11,7 @@ | |||
11 | # WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | # Affero General Public License for more details. | 13 | # Affero General Public License for more details. |
14 | # | 14 | # |
15 | # You should have received a copy of the GNU Affero General Public License | 15 | # You should have received a copy of the GNU Affero General Public License |
16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | # | 17 | # |
@@ -43,53 +43,94 @@ elif os.name == 'nt': | |||
43 | 43 | ||
44 | pinfo = pexpect() | 44 | pinfo = pexpect() |
45 | 45 | ||
46 | |||
47 | if os.name == "nt": | 46 | if os.name == "nt": |
48 | shutil.rmtree(os.path.join(os.getenv("TEMP"), "gnunet-test-peerinfo"), True) | 47 | shutil.rmtree(os.path.join(os.getenv("TEMP"), "gnunet-test-peerinfo"), True) |
49 | else: | 48 | else: |
50 | shutil.rmtree("/tmp/gnunet-test-peerinfo", True) | 49 | shutil.rmtree("/tmp/gnunet-test-peerinfo", True) |
51 | 50 | ||
52 | # create hostkey via testing lib # FIXME: The /tmp/ location needs to be adjusted to the TMP variable! | 51 | # create hostkey via testing lib # FIXME: The /tmp/ location needs to be adjusted to the TMP variable! |
53 | hkk = subprocess.Popen([gnunettesting, '-n', '1', '-c', 'test_gnunet_peerinfo_data.conf', '-k', '/tmp/gnunet-test-peerinfo/.hostkey']) | 52 | hkk = subprocess.Popen([ |
53 | gnunettesting, '-n', '1', '-c', 'test_gnunet_peerinfo_data.conf', '-k', | ||
54 | '/tmp/gnunet-test-peerinfo/.hostkey' | ||
55 | ]) | ||
54 | hkk.communicate() | 56 | hkk.communicate() |
55 | 57 | ||
56 | arm = subprocess.Popen([gnunetarm, '-sq', '-c', 'test_gnunet_peerinfo_data.conf']) | 58 | arm = subprocess.Popen([ |
59 | gnunetarm, '-sq', '-c', 'test_gnunet_peerinfo_data.conf' | ||
60 | ]) | ||
57 | arm.communicate() | 61 | arm.communicate() |
58 | 62 | ||
59 | try: | 63 | try: |
60 | pinfo.spawn(None, [peerinfo, '-c', 'test_gnunet_peerinfo_data.conf', '-s'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 64 | pinfo.spawn( |
65 | None, [peerinfo, '-c', 'test_gnunet_peerinfo_data.conf', '-s'], | ||
66 | stdout=subprocess.PIPE, | ||
67 | stderr=subprocess.STDOUT | ||
68 | ) | ||
61 | pinfo.expect("stdout", re.compile(r'I am peer `.*\'.\r?\n')) | 69 | pinfo.expect("stdout", re.compile(r'I am peer `.*\'.\r?\n')) |
62 | 70 | ||
63 | pinfo.spawn(None, [peerinfo, '-c', 'test_gnunet_peerinfo_data.conf', '-qs'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 71 | pinfo.spawn( |
64 | pinfo.expect("stdout", re.compile(r'....................................................\r?\n')) | 72 | None, [peerinfo, '-c', 'test_gnunet_peerinfo_data.conf', '-qs'], |
65 | 73 | stdout=subprocess.PIPE, | |
66 | pinfo.spawn(None, [peerinfo, '-c', 'test_gnunet_peerinfo_data.conf', 'invalid'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 74 | stderr=subprocess.STDOUT |
67 | pinfo.expect("stdout", re.compile(r'Invalid command line argument `invalid\'\r?\n')) | 75 | ) |
68 | 76 | pinfo.expect( | |
69 | arm = subprocess.Popen([gnunetarm, '-q', '-i', 'transport', '-c', 'test_gnunet_peerinfo_data.conf']) | 77 | "stdout", |
78 | re. | ||
79 | compile(r'....................................................\r?\n') | ||
80 | ) | ||
81 | |||
82 | pinfo.spawn( | ||
83 | None, [peerinfo, '-c', 'test_gnunet_peerinfo_data.conf', 'invalid'], | ||
84 | stdout=subprocess.PIPE, | ||
85 | stderr=subprocess.STDOUT | ||
86 | ) | ||
87 | pinfo.expect( | ||
88 | "stdout", re.compile(r'Invalid command line argument `invalid\'\r?\n') | ||
89 | ) | ||
90 | |||
91 | arm = subprocess.Popen([ | ||
92 | gnunetarm, '-q', '-i', 'transport', '-c', | ||
93 | 'test_gnunet_peerinfo_data.conf' | ||
94 | ]) | ||
70 | arm.communicate() | 95 | arm.communicate() |
71 | time.sleep(1) | 96 | time.sleep(1) |
72 | 97 | ||
73 | pinfo.spawn(None, [peerinfo, '-i', '-c', 'test_gnunet_peerinfo_data.conf'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 98 | pinfo.spawn( |
99 | None, [peerinfo, '-i', '-c', 'test_gnunet_peerinfo_data.conf'], | ||
100 | stdout=subprocess.PIPE, | ||
101 | stderr=subprocess.STDOUT | ||
102 | ) | ||
74 | pinfo.expect("stdout", re.compile("Peer `.*'\r?\n")) | 103 | pinfo.expect("stdout", re.compile("Peer `.*'\r?\n")) |
75 | m = pinfo.expect("stdout", re.compile("\s.*:24357\r?\n")) | 104 | m = pinfo.expect("stdout", re.compile("\s.*:24357\r?\n")) |
76 | while len(m.group(0)) > 0: | 105 | while len(m.group(0)) > 0: |
77 | m = pinfo.expect("stdout", re.compile("(\s.*:24357\r?\n|\r?\n|)")) | 106 | m = pinfo.expect("stdout", re.compile("(\s.*:24357\r?\n|\r?\n|)")) |
78 | 107 | ||
79 | pinfo.spawn(None, [peerinfo, '-i', '-c', 'test_gnunet_peerinfo_data.conf', '-n'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 108 | pinfo.spawn( |
109 | None, [peerinfo, '-i', '-c', 'test_gnunet_peerinfo_data.conf', '-n'], | ||
110 | stdout=subprocess.PIPE, | ||
111 | stderr=subprocess.STDOUT | ||
112 | ) | ||
80 | pinfo.expect("stdout", re.compile("Peer `.*'\r?\n")) | 113 | pinfo.expect("stdout", re.compile("Peer `.*'\r?\n")) |
81 | m = pinfo.expect("stdout", re.compile("\s.*:24357\r?\n")) | 114 | m = pinfo.expect("stdout", re.compile("\s.*:24357\r?\n")) |
82 | while len(m.group(0)) > 0: | 115 | while len(m.group(0)) > 0: |
83 | m = pinfo.expect("stdout", re.compile("(\s.*:24357\r?\n|\r?\n|)")) | 116 | m = pinfo.expect("stdout", re.compile("(\s.*:24357\r?\n|\r?\n|)")) |
84 | 117 | ||
85 | pinfo.spawn(None, [peerinfo, '-c', 'test_gnunet_peerinfo_data.conf', '-qs'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 118 | pinfo.spawn( |
119 | None, [peerinfo, '-c', 'test_gnunet_peerinfo_data.conf', '-qs'], | ||
120 | stdout=subprocess.PIPE, | ||
121 | stderr=subprocess.STDOUT | ||
122 | ) | ||
86 | pid = pinfo.read("stdout") | 123 | pid = pinfo.read("stdout") |
87 | pid.strip() | 124 | pid.strip() |
88 | 125 | ||
89 | finally: | 126 | finally: |
90 | arm = subprocess.Popen([gnunetarm, '-eq', '-c', 'test_gnunet_peerinfo_data.conf']) | 127 | arm = subprocess.Popen([ |
128 | gnunetarm, '-eq', '-c', 'test_gnunet_peerinfo_data.conf' | ||
129 | ]) | ||
91 | arm.communicate() | 130 | arm.communicate() |
92 | if os.name == "nt": | 131 | if os.name == "nt": |
93 | shutil.rmtree(os.path.join(os.getenv("TEMP"), "gnunet-test-peerinfo"), True) | 132 | shutil.rmtree( |
133 | os.path.join(os.getenv("TEMP"), "gnunet-test-peerinfo"), True | ||
134 | ) | ||
94 | else: | 135 | else: |
95 | shutil.rmtree("/tmp/gnunet-test-peerinfo", True) | 136 | shutil.rmtree("/tmp/gnunet-test-peerinfo", True) |