g2              Sat Jun 13 03:13:31 2009 UTC

  Added files:                 
    /phpruntests/code-samples/taskScheduler/classes     task.php 
                                                        taskScheduler.php 
                                                        taskInterface.php 
    /phpruntests/code-samples/taskScheduler/example3/files/src/adv      
                                                                        
023.phpt 
                                                                        
010.phpt 
                                                                        
009.phpt 
                                                                        
026.phpt 
                                                                        
014.phpt 
                                                                        
027.phpt 
                                                                        
020.phpt 
                                                                        
011.phpt 
                                                                        
012.phpt 
                                                                        
013.phpt 
                                                                        
017.phpt 
                                                                        
022.phpt 
                                                                        
025.phpt 
                                                                        
016.phpt 
                                                                        
015.phpt 
                                                                        
018.phpt 
                                                                        
024.phpt 
                                                                        
019.phpt 
                                                                        
008.phpt 
    /phpruntests/code-samples/taskScheduler/example3/imgConverter       
                                                                        
imageCreator.php 
                                                                        
fileReader.php 
                                                                        
fileCreator.php 
                                                                        
imageReader.php 
    /phpruntests/code-samples/taskScheduler/example3/files/src/func     
                                                                        
007.phpt 
                                                                        
010.phpt 
                                                                        
002.phpt 
                                                                        
006.phpt 
                                                                        
008.phpt 
                                                                        
005a.phpt 
                                                                        
005.phpt 
                                                                        
003.phpt 
                                                                        
004.phpt 
                                                                        
001.phpt 
                                                                        
009.phpt 
    /phpruntests/code-samples/taskScheduler/example3/files/src/basic    
                                                                        
007.phpt 
                                                                        
006.phpt 
                                                                        
001.phpt 
                                                                        
004.phpt 
                                                                        
003.phpt 
                                                                        
005.phpt 
                                                                        
002.phpt 
    /phpruntests/code-samples/taskScheduler/example1    main.php 
                                                        taskCalculate.php 
    /phpruntests/code-samples/taskScheduler/example3    taskConvert.php 
                                                        main.php 
    /phpruntests/code-samples/taskScheduler     run.php 
    /phpruntests/code-samples/taskScheduler/example2    taskSleep.php 
                                                        main.php 
  Log:
  phpruntests - added taskScheduler-prototype
  
http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/classes/task.php?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/classes/task.php
+++ phpruntests/code-samples/taskScheduler/classes/task.php
<?php

abstract class task
{
        const NOEX = 0;
        const PASS = 1;
        const FAIL = -1;

        private $state = self::NOEX;
        private $index = NULL;
        private $message = NULL;
        
        
        public function setState($state)
        {
                $this->state = $state;          
        }
        
        public function getState()
        {
                return $this->state;
        }
        
        
        public function setMessage($msg)
        {
                $this->message = $msg;
        }

        public function getMessage()
        {
                return $this->message;
        }

        
        public function setIndex($index)
        {
                $this->index = $index;
        }

        public function getIndex()
        {
                return $this->index;
        }
        
}

?>
http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/classes/taskScheduler.php?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/classes/taskScheduler.php
+++ phpruntests/code-samples/taskScheduler/classes/taskScheduler.php
<?php

declare(ticks=true);


class taskScheduler
{
        const MSG_QUEUE_KEY = 1234;             // id of the message-queue
        const MSG_QUEUE_SIZE = 1024;    // max-size of a single message
        const KILL_CHILD = 'killBill';  // kill-signal to terminate a child

        private $taskList = array();
        private $processCount = NULL;
        private $inputQueue = NULL;
        private $pidStore = array(); 
        private $time = 0;
        private $countPass = 0;
        private $countFail = 0;
        private $groupTasks = false;
        
        
        /**
         * the constructor
         * 
         * @param array $taskList               (optional)
         * @param int   $processCount   (optional)
         */
    public function __construct(array $taskList=NULL, $processCount=NULL)
        {
                if (is_array($taskList)) {
                        $this->setTaskList($taskList);
                }
                
                $this->setProcessCount($processCount);
    }

    
    /**
     * sets the task-list which has to be an array of task-objects.
     * it's also possible to use a multidimensional array. in this case the
     * tasks are distributed to the child-processes exactly in the way as they
     * are grouped in the list. the first-level index strictly has to be
     * numeric and continuous starting with zero.
     * 
     * @param array $taskList
     */
        public function setTaskList(array $taskList)
        {
                if (is_array($taskList[0])) {
                        $this->groupTasks = true;
                        $this->processCount = sizeof($taskList);
                }
                
                $this->taskList = $taskList;
        }


        /**
         * @return array $taskList
         */
        public function getTaskList()
        {
                return $this->taskList;
        }
        
        
        /**
         * sets the number of child-processes.
         * in the case of using a multidimensional task-list this parameter is
         * ignored and set to the number of task-groups.
         *  
         * @param int $count
         */
        public function setProcessCount($processCount)
        {
                if ($this->groupTasks !== true && is_numeric($processCount) && 
$processCount >= 0) {
                        $this->processCount = $processCount;
                }
        }

        
        /**
         * removes the used message-queues.
         */
    private static function cleanUp()
    {
                @msg_remove_queue(msg_get_queue(self::MSG_QUEUE_KEY));
                @msg_remove_queue(msg_get_queue(self::MSG_QUEUE_KEY+1));
                logg("CLEAN UP");       
    }

    
        /**
         * the signal-handler is called by the interrupt- or quit-signal and 
calls
         * the cleanUp-method. 
         * 
         * @param int $signal
         */
        public static function signalHandler($signal)
        {
                logg("SIGNAL: $signal");
                
                switch($signal) {
                        
                        case SIGINT:
                        case SIGQUIT:
                                self::cleanUp();
                                die("\n");
                                break;
                                
                        default:
                                break;
                }
        }

