"""
Cascade Verification Tool
Copyright (c) 2015 New York University
All Rights Reserved
"""

import benchexec.util as util
import benchexec.tools.template
import benchexec.result as result

class Tool(benchexec.tools.template.BaseTool):
    """
    Tool wrapper for Cascade (http://cascade.cims.nyu.edu/).
    """

    def executable(self):
        return util.find_executable('run_cascade')

    def name(self):
        return 'Cascade'

    def version(self, executable):
        return '2.0'

    def cmdline(self, executable, options, tasks, propertyfile, rlimits):
        assert len(tasks) == 1, "only one sourcefile supported"
        inputfile = tasks[0]
        assert propertyfile is not None
        spec = ['-spec', propertyfile]
        return [executable] + options + spec + [inputfile]

    def determine_result(self, returncode, returnsignal, output, isTimeout):
        output = '\n'.join(output)
        if "TRUE" in output:
            status = result.RESULT_TRUE_PROP
        elif "FALSE" in output:
            if "FALSE(valid-deref)" in output:
                status = result.RESULT_FALSE_DEREF
            elif "FALSE(valid-free)" in output:
                status = result.RESULT_FALSE_FREE
            elif "FALSE(valid-memtrack)" in output:
                status = result.RESULT_FALSE_MEMTRACK
            else:
                status = result.RESULT_FALSE_REACH
        else:
            status = result.RESULT_UNKNOWN

        return status

@@ -487,13 +487,43 @@
 urn 
-'2.0'
+self._version_from_tool(executable)
 %0A%0A  
@@ -953,84 +953,8 @@
  if 
-%22TRUE%22 in output:%0A            status = result.RESULT_TRUE_PROP%0A        elif 
 %22FAL
@@ -1280,32 +1280,32 @@
           else:%0A
-
                 
@@ -1339,16 +1339,92 @@
 E_REACH%0A
+        elif %22TRUE%22 in output:%0A            status = result.RESULT_TRUE_PROP%0A
         

update version output and result parsing