Add a test overview, extract constants
To let the user know that tests produce logs, include a message at the end of the test output informing about locations of E2E and Mailgate logs. Also, extract some constants.
This commit is contained in:
parent
f1a799d864
commit
ff3f6aa793
1 changed files with 31 additions and 22 deletions
|
@ -1,5 +1,24 @@
|
|||
#!/usr/local/bin/python2
|
||||
|
||||
#
|
||||
# gpg-mailgate
|
||||
#
|
||||
# This file is part of the gpg-mailgate source code.
|
||||
#
|
||||
# gpg-mailgate is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# gpg-mailgate source code is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with gpg-mailgate source code. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
@ -10,13 +29,12 @@ import logging
|
|||
|
||||
from time import sleep
|
||||
|
||||
EOL = "\n"
|
||||
|
||||
DELAY = 3
|
||||
|
||||
RELAY_SCRIPT = "test/relay.py"
|
||||
CONFIG_FILE = "test/gpg-mailgate.conf"
|
||||
|
||||
KEY_HOME = "test/keyhome"
|
||||
CERT_HOME = "test/certs"
|
||||
|
||||
PYTHON_BIN = "python2.7"
|
||||
|
||||
def build_config(config):
|
||||
|
@ -61,17 +79,6 @@ def load_file(name):
|
|||
|
||||
return contents
|
||||
|
||||
def strip_eols(strings):
|
||||
return map(lambda s: s.strip("\r"), strings)
|
||||
|
||||
def compare(result, expected):
|
||||
result_lines = strip_eols(result.split(EOL))
|
||||
expected_lines = strip_eols(expected.split(EOL))
|
||||
|
||||
return difflib.unified_diff(expected_lines, result_lines,
|
||||
fromfile='expected',
|
||||
tofile='output')
|
||||
|
||||
def report_result(message_file, expected, test_output):
|
||||
status = None
|
||||
if expected in test_output:
|
||||
|
@ -95,10 +102,10 @@ def execute_e2e_test(message_file, expected, **kwargs):
|
|||
message_file)
|
||||
result_command = "%s %s %d" % (PYTHON_BIN, RELAY_SCRIPT, kwargs["port"])
|
||||
|
||||
logging.debug("Spawning: '%s'" % (result_command))
|
||||
logging.debug("Spawning relay: '%s'" % (result_command))
|
||||
pipe = os.popen(result_command, 'r')
|
||||
|
||||
logging.debug("Spawning: '%s'" % (test_command))
|
||||
logging.debug("Spawning GPG-Lacre: '%s'" % (test_command))
|
||||
msgin = os.popen(test_command, 'w')
|
||||
msgin.write(load_file(message_file))
|
||||
msgin.close()
|
||||
|
@ -118,8 +125,10 @@ def load_test_config():
|
|||
|
||||
|
||||
config = load_test_config()
|
||||
log_paths = {"e2e": "test/logs/e2e.log",
|
||||
"lacre": "test/logs/gpg-mailgate.log"}
|
||||
|
||||
logging.basicConfig(filename = "test/logs/e2e.log",
|
||||
logging.basicConfig(filename = log_paths["e2e"],
|
||||
format = "%(asctime)s %(pathname)s:%(lineno)d %(levelname)s [%(funcName)s] %(message)s",
|
||||
datefmt = "%Y-%m-%d %H:%M:%S",
|
||||
level = logging.DEBUG)
|
||||
|
@ -128,9 +137,9 @@ config_path = os.getcwd() + "/" + CONFIG_FILE
|
|||
|
||||
write_test_config(config_path,
|
||||
port = config.getint("relay", "port"),
|
||||
gpg_keyhome = "test/keyhome",
|
||||
smime_certpath = "test/certs",
|
||||
log_file = "test/logs/gpg-mailgate.log")
|
||||
gpg_keyhome = KEY_HOME,
|
||||
smime_certpath = CERT_HOME,
|
||||
log_file = log_paths["lacre"])
|
||||
|
||||
for case_no in range(1, config.getint("tests", "cases")+1):
|
||||
case_name = "case-%d" % (case_no)
|
||||
|
@ -142,4 +151,4 @@ for case_no in range(1, config.getint("tests", "cases")+1):
|
|||
to_addr = config.get(case_name, "to"),
|
||||
port = config.getint("relay", "port"))
|
||||
|
||||
# sleep(DELAY)
|
||||
print "See diagnostic output for details. Tests: '%s', Lacre: '%s'" % (log_paths["e2e"], log_paths["lacre"])
|
||||
|
|
Loading…
Reference in a new issue