Example #1
0
"""Uses Hycreate2 to run reachability and plot a file"""
# Stanley Bak, September 2014

import subprocess
import shutil
from hybrid_tool import HybridTool
from hybrid_tool import get_script_path
from hybrid_tool import RunCode
from hybrid_tool import tool_main

# the path to the hycreate2 bin directory, relative to the work directory
TOOL_PATH = get_script_path() + "/hycreate2"

# flag to pass into hycreate, use -b for batch mode and -bd for debug batch mode
HYCREATE_BATCH_MODE_FLAG = "-b"


class HyCreateTool(HybridTool):
    """Container class for running Flow*"""

    def __init__(self):
        HybridTool.__init__(self, "hycreate", ".hyc2", TOOL_PATH)

    def _run_tool(self):
        """runs the tool, returns a value in RunCode"""
        rv = RunCode.SUCCESS

        try:
            params = ["java", "-classpath", self.tool_path, "main.Main", HYCREATE_BATCH_MODE_FLAG, self.model_path]

            proc = subprocess.Popen(params)
Example #2
0
'''Uses flow* to run reachability and gnuplot / gimp to make a plot'''

import subprocess
import re
from hybrid_tool import HybridTool
from hybrid_tool import get_script_path
from hybrid_tool import run_check_stderr
from hybrid_tool import RunCode
from hybrid_tool import tool_main

# the path to the flow* executable
TOOL_PATH = get_script_path() + "/flowstar-1.2.3/flowstar"


class FlowstarTool(HybridTool):
    '''container class for running Flow*'''
    def __init__(self):
        HybridTool.__init__(self, 'flowstar', '.flowstar', TOOL_PATH)

    def _run_tool(self):
        '''runs the tool, returns a value in RunCode'''
        rv = RunCode.SUCCESS

        # flowstar reads from stdin
        try:
            f = open(self.model_path, 'r')
        except IOError as e:
            print "Could not read from model file: " + self.model_path + " (" + e.strerror + ")"
            rv = RunCode.ERROR

        with f:
Example #3
0
'''Uses dreach to run reachability for HyPy'''

import os
import shutil

from hybrid_tool import get_script_path
from hybrid_tool import HybridTool
from hybrid_tool import RunCode
from hybrid_tool import run_check_stderr
from hybrid_tool import tool_main

# the path to the dreach executable
TOOL_PATH = get_script_path() + "/dreach/dReal-2.15.01-linux/bin/dReach"

class DReachTool(HybridTool):
    '''Container class for running dReach'''

    def __init__(self):
        HybridTool.__init__(self, "dreach", '.drh', TOOL_PATH)

    def _make_image(self):
        '''makes the image after the tool runs, returns True when no error occurs'''
        print "Skipping make image (generation of .png images is not supported in dReach)"
        return True

    def _run_tool(self):
        '''runs the tool, returns a value in RunCode'''
        rv = RunCode.SUCCESS

        # parameter order matters! k must come first
        # use --verbose for verbose printing
Example #4
0
'''Uses flow* to run reachability and gnuplot / gimp to make a plot'''

import subprocess
import re
from hybrid_tool import HybridTool
from hybrid_tool import get_script_path
from hybrid_tool import run_check_stderr
from hybrid_tool import RunCode
from hybrid_tool import tool_main

# the path to the flow* executable
TOOL_PATH = get_script_path() + "/flowstar-1.2.3/flowstar"

class FlowstarTool(HybridTool):
    '''container class for running Flow*'''
    def __init__(self):
        HybridTool.__init__(self, 'flowstar', '.flowstar', TOOL_PATH)

    def _run_tool(self):
        '''runs the tool, returns a value in RunCode'''
        rv = RunCode.SUCCESS

        # flowstar reads from stdin
        try:
            f = open(self.model_path, 'r')
        except IOError as e:
            print "Could not read from model file: " + self.model_path + " (" + e.strerror + ")"
            rv = RunCode.ERROR

        with f:
            if not run_check_stderr([self.tool_path], stdin=f):
Example #5
0
import sys
import subprocess
import threading
import os
import shutil
import re
import collections

from hybrid_tool import HybridTool
from hybrid_tool import RunCode
from hybrid_tool import get_script_path
from hybrid_tool import tool_main

# the path to the spaceex executable
TOOL_PATH = get_script_path() + "/spaceex/spaceex"


class SpaceExTool(HybridTool):
    '''Container class for running SpaceEx'''

    original_cfg_path = None
    cfg_path = None

    printed_error = False
    not_affine = False

    def __init__(self):
        HybridTool.__init__(self, "spaceex", '.xml', TOOL_PATH)

    def _print_pipe(self, is_std_err, pipe):
Example #6
0
import sys
import random
import argparse
import shutil

import hybrid_tool
from hybrid_tool import get_script_path
from hybrid_tool import get_env_var_path

from tool_flowstar import FlowstarTool
from tool_dreach import DReachTool
from tool_spaceex import SpaceExTool
from tool_hycreate import HyCreateTool

# path the the Hyst jar file
DEFAULT_HYST_PATH = get_script_path() + '/../Hyst.jar'

# tools for which models can be generated
TOOLS = {'flowstar':FlowstarTool(), 'hycreate':HyCreateTool(), \
         'spaceex':SpaceExTool(), 'dreach':DReachTool()}

# return codes for Engine.run()
def enum(**enums):
    '''return codes for Engine.run()'''
    return type('Enum', (), enums)

RUN_CODES = enum(SUCCESS='Success', ERROR_TOOL='Error (Tool)', \
    ERROR_UNSUPPORTED='Error (Unsupported Dynamics)', ERROR_CONVERSION='Error (Conversion)', \
    TIMEOUT_CONVERSION='Timeout (Conversion)', TIMEOUT_TOOL='Timeout (Tool)')

EXIT_CODE_TERM = 143
Example #7
0
import sys
import subprocess
import threading
import os
import shutil
import re
import collections

from hybrid_tool import HybridTool
from hybrid_tool import RunCode
from hybrid_tool import get_script_path
from hybrid_tool import tool_main

# the path to the spaceex executable
TOOL_PATH = get_script_path() + "/spaceex/spaceex"

class SpaceExTool(HybridTool):
    '''Container class for running SpaceEx'''

    original_cfg_path = None
    cfg_path = None

    printed_error = False
    not_affine = False

    def __init__(self):
        HybridTool.__init__(self, "spaceex", '.xml', TOOL_PATH)

    def _print_pipe(self, is_std_err, pipe):
        '''print the output from a pipe (from a subprocess), setting
Example #8
0
'''Uses Hycreate2 to run reachability and plot a file'''
# Stanley Bak, September 2014

import subprocess
import shutil
from hybrid_tool import HybridTool
from hybrid_tool import get_script_path
from hybrid_tool import RunCode
from hybrid_tool import tool_main

# the path to the hycreate2 bin directory, relative to the work directory
TOOL_PATH = get_script_path() + "/hycreate2"

# flag to pass into hycreate, use -b for batch mode and -bd for debug batch mode
HYCREATE_BATCH_MODE_FLAG = "-b"


class HyCreateTool(HybridTool):
    '''Container class for running Flow*'''
    def __init__(self):
        HybridTool.__init__(self, 'hycreate', '.hyc2', TOOL_PATH)

    def _run_tool(self):
        '''runs the tool, returns a value in RunCode'''
        rv = RunCode.SUCCESS

        try:
            params = ["java", "-classpath", self.tool_path, "main.Main", \
       HYCREATE_BATCH_MODE_FLAG, self.model_path]

            proc = subprocess.Popen(params)