Exemplo n.º 1
0
 private function pri($x, $y)
 {
     error_log("in pri:" . $x . " " . $y);
     foo($x, $y);
     if ($x == 3) {
         hphpd_break();
     }
     error_log("out pri:" . $x . " " . $y);
 }
Exemplo n.º 2
0
 private function pri($x)
 {
     error_log("in pri:" . $x);
     $y = $x + 3;
     $z = $x * 5;
     foo($y, $z);
     if ($x == 3) {
         hphpd_break();
     }
     if ($x == 4) {
         bigLoop(100000);
         // Slow enough that incorrect stepping will time out.
     }
     if ($x == 5 || $x == 6) {
         baz($x);
     }
     error_log("out pri:" . $x);
 }
Exemplo n.º 3
0
<?php

hphpd_break();
Exemplo n.º 4
0
 public function pubHardBreak($x)
 {
     error_log("pubHardBreak:" . $x);
     hphpd_break();
     error_log("pubHardBreak:done");
 }
Exemplo n.º 5
0
 /**
  * Run a fuzz test series
  * Draw input from a set of test files
  * @param array $filenames
  */
 function fuzzTest($filenames)
 {
     $dict = $this->getFuzzInput($filenames);
     $dictSize = strlen($dict);
     $logMaxLength = log($this->maxFuzzTestLength);
     $teardown = $this->parserTest->staticSetup();
     $teardown = $this->parserTest->setupDatabase($teardown);
     $teardown = $this->parserTest->setupUploads($teardown);
     $fakeTest = ['test' => '', 'desc' => '', 'input' => '', 'result' => '', 'options' => '', 'config' => ''];
     ini_set('memory_limit', $this->memoryLimit * 1048576 * 2);
     $numTotal = 0;
     $numSuccess = 0;
     $user = new User();
     $opts = ParserOptions::newFromUser($user);
     $title = Title::makeTitle(NS_MAIN, 'Parser_test');
     while (true) {
         // Generate test input
         mt_srand(++$this->seed);
         $totalLength = mt_rand(1, $this->maxFuzzTestLength);
         $input = '';
         while (strlen($input) < $totalLength) {
             $logHairLength = mt_rand(0, 1000000) / 1000000 * $logMaxLength;
             $hairLength = min(intval(exp($logHairLength)), $dictSize);
             $offset = mt_rand(0, $dictSize - $hairLength);
             $input .= substr($dict, $offset, $hairLength);
         }
         $perTestTeardown = $this->parserTest->perTestSetup($fakeTest);
         $parser = $this->parserTest->getParser();
         // Run the test
         try {
             $parser->parse($input, $title, $opts);
             $fail = false;
         } catch (Exception $exception) {
             $fail = true;
         }
         if ($fail) {
             echo "Test failed with seed {$this->seed}\n";
             echo "Input:\n";
             printf("string(%d) \"%s\"\n\n", strlen($input), $input);
             echo "{$exception}\n";
         } else {
             $numSuccess++;
         }
         $numTotal++;
         ScopedCallback::consume($perTestTeardown);
         if ($numTotal % 100 == 0) {
             $usage = intval(memory_get_usage(true) / $this->memoryLimit / 1048576 * 100);
             echo "{$this->seed}: {$numSuccess}/{$numTotal} (mem: {$usage}%)\n";
             if ($usage >= 100) {
                 echo "Out of memory:\n";
                 $memStats = $this->getMemoryBreakdown();
                 foreach ($memStats as $name => $usage) {
                     echo "{$name}: {$usage}\n";
                 }
                 if (function_exists('hphpd_break')) {
                     hphpd_break();
                 }
                 return;
             }
         }
     }
 }