
| Current Path : /var/www/web-klick.de/dsh/90_akt/PPLTest.old/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/web-klick.de/dsh/90_akt/PPLTest.old/test6001.pl |
# Testframework-Client
#
# Environment:
#
# database: Zentrale Test-Item-Datenbank
use DivBasicF::DBComSimple;
use Data::Dumper;
use Term::ReadLine;
DivBasicF::DBComSimple->read_in_environment();
my $prg = shift(@ARGV);
my $par; c();
my $com = DivBasicF::DBComSimple->new([$ENV{'database'},67002000,100,2]);
my $erg; my $zaehler; my $o; my $o1; my $prg1;
open(FFILE,"<".$prg);
my $text = join("",<FFILE>);
close(FFILE);
if ($prg eq "meta.ppl") {
$text = <<'TEXT_ENDE';
{
'name' => 'meta',
'result' => 1,
'remark' => '',
'weight' => 1,
'user' => '',
'requ' => '',
'data' => '',
'prgstack' => '',
'condition' => '',
'cookie' => '',
'interpreter' => 'edit',
'log' => '',
'status' => '',
}
TEXT_ENDE
}
if ($text =~ s/^CONTINUED... +(.*?) *\n//s) {
$com->connection($1);
while ($text =~ s/---xxx---([\n ]*)(.*?)([\n ]*)---xxx---/---xxx---/s) {
push(@$erg,$2);
}
# print Dumper($erg);
$com->msg([@$erg]);
$text = "WAITING... " . $com->get_connection() . "\n";
open(FFILE,">".$prg);
print FFILE $text;
close(FFILE);
# print $text;
}
if ($text =~ /^WAITING... +(.*?) *\n/s) { # Task ist im Wartezustand
$com->connection($1);
my $erg = $com->get(4,7);
if (ref($erg)) {
system("rm $prg");
if ($erg->[0] =~ /process_killed/) {
print "Test-Item $prg deleted.\n";
exit;
}
$prg = shift(@$erg) . ".ppl";
open(FFILE,">".$prg);
$erg = join("\n\n---xxx---\n\n","",@$erg,"");
print FFILE "CONTINUED... " . $com->get_connection() . "\n" . $erg;
close(FFILE);
if (!$par) {
if ($prg !~ /\.ppl$/ and $text !~ /^\./) {
print $erg;
}
elsif (-f "/etc/hosts" and $erg =~ /\n[0-1a-z]\:/s) {
print $erg;
$o = Term::ReadLine->new(0)->readline("> ");
$erg =~ s/^(.*---xxx---)(.*?\n[0-1a-z]\: .*?)(---xxx---.*)$/$1\n\n$o\n\n$3/s;
print $erg;
open(FFILE,">".$prg);
print FFILE "CONTINUED... " . $com->get_connection() . "\n" . $erg;
close(FFILE);
}
elsif (-f "/etc/hosts") {
system("joe $prg");
}
else {
system("notepad $prg");
}
}
print "Output to $prg ...\n";
} else {
print $text;
}
if ($text =~ s/^\.//) {
print "====================================================\n";
system("exec perl $0 $text");
}
}
elsif (!$text and $prg =~ s/\.ppl$//) { # Arbeitskopie eines Test-Items
$com->msg(["find",$prg]); # aus der DB anlegen
my $erg = $com->get(1000,7);
$com->msg(["kill9"]);
if (@$erg) {
open(FFILE,">".$prg.".ppl");
print FFILE "CONTINUED... " . $erg->[0] .
"\n\n---xxx---\n\nedit\n\n---xxx---\n";
close(FFILE);
}
}
#elsif (!$text and $prg =~ /\./) {
# $com->msg(["step",@ARGV]);
# open(FFILE,">".$prg);
# print FFILE "WAITING... " . $com->get_connection() . "\n";
# close(FFILE);
# system("exec perl $0 $prg");
#}
elsif ($text and $prg =~ /^(.*)\.(.*)$/) { # Neuer Task
$o = $1;
$o1 = $2;
$zaehler = 0;
opendir(DDIR,".");
while (0 == 0) {
$prg1 = readdir(DDIR);
last if (!$prg1);
if ($prg1 =~ /^$o\_\_(\d+)\.$o1/) {
$erg = $1;
if ($erg > $zaehler) {
$zaehler = $erg;
}
}
}
closedir(DDIR);
$prg1 = $o . "__" . sprintf("%03u",$zaehler+1) . "." . $o1;
$text =~ s/^(.*)---xxx---([\n ]*)(.*?)([\n ]*)---xxx---/$3/s;
if (!($ENV{'user'})) { $ENV{'user'} = "xx"; }
$com->msg(["test_program",$text,time().".".$ENV{'user'}]);
$erg = "WAITING... " . $com->get_connection() . "\n";
open(FFILE,">".$prg1);
print FFILE $erg;
close(FFILE);
print $erg . "Generated File: $prg1\n";
}
elsif ($prg !~ /\./) {
$com->msg(["list",$prg,@ARGV]);
my $erg = $com->get(1000,7);
$com->msg(["kill9"]);
print "FehlerW Sum Erg Name\n\n";
foreach $o (@$erg) { # [gesresult,gesweight,conn,objlock,sleep,name,result,
# remark,weight,user,requ,status]
if ($o->[11] == 1) { # Abfrage Status
$o1 = $o->[5];
if (length($o1) < 30) {
$o1 = substr($o1." ",0,30);
}
print sprintf("%5.3f",0.001 * $o->[1]) . " " .
sprintf("%4u",$o->[0]) . " " . sprintf("%4u",$o->[6]) . " " .
$o1 . " " . $o->[7] . "\n";
}
elsif ($o->[11] == 2) { # schlaeft
print " " .
substr(" (" . sprintf("%1u",$o->[4] - time()) .
") ",0,11) . $o->[5] . "\n";
}
elsif ($o->[11] == 9) { # laeuft noch
print " " . $o->[5] . "\n";
}
elsif ($o->[11] == 3) { # Test-Item nur virtuell
print sprintf("%5.3f",0.001 * $o->[1]) . " " .
sprintf("%4u",$o->[0]) . " " . sprintf("%4u",$o->[6]) . " (" .
$o->[5] . ")\n";
}
else {
print " \n";
}
}
}
else {
print "File not found...\n";
}
sub c {
return if ($prg ne "c");
system("cp $ARGV[0]\70_Quellen\SWE_BAE_SK\Application\Output\$ARGV[1]\mmi\monitordata\MonitorData.xml $ARGV[2]");
system("cp $ARGV[0]\70_Quellen\SWE_BAE_SK\Application\Code\Local\MMI\Repository\Libs\list.xml $ARGV[2]");
system("cp $ARGV[0]\70_Quellen\SWE_BAE_SK\SimulationNET/bin/WIN32_$ARGV[1]/SimulationApplication.exe $ARGV[2]");
system("cp $ARGV[0]\70_Quellen\SWE_BAE_SK\SimulationNET/bin/WIN32_$ARGV[1]/*.dll $ARGV[2]");
system("cp $ARGV[0]\70_Quellen\SWE_BAE_SK\SimulationNET/bin/WIN32_$ARGV[1]/*.DLL $ARGV[2]");
exit;
}
1;