24 lines
2.7 KiB
PHP
24 lines
2.7 KiB
PHP
<?php
|
|
// Exercise the EXACT serialized fallback wrapper from Manager/module.php in an isolated harness.
|
|
if (function_exists('IPS_GetKernelVersion')) throw new RuntimeException('Offline only');
|
|
$source=file_get_contents(__DIR__.'/../../Manager/module.php');
|
|
$a=strpos($source,' private function regeln(bool $erneuern): void');$b=strpos($source,' private function regelnIntern(bool $erneuern): void',$a);
|
|
if($a===false||$b===false)throw new RuntimeException('Manager wrapper source changed');
|
|
$method=substr($source,$a,$b-$a);$calls=[];$locked=false;
|
|
function IPS_SemaphoreEnter($k,$t){global$locked;if($locked)return false;$locked=true;return true;}
|
|
function IPS_SemaphoreLeave($k){global$locked;$locked=false;}
|
|
function IPS_GetInstance($id){return ['InstanceStatus'=>$GLOBALS['instance']->status];}
|
|
eval('class FallbackHarness { const STATUS_AKTIV=102; public $InstanceID=17004,$trial=true,$active=true,$status=102,$abortFirst=true,$throwFirst=false,$passes=[],$attributes=[],$stops=[];'.
|
|
'public function run(){ $this->regeln(false); } private function v4ManagerTestSession(){return $this->trial?[1]:[];} private function GetValue($k){return $this->active;}'.
|
|
'private function WriteAttributeString($k,$v){$this->attributes[$k]=$v;} private function v4ManagerTestAbbrechen($s){$this->stops[]=$s;$this->trial=false;}'.
|
|
'private function regelnIntern(bool $r):void { $this->passes[]=$r;if(count($this->passes)==1){if($this->throwFirst)throw new RuntimeException("synthetic_failure");if($this->abortFirst)$this->trial=false;}}'. $method.'}');
|
|
$count=0;function ck($v,$s){global$count;if(!$v)throw new RuntimeException('FAIL '.$s);$count++;echo "PASS $s\n";}
|
|
$instance=new FallbackHarness();$instance->run();ck($instance->passes===[false,true],'trial abort performs exactly one fresh ordinary recomputation');
|
|
ck($instance->attributes['LetzteSollwerte']==='{}','pre-trial cached target is discarded before fallback');ck(!$locked,'control semaphore released after fallback');
|
|
$instance=new FallbackHarness();$instance->trial=false;$instance->run();ck($instance->passes===[false],'ordinary control path does not gain extra passes');
|
|
$instance=new FallbackHarness();$instance->abortFirst=false;$instance->run();ck($instance->passes===[false],'valid trial not overridden by ordinary pass');
|
|
$instance=new FallbackHarness();$instance->status=201;$instance->run();ck($instance->passes===[false],'invalid measurement status prevents forced ordinary recomputation');
|
|
$instance=new FallbackHarness();$instance->throwFirst=true;try{$instance->run();}catch(RuntimeException $e){}
|
|
ck(!$locked&&!$instance->trial&&count($instance->stops)===1,'exception revokes trial and releases semaphore without endless retries');
|
|
echo "TOTAL $count actual manager fallback-wrapper checks passed. No real IPS runtime.\n";
|