X-Git-Url: https://mop.ddnsfree.com/gitweb/?p=curl-de-sac.git;a=blobdiff_plain;f=webtest%2Fcds_test01.php;fp=webtest%2Fcds_test01.php;h=ed005fc846abc1e126efa6d46bcb284cb444799d;hp=f95954777cf16fd48a15893b9d47a56e63bbcf72;hb=7edbe80f9797346b9950db411461f306d0e4b15d;hpb=145bd6ad7eb14e0f610251d6e1933312fb020520 diff --git a/webtest/cds_test01.php b/webtest/cds_test01.php index f959547..ed005fc 100755 --- a/webtest/cds_test01.php +++ b/webtest/cds_test01.php @@ -1,23 +1,84 @@ #!/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) + { + 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"); } } +class long_cmd extends CDS_cmd { + var $long_data; + + function long_cmd($ch, $cmd_cls, $long_data) + { + parent::__construct($ch, $cmd_cls); + $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) + { + 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() @@ -26,15 +87,17 @@ class long_cmd_cls extends CDS_cmd_cls { } } + 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 + printf("Register CLS1\n"); if (($cds->cmd_register($cmd_cls1)) == FALSE) { fprintf(STDERR, "cmd_cls1 registration failed\n"); exit(1); @@ -44,20 +107,65 @@ function main() $cmd_cls2 = new long_cmd_cls(); // register cds_cmd 2 + printf("Register CLS2\n"); if (($cds->cmd_register($cmd_cls2)) == FALSE) { fprintf(STDERR, "cmd_cls2 registration failed\n"); exit(2); } // register cds_cmd 2 (retry) + printf("Re-register CLS2 (must go wrong)\n"); if (($cds->cmd_register($cmd_cls2)) != FALSE) { fprintf(STDERR, "cmd_cls2 re-registration success\n"); exit(3); } + print_r($cds); + printf("Deregister CLS2\n"); + if (($cds->cmd_deregister($cmd_cls2)) == FALSE) { + fprintf(STDERR, "cmd_cls2 deregistration failed\n"); + exit(4); + } + print_r($cds); + + // re-re-register cds_cmd 2 + printf("Re-re-register CLS2\n"); + if (($cds->cmd_register($cmd_cls2)) == FALSE) { + fprintf(STDERR, "cmd_cls2 re-re-registration failed\n"); + exit(5); + } + + printf("Deregister all\n"); + $cds->cmd_deregister_all(); + + // registrer cds_cmd 1 + printf("Register CLS1\n"); + if (($cds->cmd_register($cmd_cls1)) == FALSE) { + fprintf(STDERR, "cmd_cls1 registration failed\n"); + exit(1); + } + + // register cds_cmd 2 + printf("Register CLS2\n"); + if (($cds->cmd_register($cmd_cls2)) == FALSE) { + fprintf(STDERR, "cmd_cls2 registration failed\n"); + exit(2); + } print_r($cds); printf("SUCCESS\n"); + for ($i = 0 ; $i < 10 ; $i++) { + if ($i == 2) { + print("load short\n"); + if ($cds->execute("short", WEBURL.'/short.php') == FALSE) { + printf("push command failed\n"); + exit(123); + } + } + printf("Call process\n"); + $cds->process(); + sleep(1); + } // start loop // print status // if input data execute some command