    /**
     * switch to run the classic- or the fork-mode
     */
        public function run()
        {
                if ($this->processCount > 0) {
                        $this->runFork();
                }
                else $this->runClassic();
        }
        
        
        /**
         * executes the tasks in a simple loop 
         * 
         * @return void
         */
        private function runClassic()
        {
                $s = microtime(true);
                
                for ($i=0; $i<sizeof($this->taskList); $i++) {
                        
                        $task = $this->taskList[$i];
                        
                        if ($task->run() === true) {                    
                                $task->setState(task::PASS);
                                $this->countPass++;
                        } else {
                                $task->setState(task::FAIL);
                                $this->countFail++;
                        }
                        
                        print ".";
                        flush();
                        
                        $this->taskList[$i] = $task;
                }
                
                $error = microtime(true);
                
                $this->time = round($error-$s,5);

                return;
        }

        
        /**
         * starts the sender, the receiver and forks the defined
         * number of child-processes.
         * 
         * @return void
         */
        private function runFork()
        {
                $startTime = microtime(true);
                
                // register signal-handler
                pcntl_signal(SIGINT, "taskScheduler::signalHandler");
                pcntl_signal(SIGQUIT, "taskScheduler::signalHandler");

                // trim the processCount if nesecarry
                if (is_null($this->processCount) || $this->processCount > 
sizeof($this->taskList)) {
                        $this->processCount = sizeof($this->taskList);
                }
                                
                // fork the child-processes
                for ($i=0; $i<=$this->processCount; $i++) {

                        $this->pidStore[$i] = pcntl_fork();

                        switch ($this->pidStore[$i]) {
                                
                                case -1:        // failure
                                        die("could not fork"); 
                                        break;
                                
                                case 0:         // child
                                        if ($i==0) {
                                                $this->sender();
                                        } else {                                
        
                                                $cid = ($this->groupTasks == 
true) ? $i : NULL;
                                                $this->child($cid);
                                        }
                                        break;
                                        
                                default:        // parent
                                        break;
                        }
                }

                // start the receiver
                $this->receiver();

                // wait until all child-processes are terminated
                for ($i=0; $i<=$this->processCount; $i++) {

                        pcntl_waitpid($this->pidStore[$i], $status);
                        logg("child $i terminated - status $status");
                }

                $endTime = microtime(true);
                $this->time = round($endTime-$startTime,5);
                
                // remove the msg-queue
                self::cleanUp();

                logg("EXIT MAIN");
                return;
        }
        
        
        /**
         * the receiver is listening to the result-queue and stores the 
incomming
         * tasks back to the task-list.
         * when finished it sends the kill-signal to all children and terminates
         * itself.
         * 
         * @return void
         */
        private function receiver()
        {
                logg("RECEIVER START - ".sizeof($this->taskList)." tasks");

                $resultQueue = msg_get_queue(self::MSG_QUEUE_KEY+1);

                $task = '';
                $type = 1;
                
                if ($this->groupTasks == true) { 
                        $limit = 0;
                        foreach ($this->taskList as $list) {
                                $limit += sizeof($list);
                        } 
                } else {
                        $limit = sizeof($this->taskList);  
                }

                for ($i=0; $i<$limit; $i++) {
                
                        if (msg_receive($resultQueue, 0, $type, 
self::MSG_QUEUE_SIZE, $task, true, NULL, $error)) {

                                // check state
                                if ($task->getState() == task::PASS) {
                                        $this->countPass++;
                                } else {
                                        $this->countFail++;
                                }

                                // store result                         
                                $index = $task->getIndex();
                                
                                if ($this->groupTasks == true) {
                                        $this->taskList[$type-2][$index] = 
$task;
                                        logg("RECEIVER store task 
".($type-1)."-$index");
                                        
                                } else {
                                        $this->taskList[$index] = $task;
                                        logg("RECEIVER store task $index");
                                }
                        }
                        else logg("RECEIVER ERROR $error");
                }
                
                $inputQueue = msg_get_queue(self::MSG_QUEUE_KEY);
                
                for ($i=1; $i<=$this->processCount; $i++) {

                        if (msg_send($inputQueue, $i, self::KILL_CHILD, true, 
true, $error)) {
                                
                                logg("RECEIVER send KILL_CHILD");
                        }
                        else logg("RECEIVER ERROR $error");
                }

                logg("RECEIVER EXIT");
                return;
        }

        
        /**
         * the sender is passes through the task-list and distributes the single
         * tasks to the child-processes using the input-queue.
         * when finished it terminates itself.
         * 
         * @return void
         */
        private function sender()
        {
                logg("SENDER START - ".sizeof($this->taskList)." tasks");

                $this->inputQueue = msg_get_queue(self::MSG_QUEUE_KEY);

                for ($i=0; $i<sizeof($this->taskList); $i++) {

                        if ($this->groupTasks == true) {
                                
                                for ($j=0; $j<sizeof($this->taskList[$i]); 
$j++) {

                                        
$this->sendTask($this->taskList[$i][$j], $j, $i+1);
                                }

                        } else {
                                
                                $this->sendTask($this->taskList[$i], $i);
                        }
                }

                logg("SENDER EXIT");
                exit(0);
        }
        
        
        /**
         * helper-class of sender.
         * sends a task to a child-process using the input-queue.
         * 
         * @param  task $task   the task to send
         * @param  int  $index  the task's index in the taskList 
         * @param  int  $type   the message-type (default=1)
         * @return void
         */
        private function sendTask(task $task, $index, $type=1)
        {
                $task->setIndex($index);

                if (msg_send($this->inputQueue, $type, $task, true, true, 
$error)) {
                        
                        logg("SENDER send task $type - $index");
                }
                else logg("SENDER ERROR $error");
                
                return;
        }

        
        /**
         * the child is listening to the input-queue and executes the incomming
         * tasks. afterwards it setts the task-state and sends it back to the
         * receiver by the result-queue.
         * after receiving the kill-signal from the receiver it terminates 
itself. 
         * 
         * @param  int  $cid    the child-id (default=NULL)
         * @return void
         */
        private function child($cid=NULL)
        {
                if (is_null($cid)) {
                        $cid = 0;
                }
                
                logg("child $cid START");

                $inputQueue = msg_get_queue(self::MSG_QUEUE_KEY);
                $resultQueue = msg_get_queue(self::MSG_QUEUE_KEY+1);

                $type = 1;

                while (true) {

                        if (msg_receive($inputQueue, $cid, $type, 
self::MSG_QUEUE_SIZE, $task, true, NULL, $error)) {

                                if ($task == self::KILL_CHILD)
                                        break;

                                $index = $task->getIndex();
                                
                                logg("child $cid - run task $index");

                                if ($task->run() === true) {                    
                                        $task->setState(task::PASS);
                                } else {
                                        $task->setState(task::FAIL);
                                }
                                
                                print ".";
                                flush();

                                if (msg_send($resultQueue, $cid+1, $task, true, 
true, $error)) {
                                
                                        logg("child $cid - send task $index");
                                }
                                else logg("child $cid ERROR $error");
        
                        }
                        else logg("child $cid ERROR $error");
                }
                
                logg("child $cid EXIT");
                exit(0);
        }

        
        /**
         * prints the statistic
         * 
         * @return void
         */
        public function printStatistic()
        {
                print "\n----------------------------------------\n";
                
                if ($this->groupTasks == true) {
                
                        $count = 0;
                        foreach ($this->taskList as $list) {
                                $count += sizeof($list);
                        }
                        
                        print "Groups:\t\t".sizeof($this->taskList)."\n";
                        print "Tasks:\t\t".$count."\n";

                } else {
                        $count = sizeof($this->taskList);
                        print "Tasks:\t\t".$count."\n";
                }

                print "PASSED:\t\t".$this->countPass." 
(".round($this->countPass/$count*100,2)."%)\n";
                print "FAILED:\t\t".$this->countFail." 
(".round($this->countFail/$count*100,2)."%)\n";
                print "Processes:\t".$this->processCount."\n";
                print "Seconds:\t".$this->time."\n";
                
                if ($this->processCount > 0) {
                        print "AVG 
sec/task:\t".round($this->time/$this->processCount,5)."\n";
                }
                
                print "----------------------------------------\n";
                flush();
        }
        
        
        /**
         * prints a overview of the faild tasks
         * 
         * @return void
         */
        public function printFailedTasks()
        {
                if ($this->countFail > 0) {
                
                        print "FAILED TASKS";
                        print "\n----------------------------------------\n";
                        
                        for ($i=0; $i<sizeof($this->taskList); $i++) {
        
                                $task = $this->taskList[$i];
                                
                                if ($task->getState() == task::FAIL) {
                                        print "Task $i: 
".$task->getMessage()."\n";
                                }
                        }
                        
                        print "----------------------------------------\n";
                        flush();
                }
        }
        
}

?>
http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/classes/taskInterface.php?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/classes/taskInterface.php
+++ phpruntests/code-samples/taskScheduler/classes/taskInterface.php
<?php

interface taskInterface
{
        public function run();
}

?>
http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/adv/023.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/adv/023.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/adv/023.phpt
--TEST--
Cookies test#2
--COOKIE--
c o o k i e=value; c o o k i e= v a l u e ;;c%20o+o 
k+i%20e=v;name="value","value",UEhQIQ==;UEhQIQ==foo
--FILE--
<?php
var_dump($_COOKIE);
?>
--EXPECT--
array(3) {
  [u"c_o_o_k_i_e"]=>
  unicode(1) "v"
  [u"name"]=>
  unicode(24) ""value","value",UEhQIQ=="
  [u"UEhQIQ"]=>
  unicode(4) "=foo"
}

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/adv/010.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/adv/010.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/adv/010.phpt
--TEST--
Testing | and & operators
--FILE--
<?php $a=8; $b=4; $c=8; echo $a|$b&$c?>
--EXPECT--
8

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/adv/009.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/adv/009.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/adv/009.phpt
--TEST--
Subtract 3 variables and print result
--FILE--
<?php $a=27; $b=7; $c=10; $d=$a-$b-$c; echo $d?>
--EXPECT--
10

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/adv/026.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/adv/026.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/adv/026.phpt
--TEST--
Registration of HTTP_RAW_POST_DATA due to unknown content-type
--INI--
magic_quotes_gpc=0
always_populate_raw_post_data=0
--SKIPIF--
<?php if (php_sapi_name()=='cli') echo 'skip'; ?>
--POST_RAW--
Content-Type: unknown/type
a=1&b=ZYX
--FILE--
<?php
var_dump($_POST, $HTTP_RAW_POST_DATA);
?>
--EXPECT--
array(0) {
}
unicode(9) "a=1&b=ZYX"

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/adv/014.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/adv/014.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/adv/014.phpt
--TEST--
POST Method test and arrays - 2
--SKIPIF--
<?php if (php_sapi_name()=='cli') echo 'skip'; ?>
--POST--
a[]=1&a[]=1
--FILE--
<?php
var_dump($_POST['a']); 
?>
--EXPECT--
array(2) {
  [0]=>
  unicode(1) "1"
  [1]=>
  unicode(1) "1"
}

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/adv/027.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/adv/027.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/adv/027.phpt
--TEST--
Handling of max_input_nesting_level being reached
--INI--
magic_quotes_gpc=0
always_populate_raw_post_data=0
display_errors=0
max_input_nesting_level=10
track_errors=1
log_errors=0
--SKIPIF--
<?php if (php_sapi_name()=='cli') echo 'skip'; ?>
--POST--
a=1&b=ZYX&c[][][][][][][][][][][][][][][][][][][][][][]=123&d=123&e[][]][]=3
--FILE--
<?php
var_dump($_POST, $php_errormsg);
?>
--EXPECT--
array(4) {
  [u"a"]=>
  unicode(1) "1"
  [u"b"]=>
  unicode(3) "ZYX"
  [u"d"]=>
  unicode(3) "123"
  [u"e"]=>
  array(1) {
    [0]=>
    array(1) {
      [0]=>
      unicode(1) "3"
    }
  }
}
unicode(106) "Input variable nesting level exceeded 10. To increase the limit 
change max_input_nesting_level in php.ini."

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/adv/020.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/adv/020.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/adv/020.phpt
--TEST--
POST Method test and arrays - 8 
--SKIPIF--
<?php if (php_sapi_name()=='cli') echo 'skip'; ?>
--POST--
a[a[]]=1&a[b[]]=3
--FILE--
<?php
var_dump($_POST['a']); 
?>
--EXPECT--
array(2) {
  [u"a["]=>
  unicode(1) "1"
  [u"b["]=>
  unicode(1) "3"
}

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/adv/011.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/adv/011.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/adv/011.phpt
--TEST--
Testing $argc and $argv handling (GET)
--SKIPIF--
<?php if (php_sapi_name()=='cli') echo 'skip'; ?>
--INI--
register_argc_argv=1
--GET--
ab+cd+ef+123+test
--FILE--
<?php 
for ($i=0; $i<$_SERVER['argc']; $i++) {
        echo "$i: ".$_SERVER['argv'][$i]."\n";
}
?>
--EXPECT--
0: ab
1: cd
2: ef
3: 123
4: test

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/adv/012.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/adv/012.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/adv/012.phpt
--TEST--
Testing $argc and $argv handling (cli)
--SKIPIF--
<?php if(php_sapi_name()!='cli') echo 'skip'; ?>
--INI--
register_argc_argv=1
variables_order=GPS
--ARGS--
ab cd ef 123 test
--FILE--
<?php 

