コード例 #1
0
ファイル: WinCacheUScenario.java プロジェクト: OSTC/PFTT2
  @Override
  public IScenarioSetup setup(ConsoleManager cm, Host host, PhpBuild build, PhpIni ini) {
    if (!host.isWindows() || !build.isNTS(host)) return SETUP_FAILED;

    configure(ini);

    return new WinCacheUScenarioSetup();
  }
コード例 #2
0
ファイル: PhptTestPack.java プロジェクト: weltling/PFTT2
  // TODO rename this - always call before (only once) before using PhptTestPack
  public void add_named_tests(
      List<PhptTestCase> test_files,
      List<String> names,
      PhptTelemetryWriter twriter,
      PhpBuild build,
      boolean ignore_missing)
      throws FileNotFoundException, IOException, Exception {
    test_pack_file = new File(test_pack);
    test_pack = test_pack_file.getAbsolutePath(); // normalize path

    LinkedList<PhptTestCase> redirect_targets = new LinkedList<PhptTestCase>();

    Iterator<String> name_it = names.iterator();
    String name;
    File file;
    PhptTestCase test_case;
    while (name_it.hasNext()) {
      name = name_it.next();

      if (name.endsWith(PhptTestCase.PHPT_FILE_EXTENSION)) {
        file = new File(test_pack_file, host.fixPath(name));
        if (file.exists()) {
          // String is exact name of test

          test_case = PhptTestCase.load(host, this, name, twriter);

          add_test_case(test_case, test_files, names, twriter, build, null, redirect_targets);

          // don't need to search for it
          name_it.remove();
        }
      }
    }

    if (names.size() > 0) {
      // assume any remaining names are name fragments and search for tests with matching names

      add_test_files(
          test_pack_file.listFiles(), test_files, names, twriter, build, null, redirect_targets);
    }

    if (!ignore_missing && names.size() > 0) {
      // one or more test names not matched to an actual test
      throw new FileNotFoundException(names.toString());
    }

    // sort alphabetically
    Collections.sort(
        test_files,
        new Comparator<PhptTestCase>() {
          @Override
          public int compare(PhptTestCase o1, PhptTestCase o2) {
            return o2.getName().compareTo(o2.getName());
          }
        });

    twriter.setTotalCount(test_files.size());
  }
コード例 #3
0
ファイル: WinCacheUScenario.java プロジェクト: OSTC/PFTT2
  public IScenarioSetup setup(
      ConsoleManager cm,
      Host host,
      PhpBuild build,
      ScenarioSet scenario_set,
      EScenarioSetPermutationLayer layer) {
    if (!host.isWindows() || !build.isNTS(host)) return SETUP_FAILED;

    String dll_path;
    EBuildBranch branch;
    try {
      branch = build.getVersionBranch(cm, host);
    } catch (Exception ex) {
      ex.printStackTrace();
      return SETUP_FAILED;
    }
    if (set_dll != null) {
      dll_path = set_dll.getPath();
    } else {
      switch (branch) {
        case PHP_5_3:
          dll_path = getDllPath53(host);
          break;
        case PHP_5_4:
          dll_path = getDllPath54(host);
          break;
        default:
          dll_path = getDllPath55Plus(host);
          break;
      }
    }
    // install wincache
    try {
      host.copy(dll_path, build.getDefaultExtensionDir() + "/php_wincache.dll");
    } catch (Exception ex) {
      ex.printStackTrace();
      return SETUP_FAILED;
    }

    cm.println(EPrintType.CLUE, getClass(), "Found WinCache in: " + dll_path);

    return new WinCacheUScenarioSetup();
  }
