X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=webtest%2Fcds_test01.php;h=6156ef17dd095c181bcb522d5a8b891e24723644;hb=2630bbd10b83238863e371681cc7d272e73a3f39;hp=f95954777cf16fd48a15893b9d47a56e63bbcf72;hpb=db714d824435fb021bc4d4158a7e628221fbdcd9;p=curl-de-sac.git diff --git a/webtest/cds_test01.php b/webtest/cds_test01.php index f959547..6156ef1 100755 --- a/webtest/cds_test01.php +++ b/webtest/cds_test01.php @@ -1,42 +1,113 @@ #!/usr/bin/php short_data = $short_data; + } +} + class short_cmd_cls extends CDS_cmd_cls { function short_cmd_cls() { parent::__construct("short", 10); } + function create($cds, $url) + { + if ($cds->dbg_get() > 0) { + printf("short::create url:[%s]\n", $url); + } + + do { + if (($ch = parent::pre_create($url)) == FALSE) + break; + + if (parent::create($cds, $ch) == FALSE) + break; + + $cmd = new short_cmd($ch, $this, "none currently"); + + return $cmd; + } while (FALSE); + + return FALSE; + } + function cb() { - printf("short_cb:\n"); + if ($this->dbg_get() > 0) { + printf("short_cb:\n"); + } + } +} + +class long_cmd extends CDS_cmd { + var $long_data; + + function long_cmd($cmd_cls, $ch, $long_data) + { + parent::__construct($cmd_cls, $ch); + $this->long_data = $long_data; } } class long_cmd_cls extends CDS_cmd_cls { function long_cmd_cls() { - parent::__construct("long", 15); + parent::__construct("long", 10); + } + + function create($cds, $url) + { + if ($cds->dbg_get() > 0) { + printf("long::create url:[%s]\n", $url); + } + + do { + if (($ch = parent::pre_create($url)) == FALSE) + break; + + if (parent::create($cds, $ch) == FALSE) + break; + + $cmd = new long_cmd($ch, $this, "none currently"); + + return $cmd; + } while (FALSE); + + return FALSE; } function cb() { - printf("long_cb:\n"); + if ($this->dbg_get() > 0) { + printf("long_cb:\n"); + } } } + function main() { // create cds - $cds = new Curl_de_sac(); + $cds = new Curl_de_sac(999); // create cds_cmd 1 $cmd_cls1 = new short_cmd_cls(); // registrer cds_cmd 1 - if (($cds->cmd_register($cmd_cls1)) == FALSE) { - fprintf(STDERR, "cmd_cls1 registration failed\n"); + printf("MAIN: Register CLS1\n"); + if (($cds->cmd_cls_register($cmd_cls1)) == FALSE) { + fprintf(STDERR, "MAIN: cmd_cls1 registration failed\n"); exit(1); } @@ -44,20 +115,68 @@ function main() $cmd_cls2 = new long_cmd_cls(); // register cds_cmd 2 - if (($cds->cmd_register($cmd_cls2)) == FALSE) { - fprintf(STDERR, "cmd_cls2 registration failed\n"); + printf("MAIN: Register CLS2\n"); + if (($cds->cmd_cls_register($cmd_cls2)) == FALSE) { + fprintf(STDERR, "MAIN: cmd_cls2 registration failed\n"); exit(2); } // register cds_cmd 2 (retry) - if (($cds->cmd_register($cmd_cls2)) != FALSE) { - fprintf(STDERR, "cmd_cls2 re-registration success\n"); + printf("MAIN: Re-register CLS2 (must go wrong)\n"); + if (($cds->cmd_cls_register($cmd_cls2)) != FALSE) { + fprintf(STDERR, "MAIN: cmd_cls2 re-registration success\n"); exit(3); } + printf("MAIN: CDS:\n"); print_r($cds); - printf("SUCCESS\n"); + printf("MAIN: Deregister CLS2\n"); + if (($cds->cmd_cls_deregister($cmd_cls2)) == FALSE) { + fprintf(STDERR, "MAIN: cmd_cls2 deregistration failed\n"); + exit(4); + } + printf("MAIN: CDS:\n"); + print_r($cds); + + // re-re-register cds_cmd 2 + printf("MAIN: Re-re-register CLS2\n"); + if (($cds->cmd_cls_register($cmd_cls2)) == FALSE) { + fprintf(STDERR, "MAIN: cmd_cls2 re-re-registration failed\n"); + exit(5); + } + + printf("MAIN: Deregister all\n"); + $cds->cmd_cls_deregister_all(); + // registrer cds_cmd 1 + printf("MAIN: register CLS1\n"); + if (($cds->cmd_cls_register($cmd_cls1)) == FALSE) { + fprintf(STDERR, "MAIN: cmd_cls1 registration failed\n"); + exit(1); + } + + // register cds_cmd 2 + printf("MAIN: register CLS2\n"); + if (($cds->cmd_cls_register($cmd_cls2)) == FALSE) { + fprintf(STDERR, "MAIN: cmd_cls2 registration failed\n"); + exit(2); + } + printf("MAIN: CDS:\n"); + print_r($cds); + printf("MAIN: SUCCESS\n"); + + for ($i = 0 ; $i < 10 ; $i++) { + if ($i == 2) { + printf("MAIN: load short\n"); + if ($cds->execute("short", WEBURL.'/short.php') == FALSE) { + printf("MAIN: push command failed\n"); + exit(123); + } + } + printf("MAIN: Call process\n"); + $cds->process(); + usleep(500000); + } // start loop // print status // if input data execute some command