Exemplo n.º 1
0
class Maker(Test):
    """A vcdMaker specific test class."""
    def __init__(self, node, test_directory):
        """The Maker class constructor.

        Arguments:
        node - The XML node to be read.
        test_directory - The test directory.
        """

        Test.__init__(self, node, test_directory)

        self.command = []
        self.unique_params = {
            'input_file': ['', 'Missing input file'],
            'time_unit': ['', 'Missing time unit'],
            'line_counter': ['', '']
        }

        for element in node.iter(tag='unique'):
            self.unique = Flat(element, self.unique_params)

        self.create_command(test_directory)

    def create_command(self, test_directory):
        """Builds the vcdMaker specific command line."""

        self.command.append('-t')
        self.command.append(self.unique.get_parameter('time_unit'))

        if self.unique.get_parameter('line_counter'):
            self.command.append('-c')
            self.command.append(self.unique.get_parameter('line_counter'))

        self.command.append('-o')
        self.command.append(
            os.path.join(test_directory,
                         self.common.get_parameter('output_file')))
        self.command.append(
            os.path.join(test_directory,
                         self.unique.get_parameter('input_file')))
Exemplo n.º 2
0
class Merge(Test):
    """A vcdMerge specific test class."""
    def __init__(self, node, test_directory):
        """The Merge class constructor.

        Arguments:
        node - The XML node to be read.
        test_directory - The test directory.
        """

        Test.__init__(self, node, test_directory)

        self.command = []
        self.unique_params = {'time_unit': ['', '']}

        for element in node.iter(tag='unique'):
            self.unique = Flat(element, self.unique_params)
            for item in element.iter(tag='sources'):
                self.sources = Sources(item, test_directory)

        self.create_command(test_directory)

    def create_command(self, test_directory):
        """Builds the vcdMerge specific command line."""

        self.command.append('-o')
        self.command.append(
            os.path.join(test_directory,
                         self.common.get_parameter('output_file')))

        if self.unique.get_parameter('time_unit'):
            self.command.append('-t')
            self.command.append(self.unique.get_parameter('time_unit'))

        for source in self.sources.get():
            self.command.append(source.get())
Exemplo n.º 3
0
class Source(object):
    """A class for storing a source specific parameters."""
    def __init__(self, node, test_directory):
        """The Source class constructor.

        Arguments:
        node - The XML node to be read.
        test_directory - The test directory.
        """
        self.parameters = {
            'format': ['', 'Missing source format.'],
            'time_stamp': ['', 'Missing source time stamp.'],
            'time_unit': ['', 'Missing source time unit.'],
            'prefix': ['', ''],
            'line_counter': ['', ''],
            'input_file': ['', 'Missing source input file.']
        }

        self.data = Flat(node, self.parameters)
        self.source = []
        self.create_source(test_directory)

    def create_source(self, test_directory):
        """Builds the list of source parameters."""
        self.source = [
            self.data.get_parameter('format'),
            self.data.get_parameter('time_stamp'),
            self.data.get_parameter('time_unit'),
            self.data.get_parameter('prefix'),
            self.data.get_parameter('line_counter'),
            os.path.join(test_directory, self.data.get_parameter('input_file'))
        ]

    def get(self):
        """Returns the source string to be passed as an argument
        to vcdMerge.
        """

        return ','.join(self.source)