+ /* Make sure this analysis is supported at all. */
+ if (!isSupported()) {
+ return false;
+ }
+
+ if (!fFeatures.contains(Features.TEST_COMPATIBILITY)) {
+ /*
+ * No support for dynamic compatibility testing: suppose this
+ * analysis can run on any trace.
+ */
+ return true;
+ }
+
+ /* Check if this trace is already registered in the cache. */
+ if (fTraceCompatibilityCache.getOrDefault(trace, false)) {
+ return true;
+ }
+
+ /*
+ * Test compatibility since it's supported.
+ */
+ return testCompatibility(trace);
+ }
+
+ private void setFeatures() {
+ if (fMiVersion == 0) {
+ // Pre-1.0 LAMI protocol: supported for backward compatibility
+ fFeatures.add(Features.VERSION_IS_SUPPORTED);
+ return;
+ }
+
+ if (fMiVersion >= 100 && fMiVersion < 200) {
+ // LAMI 1.x
+ fFeatures.add(Features.VERSION_IS_SUPPORTED);
+ fFeatures.add(Features.OUTPUT_PROGRESS);
+ fFeatures.add(Features.TEST_COMPATIBILITY);
+ }
+ }
+
+ private void readVersion() {
+ final String command = fScriptCommand.get(0);
+ final List<String> commandLine = ImmutableList.<@NonNull String> builder()
+ .add(command).add(MI_VERSION_FLAG).build();
+ final String output = getOutputFromCommand(commandLine);
+
+ if (output == null) {
+ LOGGER.info(() -> String.format(LOG_NO_MI_VERSION_FMT, command));
+ return;
+ }
+
+ final String versionString = output.trim();
+
+ if (!versionString.matches("\\d{1,3}\\.\\d{1,3}")) { //$NON-NLS-1$
+ LOGGER.info(() -> String.format(LOG_NO_MI_VERSION_FMT, command));
+ return;
+ }
+
+ LOGGER.info(() -> String.format("[LamiAnalysis:MIVersionReport] Command \"%s\" reports MI version %s", //$NON-NLS-1$
+ command, versionString));
+
+ final String[] parts = versionString.split("\\."); //$NON-NLS-1$
+ final int major = Integer.valueOf(parts[0]);
+ final int minor = Integer.valueOf(parts[1]);
+
+ fMiVersion = major * 100 + minor;