spectrum2/tests/runtests.py

60 lines
1.2 KiB
Python
Raw Normal View History

2011-06-07 15:31:52 +02:00
import os
import sys
from subprocess import *
import time
def run_spectrum(backend):
f = open("sample.cfg", "w")
f.write("\
[service]\n\
jid = localhost\n\
password = secret\n\
server = 127.0.0.1\n\
port = 5222\n\
server_mode = 1\n\
backend=../backends/%s/%s_backend\n\
protocol=prpl-jabber\n\
\
[database]\n\
database = test.sql\n\
prefix=icq\n\
" % (backend, backend)
)
f.close()
2011-06-08 13:17:09 +02:00
p = Popen("../spectrum/src/spectrum sample.cfg >> test.log 2> /dev/null", shell=True)
time.sleep(2)
2011-06-07 15:31:52 +02:00
return p
os.system("killall spectrum 2> /dev/null")
2011-06-08 13:17:09 +02:00
os.system("rm test.log")
2011-06-07 15:31:52 +02:00
for backend in os.listdir("../backends"):
if not os.path.isdir("../backends/" + backend) or backend == "CMakeFiles":
continue
for d in os.listdir("."):
binary = d + "/" + d + "_test"
if not os.path.exists(binary):
continue
p = run_spectrum(backend);
if backend.find("purple") >= 0:
2011-06-08 13:17:09 +02:00
p = Popen(binary + " pyjim%jabber.cz@localhost test", shell=True)
2011-06-07 15:31:52 +02:00
else:
2011-06-08 13:17:09 +02:00
p = Popen(binary + " testnickname%irc.freenode.net@localhost test", shell=True)
time.sleep(5)
p.poll()
if p.returncode == 0:
2011-06-07 15:31:52 +02:00
print "[ PASS ]", backend, binary
else:
print "[ FAIL ]", backend, binary
os.system("killall spectrum 2> /dev/null")