$argc = $_SERVER['argc'];
$argv = $_SERVER['argv'];

for ($i=1; $i<$argc; $i++) {
        echo ($i-1).": ".$argv[$i]."\n";
}

?>
--EXPECT--
0: ab
1: cd
2: ef
3: 123
4: test

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/adv/013.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/adv/013.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/adv/013.phpt
--TEST--
POST Method test and arrays
--SKIPIF--
<?php if (php_sapi_name()=='cli') echo 'skip'; ?>
--POST--
a[]=1
--FILE--
<?php
var_dump($_POST['a']); 
?>
--EXPECT--
array(1) {
  [0]=>
  unicode(1) "1"
}

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/adv/017.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/adv/017.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/adv/017.phpt
--TEST--
POST Method test and arrays - 5 
--SKIPIF--
<?php if (php_sapi_name()=='cli') echo 'skip'; ?>
--POST--
a[]=1&a[a]=1&a[b]=3
--FILE--
<?php
var_dump($_POST['a']); 
?>
--EXPECT--
array(3) {
  [0]=>
  unicode(1) "1"
  [u"a"]=>
  unicode(1) "1"
  [u"b"]=>
  unicode(1) "3"
}

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/adv/022.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/adv/022.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/adv/022.phpt
--TEST--
Cookies test#1
--COOKIE--
cookie1=val1  ; cookie2=val2%20; cookie3=val 3.; cookie 4= value 4 %3B; 
cookie1=bogus; %20cookie1=ignore;+cookie1=ignore;cookie1;cookie  5=%20 value; 
cookie%206=þæö;cookie+7=;$cookie.8;cookie-9=1;;;- & % $cookie 10=10
--FILE--
<?php
var_dump($_COOKIE);
?>
--EXPECTF--
array(10) {
  [u"cookie1"]=>
  unicode(0) ""
  [u"cookie2"]=>
  unicode(5) "val2 "
  [u"cookie3"]=>
  unicode(6) "val 3."
  [u"cookie_4"]=>
  unicode(10) " value 4 ;"
  [u"cookie__5"]=>
  unicode(7) "  value"
  [u"cookie_6"]=>
  unicode(3) "%s"
  [u"cookie_7"]=>
  unicode(0) ""
  [u"$cookie_8"]=>
  unicode(0) ""
  [u"cookie-9"]=>
  unicode(1) "1"
  [u"-_&_%_$cookie_10"]=>
  unicode(2) "10"
}

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/adv/025.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/adv/025.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/adv/025.phpt
--TEST--
Test HTTP_RAW_POST_DATA with excessive post length
--INI--
magic_quotes_gpc=0
always_populate_raw_post_data=1
post_max_size=1K
--SKIPIF--
<?php if (php_sapi_name()=='cli') echo 'skip'; ?>
--POST--
a=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!
 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaa
