Changeset 0f65ea9 in mod_gnutls


Ignore:
Timestamp:
Jan 3, 2020, 5:05:34 AM (3 months ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
master
Children:
905063e
Parents:
076049a
Message:

Use post_check hook in 28_HTTP2_support

Location:
test
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • test/mgstest/__init__.py

    r076049a r0f65ea9  
    11#!/usr/bin/python3
    22
    3 # Copyright 2019 Fiona Klute
     3# Copyright 2019-2020 Fiona Klute
    44#
    55# Licensed under the Apache License, Version 2.0 (the "License");
     
    6767            return m
    6868    return None
     69
     70
     71
     72def require_match(regexp, file, error_message=None):
     73    """Return the first match of the regular expression in file (by line),
     74    or raise TestExpectationFailed.
     75
     76    If error_message is not None the exception message will be that
     77    string, otherwise a generic message containing the regular
     78    expression pattern. Technically applicable to any iterable
     79    containing strings, not just files opened for reading.
     80
     81    """
     82    m = first_line_match(regexp, file)
     83    if m:
     84        return m
     85
     86    if error_message:
     87        raise TestExpectationFailed(error_message)
     88    else:
     89        raise TestExpectationFailed(f'No match found for {regexp.pattern}!')
  • test/test-28_HTTP2_support.bash

    r076049a r0f65ea9  
    1414fi
    1515
    16 # expected output files
    17 log="outputs/28_HTTP2_support.log"
    18 output="outputs/28_HTTP2_support.output"
    19 
    20 ${srcdir}/netns_py.bash ${srcdir}/runtest.py --test-number 28 \
    21          --log-connection "${log}" --log-responses "${output}"
    22 
    23 echo "Checking for HTTP/2 in logged header:"
    24 grep "HTTP/2 200" "${log}"
    25 echo "Checking for TLS session status:"
    26 grep "Current TLS session: (TLS" "${output}"
     16. ${srcdir}/netns_py.bash ${srcdir}/runtest.py --test-number 28
  • test/tests/28_HTTP2_support/hooks.py

    r076049a r0f65ea9  
    11import os
     2import re
    23import subprocess
     4from mgstest import require_match
    35
    46def run_connection(testname, conn_log, response_log):
     
    1517    print(proc.stdout)
    1618    print(proc.stdout, file=response_log)
     19
     20def post_check(conn_log, response_log):
     21    print('Checking for HTTP/2 in logged header:')
     22    print(require_match(re.compile(r'\bHTTP/2 200\b'), conn_log).group(0))
     23    print('Checking for TLS session status:')
     24    print(require_match(re.compile(r'^Current TLS session:\s\(TLS.*$'),
     25                        response_log)
     26          .group(0))
Note: See TracChangeset for help on using the changeset viewer.