コード例 #4
0
ファイル: PhptTestPack.java プロジェクト: weltling/PFTT2
  private void add_test_case(
      PhptTestCase test_case,
      List<PhptTestCase> test_files,
      List<String> names,
      PhptTelemetryWriter twriter,
      PhpBuild build,
      PhptTestCase redirect_parent,
      List<PhptTestCase> redirect_targets)
      throws FileNotFoundException, IOException, Exception {
    if (test_case.containsSection(EPhptSection.REDIRECTTEST)) {
      if (build == null || redirect_parent != null) {
        // ignore the test
      } else {
        // execute php code in the REDIRECTTEST section to get the test(s) to load
        for (String target_test_name : test_case.readRedirectTestNames(host, build)) {

          // test may actually be a directory => load all the PHPT tests from that directory
          File dir = new File(test_pack + host.dirSeparator() + target_test_name);
          if (dir.isDirectory()) {
            // add all PHPTs in directory
            add_test_files(
                dir.listFiles(),
                test_files,
                names,
                twriter,
                build,
                redirect_parent,
                redirect_targets);

          } else {
            // test refers to a specific test, try to load it
            test_case =
                PhptTestCase.load(host, this, false, target_test_name, twriter, redirect_parent);

            if (redirect_targets.contains(test_case))
              // can only have 1 level of redirection
              return;
            redirect_targets.add(test_case);

            test_files.add(test_case);
          }
        }
      }
    } else {
      if (redirect_parent != null) {
        if (redirect_targets.contains(test_case)) return;
        // can only have 1 level of redirection
        redirect_targets.add(test_case);
      }

      test_files.add(test_case);
    }
  }
コード例 #5
0
ファイル: WinCacheUScenario.java プロジェクト: OSTC/PFTT2
 @Override
 public boolean isSupported(
     ConsoleManager cm,
     Host host,
     PhpBuild build,
     ScenarioSet scenario_set,
     EScenarioSetPermutationLayer layer) {
   if (!host.isWindows()) {
     if (cm != null) {
       cm.println(EPrintType.CLUE, getClass(), "Scenario only supported on Windows.");
     }
     return false;
   } else if (!build.isX86()) {
     if (cm != null) {
       cm.println(
           EPrintType.CLUE,
           getClass(),
           "Must use X86 build for this scenario: " + build.getBuildPath());
     }
     return false;
   } else if (!build.isNTS(host)) {
     if (cm != null) {
       cm.println(
           EPrintType.CLUE,
           getClass(),
           "Must use NTS build for this scenario: " + build.getBuildPath());
     }
     return false;
   } else if (!(
   // LATER? Apache FastCGI support on Windows
   scenario_set.contains(CliScenario.class)
       || scenario_set.contains(IISScenario.class)
       // WinCacheU should support builtin web server b/c (low priority though):
       //  web developers use wincache's user cache in their applications
       //  web developers like to use the builtin web server to run/test their application
       || scenario_set.contains(BuiltinWebServerScenario.class))) {
     if (cm != null) {
       cm.println(
           EPrintType.CLUE,
           getClass(),
           "Must load CLI, IIS or Builtin Web scenario. Try adding `iis` to your -config.");
     }
     return false;
   } else {
     return true;
   }
 }
コード例 #6
0
ファイル: WinCacheUScenario.java プロジェクト: OSTC/PFTT2
 @Overridable
 protected String getDllPath53(Host host) {
   return host.getPfttCacheDir() + "/dep/wincache/wincache-1.3.4-5.3-nts-vc9-x86/php_wincache.dll";
 }
コード例 #7
0
ファイル: WinCacheUScenario.java プロジェクト: OSTC/PFTT2
 @Overridable
 protected String getDllPath55Plus(Host host) {
   return host.getPfttCacheDir()
       + "/dep/wincache/wincache-1.3.5-5.5-nts-vc11-x86/php_wincache.dll";
 }
コード例 #8
0
ファイル: PhptTestPack.java プロジェクト: weltling/PFTT2
 public boolean open(Host host) {
   this.host = host;
   this.test_pack = host.fixPath(test_pack);
   return host.exists(this.test_pack);
 }
コード例 #9
0
ファイル: PhptTestPack.java プロジェクト: weltling/PFTT2
 public String getContents(Host host, String name) throws IOException {
   return host.getContentsDetectCharset(
       new File(test_pack_file, name).getAbsolutePath(), PhptTestCase.newCharsetDeciderDecoder());
 }