--FILE--
<?php
var_dump($_POST, $HTTP_RAW_POST_DATA);
?>
--EXPECTF--
Warning: Unknown: POST Content-Length of 2050 bytes exceeds the limit of 1024 
bytes in Unknown on line 0

Warning: Cannot modify header information - headers already sent in Unknown on 
line 0

Notice: Undefined variable: HTTP_RAW_POST_DATA in %s on line %d
array(0) {
}
NULL

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/adv/016.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/adv/016.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/adv/016.phpt
--TEST--
POST Method test and arrays - 4 
--SKIPIF--
<?php if (php_sapi_name()=='cli') echo 'skip'; ?>
--POST--
a[a]=1&a[b]=3
--FILE--
<?php
var_dump($_POST['a']); 
?>
--EXPECT--
array(2) {
  [u"a"]=>
  unicode(1) "1"
  [u"b"]=>
  unicode(1) "3"
}

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/adv/015.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/adv/015.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/adv/015.phpt
--TEST--
POST Method test and arrays - 3 
--SKIPIF--
<?php if (php_sapi_name()=='cli') echo 'skip'; ?>
--POST--
a[]=1&a[0]=5
--FILE--
<?php
var_dump($_POST['a']); 
?>
--EXPECT--
array(1) {
  [0]=>
  unicode(1) "5"
}

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/adv/018.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/adv/018.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/adv/018.phpt
--TEST--
POST Method test and arrays - 6 
--SKIPIF--
<?php if (php_sapi_name()=='cli') echo 'skip'; ?>
--POST--
a[][]=1&a[][]=3&b[a][b][c]=1&b[a][b][d]=1
--FILE--
<?php
var_dump($_POST['a']); 
var_dump($_POST['b']); 
?>
--EXPECT--
array(2) {
  [0]=>
  array(1) {
    [0]=>
    unicode(1) "1"
  }
  [1]=>
  array(1) {
    [0]=>
    unicode(1) "3"
  }
}
array(1) {
  [u"a"]=>
  array(1) {
    [u"b"]=>
    array(2) {
      [u"c"]=>
      unicode(1) "1"
      [u"d"]=>
      unicode(1) "1"
    }
  }
}

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/adv/024.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/adv/024.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/adv/024.phpt
--TEST--
Test HTTP_RAW_POST_DATA creation
--INI--
magic_quotes_gpc=0
always_populate_raw_post_data=1
--SKIPIF--
<?php if (php_sapi_name()=='cli') echo 'skip'; ?>
--POST--
a=ABC&y=XYZ&c[]=1&c[]=2&c[a]=3
--FILE--
<?php
var_dump($_POST, $HTTP_RAW_POST_DATA);
?>
--EXPECT--
array(3) {
  [u"a"]=>
  unicode(3) "ABC"
  [u"y"]=>
  unicode(3) "XYZ"
  [u"c"]=>
  array(3) {
    [0]=>
    unicode(1) "1"
    [1]=>
    unicode(1) "2"
    [u"a"]=>
    unicode(1) "3"
  }
}
unicode(30) "a=ABC&y=XYZ&c[]=1&c[]=2&c[a]=3"

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/adv/019.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/adv/019.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/adv/019.phpt
--TEST--
POST Method test and arrays - 7 
--SKIPIF--
<?php if (php_sapi_name()=='cli') echo 'skip'; ?>
--POST--
a[]=1&a[]]=3&a[[]=4
--FILE--
<?php
var_dump($_POST['a']); 
?>
--EXPECT--
array(3) {
  [0]=>
  unicode(1) "1"
  [1]=>
  unicode(1) "3"
  [u"["]=>
  unicode(1) "4"
}

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/adv/008.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/adv/008.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/adv/008.phpt
--TEST--
Divide 3 variables and print result
--FILE--
<?php $a=27; $b=3; $c=3; $d=$a/$b/$c; echo $d?>
--EXPECT--
3

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/imgConverter/imageCreator.php?view=markup&rev=1.1
Index: 
phpruntests/code-samples/taskScheduler/example3/imgConverter/imageCreator.php
+++ 
phpruntests/code-samples/taskScheduler/example3/imgConverter/imageCreator.php
<?php


class imageCreator {
        
        
        private $chars = array();
        private $image = NULL;
        private $size = 0;
        
        private $pixelGap = 2;
        
        
        public function __construct(array $chars) {

                $this->chars = $chars;
        }
        

        public function draw() {
                
                $s = $this->size = 
ceil(sqrt(sizeof($this->chars)/3))*$this->pixelGap;
                
                $this->image = 
ImageCreateTrueColor($this->size-$this->pixelGap+1, 
$this->size-$this->pixelGap+1);
                
                $bg = ImageColorAllocate($this->image, 255, 255, 255);
                
                ImageFill($this->image, 0, 0, $bg);
                ImageColorTransparent($this->image, $bg);

                $colors = array();

                $x = 0;
                $y = 0;

                for ($i=0; $i<sizeof($this->chars); $i+=3) {
                        
                        if ($i>0 && $x%$s==0) {
                                
                                $x = 0;
                                $y += $this->pixelGap ;
                        }
                        
                        $r = $this->chars[$i];
                        $g = $this->chars[$i+1];
                        $b = $this->chars[$i+2];
                        
                        $v = $r.$g.$b;

                        if (!isset($colors[$v]))
                                $colors[$v] = ImageColorAllocate($this->image , 
$r*2, $g*2, $b*2);

                        ImageLine($this->image , $x, $y, $x, $y, $colors[$v]);

                        $x += $this->pixelGap;
                }
                
                // $this->quadSize();

                // imageellipse($this->image, $size, $size, $size*2, $size*2, 
$bg);
        }
        
        
        public function quadSize() {
                
                $s = $this->size+$this->pixelGap-1;
                
                $img = ImageCreateTrueColor($s*2, $s*2);
                
                $bg = ImageColorAllocate($this->image , 255, 255, 255);
                
                ImageFill($img, 0, 0, $bg);
                ImageColorTransparent($img, $bg);
                
                imagecopymerge($img, $this->image, $s, $s, 0, 0, $s, $s, 100);

                $tmp = ImageCreateTrueColor($s, $s);
                
                imagecopyresampled($tmp, $this->image, 0, 0, ($s-1), 0, $s, $s, 
0-$s, $s);
                imagecopymerge($img, $tmp, 0, $s, 0, 0, $s, $s, 100);
                
                imagecopyresampled($tmp, $this->image, 0, 0, 0, ($s-1), $s, $s, 
$s, 0-$s);
                imagecopymerge($img, $tmp, $s, 0, 0, 0, $s, $s, 100);
                
                imagecopyresampled($tmp, $this->image, 0, 0, ($s-1), ($s-1), 
$s, $s, 0-$s, 0-$s);
                imagecopymerge($img, $tmp, 0, 0, 0, 0, $s, $s, 100);
                
                $this->image = $img;
        }
        
        
        
        public function nice() {
                
                $sum = array_sum($this->chars);
                
                $s = ceil(sqrt($sum));
                
                $this->image = ImageCreateTrueColor(sizeof($this->chars)*2, 
255);
                
                $bg = ImageColorAllocate($this->image, 255, 255, 255);
                
                ImageFill($this->image, 0, 0, $bg);
                ImageColorTransparent($this->image, $bg);

                $colors = array();
                
                for ($i=0; $i<sizeof($this->chars); $i++) {
        
                        $v = $this->chars[$i]*2;

                        if (!isset($colors[$v]))
                                $colors[$v] = ImageColorAllocate($this->image , 
$v, $v, $v);

                        ImageLine($this->image , $i*2, 255, $i*2, 255-$v, 
$colors[$v]);
                }               
        }

        
        public function saveImage($name) {
                
                return ImagePNG($this->image, $name);
        }
        
        public function setPixelGap($gap) {
                
                $this->pixelGap = is_numeric($gap) ? $gap+1 : 1;
        }
        
} 


