From bcde36dfed549d86077b44e0baca8413fbc34742 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florent=20Thi=C3=A9ry?= <florent.thiery@ubicast.eu> Date: Wed, 8 Feb 2017 10:23:06 +0100 Subject: [PATCH] fix postfix test, fixes #20388 --- tests/test_postfix.py | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/tests/test_postfix.py b/tests/test_postfix.py index de99cc15..15afa1e2 100755 --- a/tests/test_postfix.py +++ b/tests/test_postfix.py @@ -4,34 +4,17 @@ Check that emails can be sent. ''' import os -import re import subprocess import sys if not os.path.exists('/etc/postfix'): print('Postfix dir does not exists, test skipped.') + sys.exit(1) else: # check that postfix listens the port 25 correctly - out = subprocess.check_output('netstat -pant | grep \':25\'', shell=True) - out = out.decode('utf-8') if out else '' - - # netstat -pant output columns are: - # Proto | Recv-Q | Send-Q | Local address | Foreign address | State | PID/Program name - - expected = r'tcp +\d +\d +127\.0\.0\.1:25 +0\.0\.0\.0:\* +LISTEN +[\d]+/master' - found = False - if out: - for line in out.split('\n'): - line = re.sub(r' +', ' ', line) - if line: - if not re.match(expected, line): - print('Unexpected result for postfix listening ports:\n%s' % line) - sys.exit(1) - else: - found = True - - if not found: + status, out = subprocess.getstatusoutput('netstat -pant | grep master | grep 127.0.0.1:25', shell=True) + if status != 0: print('The port 25 is not listened by any process.') sys.exit(1) print('Postfix listening port: OK.') -- GitLab