本文整理汇总了Java中gov.nasa.jpf.JPF类的典型用法代码示例。如果您正苦于以下问题:Java JPF类的具体用法?Java JPF怎么用?Java JPF使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JPF类属于gov.nasa.jpf包,在下文中一共展示了JPF类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: HeuristicListener
import gov.nasa.jpf.JPF; //导入依赖的package包/类
public HeuristicListener(Config jpfConf, JPF jpf) {
super(jpfConf, jpf);
policiesEnabled = jpfConf.getBoolean(WorstCaseAnalyzer.ENABLE_POLICIES, WorstCaseAnalyzer.ENABLE_POLICIES_DEF);
if (policiesEnabled) {
PolicyManager policyManager = new PolicyManager(new File(getSerializedInputDir(jpfConf)));
try {
this.heuristicPolicy = policyManager.loadPolicy(measuredMethods, Policy.class);
} catch (IOException | PolicyManagerException e) {
logger.severe(e.getMessage());
throw new RuntimeException(e);
}
}
// Set termination strategy
this.terminationStrategy = jpfConf.getInstance(TERMINATION_STRATEGY_CONF,
TerminationStrategy.class, DEFAULT_TERMINATION_STRATEGY);
}
示例2: generateJPFConfig
import gov.nasa.jpf.JPF; //导入依赖的package包/类
/**
* generates a jpf config corresponding to this configuration
*
* @param conf
* @return
*/
public Config generateJPFConfig(Config conf) {
Config newConf = new Config("");
if(conf != null) {
newConf.putAll(conf);
newConf.setClassLoader(conf.getClassLoader());
}
else {
newConf.initClassLoader(JPF.class.getClassLoader());
}
StringBuilder sb = new StringBuilder();
boolean first = true;
for(ConcolicMethodConfig mc : concolicMethods.values()) {
generatePerturbConfig(mc, newConf);
if(first)
first = false;
else
sb.append(',');
sb.append(mc.getId());
}
newConf.setProperty("perturb.params", sb.toString());
return newConf;
}
示例3: log__Ljava_lang_String_2ILjava_lang_String_2_3Ljava_lang_Object_2__V
import gov.nasa.jpf.JPF; //导入依赖的package包/类
@MJI
public static void log__Ljava_lang_String_2ILjava_lang_String_2_3Ljava_lang_Object_2__V (MJIEnv env, int clsObjRef,
int loggerIdRef, int logLevel, int fmtRef, int argsRef){
String loggerId = env.getStringObject(loggerIdRef);
String fmt = env.getStringObject(fmtRef);
JPFLogger logger = JPF.getLogger(loggerId);
int[] argRefs = env.getReferenceArrayObject( argsRef);
Object[] args = new Object[argRefs.length];
for (int i=0; i<args.length; i++){
ElementInfo eiArg = env.getElementInfo(argRefs[i]);
if (eiArg.isStringObject()){
args[i] = env.getStringObject(argRefs[i]);
} else if (eiArg.isBoxObject()){
args[i] = eiArg.asBoxObject();
} else {
args[i] = eiArg.toString();
}
}
String msg = String.format(fmt, args);
log( logger, logLevel, msg);
}
示例4: CoverageAnalyzer
import gov.nasa.jpf.JPF; //导入依赖的package包/类
public CoverageAnalyzer(Config conf, JPF jpf) {
includes = StringSetMatcher.getNonEmpty(conf.getStringArray("coverage.include"));
excludes = StringSetMatcher.getNonEmpty(conf.getStringArray("coverage.exclude"));
showMethods = conf.getBoolean("coverage.show_methods", false);
showMethodBodies = conf.getBoolean("coverage.show_bodies", false);
excludeHandlers = conf.getBoolean("coverage.exclude_handlers", false);
showBranchCoverage = conf.getBoolean("coverage.show_branches", true);
loadedOnly = conf.getBoolean("coverage.loaded_only", true);
showRequirements = conf.getBoolean("coverage.show_requirements", false);
if (!loadedOnly) {
getCoverageCandidates(); // this might take a little while
}
jpf.addPublisherExtension(ConsolePublisher.class, this);
}
示例5: PathOutputMonitor
import gov.nasa.jpf.JPF; //导入依赖的package包/类
public PathOutputMonitor (Config config, JPF jpf) {
vm = jpf.getVM();
vm.storePathOutput();
jpf.addPublisherExtension(ConsolePublisher.class, this);
printOutput = config.getBoolean("pom.print_output", true);
deferOutput = config.getBoolean("pom.defer_output", true);
psClass = config.getClass("pom.output_spec.class", PathOutputSpec.class);
if (psClass == null) {
psClass = RegexOutputSpec.class;
}
anySpecs = loadSpecs(config, "pom.any");
allSpecs = loadSpecs(config, "pom.all");
noneSpecs = loadSpecs(config, "pom.none");
violatedSpecs = new ArrayList<PathOutputSpec>();
}
示例6: SimpleDot
import gov.nasa.jpf.JPF; //导入依赖的package包/类
public SimpleDot( Config config, JPF jpf){
graphAttrs = config.getString("dot.graph_attr", GRAPH_ATTRS);
genericNodeAttrs = config.getString("dot.node_attr", GENERIC_NODE_ATTRS);
genericEdgeAttrs = config.getString("dot.edge_attr", GENERIC_EDGE_ATTRS);
newEdgeAttrs = config.getString("dot.new_edge_attr", NEW_EDGE_ATTRS);
visitedEdgeAttrs = config.getString("dot.visited_edge_attr", VISITED_EDGE_ATTRS);
startNodeAttrs = config.getString("dot.start_node_attr", START_NODE_ATTRS);
endNodeAttrs = config.getString("dot.end_node_attr", END_NODE_ATTRS);
errorNodeAttrs = config.getString("dot.error_node_attr", ERROR_NODE_ATTRS);
backtrackEdgeAttrs = config.getString("dot.bt_edge_attr", BACKTRACK_EDGE_ATTRS);
restoreEdgeAttrs = config.getString("dot.restore_edge_attr", RESTORED_EDGE_ATTRS);
printFile = config.getBoolean("dot.print_file", false);
showTarget = config.getBoolean("dot.show_target", false);
// app and filename are not known until the search is started
jpf.addPublisherExtension(ConsolePublisher.class, this);
}
示例7: ChoiceTracker
import gov.nasa.jpf.JPF; //导入依赖的package包/类
public ChoiceTracker (Config config, JPF jpf) {
this.config = config;
vm = jpf.getVM();
search = jpf.getSearch();
String fname = config.getString("choice.trace");
if (fname == null) {
isReportExtension = true;
jpf.addPublisherExtension(ConsolePublisher.class, this);
// pw is going to be set later
} else {
try {
pw = new PrintWriter(fname);
} catch (FileNotFoundException fnfx) {
System.err.println("cannot write choice trace to file: " + fname);
pw = new PrintWriter(System.out);
}
}
excludes = config.getStringArray("choice.exclude");
cgClasses = config.getClasses("choice.class");
format = config.getEnum("choice.format", Format.values(), Format.CG);
showLocation = config.getBoolean("choice.show_location", true);
}
示例8: ObjectTracker
import gov.nasa.jpf.JPF; //导入依赖的package包/类
public ObjectTracker (Config conf, JPF jpf) {
includeClasses = StringSetMatcher.getNonEmpty(conf.getStringArray("ot.include"));
excludeClasses = StringSetMatcher.getNonEmpty(conf.getStringArray("ot.exclude", new String[] { "*" }));
trackedRefs = new SortedArrayIntSet();
int[] refs = conf.getIntArray("ot.refs");
if (refs != null){
for (int i=0; i<refs.length; i++){
trackedRefs.add(refs[i]);
}
}
logCalls = conf.getBoolean("ot.log_calls", true);
logFieldAccess = conf.getBoolean("ot.log_fields", true);
registerListener(jpf);
jpf.addPublisherExtension(ConsolePublisher.class, this);
}
示例9: BudgetChecker
import gov.nasa.jpf.JPF; //导入依赖的package包/类
public BudgetChecker (Config conf, JPF jpf) {
//--- get the configured budget limits (0 means not set)
maxTime = conf.getDuration("budget.max_time", 0);
maxHeap = conf.getMemorySize("budget.max_heap", 0);
maxDepth = conf.getInt("budget.max_depth", 0);
maxInsn = conf.getLong("budget.max_insn", 0);
maxState = conf.getInt("budget.max_state", 0);
maxNewStates = conf.getInt("budget.max_new_states", 0);
tStart = System.currentTimeMillis();
if (maxHeap > 0) {
mxb = ManagementFactory.getMemoryMXBean();
muStart = mxb.getHeapMemoryUsage();
mStart = muStart.getUsed();
}
search = jpf.getSearch();
vm = jpf.getVM();
}
示例10: TraceStorer
import gov.nasa.jpf.JPF; //导入依赖的package包/类
public TraceStorer (Config config, JPF jpf){
traceFileName = config.getString("trace.file", "trace");
storeMultiple = config.getBoolean("trace.multiple", false);
storeDepth = config.getInt("trace.depth", Integer.MAX_VALUE);
verbose = config.getBoolean("trace.verbose", false);
terminateOnStore = config.getBoolean("trace.terminate", false);
storeOnConstraintHit = config.getBoolean("trace.store_constraint", false);
storeCalls = StringSetMatcher.getNonEmpty(config.getStringArray("trace.store_calls"));
storeThreads = StringSetMatcher.getNonEmpty(config.getStringArray("trace.store_threads"));
vm = jpf.getVM();
search = jpf.getSearch();
}
示例11: getRevision
import gov.nasa.jpf.JPF; //导入依赖的package包/类
protected String getRevision() {
try {
InputStream is = JPF.class.getResourceAsStream(".version");
if (is != null){
int len = is.available();
byte[] data = new byte[len];
is.read(data);
is.close();
return new String(data).trim();
} else {
return null;
}
} catch (Throwable t){
return null;
}
}
示例12: getRepositoryInfo
import gov.nasa.jpf.JPF; //导入依赖的package包/类
protected String getRepositoryInfo() {
try {
InputStream is = JPF.class.getResourceAsStream("build.properties");
if (is != null){
Properties revInfo = new Properties();
revInfo.load(is);
StringBuffer sb = new StringBuffer();
String date = revInfo.getProperty("date");
String author = revInfo.getProperty("author");
String rev = revInfo.getProperty("rev");
String machine = revInfo.getProperty("hostname");
String loc = revInfo.getProperty("location");
String upstream = revInfo.getProperty("upstream");
return String.format("%s %s %s %s %s", date,author,rev,machine,loc);
}
} catch (IOException iox) {
return null;
}
return null;
}
示例13: noPropertyViolation
import gov.nasa.jpf.JPF; //导入依赖的package包/类
/**
* run JPF expecting no SuT property violations
*/
protected JPF noPropertyViolation (StackTraceElement testMethod, String... args) {
JPF jpf = null;
report(args);
try {
jpf = createAndRunJPF( testMethod, args);
} catch (Throwable t) {
// we get as much as one little hickup and we declare it failed
t.printStackTrace();
fail("JPF internal exception executing: ", args, t.toString());
return jpf;
}
List<Error> errors = jpf.getSearchErrors();
if ((errors != null) && (errors.size() > 0)) {
fail("JPF found unexpected errors: " + (errors.get(0)).getDescription());
}
return jpf;
}
示例14: jpfException
import gov.nasa.jpf.JPF; //导入依赖的package包/类
/**
* run JPF expecting it to throw an exception
* NOTE - xClassName needs to be the concrete exception, not a super class
* @param args JPF main() arguments
*/
protected JPF jpfException (StackTraceElement testMethod, Class<? extends Throwable> xCls, String... args) {
JPF jpf = null;
Throwable exception = null;
report(args);
try {
jpf = createAndRunJPF( testMethod, args);
} catch (JPF.ExitException xx) {
exception = xx.getCause();
} catch (Throwable x) {
exception = x;
}
if (exception != null){
if (!xCls.isAssignableFrom(exception.getClass())){
fail("JPF produced wrong exception: " + exception + ", expected: " + xCls.getName());
}
} else {
fail("JPF failed to produce exception, expected: " + xCls.getName());
}
return jpf;
}
示例15: propertyViolation
import gov.nasa.jpf.JPF; //导入依赖的package包/类
/**
* run JPF expecting a property violation of the SuT
* @param args JPF main() arguments
*/
protected JPF propertyViolation (StackTraceElement testMethod, Class<? extends Property> propertyCls, String... args ){
JPF jpf = null;
report(args);
try {
jpf = createAndRunJPF( testMethod, args);
} catch (Throwable t) {
t.printStackTrace();
fail("JPF internal exception executing: ", args, t.toString());
}
List<Error> errors = jpf.getSearchErrors();
if (errors != null) {
for (Error e : errors) {
if (propertyCls == e.getProperty().getClass()) {
return jpf; // success, we got the sucker
}
}
}
fail("JPF failed to detect error: " + propertyCls.getName());
return jpf;
}