?>
http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/imgConverter/fileReader.php?view=markup&rev=1.1
Index: 
phpruntests/code-samples/taskScheduler/example3/imgConverter/fileReader.php
+++ phpruntests/code-samples/taskScheduler/example3/imgConverter/fileReader.php
<?php

class fileReader {
        
        
        private $file = NULL; 
        private $chars = array();
        
        private $trimFile = false;
        
        
        public function __construct($file) {
                
                $this->file = new SplFileInfo($file);
        
                if ($this->file->isFile() == false)
                        die($file.' is not a valid file');              
        }
        
        
        public function getAsciiChars() {
                
                return $this->chars;
        }
        
        
        public function setTrim($trim) {
                
                $this->trimFile = is_bool($trim) ? $trim : false;
        }
        
        
        public function read() {

                $lines = file($this->file->getPathname(), 
FILE_IGNORE_NEW_LINES);

                foreach ($lines as $line) {
                        
                        if ($this->trimFile) $line = trim($line);
                        
                        for ($i=0; $i<strlen($line); $i++) {
                        
                                $this->chars[] = ord($line{$i});                
                        }
                        
                        $this->chars[] = 10; // new line                        
                }
        }
        

        
}

?>
http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/imgConverter/fileCreator.php?view=markup&rev=1.1
Index: 
phpruntests/code-samples/taskScheduler/example3/imgConverter/fileCreator.php
+++ phpruntests/code-samples/taskScheduler/example3/imgConverter/fileCreator.php
<?php

class fileCreator {

        
        private $chars = array();
        private $buffer = '';
        
        
        public function __construct(array $chars) {

                $this->chars = $chars;
        }
        
        
        public function create() {
                
                for ($i=0; $i<sizeof($this->chars); $i++) {
                        
                        if ($this->chars[$i] != 255) {
                        
                                $this->buffer.= chr($this->chars[$i]);
                        }
                }
        }
        
        
        public function getBufferString() {
                
                return $this->buffer;
        }
        
        
        public function write($file) {

                $f = fopen($file, 'w');

                fwrite($f, $this->buffer);

                fclose($f);
        }
        

        
        
}

?>
http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/imgConverter/imageReader.php?view=markup&rev=1.1
Index: 
phpruntests/code-samples/taskScheduler/example3/imgConverter/imageReader.php
+++ phpruntests/code-samples/taskScheduler/example3/imgConverter/imageReader.php
<?php

class imageReader {
        
        
        private $file = NULL; 
        private $chars = array();
        private $size = 0;
        
        private $pixelGap = 2;

        
        public function __construct($file) {
                
                $this->file = new SplFileInfo($file);
        
                if ($this->file->isFile() == false)
                        throw Exception($file.' is not a valid file');  

                $info = getimagesize($this->file);
                
                if ($info[0] != $info[1])
                        throw Exception($file.' has invalid dimensions');
                        
                $this->size = $info[0];
                        
                if ($info['mime'] != 'image/png')
                        throw Exception($file.' has to ba a png');
        }

        
        public function read() {

                $img = ImageCreateFromPNG($this->file);

                $x = 0;
                $y = 0;

                for ($i=0; $i<($this->size*$this->size); $i++) {
                        
                        if ($i>0 && $x%$this->size==0) {
                                
                                $x = 0;
                                $y += $this->pixelGap;
                        }
                        
                        $rgb = ImageColorAt($img, $x, $y);

                        if ($rgb) {

                                $this->chars[] = (($rgb >> 16) & 0xFF);
                                $this->chars[] = (($rgb >> 8) & 0xFF);
                                $this->chars[] = ($rgb & 0xFF);
                        }
                        
                        $x += $this->pixelGap;
                }
        }

        
        public function getAsciiChars() {
                
                return $this->chars;
        }
        
