

import re
import benchexec.util as util
import benchexec.tools.template


class Tool(benchexec.tools.template.BaseTool):
    """
    Fuzzing with stochastic optimization guided by CMA-ES

    Hynsung Kim, Gidon Ernst
    https://github.com/lazygrey/fuzzing_with_cmaes
    """

    REQUIRED_PATHS = [
        "fuzzer",
        "fuzzer.py",
        "cma",
        "verifiers_bytes",
        "verifiers_real",
    ]

    def executable(self):
        return util.find_executable("fuzzer")

    def version(self, executable):
        return self._version_from_tool(executable)

    def name(self):
        return "CMA-ES Fuzz"

    def get_value_from_output(self, lines, identifier):
        for line in reversed(lines):
            pattern = identifier
            if pattern[-1] != ":":
                pattern += ":"
            match = re.match("^" + pattern + "([^(]*)", line)
            if match and match.group(1):
                return match.group(1).strip()
        return None



import re
import benchexec.tools.template

class Tool(benchexec.tools.template.BaseTool2):
    """
    Fuzzing with stochastic optimization guided by CMA-ES

    Hynsung Kim, Gidon Ernst
    https://github.com/lazygrey/fuzzing_with_cmaes
    """

    REQUIRED_PATHS = [
        "fuzzer",
        "fuzzer.py",
        "cma",
        "verifiers_bytes",
        "verifiers_real",
    ]

    def executable(self, tool_locator):
        return tool_locator.find_executable("fuzzer")

    def version(self, executable):
        return self._version_from_tool(executable)

    def name(self):
        return "CMA-ES Fuzz"

    def get_value_from_output(self, output, identifier):
        for line in reversed(output):
            if line.startswith(identifier):
                return line[len(identifier):]
        return None

Update module to version 2
Update module to version 2

  
  
  import re
- import benchexec.util as util
  import benchexec.tools.template
  
- 
- class Tool(benchexec.tools.template.BaseTool):
+ class Tool(benchexec.tools.template.BaseTool2):
      """
      Fuzzing with stochastic optimization guided by CMA-ES
  
      Hynsung Kim, Gidon Ernst
      https://github.com/lazygrey/fuzzing_with_cmaes
      """
  
      REQUIRED_PATHS = [
          "fuzzer",
          "fuzzer.py",
          "cma",
          "verifiers_bytes",
          "verifiers_real",
      ]
  
-     def executable(self):
+     def executable(self, tool_locator):
-         return util.find_executable("fuzzer")
+         return tool_locator.find_executable("fuzzer")
  
      def version(self, executable):
          return self._version_from_tool(executable)
  
      def name(self):
          return "CMA-ES Fuzz"
  
-     def get_value_from_output(self, lines, identifier):
+     def get_value_from_output(self, output, identifier):
-         for line in reversed(lines):
+         for line in reversed(output):
+             if line.startswith(identifier):
+                 return line[len(identifier):]
-             pattern = identifier
-             if pattern[-1] != ":":
-                 pattern += ":"
-             match = re.match("^" + pattern + "([^(]*)", line)
-             if match and match.group(1):
-                 return match.group(1).strip()
          return None
  
Update module to version 2
## Code Before:


import re
import benchexec.util as util
import benchexec.tools.template


class Tool(benchexec.tools.template.BaseTool):
    """
    Fuzzing with stochastic optimization guided by CMA-ES

    Hynsung Kim, Gidon Ernst
    https://github.com/lazygrey/fuzzing_with_cmaes
    """

    REQUIRED_PATHS = [
        "fuzzer",
        "fuzzer.py",
        "cma",
        "verifiers_bytes",
        "verifiers_real",
    ]

    def executable(self):
        return util.find_executable("fuzzer")

    def version(self, executable):
        return self._version_from_tool(executable)

    def name(self):
        return "CMA-ES Fuzz"

    def get_value_from_output(self, lines, identifier):
        for line in reversed(lines):
            pattern = identifier
            if pattern[-1] != ":":
                pattern += ":"
            match = re.match("^" + pattern + "([^(]*)", line)
            if match and match.group(1):
                return match.group(1).strip()
        return None

## Instruction:
Update module to version 2
## Code After:


import re
import benchexec.tools.template

class Tool(benchexec.tools.template.BaseTool2):
    """
    Fuzzing with stochastic optimization guided by CMA-ES

    Hynsung Kim, Gidon Ernst
    https://github.com/lazygrey/fuzzing_with_cmaes
    """

    REQUIRED_PATHS = [
        "fuzzer",
        "fuzzer.py",
        "cma",
        "verifiers_bytes",
        "verifiers_real",
    ]

    def executable(self, tool_locator):
        return tool_locator.find_executable("fuzzer")

    def version(self, executable):
        return self._version_from_tool(executable)

    def name(self):
        return "CMA-ES Fuzz"

    def get_value_from_output(self, output, identifier):
        for line in reversed(output):
            if line.startswith(identifier):
                return line[len(identifier):]
        return None
