> $bin/calls\ncat $bin/state\n"); file_put_contents("$bin/zmpkg.pl", "#!/bin/sh\necho stopped > $bin/state\n"); chmod("$bin/zmdc.pl", 0755); chmod("$bin/zmpkg.pl", 0755); function calls() { $file = ZM_PATH_BIN.'/calls'; return file_exists($file) ? count(file($file)) : 0; } check('first check runs zmdc.pl', daemonCheck(), 1); check('second check gives the same answer', daemonCheck(), 1); check('zmdc.pl ran once for both', calls(), 1); daemonCheck('zmc', '-m 1'); daemonCheck('zmc', '-m 1'); check('checks of one daemon still run zmdc.pl each time', calls(), 3); packageControl('stop'); check('after a run state change zmdc.pl is asked again', daemonCheck(), 0); check('zmdc.pl ran once more', calls(), 4); check('a stopped answer is kept too', daemonCheck(), 0); check('zmdc.pl was not run for it', calls(), 4); array_map('unlink', glob("$bin/*")); rmdir($bin); echo "\n$passes passed, $failures failed\n"; exit($failures ? 1 : 0);