:py:mod:`buildtest.buildsystem.checks` ====================================== .. py:module:: buildtest.buildsystem.checks Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: buildtest.buildsystem.checks.is_metrics_defined buildtest.buildsystem.checks.returncode_check buildtest.buildsystem.checks.runtime_check buildtest.buildsystem.checks.file_regex_check buildtest.buildsystem.checks.regex_check buildtest.buildsystem.checks.is_symlink_check buildtest.buildsystem.checks.exists_check buildtest.buildsystem.checks.is_file_check buildtest.buildsystem.checks.is_dir_check buildtest.buildsystem.checks.convert_metrics buildtest.buildsystem.checks.comparison_check buildtest.buildsystem.checks.contains_check buildtest.buildsystem.checks.assert_range_check buildtest.buildsystem.checks.file_count_check buildtest.buildsystem.checks.linecount_check buildtest.buildsystem.checks.file_linecount_check Attributes ~~~~~~~~~~ .. autoapisummary:: buildtest.buildsystem.checks.logger .. py:data:: logger .. py:function:: is_metrics_defined(builder, name) Returns True if metrics value is defined, otherwise returns False :param builder: An instance of BuilderBase class used for printing the builder name :type builder: buildtest.builders.base.BuilderBase :param name: Name of metric :type name: str .. py:function:: returncode_check(builder) Check status check of ``returncode`` field if specified in status property. :param builder: An instance of BuilderBase class used for printing the builder name :type builder: buildtest.builders.base.BuilderBase .. py:function:: runtime_check(builder) This method will return a boolean (True/False) based on runtime specified in buildspec and check with test runtime. User can specify both `min` and `max`, or just specify `min` or `max`. :param builder: An instance of BuilderBase class used for printing the builder name :type builder: buildtest.builders.base.BuilderBase .. py:function:: file_regex_check(builder) This method will check if file exists and conduct a regular expression check using `re.search `_ method. This method is invoked if ``file_regex`` is defined in ``status`` field. If file doesn't exist we return False. If file exists we read the file and apply regular expression for every file specified in ``file_regex`` field. :param builder: An instance of BuilderBase class used for printing the builder name :type builder: buildtest.builders.base.BuilderBase :returns: Returns True if there is a regex match otherwise returns False. :rtype: bool .. py:function:: regex_check(builder) This method conducts a regular expression check using `re.search `_ with regular expression defined in Buildspec. User must specify an output stream (stdout, stderr) to select when performing regex. In buildtest, this would read the .out or .err file based on stream and run the regular expression to see if there is a match. This method will return a boolean True indicates there is a match otherwise False if ``regex`` object not defined or ``re.search`` doesn't find a match. :param builder: An instance of BuilderBase class used for printing the builder name :type builder: buildtest.builders.base.BuilderBase :returns: Returns True if their is a regex match otherwise returns False. :rtype: bool .. py:function:: is_symlink_check(builder) This method will perform symlink status check for ``is_symlink`` property. Each item is tested for symblolic link and returns a boolean to inform if all items are symbolic links or not. :param builder: An instance of BuilderBase class used for printing the builder name :type builder: buildtest.builders.base.BuilderBase :returns: A boolean for is_symlink status check :rtype: bool .. py:function:: exists_check(builder) This method will perform status check for ``exists`` property. Each value is tested for file existence and returns a boolean to inform if all files exist or not. :param builder: An instance of BuilderBase class used for printing the builder name :type builder: buildtest.builders.base.BuilderBase :returns: A boolean for exists status check :rtype: bool .. py:function:: is_file_check(builder) This method will perform status check for ``is_file`` property. Each item in ``is_file`` is checked by determining if its a file. The return is a single boolean where we perform a logical AND to determine final status check for is_file :param builder: An instance of BuilderBase class used for printing the builder name :type builder: buildtest.builders.base.BuilderBase :returns: A boolean for is_file status check :rtype: bool .. py:function:: is_dir_check(builder) This method will perform status check for ``is_dir`` property. Each item in ``is_dir`` is checked by determining if its a directory. The return is a single boolean where we perform a logical AND to determine final status check for ``is_dir`` :param builder: An instance of BuilderBase class used for printing the builder name :type builder: buildtest.builders.base.BuilderBase :returns: A boolean for ``is_dir`` status check :rtype: bool .. py:function:: convert_metrics(metric_value, dtype) This method will convert input argument ``metric_value`` and ``ref_value`` to the datatype defined by ``dtype`` which can be **int**, **float**, or **str** :param metric_value: Value assigned to metric that is converted to its type defined by dtype :param dtype: A string value which can be 'str', 'int', 'float' :type dtype: str :returns: A tuple consisting of (metric_value, ref_value) :rtype: Tuple .. py:function:: comparison_check(builder, comparison_type) Perform check on comparison operators (>, >=, <, <=, ==, !=). The return is a boolean value that determines if the check has passed. One can specify multiple assert checks to check each metric with its reference value. When multiple items are specified, the operation is a logical **AND** by default, unless ``mode`` is specified and it is `or`, `OR` then the operation is logical **OR**. :param builder: An instance of BuilderBase class used for printing the builder name :type builder: buildtest.builders.base.BuilderBase :param comparison_type: A string value which can be 'ge', 'gt', 'le', 'lt', 'eq', 'ne' that is used to determine which comparison type to perform :type comparison_type: str :returns: True or False for performance check :rtype: bool .. py:function:: contains_check(builder, comparison_type) This method perform check for existence of value in a list of reference values. The ``contains`` or ``not_contains`` property is used to determine if metric value exist in the reference values. The list of assertion is logically **AND** by default, but if ``mode`` is specified then we will perform a logical **OR**. :param builder: An instance of BuilderBase class used for printing the builder name :type builder: buildtest.builders.base.BuilderBase :returns: True or False for performance check ``contains`` :rtype: bool .. py:function:: assert_range_check(builder) This method is perform Assert Range used when ``assert_range`` property is specified in status check. This method will evaluate each metric value with lower and upper bound and store assertion in list. The list of assertion is logically AND which will return a True or False for the status check. :param builder: An instance of BuilderBase class used for printing the builder name :type builder: buildtest.builders.base.BuilderBase :returns: True or False for performance check ``assert_range`` :rtype: bool .. py:function:: file_count_check(builder) This method is used to perform file count check when ``file_count`` property is specified in status check. This method will evaluate the number of files in a directory and compare it with the reference specified via ``count``. The comparison is done using ``==`` operator. :param builder: An instance of BuilderBase class used for printing the builder name :type builder: buildtest.builders.base.BuilderBase :returns: True or False for performance check ``file_count`` :rtype: bool .. py:function:: linecount_check(builder) This method is used to perform line count check when ``linecount`` property is specified :param builder: An instance of BuilderBase class used for printing the builder name :type builder: buildtest.builders.base.BuilderBase .. py:function:: file_linecount_check(builder) This method is used to perform line count check when ``file_linecount`` property is specified :param builder: An instance of BuilderBase class used for printing the builder name :type builder: buildtest.builders.base.BuilderBase