/** * @expectedException LogicException * @expectedExceptionMessage Lock is not acqiured */ public function testReleaseWithNoAcquire() { $lockA = new Lock($this->file); $lockA->release(); }
INFO; die(1); } $pidfile = $argv[1]; $processCount = (int) $argv[2]; $iterationsCount = (int) $argv[3]; $block = (bool) (int) $argv[4]; $payload = function ($file, $count, $block = false) { $pid = getmypid(); try { for ($i = 0; $i < $count; $i++) { $lock = new Lock($file); if ($lock->acquire($block)) { echo "{$pid} acquire\n"; usleep(1); if ($pid != ($fileContents = @file_get_contents($file))) { throw new Exception("Invalid file contents '{$fileContents}'"); } echo "{$pid} release\n"; $lock->release(); } else { echo "{$pid} skip\n"; } usleep(1); } } catch (Exception $e) { echo "ERROR: {$pid} {$e->getMessage()}\n"; } }; $runner = new ForkRunner(); $res = $runner->run($processCount, $payload, array($pidfile, $iterationsCount, $block));