summaryrefslogtreecommitdiffstats
path: root/rubbos/app/httpd-2.0.64/srclib/apr-util/test/data/billion-laughs.xml
diff options
context:
space:
mode:
Diffstat (limited to 'rubbos/app/httpd-2.0.64/srclib/apr-util/test/data/billion-laughs.xml')
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr-util/test/data/billion-laughs.xml36
1 files changed, 36 insertions, 0 deletions
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr-util/test/data/billion-laughs.xml b/rubbos/app/httpd-2.0.64/srclib/apr-util/test/data/billion-laughs.xml
new file mode 100644
index 00000000..3af89ae4
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr-util/test/data/billion-laughs.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<!DOCTYPE billion [
+<!ELEMENT billion (#PCDATA)>
+<!ENTITY laugh0 "ha">
+<!ENTITY laugh1 "&laugh0;&laugh0;">
+<!ENTITY laugh2 "&laugh1;&laugh1;">
+<!ENTITY laugh3 "&laugh2;&laugh2;">
+<!ENTITY laugh4 "&laugh3;&laugh3;">
+<!ENTITY laugh5 "&laugh4;&laugh4;">
+<!ENTITY laugh6 "&laugh5;&laugh5;">
+<!ENTITY laugh7 "&laugh6;&laugh6;">
+<!ENTITY laugh8 "&laugh7;&laugh7;">
+<!ENTITY laugh9 "&laugh8;&laugh8;">
+<!ENTITY laugh10 "&laugh9;&laugh9;">
+<!ENTITY laugh11 "&laugh10;&laugh10;">
+<!ENTITY laugh12 "&laugh11;&laugh11;">
+<!ENTITY laugh13 "&laugh12;&laugh12;">
+<!ENTITY laugh14 "&laugh13;&laugh13;">
+<!ENTITY laugh15 "&laugh14;&laugh14;">
+<!ENTITY laugh16 "&laugh15;&laugh15;">
+<!ENTITY laugh17 "&laugh16;&laugh16;">
+<!ENTITY laugh18 "&laugh17;&laugh17;">
+<!ENTITY laugh19 "&laugh18;&laugh18;">
+<!ENTITY laugh20 "&laugh19;&laugh19;">
+<!ENTITY laugh21 "&laugh20;&laugh20;">
+<!ENTITY laugh22 "&laugh21;&laugh21;">
+<!ENTITY laugh23 "&laugh22;&laugh22;">
+<!ENTITY laugh24 "&laugh23;&laugh23;">
+<!ENTITY laugh25 "&laugh24;&laugh24;">
+<!ENTITY laugh26 "&laugh25;&laugh25;">
+<!ENTITY laugh27 "&laugh26;&laugh26;">
+<!ENTITY laugh28 "&laugh27;&laugh27;">
+<!ENTITY laugh29 "&laugh28;&laugh28;">
+<!ENTITY laugh30 "&laugh29;&laugh29;">
+]>
+<billion>&laugh30;</billion>
hlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #a6e22e } /* Name.Function.Magic */ .highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ } @media (prefers-color-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
# Copyright 2016 Cisco Systems, Inc.  All rights reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

import os
import subprocess
import yaml

from .log import LOG


class TrafficServerException(Exception):
    pass

class TrafficServer(object):
    """Base class for traffic servers."""

class TRexTrafficServer(TrafficServer):
    """Creates configuration file for TRex and runs server."""

    def __init__(self, trex_base_dir='/opt/trex'):
        contents = os.listdir(trex_base_dir)
        # only one version of TRex should be supported in container
        assert len(contents) == 1
        self.trex_dir = os.path.join(trex_base_dir, contents[0])

    def run_server(self, generator_config, filename='/etc/trex_cfg.yaml'):
        """Run TRex server for specified traffic profile.

        :param traffic_profile: traffic profile object based on config file
        :param filename: path where to save TRex config file
        """
        cfg = self.__save_config(generator_config, filename)
        cores = generator_config.cores
        vtep_vlan = generator_config.gen_config.get('vtep_vlan')
        sw_mode = "--software" if generator_config.software_mode else ""
        vlan_opt = "--vlan" if (generator_config.vlan_tagging or vtep_vlan) else ""
        if generator_config.mbuf_factor:
            mbuf_opt = "--mbuf-factor " + str(generator_config.mbuf_factor)
        else:
            mbuf_opt = ""
        hdrh_opt = "--hdrh" if generator_config.hdrh else ""
        # --unbind-unused-ports: for NIC that have more than 2 ports such as Intel X710
        # this will instruct trex to unbind all ports that are unused instead of
        # erroring out with an exception (i40e only)
        cmd = ['nohup', '/bin/bash', '-c',
               './t-rex-64 -i -c {} --iom 0 --no-scapy-server '
               '--unbind-unused-ports --close-at-end {} {} '
               '{} {} --cfg {} &> /tmp/trex.log & disown'.format(cores, sw_mode,
                                                                 vlan_opt,
                                                                 hdrh_opt,
                                                                 mbuf_opt, cfg)]
        LOG.info(' '.join(cmd))
        subprocess.Popen(cmd, cwd=self.trex_dir)
        LOG.info('TRex server is running...')

    def __load_config(self, filename):
        result = {}
        if os.path.exists(filename):
            with open(filename, 'r') as stream:
                try:
                    result = yaml.safe_load(stream)
                except yaml.YAMLError as exc:
                    print(exc)
        return result

    def __save_config(self, generator_config, filename):
        result = self.__prepare_config(generator_config)
        yaml.safe_load(result)
        if os.path.exists(filename):
            os.remove(filename)
        with open(filename, 'w') as f:
            f.write(result)
        return filename

    def __prepare_config(self, generator_config):
        ifs = ",".join([repr(pci) for pci in generator_config.pcis])
        result = """# Config generated by NFVbench
        - port_limit : 2
          version    : 2
          zmq_pub_port : {zmq_pub_port}
          zmq_rpc_port : {zmq_rpc_port}
          prefix       : {prefix}
          limit_memory : {limit_memory}
          interfaces : [{ifs}]""".format(zmq_pub_port=generator_config.zmq_pub_port,
                                         zmq_rpc_port=generator_config.zmq_rpc_port,
                                         prefix=generator_config.name,
                                         limit_memory=generator_config.limit_memory,
                                         ifs=ifs)
        if hasattr(generator_config, 'mbuf_64') and generator_config.mbuf_64:
            result += """
          memory       :
            mbuf_64           : {mbuf_64}""".format(mbuf_64=generator_config.mbuf_64)

        if self.__check_platform_config(generator_config):
            try:
                platform = """
          platform     :
            master_thread_id  : {master_thread_id}
            latency_thread_id : {latency_thread_id}
            dual_if:""".format(master_thread_id=generator_config.gen_config.platform.
                               master_thread_id,
                               latency_thread_id=generator_config.gen_config.platform.
                               latency_thread_id)
                result += platform

                for core in generator_config.gen_config.platform.dual_if:
                    threads = ""
                    try:
                        threads = ",".join([repr(thread) for thread in core.threads])
                    except TypeError:
                        LOG.warning("No threads defined for socket %s", core.socket)
                    core_result = """
                  - socket : {socket}
                    threads : [{threads}]""".format(socket=core.socket, threads=threads)
                    result += core_result
            except (KeyError, AttributeError):
                pass
        return result

    def __check_platform_config(self, generator_config):
        return hasattr(generator_config.gen_config, 'platform') \
            and hasattr(generator_config.gen_config.platform, "master_thread_id") \
            and generator_config.gen_config.platform.master_thread_id is not None \
            and hasattr(generator_config.gen_config.platform, "latency_thread_id") \
            and generator_config.gen_config.platform.latency_thread_id is not None

    def check_config_updated(self, generator_config):
        existing_config = self.__load_config(filename='/etc/trex_cfg.yaml')
        new_config = yaml.safe_load(self.__prepare_config(generator_config))
        LOG.debug("Existing config: %s", existing_config)
        LOG.debug("New config: %s", new_config)
        if existing_config == new_config:
            return False
        return True