-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.py
More file actions
executable file
·26 lines (24 loc) · 1.08 KB
/
tests.py
File metadata and controls
executable file
·26 lines (24 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python
import subprocess;
import os;
from subprocess import Popen;
def check(args, expected_code, expected_texts):
cmd = "./vrun " + args
p = Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE);
code = p.wait();
out, err = p.communicate();
all = out + err
if code != expected_code:
raise Exception("command '%s' exited with status %s, expected %s. Output:\n%s\n" % ( cmd, code, expected_code, all))
for e in expected_texts:
if not e in all:
raise Exception("expected \n===\n%s\n===\nin command output: \n===\n%s\n===\n" % (e, all))
return (cmd, out, err)
# no arguments
print check("target/bin/getaddrinfo -h", 2, ["target/bin/getaddrinfo: network address and service translation"])
# non-existent
print check("target/bin/getaddrinfo localhost", 0, ["AF_INET\tSOCK_STREAM\tIPPROTO_TCP\t127.0.0.1"]);
print check("target/bin/gethostbyname localhost", 0, ["hostname: localhost", "address: 127.0.0.1"]);
print check("target/bin/gethostbyname2 localhost", 0, ["hostname: localhost", "address: 127.0.0.1"]);
# multi-level alias
print "OK"