        public function setPixelGap($gap) {
                
                $this->pixelGap = is_numeric($gap) ? $gap+1 : 1;
        }

        
}

?>
http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/func/007.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/func/007.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/func/007.phpt
--TEST--
INI functions test
--FILE--
<?php

$ini1 =  ini_get('include_path'); 
ini_set('include_path','ini_set_works');
echo ini_get('include_path')."\n";
ini_restore('include_path');
$ini2 =  ini_get('include_path'); 

if ($ini1 !== $ini2) {
        echo "ini_restore() does not work.\n";
}
else {
        echo "ini_restore_works\n";
}

?>
--EXPECT--
ini_set_works
ini_restore_works

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/func/010.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/func/010.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/func/010.phpt
--TEST--
function with many parameters
--FILE--
<?php

// the stack size + some random constant
$boundary = 64*1024;
$limit    = $boundary+42;


function test($a, $b)
{
        var_dump($a === $b);
        test2($a,$b);
}

function test2($a, $b)
{
        if ($a !== $b) {
                var_dump("something went wrong: $a !== $b");
        }
}


// generate the function
$str = "<?php\nfunction x(";

for($i=0; $i < $limit; ++$i) {
        $str .= '$v'.dechex($i).($i===($limit-1) ? '' : ',');
}

$str .= ') {
        test($v42, \'42\');
        test(\'4000\', $v4000);
        test2($v300, \'300\');
        test($v0, \'0\'); // first
        test($v'.dechex($limit-1).", '".dechex($limit-1).'\'); // last
        test($v'.dechex($boundary).", '".dechex($boundary).'\'); //boundary
        test($v'.dechex($boundary+1).", '".dechex($boundary+1).'\'); 
//boundary+1
        test($v'.dechex($boundary-1).", '".dechex($boundary-1).'\'); 
//boundary-1
}';

// generate the function call
$str .= "\n\nx(";

for($i=0; $i< $limit; ++$i) {
        $str .= "'".dechex($i)."'".($i===($limit-1) ? '' : ',');
}

$str .= ");\n";

$filename = dirname(__FILE__).'/010-file.php';
file_put_contents(dirname(__FILE__).'/010-file.php', $str);
unset($str);

include($filename);

echo "Done\n";

?>
--CLEAN--
<?php
@unlink(dirname(__FILE__).'/010-file.php');
?>
--EXPECT--
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
Done

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/func/002.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/func/002.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/func/002.phpt
--TEST--
Static variables in functions
--FILE--
<?php 
function blah()
{
  static $hey=0,$yo=0;

  echo "hey=".$hey++.", ",$yo--."\n";
}
    
blah();
blah();
blah();
if (isset($hey) || isset($yo)) {
  echo "Local variables became global :(\n";
}
--EXPECT--
hey=0, 0
hey=1, -1
hey=2, -2

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/func/006.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/func/006.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/func/006.phpt
--TEST--
Output buffering tests
--INI--
output_buffering=0
output_handler=
zlib.output_compression=0
zlib.output_handler=
--FILE--
<?php
ob_start();
echo ob_get_level();
echo 'A';
  ob_start();
  echo ob_get_level();
  echo 'B';
  $b = ob_get_contents();
  ob_end_clean();
$a = ob_get_contents();
ob_end_clean();

var_dump( $b ); // 2B
var_dump( $a ); // 1A
?>
--EXPECT--
string(2) "2B"
string(2) "1A"

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/func/008.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/func/008.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/func/008.phpt
--TEST--
Test for buffering in core functions with implicit flush off
--INI--
implicit_flush=0
--FILE--
<?php
$res = var_export("foo1");
echo "\n";
$res = var_export("foo2", TRUE);
echo "\n";
echo $res."\n";
?>
--EXPECT--
'foo1'

'foo2'

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/func/005a.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/func/005a.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/func/005a.phpt
--TEST--
Testing register_shutdown_function() with timeout. (Bug: #21513)
--FILE--
<?php

ini_set('display_errors', 0);
    
echo "Start\n";

function boo()
{
        echo "Shutdown\n";
}

register_shutdown_function("boo");

/* not necessary, just to show the error sooner */
set_time_limit(1); 

/* infinite loop to simulate long processing */
for (;;) {}

echo "End\n";

?>
--EXPECT--
Start
Shutdown

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/func/005.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/func/005.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/func/005.phpt
--TEST--
Testing register_shutdown_function()
--FILE--
<?php 

function foo()
{
        print "foo";
}

register_shutdown_function("foo");

print "foo() will be called on shutdown...\n";

?>
--EXPECT--
foo() will be called on shutdown...
foo

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/func/003.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/func/003.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/func/003.phpt
--TEST--
General function test
--FILE--
<?php 

function a()
{
  echo "hey\n";
}

function b($i)
{
  echo "$i\n";
}


function c($i,$j)
{
  echo "Counting from $i to $j\n";
  for ($k=$i; $k<=$j; $k++) {
    echo "$k\n";
  }
}



a();
b("blah");
a();
b("blah","blah");
c(7,14);

a();


function factorial($n)
{
  if ($n==0 || $n==1) {
    return 1;
  } else {
    return factorial($n-1)*$n;
  }
}


function factorial2($start, $n)
{
  if ($n<=$start) {
    return $start;
  } else {
    return factorial2($start,$n-1)*$n;
  }
}


for ($k=0; $k<10; $k++) {
  for ($i=0; $i<=10; $i++) {
    $n=factorial($i);
    echo "factorial($i) = $n\n";
  }
}


echo "and now, from a function...\n";

function call_fact()
{
  echo "(it should break at 5...)\n";
  for ($i=0; $i<=10; $i++) {
    if ($i == 5) break;
    $n=factorial($i);
    echo "factorial($i) = $n\n";
  }
}

function return4() { return 4; }
function return7() { return 7; }

for ($k=0; $k<10; $k++) {
  call_fact();
}

echo "------\n";
$result = factorial(factorial(3));
echo "$result\n";

$result=factorial2(return4(),return7());
echo "$result\n";

function andi($i, $j)
{
        for ($k=$i ; $k<=$j ; $k++) {
                if ($k >5) continue;
                echo "$k\n";
        }
}

andi (3,10);
--EXPECT--
hey
blah
hey
blah
Counting from 7 to 14
7
8
9
10
11
12
13
14
hey
factorial(0) = 1
factorial(1) = 1
factorial(2) = 2
factorial(3) = 6
factorial(4) = 24
factorial(5) = 120
factorial(6) = 720
factorial(7) = 5040
factorial(8) = 40320
factorial(9) = 362880
factorial(10) = 3628800
factorial(0) = 1
factorial(1) = 1
factorial(2) = 2
factorial(3) = 6
factorial(4) = 24
factorial(5) = 120
factorial(6) = 720
factorial(7) = 5040
factorial(8) = 40320
factorial(9) = 362880
factorial(10) = 3628800
factorial(0) = 1
factorial(1) = 1
factorial(2) = 2
factorial(3) = 6
factorial(4) = 24
factorial(5) = 120
factorial(6) = 720
factorial(7) = 5040
factorial(8) = 40320
factorial(9) = 362880
factorial(10) = 3628800
factorial(0) = 1
factorial(1) = 1
factorial(2) = 2
factorial(3) = 6
factorial(4) = 24
factorial(5) = 120
factorial(6) = 720
factorial(7) = 5040
factorial(8) = 40320
factorial(9) = 362880
factorial(10) = 3628800
factorial(0) = 1
factorial(1) = 1
factorial(2) = 2
factorial(3) = 6
factorial(4) = 24
factorial(5) = 120
factorial(6) = 720
factorial(7) = 5040
factorial(8) = 40320
factorial(9) = 362880
factorial(10) = 3628800
factorial(0) = 1
factorial(1) = 1
factorial(2) = 2
factorial(3) = 6
factorial(4) = 24
factorial(5) = 120
factorial(6) = 720
factorial(7) = 5040
factorial(8) = 40320
factorial(9) = 362880
factorial(10) = 3628800
factorial(0) = 1
factorial(1) = 1
factorial(2) = 2
factorial(3) = 6
factorial(4) = 24
factorial(5) = 120
factorial(6) = 720
factorial(7) = 5040
factorial(8) = 40320
factorial(9) = 362880
factorial(10) = 3628800
factorial(0) = 1
factorial(1) = 1
factorial(2) = 2
factorial(3) = 6
factorial(4) = 24
factorial(5) = 120
factorial(6) = 720
factorial(7) = 5040
factorial(8) = 40320
factorial(9) = 362880
factorial(10) = 3628800
factorial(0) = 1
factorial(1) = 1
factorial(2) = 2
factorial(3) = 6
factorial(4) = 24
factorial(5) = 120
factorial(6) = 720
factorial(7) = 5040
factorial(8) = 40320
factorial(9) = 362880
factorial(10) = 3628800
factorial(0) = 1
factorial(1) = 1
factorial(2) = 2
factorial(3) = 6
factorial(4) = 24
factorial(5) = 120
factorial(6) = 720
factorial(7) = 5040
factorial(8) = 40320
factorial(9) = 362880
factorial(10) = 3628800
and now, from a function...
(it should break at 5...)
factorial(0) = 1
factorial(1) = 1
factorial(2) = 2
factorial(3) = 6
factorial(4) = 24
(it should break at 5...)
factorial(0) = 1
factorial(1) = 1
factorial(2) = 2
factorial(3) = 6
factorial(4) = 24
(it should break at 5...)
factorial(0) = 1
factorial(1) = 1
factorial(2) = 2
factorial(3) = 6
factorial(4) = 24
(it should break at 5...)
factorial(0) = 1
factorial(1) = 1
factorial(2) = 2
factorial(3) = 6
factorial(4) = 24
(it should break at 5...)
factorial(0) = 1
factorial(1) = 1
factorial(2) = 2
factorial(3) = 6
factorial(4) = 24
(it should break at 5...)
factorial(0) = 1
factorial(1) = 1
factorial(2) = 2
factorial(3) = 6
factorial(4) = 24
(it should break at 5...)
factorial(0) = 1
factorial(1) = 1
factorial(2) = 2
factorial(3) = 6
factorial(4) = 24
(it should break at 5...)
factorial(0) = 1
factorial(1) = 1
factorial(2) = 2
factorial(3) = 6
factorial(4) = 24
(it should break at 5...)
factorial(0) = 1
factorial(1) = 1
factorial(2) = 2
factorial(3) = 6
factorial(4) = 24
(it should break at 5...)
factorial(0) = 1
factorial(1) = 1
factorial(2) = 2
factorial(3) = 6
factorial(4) = 24
------
720
840
3
4
5

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/func/004.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/func/004.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/func/004.phpt
--TEST--
General function test
--FILE--
<?php 

echo "Before function declaration...\n";

function print_something_multiple_times($something,$times)
{
  echo "----\nIn function, printing the string \"$something\" $times times\n";
  for ($i=0; $i<$times; $i++) {
    echo "$i) $something\n";
  }
  echo "Done with function...\n-----\n";
}

function some_other_function()
{
  echo "This is some other function, to ensure more than just one function 
works fine...\n";
}


echo "After function declaration...\n";

echo "Calling function for the first time...\n";
print_something_multiple_times("This works!",10);
echo "Returned from function call...\n";

echo "Calling the function for the second time...\n";
print_something_multiple_times("This like, really works and stuff...",3);
echo "Returned from function call...\n";

some_other_function();

?>
--EXPECT--

Before function declaration...
After function declaration...
Calling function for the first time...
----
In function, printing the string "This works!" 10 times
0) This works!
1) This works!
2) This works!
3) This works!
4) This works!
5) This works!
6) This works!
7) This works!
8) This works!
9) This works!
Done with function...
-----
Returned from function call...
Calling the function for the second time...
----
In function, printing the string "This like, really works and stuff..." 3 times
0) This like, really works and stuff...
1) This like, really works and stuff...
2) This like, really works and stuff...
Done with function...
-----
Returned from function call...
This is some other function, to ensure more than just one function works fine...

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/func/001.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/func/001.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/func/001.phpt
--TEST--
Strlen() function test
--FILE--
<?php echo strlen("abcdef")?>
--EXPECT--
6

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/func/009.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/func/009.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/func/009.phpt
--TEST--
Test for buffering in core functions with implicit flush on
--INI--
implicit_flush=1
--FILE--
<?php
$res = var_export("foo1");
echo "\n";
$res = var_export("foo2", TRUE);
echo "\n";
echo $res."\n";
?>
--EXPECT--
'foo1'

'foo2'

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/basic/007.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/basic/007.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/basic/007.phpt
--TEST--
Multiply 3 variables and print result
--FILE--
<?php $a=2; $b=4; $c=8; $d=$a*$b*$c; echo $d?>
--EXPECT--
64

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/basic/006.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/basic/006.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/basic/006.phpt
--TEST--
Add 3 variables together and print result
--FILE--
<?php $a=1; $b=2; $c=3; $d=$a+$b+$c; echo $d?>
--EXPECT--
6

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/basic/001.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/basic/001.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/basic/001.phpt
--TEST--
Trivial "Hello World" test
--FILE--
<?php echo "Hello World"?>
--EXPECT--
Hello World

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/basic/004.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/basic/004.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/basic/004.phpt
--TEST--
Two variables in POST data
--SKIPIF--
<?php if (php_sapi_name()=='cli') echo 'skip'; ?>
--POST--
a=Hello+World&b=Hello+Again+World
--FILE--
<?php 
error_reporting(0);
echo "{$_POST['a']} {$_POST['b']}" ?>
--EXPECT--
Hello World Hello Again World

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/basic/003.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/basic/003.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/basic/003.phpt
--TEST--
GET and POST Method combined
--SKIPIF--
<?php if (php_sapi_name()=='cli') echo 'skip'; ?>
--POST--
a=Hello+World
--GET--
b=Hello+Again+World&c=Hi+Mom
--FILE--
<?php 
error_reporting(0);
echo "post-a=({$_POST['a']}) get-b=({$_GET['b']}) get-c=({$_GET['c']})"?>
--EXPECT--
post-a=(Hello World) get-b=(Hello Again World) get-c=(Hi Mom)

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/basic/005.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/basic/005.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/basic/005.phpt
--TEST--
Three variables in POST data
--SKIPIF--
<?php if (php_sapi_name()=='cli') echo 'skip'; ?>
--POST--
a=Hello+World&b=Hello+Again+World&c=1
--FILE--
<?php 
error_reporting(0);
echo "{$_POST['a']} {$_POST['b']} {$_POST['c']}"?>
--EXPECT--
Hello World Hello Again World 1

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/files/src/basic/002.phpt?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/files/src/basic/002.phpt
+++ phpruntests/code-samples/taskScheduler/example3/files/src/basic/002.phpt
--TEST--
Simple POST Method test
--SKIPIF--
<?php if (php_sapi_name()=='cli') echo 'skip'; ?>
--POST--
a=Hello+World
--FILE--
<?php
echo $_POST['a']; ?>
--EXPECT--
Hello World

http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example1/main.php?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example1/main.php
+++ phpruntests/code-samples/taskScheduler/example1/main.php
<?php

include 'taskCalculate.php';


function createTaskList()
{
        $list = array();

        for ($i=0; $i<rand(128,256); $i++) {
                
                $num = array();
                
                for ($j=0; $j<rand(32,64); $j++) {
                        
                        $num[$j] = rand(0,9);
                }

                $list[$i] = new taskCalculate($num);
        }
        
        return $list;
} 

?>
http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example1/taskCalculate.php?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example1/taskCalculate.php
+++ phpruntests/code-samples/taskScheduler/example1/taskCalculate.php
<?php

class taskCalculate extends task implements taskInterface
{
        private $numbers = array();
        private $result = 0;
        
        
        public function __construct(array $numbers)
        {
                $this->numbers = $numbers;
        }
        
        
        public function run()
        {
                $r = 0;
                
                foreach($this->numbers as $num) {

                        $num = (int)$num;
                        $r += $num;
                }
                                
                if ($r%26 == 0) {
                        
                        $this->setMessage("just an example");
                        return false;
                }

                $this->result = $r;
                return true;
        }
        
        
        public function getResult()
        {
                return $this->result;
        }
        
}


?>
http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/taskConvert.php?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/taskConvert.php
+++ phpruntests/code-samples/taskScheduler/example3/taskConvert.php
<?php

class taskConvert extends task implements taskInterface
{
        private $sourceFile = NULL;
        
        
        public function __construct($sourceFile)
        {
                $this->sourceFile = $sourceFile;
        }
        
        
        public function run()
        {
                if (is_null($this->sourceFile)) {
                        
                        $this->setState(self::FAIL);
                        $this->setMessage('no source file');
                        return false;
                }

                $reader = new 
fileReader('example3/files/src'.$this->sourceFile);
                $reader->read();
                $chars = $reader->getAsciiChars();
                
                $n = 'example3/files/dest'.$this->sourceFile.'.png';

                $img = new imageCreator($chars);
                $img->draw();
                $img->saveImage($n);

                return true;
        }
        
}


?>
http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example3/main.php?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example3/main.php
+++ phpruntests/code-samples/taskScheduler/example3/main.php
<?php

include 'taskConvert.php';

include 'imgConverter/fileCreator.php';
include 'imgConverter/fileReader.php';
include 'imgConverter/imageCreator.php';
include 'imgConverter/imageReader.php';


function createTaskList()
{
        return readSource('example3/files');
}


function readSource($base, $path=NULL)
{
        $files = array();
        
        foreach (new DirectoryIterator($base.'/src/'.$path) as $file) {
                
                if ($file->isDot()) continue;

                $name = $file->getFileName();
                
                if (substr($name,0,1) == '.') continue;

                if ($file->isDir()) {
                        
                        $dest = $base.'/dest'.$path.'/'.$name;

                        if (!file_exists($dest)) {
                        
                                mkdir($dest);
                                chmod($dest, 0777);
                        }
                                                        
                        $files[] = readSource($base, $path.'/'.$name);
                }
                
                elseif ($file->isFile()) {

                        $files[] = new taskConvert($path.'/'.$name);
                }
        }

        return $files;
}

?>
http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/run.php?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/run.php
+++ phpruntests/code-samples/taskScheduler/run.php
<?php

include 'classes/taskScheduler.php';
include 'classes/taskInterface.php';
include 'classes/task.php';


// logger

date_default_timezone_set("Europe/Berlin");

function logg($msg) {

        $debug = false;
        
        if ($debug) {
                
                print  '['.date('h:i:s').'] '.$msg."\n";
                flush();
        }
}


// arguments

$argc = sizeof($argv);

if ($argc == 2 || $argc == 3) {
        
        $src = $argv[1];
        $count = isset($argv[2]) ? $argv[2] : NULL;
} else {
        
        die("USAGE: php run.php example processCount\n");
}


// include exmaple & create task-list

$src = $src.'/main.php';

if (!file_exists($src)) {
        
        die("invalid example\n");
}

include $src;

$taskList = createTaskList();


// init scheduler

$c = new taskScheduler();
$c->setTaskList($taskList);
$c->setProcessCount($count);
$c->run();
$c->printStatistic();

// var_dump($c->getTaskList());

$c->printFailedTasks();

exit(0);

?>


http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example2/taskSleep.php?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example2/taskSleep.php
+++ phpruntests/code-samples/taskScheduler/example2/taskSleep.php
<?php

class taskSleep extends task implements taskInterface
{
        private $sleep = 0;
        
        
        public function __construct($sleep)
        {
                $this->sleep = $sleep;
        }
        
        
        public function run()
        {
                sleep($this->sleep);
                return true;
        }
}


?>
http://cvs.php.net/viewvc.cgi/phpruntests/code-samples/taskScheduler/example2/main.php?view=markup&rev=1.1
Index: phpruntests/code-samples/taskScheduler/example2/main.php
+++ phpruntests/code-samples/taskScheduler/example2/main.php
<?php

include 'taskSleep.php';


function createTaskList()
{
        $list = array();

        for ($i=0; $i<10; $i++) {

                $list[$i] = new taskSleep($i%3);
        }
        
        return $list;
} 

?>
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to