Esempio n. 1
0
function sereal_test($orig, $name = null)
{
    try {
        $got = sereal_decode(sereal_encode($orig));
    } catch (Exception $e) {
        $got = null;
    }
    return is_deeply($got, $orig, $name);
}
//    SKIP: {
//        skip( "/?{...}/ and \\d+ cause a panic in this version of perl ($])", 12 ) if $PERL_VERSION_5_005;
ok(!$re->match('foo'), 'match pattern-4 foo');
ok(!$re->mvar(2), 'match pattern-4 foo novar');
$target = 'c-u-350';
ok($re->match($target), "match pattern-4 {$target}");
ok($re->mvar(0), $target, 'match pattern-4 capture 1');
ok($re->mvar(1), 'u', 'match pattern-4 capture 2');
ok($re->mvar(2) == 350, 'match pattern-4 capture 3');
$target = 'c-2048';
ok($re->match($target), "match pattern-4 {$target}");
ok($re->mvar(0), $target, 'match pattern-4 capture 4');
ok($re->mvar(1) == 2048, 'match pattern-4 capture 5');
ok(!$re->mvar(2), 'match pattern-4 undef');
is_deeply($re->mbegin, [0, undef, undef, 2], 'match pattern-3 mbegin');
is_deeply($re->mend, [6, undef, undef, 6, undef], 'match pattern-3 mend');
//    }
$re = new Regexp_Assemble(['track' => 1]);
$re->add('^c-\\d+$')->add('^c-\\w+$')->add('^c-[aeiou]-\\d+$');
//    SKIP: {
//        skip( "/?{...}/ and \\d+ cause a panic in this version of perl ($])", 6 ) if $PERL_VERSION_5_005;
ok(!$re->match('foo'), 'match pattern-5 foo');
ok(!$re->mvar(2), 'match pattern-4 foo novar');
$target = 'c-u-350';
ok($re->match($target), "match pattern-5 {$target}");
ok($re->mvar(0), $target, 'match pattern-5');
ok(!$re->mvar(1), 'match pattern-5 no capture 2');
ok(!$re->mvar(2), 'match pattern-5 no capture 3');
//    }
$re = new Regexp_Assemble(['track' => 1]);
$re->add('^cat')->add('^candle$')->flags('i');
$lib = isset($_SERVER['TESTLIB']) ? $_SERVER['TESTLIB'] : 'Test-More.php';
require_once $lib;
#plan(3);
diag('Test of various functions not otherwise broken out.');
pass("pass() is ok");
fail("fail() is not ok");
is('Ab3', 'Ab3', 'is() is ok');
isnt('Ab3', 123, 'isnt() is ok');
like('yackowackodot', '/wacko/', "like() is ok");
unlike('yackowackodot', '/boing/', "unlike() is ok");
cmp_ok(12, '>', 10, 'cmp_ok() is ok');
can_ok($__Test, 'plan');
isa_ok($__Test, 'TestMore', 'Default Testing object');
include_ok('t/goodlib.php');
require_ok('t/goodpage.php');
$foo = array(1, 'B', 'third');
$oof = array('third', 'B', 1);
$bar = array('q' => 23, 'Y' => 42);
$rab = array('Y' => 42, 'q' => 23);
is_deeply($foo, $foo, 'is_deeply() is ok');
isnt_deeply($foo, $bar, 'isnt_deeply() is ok');
/*
function skip($SkipReason, $num) {
function todo ($why, $howmany) {
function todo_skip ($why, $howmany) {
function todo_start ($why) {
function todo_end () {
*/
diag("Should fail 1 test, testing fail()");
done_testing();
Esempio n. 4
0
<?php

require 'test-more.php';
require '../scripts/ss_get_by_ssh.php';
$debug = true;
is_deeply(proc_stat_parse(null, file_get_contents('samples/proc_stat-001.txt')), array('STAT_interrupts' => '339490', 'STAT_context_switches' => '697948', 'STAT_forks' => '11558', 'STAT_CPU_user' => '24198', 'STAT_CPU_nice' => '0', 'STAT_CPU_system' => '69614', 'STAT_CPU_idle' => '2630536', 'STAT_CPU_iowait' => '558', 'STAT_CPU_irq' => '5872', 'STAT_CPU_softirq' => '1572', 'STAT_CPU_steal' => '0', 'STAT_CPU_guest' => '0'), 'samples/proc_stat-001.txt');
is_deeply(proc_stat_parse(null, file_get_contents('samples/proc_stat-002.txt')), array('STAT_interrupts' => '87480486', 'STAT_context_switches' => '125521467', 'STAT_forks' => '239810', 'STAT_CPU_user' => '2261920', 'STAT_CPU_nice' => '38824', 'STAT_CPU_system' => '986335', 'STAT_CPU_idle' => '39683698', 'STAT_CPU_iowait' => '62368', 'STAT_CPU_irq' => '19193', 'STAT_CPU_softirq' => '8499', 'STAT_CPU_steal' => '0', 'STAT_CPU_guest' => '0'), 'samples/proc_stat-002.txt');
is(ss_get_by_ssh(array('file' => 'samples/proc_stat-001.txt', 'type' => 'proc_stat', 'host' => 'localhost', 'items' => 'ag,ah,ai,aj,ak,al,am,an,ao,ap,aq,ar')), 'ag:24198 ah:0 ai:69614 aj:2630536 ak:558 al:5872 am:1572 an:0 ao:0' . ' ap:339490 aq:697948 ar:11558', 'main(samples/proc_stat-001.txt)');
is_deeply(memory_parse(null, file_get_contents('samples/free-001.txt')), array('STAT_memcached' => '22106112', 'STAT_membuffer' => '1531904', 'STAT_memshared' => '0', 'STAT_memfree' => '17928192', 'STAT_memused' => '21389312'), 'samples/free-001.txt');
is_deeply(memory_parse(null, file_get_contents('samples/free-002.txt')), array('STAT_memcached' => '1088184320', 'STAT_membuffer' => '131469312', 'STAT_memshared' => '0', 'STAT_memfree' => '189325312', 'STAT_memused' => '7568291328'), 'samples/free-002.txt (issue 102)');
is(ss_get_by_ssh(array('file' => 'samples/free-001.txt', 'type' => 'memory', 'host' => 'localhost', 'items' => 'au,av,aw,ax,ay')), 'au:22106112 av:1531904 aw:0 ax:17928192 ay:21389312', 'main(samples/free-001.txt)');
is_deeply(w_parse(null, file_get_contents('samples/w-001.txt')), array('STAT_loadavg' => '1.43', 'STAT_numusers' => '2'), 'samples/w-001.txt');
is_deeply(w_parse(null, file_get_contents('samples/w-002.txt')), array('STAT_loadavg' => '0.35', 'STAT_numusers' => '6'), 'samples/w-002.txt');
is_deeply(w_parse(null, file_get_contents('samples/w-003.txt')), array('STAT_loadavg' => '0.00', 'STAT_numusers' => '1'), 'samples/w-003.txt');
is(ss_get_by_ssh(array('file' => 'samples/w-001.txt', 'type' => 'w', 'host' => 'localhost', 'items' => 'as,at')), 'as:1.43 at:2', 'main(samples/w-002.txt)');
is_deeply(memcached_parse(null, file_get_contents('samples/memcached-001.txt')), array('MEMC_pid' => '2120', 'MEMC_uptime' => '32314', 'MEMC_time' => '1261775864', 'MEMC_version' => '1.2.2', 'MEMC_pointer_size' => '32', 'MEMC_rusage_user' => '396024', 'MEMC_rusage_system' => '1956122', 'MEMC_curr_items' => '0', 'MEMC_total_items' => '0', 'MEMC_bytes' => '0', 'MEMC_curr_connections' => '1', 'MEMC_total_connections' => '5', 'MEMC_connection_structures' => '2', 'MEMC_cmd_get' => '0', 'MEMC_cmd_set' => '0', 'MEMC_get_hits' => '0', 'MEMC_get_misses' => '0', 'MEMC_evictions' => '0', 'MEMC_bytes_read' => '45', 'MEMC_bytes_written' => '942', 'MEMC_limit_maxbytes' => '67108864', 'MEMC_threads' => '1'), 'samples/memcached-001.txt');
is_deeply(nginx_parse(null, file_get_contents('samples/nginx-001.txt')), array('NGINX_active_connections' => '251', 'NGINX_server_accepts' => '255601634', 'NGINX_server_handled' => '255601634', 'NGINX_server_requests' => '671013148', 'NGINX_reading' => '5', 'NGINX_writing' => '27', 'NGINX_waiting' => '219'), 'samples/nginx-001.txt');
is_deeply(apache_parse(null, file_get_contents('samples/apache-001.txt')), array('Requests' => '3452389', 'Bytes_sent' => '23852769280', 'Idle_workers' => '8', 'Busy_workers' => '1', 'CPU_Load' => '.023871', 'Waiting_for_connection' => '8', 'Starting_up' => 0, 'Reading_request' => 0, 'Sending_reply' => '1', 'Keepalive' => 0, 'DNS_lookup' => 0, 'Closing_connection' => 0, 'Logging' => 0, 'Gracefully_finishing' => 0, 'Idle_cleanup' => 0, 'Open_slot' => '247'), 'samples/apache-001.txt');
is_deeply(diskstats_parse(array('device' => 'hda1'), file_get_contents('samples/diskstats-001.txt')), array('DISK_reads' => '12043', 'DISK_reads_merged' => '387', 'DISK_sectors_read' => '300113', 'DISK_time_spent_reading' => '6472', 'DISK_writes' => '12737', 'DISK_writes_merged' => '21340', 'DISK_sectors_written' => '272616', 'DISK_time_spent_writing' => '22360', 'DISK_io_ops_in_progress' => '0', 'DISK_io_time' => '12368', 'DISK_io_time_weighted' => '28832'), 'samples/diskstats-001.txt');
is_deeply(diskstats_parse(array('device' => 'sda4'), file_get_contents('samples/diskstats-002.txt')), array('DISK_reads' => '30566', 'DISK_reads_merged' => '3341', 'DISK_sectors_read' => '586664', 'DISK_time_spent_reading' => '370308', 'DISK_writes' => '150943', 'DISK_writes_merged' => '163833', 'DISK_sectors_written' => '2518672', 'DISK_time_spent_writing' => '12081496', 'DISK_io_time' => '347416', 'DISK_io_time_weighted' => '12451664', 'DISK_io_ops_in_progress' => '0'), 'samples/diskstats-002.txt');
is_deeply(diskstats_parse(array('device' => 'sda2'), file_get_contents('samples/diskstats-003.txt')), array('DISK_reads' => '15425346', 'DISK_reads_merged' => '0', 'DISK_sectors_read' => '385290786', 'DISK_time_spent_reading' => '0', 'DISK_writes' => '472909074', 'DISK_writes_merged' => '0', 'DISK_sectors_written' => '3783272616', 'DISK_time_spent_writing' => '0', 'DISK_io_time' => '0', 'DISK_io_time_weighted' => '0', 'DISK_io_ops_in_progress' => '0'), 'samples/diskstats-003.txt');
is(ss_get_by_ssh(array('file' => 'samples/diskstats-001.txt', 'type' => 'diskstats', 'host' => 'localhost', 'items' => 'bj,bk,bl,bm,bn,bo,bp,bq,br,bs,bt', 'device' => 'hda1')), 'bj:12043 bk:387 bl:300113 bm:6472 bn:12737 bo:21340 bp:272616 bq:22360 ' . 'br:0 bs:12368 bt:28832', 'main(samples/diskstats-001.txt)');
is_deeply(openvz_parse(array(), file_get_contents('samples/openvz-001.txt')), array('OPVZ_kmemsize_held' => '8906701', 'OPVZ_kmemsize_failcnt' => '0', 'OPVZ_lockedpages_held' => '0', 'OPVZ_lockedpages_failcnt' => '0', 'OPVZ_privvmpages_held' => '39695', 'OPVZ_privvmpages_failcnt' => '0', 'OPVZ_shmpages_held' => '688', 'OPVZ_shmpages_failcnt' => '0', 'OPVZ_numproc_held' => '32', 'OPVZ_numproc_failcnt' => '0', 'OPVZ_physpages_held' => '11101', 'OPVZ_physpages_failcnt' => '0', 'OPVZ_vmguarpages_held' => '0', 'OPVZ_vmguarpages_failcnt' => '0', 'OPVZ_oomguarpages_held' => '11101', 'OPVZ_oomguarpages_failcnt' => '0', 'OPVZ_numtcpsock_held' => '6', 'OPVZ_numtcpsock_failcnt' => '0', 'OPVZ_numflock_held' => '6', 'OPVZ_numflock_failcnt' => '0', 'OPVZ_numpty_held' => '1', 'OPVZ_numpty_failcnt' => '0', 'OPVZ_numsiginfo_held' => '0', 'OPVZ_numsiginfo_failcnt' => '0', 'OPVZ_tcpsndbuf_held' => '338656', 'OPVZ_tcpsndbuf_failcnt' => '0', 'OPVZ_tcprcvbuf_held' => '98304', 'OPVZ_tcprcvbuf_failcnt' => '0', 'OPVZ_othersockbuf_held' => '9280', 'OPVZ_othersockbuf_failcnt' => '0', 'OPVZ_dgramrcvbuf_held' => '0', 'OPVZ_dgramrcvbuf_failcnt' => '0', 'OPVZ_numothersock_held' => '9', 'OPVZ_numothersock_failcnt' => '0', 'OPVZ_dcachesize_held' => '0', 'OPVZ_dcachesize_failcnt' => '0', 'OPVZ_numfile_held' => '788', 'OPVZ_numfile_failcnt' => '0', 'OPVZ_numiptent_held' => '10', 'OPVZ_numiptent_failcnt' => '0'), 'samples/openvz-001.txt');
is(ss_get_by_ssh(array('file' => 'samples/openvz-001.txt', 'type' => 'openvz', 'host' => 'localhost', 'items' => 'bu,bv,bw,bx,by,bz,c0')), 'bu:8906701 bv:0 bw:0 bx:0 by:39695 bz:0 c0:688', 'main(samples/openvz-001.txt)');
is_deeply(redis_parse(null, file_get_contents('samples/redis-001.txt')), array('REDIS_connected_clients' => '119', 'REDIS_connected_slaves' => '911', 'REDIS_used_memory' => '412372', 'REDIS_changes_since_last_save' => '4321', 'REDIS_total_connections_received' => '3333', 'REDIS_total_commands_processed' => '5'), 'samples/redis-001.txt');
is(ss_get_by_ssh(array('file' => 'samples/redis-001.txt', 'type' => 'redis', 'host' => 'localhost', 'items' => 'cy,cz,d0,d1,d2,d3')), 'cy:119 cz:911 d0:412372 d1:4321 d2:3333 d3:5', 'main(samples/redis-001.txt)');
is_deeply(jmx_parse(null, file_get_contents('samples/jmx-001.txt')), array('JMX_heap_memory_used' => '52685256', 'JMX_heap_memory_committed' => '205979648', 'JMX_heap_memory_max' => '1864171520', 'JMX_non_heap_memory_used' => '55160928', 'JMX_non_heap_memory_committed' => '61603840', 'JMX_non_heap_memory_max' => '318767104', 'JMX_open_file_descriptors' => '60', 'JMX_max_file_descriptors' => '1024'), 'samples/jmx-001.txt');
is(ss_get_by_ssh(array('file' => 'samples/jmx-001.txt', 'type' => 'jmx', 'host' => 'localhost', 'items' => 'd4,d5,d6,d7,d8,d9,da,db')), 'd4:52685256 d5:205979648 d6:1864171520 d7:55160928 d8:61603840 d9:318767104 da:60 db:1024', 'main(samples/jmx-001.txt)');
is_deeply(mongodb_parse(null, file_get_contents('samples/mongodb-001.txt')), array('MONGODB_connected_clients' => '3', 'MONGODB_used_resident_memory' => '16029581312', 'MONGODB_used_mapped_memory' => '64981303296', 'MONGODB_used_virtual_memory' => '65457356800', 'MONGODB_index_accesses' => '1589814', 'MONGODB_index_hits' => '1589814', 'MONGODB_index_misses' => '0', 'MONGODB_index_resets' => '0', 'MONGODB_back_flushes' => '4883', 'MONGODB_back_total_ms' => '2309034', 'MONGODB_back_average_ms' => '472', 'MONGODB_back_last_ms' => '36', 'MONGODB_op_inserts' => '1584705', 'MONGODB_op_queries' => '145518', 'MONGODB_op_updates' => '2521129', 'MONGODB_op_deletes' => '601', 'MONGODB_op_getmores' => '2268817', 'MONGODB_op_commands' => '17810', 'MONGODB_slave_lag' => '0'), 'samples/mongodb-001.txt');
is(ss_get_by_ssh(array('file' => 'samples/mongodb-001.txt', 'type' => 'mongodb', 'host' => 'localhost', 'items' => 'dc,dd,de,df,dg,dh,di,dj,dk,dl,dm,dn,do,dp,dq,dr,ds,dt,du')), 'dc:3 dd:16029581312 de:64981303296 df:65457356800 dg:1589814 dh:1589814 di:0 dj:0 dk:4883 dl:2309034 dm:472 dn:36 do:1584705 dp:145518 dq:2521129 dr:601 ds:2268817 dt:17810 du:0', 'main(samples/mongodb-001.txt)');
function permute($target, $path)
{
    foreach (range(0, 4) as $x1) {
        foreach (range(0, 4) as $x2) {
            if ($x2 == $x1) {
                continue;
            }
            foreach (range(0, 4) as $x3) {
                if (count(array_filter([$x1, $x2], function ($_) use($x3) {
                    return $_ == $x3;
                }))) {
                    continue;
                }
                foreach (range(0, 4) as $x4) {
                    if (count(array_filter([$x1, $x2, $x3], function ($_) use($x4) {
                        return $_ == $x4;
                    }))) {
                        continue;
                    }
                    foreach (range(0, 4) as $x5) {
                        if (count(array_filter([$x1, $x2, $x3, $x4], function ($_) use($x5) {
                            return $_ == $x5;
                        }))) {
                            continue;
                        }
                        $ra = new Regexp_Assemble();
                        $ra->insert($path[$x1])->insert($path[$x2])->insert($path[$x3])->insert($path[$x4])->insert($path[$x5]);
                        is_deeply($ra->__path, $target, 'join: /' . join('/ /', array(join('', $path[$x1]), join('', $path[$x2]), join('', $path[$x3]), join('', $path[$x4]), join('', $path[$x5]))) . '/\\n' . $ra->dump() . ' versus ' . $ra->_dump($target) . "\n");
                    }
                }
            }
        }
    }
}
is_deeply(memcached_parse(null, file_get_contents('samples/memcached-001.txt')), array('MEMC_pid' => '2120', 'MEMC_uptime' => '32314', 'MEMC_time' => '1261775864', 'MEMC_version' => '1.2.2', 'MEMC_pointer_size' => '32', 'MEMC_rusage_user' => '396024', 'MEMC_rusage_system' => '1956122', 'MEMC_curr_items' => '0', 'MEMC_total_items' => '0', 'MEMC_bytes' => '0', 'MEMC_curr_connections' => '1', 'MEMC_total_connections' => '5', 'MEMC_connection_structures' => '2', 'MEMC_cmd_get' => '0', 'MEMC_cmd_set' => '0', 'MEMC_get_hits' => '0', 'MEMC_get_misses' => '0', 'MEMC_evictions' => '0', 'MEMC_bytes_read' => '45', 'MEMC_bytes_written' => '942', 'MEMC_limit_maxbytes' => '67108864', 'MEMC_threads' => '1'), 'samples/memcached-001.txt');
is(ss_get_by_ssh(array('file' => 'samples/memcached-001.txt', 'type' => 'memcached', 'host' => 'localhost', 'items' => 'ij,ik,il,im,in,io,ip,iq,ir,is,it,iu,iv')), 'ij:396024 ik:1956122 il:0 im:0 in:0 io:1 ip:5 iq:0 ir:0 is:0 it:0 iu:45' . ' iv:942', 'main(samples/memcached-001.txt)');
is_deeply(nginx_parse(null, file_get_contents('samples/nginx-001.txt')), array('NGINX_active_connections' => '251', 'NGINX_server_accepts' => '255601634', 'NGINX_server_handled' => '255601634', 'NGINX_server_requests' => '671013148', 'NGINX_reading' => '5', 'NGINX_writing' => '27', 'NGINX_waiting' => '219'), 'samples/nginx-001.txt');
is(ss_get_by_ssh(array('file' => 'samples/nginx-001.txt', 'type' => 'nginx', 'host' => 'localhost', 'items' => 'hw,hx,hy,hz,ig,ih,ii')), 'hw:251 hx:255601634 hy:255601634 hz:671013148 ig:5 ih:27 ii:219', 'main(samples/nginx-001.txt)');
is_deeply(apache_parse(null, file_get_contents('samples/apache-001.txt')), array('APACHE_Requests' => '3452389', 'APACHE_Bytes_sent' => '23852769280', 'APACHE_Idle_workers' => '8', 'APACHE_Busy_workers' => '1', 'APACHE_CPU_Load' => '.023871', 'APACHE_Waiting_for_connection' => '8', 'APACHE_Starting_up' => 0, 'APACHE_Reading_request' => 0, 'APACHE_Sending_reply' => '1', 'APACHE_Keepalive' => 0, 'APACHE_DNS_lookup' => 0, 'APACHE_Closing_connection' => 0, 'APACHE_Logging' => 0, 'APACHE_Gracefully_finishing' => 0, 'APACHE_Idle_cleanup' => 0, 'APACHE_Open_slot' => '247'), 'samples/apache-001.txt');
is_deeply(apache_parse(null, file_get_contents('samples/apache-002.txt')), array('APACHE_Requests' => '368', 'APACHE_Bytes_sent' => 1151 * 1024, 'APACHE_Idle_workers' => '19', 'APACHE_Busy_workers' => '1', 'APACHE_CPU_Load' => '.0284617', 'APACHE_Waiting_for_connection' => '19', 'APACHE_Starting_up' => 0, 'APACHE_Reading_request' => 0, 'APACHE_Sending_reply' => '1', 'APACHE_Keepalive' => 0, 'APACHE_DNS_lookup' => 0, 'APACHE_Closing_connection' => 0, 'APACHE_Logging' => 0, 'APACHE_Gracefully_finishing' => 0, 'APACHE_Idle_cleanup' => 0, 'APACHE_Open_slot' => '236'), 'samples/apache-002.txt');
is(ss_get_by_ssh(array('file' => 'samples/apache-001.txt', 'type' => 'apache', 'host' => 'localhost', 'items' => 'gg,gh,gi,gj,gk,gl,gm,gn,go,gp,gq,gr,gs,gt,gu,gv')), 'gg:3452389 gh:23852769280 gi:8 gj:1 gk:.023871 gl:8 gm:0 gn:0 go:1 gp:0' . ' gq:0 gr:0 gs:0 gt:0 gu:0 gv:247', 'main(samples/apache-001.txt)');
is_deeply(diskstats_parse(array('device' => 'hda1'), file_get_contents('samples/diskstats-001.txt')), array('DISK_reads' => '12043', 'DISK_reads_merged' => '387', 'DISK_sectors_read' => '300113', 'DISK_time_spent_reading' => '6472', 'DISK_writes' => '12737', 'DISK_writes_merged' => '21340', 'DISK_sectors_written' => '272616', 'DISK_time_spent_writing' => '22360', 'DISK_io_time' => '12368', 'DISK_io_time_weighted' => '28832', 'DISK_io_ops' => '24780'), 'samples/diskstats-001.txt');
is_deeply(diskstats_parse(array('device' => 'sda4'), file_get_contents('samples/diskstats-002.txt')), array('DISK_reads' => '30566', 'DISK_reads_merged' => '3341', 'DISK_sectors_read' => '586664', 'DISK_time_spent_reading' => '370308', 'DISK_writes' => '150943', 'DISK_writes_merged' => '163833', 'DISK_sectors_written' => '2518672', 'DISK_time_spent_writing' => '12081496', 'DISK_io_time' => '347416', 'DISK_io_time_weighted' => '12451664', 'DISK_io_ops' => '181509'), 'samples/diskstats-002.txt');
is_deeply(diskstats_parse(array('device' => 'sda2'), file_get_contents('samples/diskstats-003.txt')), array('DISK_reads' => '15425346', 'DISK_reads_merged' => '0', 'DISK_sectors_read' => '385290786', 'DISK_time_spent_reading' => '0', 'DISK_writes' => '472909074', 'DISK_writes_merged' => '0', 'DISK_sectors_written' => '3783272616', 'DISK_time_spent_writing' => '0', 'DISK_io_time' => '0', 'DISK_io_time_weighted' => '0', 'DISK_io_ops' => '488334420'), 'samples/diskstats-003.txt');
is(ss_get_by_ssh(array('file' => 'samples/diskstats-001.txt', 'type' => 'diskstats', 'host' => 'localhost', 'items' => 'iw,ix,iy,iz,jg,jh,ji,jj,jk,jl,jm', 'device' => 'hda1')), 'iw:12043 ix:387 iy:300113 iz:6472 jg:12737 jh:21340 ji:272616 jj:22360' . ' jk:24780 jl:12368 jm:28832', 'main(samples/diskstats-001.txt)');
is_deeply(openvz_parse(array(), file_get_contents('samples/openvz-001.txt')), array('OPVZ_kmemsize_held' => '8906701', 'OPVZ_kmemsize_failcnt' => '0', 'OPVZ_lockedpages_held' => '0', 'OPVZ_lockedpages_failcnt' => '0', 'OPVZ_privvmpages_held' => '39695', 'OPVZ_privvmpages_failcnt' => '0', 'OPVZ_shmpages_held' => '688', 'OPVZ_shmpages_failcnt' => '0', 'OPVZ_numproc_held' => '32', 'OPVZ_numproc_failcnt' => '0', 'OPVZ_physpages_held' => '11101', 'OPVZ_physpages_failcnt' => '0', 'OPVZ_vmguarpages_held' => '0', 'OPVZ_vmguarpages_failcnt' => '0', 'OPVZ_oomguarpages_held' => '11101', 'OPVZ_oomguarpages_failcnt' => '0', 'OPVZ_numtcpsock_held' => '6', 'OPVZ_numtcpsock_failcnt' => '0', 'OPVZ_numflock_held' => '6', 'OPVZ_numflock_failcnt' => '0', 'OPVZ_numpty_held' => '1', 'OPVZ_numpty_failcnt' => '0', 'OPVZ_numsiginfo_held' => '0', 'OPVZ_numsiginfo_failcnt' => '0', 'OPVZ_tcpsndbuf_held' => '338656', 'OPVZ_tcpsndbuf_failcnt' => '0', 'OPVZ_tcprcvbuf_held' => '98304', 'OPVZ_tcprcvbuf_failcnt' => '0', 'OPVZ_othersockbuf_held' => '9280', 'OPVZ_othersockbuf_failcnt' => '0', 'OPVZ_dgramrcvbuf_held' => '0', 'OPVZ_dgramrcvbuf_failcnt' => '0', 'OPVZ_numothersock_held' => '9', 'OPVZ_numothersock_failcnt' => '0', 'OPVZ_dcachesize_held' => '0', 'OPVZ_dcachesize_failcnt' => '0', 'OPVZ_numfile_held' => '788', 'OPVZ_numfile_failcnt' => '0', 'OPVZ_numiptent_held' => '10', 'OPVZ_numiptent_failcnt' => '0'), 'samples/openvz-001.txt');
is(ss_get_by_ssh(array('file' => 'samples/openvz-001.txt', 'type' => 'openvz', 'host' => 'localhost', 'items' => 'jn,jo,jp,jq,jr,js,jt,ju,jv,jw,jx,jy,jz,kg,kh,ki,kj,kk,kl,km,kn,ko,kp,kq,kr,ks,kt,ku,kv,kw,kx,ky,kz,lg,lh,li,lj,lk,ll,lm')), 'jn:8906701 jo:0 jp:0 jq:0 jr:39695 js:0 jt:688 ju:0 jv:32 jw:0 jx:11101' . ' jy:0 jz:0 kg:0 kh:11101 ki:0 kj:6 kk:0 kl:6 km:0 kn:1 ko:0 kp:0 kq:0' . ' kr:338656 ks:0 kt:98304 ku:0 kv:9280 kw:0 kx:0 ky:0 kz:9 lg:0 lh:0 li:0' . ' lj:788 lk:0 ll:10 lm:0', 'main(samples/openvz-001.txt)');
is_deeply(redis_parse(null, file_get_contents('samples/redis-001.txt')), array('REDIS_connected_clients' => '119', 'REDIS_connected_slaves' => '911', 'REDIS_used_memory' => '412372', 'REDIS_changes_since_last_save' => '4321', 'REDIS_total_connections_received' => '3333', 'REDIS_total_commands_processed' => '5'), 'samples/redis-001.txt');
is(ss_get_by_ssh(array('file' => 'samples/redis-001.txt', 'type' => 'redis', 'host' => 'localhost', 'items' => 'ln,lo,lp,lq,lr,ls')), 'ln:119 lo:911 lp:412372 lq:4321 lr:3333 ls:5', 'main(samples/redis-001.txt)');
is_deeply(redis_parse(null, file_get_contents('samples/redis-002.txt')), array('REDIS_connected_clients' => '1', 'REDIS_connected_slaves' => '1', 'REDIS_used_memory' => '856928', 'REDIS_changes_since_last_save' => '88', 'REDIS_total_connections_received' => '4', 'REDIS_total_commands_processed' => '3'), 'samples/redis-002.txt');
is(ss_get_by_ssh(array('file' => 'samples/redis-002.txt', 'type' => 'redis', 'host' => 'localhost', 'items' => 'ln,lo,lp,lq,lr,ls')), 'ln:1 lo:1 lp:856928 lq:88 lr:4 ls:3', 'main(samples/redis-002.txt)');
is_deeply(jmx_parse(null, file_get_contents('samples/jmx-001.txt')), array('JMX_heap_memory_used' => '52685256', 'JMX_heap_memory_committed' => '205979648', 'JMX_heap_memory_max' => '1864171520', 'JMX_non_heap_memory_used' => '55160928', 'JMX_non_heap_memory_committed' => '61603840', 'JMX_non_heap_memory_max' => '318767104', 'JMX_open_file_descriptors' => '60', 'JMX_max_file_descriptors' => '1024', 'JMX_current_threads_busy' => '7', 'JMX_current_thread_count' => '172', 'JMX_max_threads' => '200'), 'samples/jmx-001.txt');
is(ss_get_by_ssh(array('file' => 'samples/jmx-001.txt', 'type' => 'jmx', 'host' => 'localhost', 'items' => 'lt,lu,lv,lw,lx,ly,lz,mg,mh,mi,mj')), 'lt:52685256 lu:205979648 lv:1864171520 lw:55160928 lx:61603840' . ' ly:318767104 lz:60 mg:1024 mh:7 mi:172 mj:200', 'main(samples/jmx-001.txt)');
is_deeply(mongodb_parse(null, file_get_contents('samples/mongodb-001.txt')), array('MONGODB_connected_clients' => '3', 'MONGODB_used_resident_memory' => '16029581312', 'MONGODB_used_mapped_memory' => '64981303296', 'MONGODB_used_virtual_memory' => '65457356800', 'MONGODB_index_accesses' => '1589814', 'MONGODB_index_hits' => '1589814', 'MONGODB_index_misses' => '0', 'MONGODB_index_resets' => '0', 'MONGODB_back_flushes' => '4883', 'MONGODB_back_total_ms' => '2309034', 'MONGODB_back_average_ms' => '472', 'MONGODB_back_last_ms' => '36', 'MONGODB_op_inserts' => '1584705', 'MONGODB_op_queries' => '145518', 'MONGODB_op_updates' => '2521129', 'MONGODB_op_deletes' => '601', 'MONGODB_op_getmores' => '2268817', 'MONGODB_op_commands' => '17810', 'MONGODB_slave_lag' => '0'), 'samples/mongodb-001.txt');
is(ss_get_by_ssh(array('file' => 'samples/mongodb-001.txt', 'type' => 'mongodb', 'host' => 'localhost', 'items' => 'mk,ml,mm,mn,mo,mp,mq,mr,ms,mt,mu,mv,mw,mx,my,mz,ng,nh,ni')), 'mk:3 ml:16029581312 mm:64981303296 mn:65457356800 mo:1589814 mp:1589814' . ' mq:0 mr:0 ms:4883 mt:2309034 mu:472 mv:36 mw:1584705 mx:145518' . ' my:2521129 mz:601 ng:2268817 nh:17810 ni:0', 'main(samples/mongodb-001.txt)');
is_deeply(df_parse(array('volume' => '/dev/vzfs'), file_get_contents('samples/df-001.txt')), array('DISKFREE_used' => '4596444160', 'DISKFREE_available' => '26860835840'), 'samples/df-001.txt');
is(ss_get_by_ssh(array('file' => 'samples/df-001.txt', 'type' => 'df', 'host' => 'localhost', 'items' => 'nj,nk', 'volume' => '/dev/vzfs')), 'nj:4596444160 nk:26860835840', 'main(samples/df-001.txt)');
is_deeply(df_parse(array('volume' => '/dev/mapper/vg00-server'), file_get_contents('samples/df-002.txt')), array('DISKFREE_used' => '437121024', 'DISKFREE_available' => '3575664640'), 'samples/df-002.txt');
is(ss_get_by_ssh(array('file' => 'samples/df-002.txt', 'type' => 'df', 'host' => 'localhost', 'items' => 'nj,nk', 'volume' => '/dev/mapper/vg00-server')), 'nj:437121024 nk:3575664640', 'main(samples/df-002.txt)');
is_deeply(netdev_parse(array('device' => 'eth0'), file_get_contents('samples/netdev-001.txt')), array('NETDEV_inbound' => '99704481', 'NETDEV_rxerrs' => '0', 'NETDEV_rxdrop' => '0', 'NETDEV_rxfifo' => '0', 'NETDEV_rxframe' => '0', 'NETDEV_outbound' => '21749178', 'NETDEV_txerrs' => '0', 'NETDEV_txdrop' => '0', 'NETDEV_txfifo' => '0', 'NETDEV_txcolls' => '0', 'NETDEV_txcarrier' => '0'), 'samples/netdev-001.txt');
is(ss_get_by_ssh(array('file' => 'samples/netdev-001.txt', 'type' => 'netdev', 'host' => 'localhost', 'items' => 'nl,nm,nn,no,np,nq,nr,ns,nt,nu,nv', 'device' => 'eth0')), 'nl:99704481 nm:0 nn:0 no:0 np:0 nq:21749178 nr:0 ns:0 nt:0 nu:0 nv:0', 'main(samples/netdev-001.txt)');
is_deeply(netstat_parse(null, file_get_contents('samples/netstat-001.txt')), array('NETSTAT_established' => '7', 'NETSTAT_syn_sent' => '0', 'NETSTAT_syn_recv' => '0', 'NETSTAT_fin_wait1' => '1', 'NETSTAT_fin_wait2' => '27', 'NETSTAT_time_wait' => '6412', 'NETSTAT_close' => '0', 'NETSTAT_close_wait' => '0', 'NETSTAT_last_ack' => '0', 'NETSTAT_listen' => '11', 'NETSTAT_closing' => '0', 'NETSTAT_unknown' => '0'), 'samples/netstat-001.txt');
is(ss_get_by_ssh(array('file' => 'samples/netstat-001.txt', 'type' => 'netstat', 'host' => 'localhost', 'items' => 'nw,nx,ny,nz,og,oh,oi,oj,ok,ol,om,on')), 'nw:7 nx:0 ny:0 nz:1 og:27 oh:6412 oi:0 oj:0 ok:0 ol:11 om:0 on:0', 'main(samples/netstat-001.txt)');
is_deeply(vmstat_parse(null, file_get_contents('samples/vmstat-001.txt')), array('VMSTAT_pswpin' => '32', 'VMSTAT_pswpout' => '1274'), 'samples/vmstat-001.txt');
is(ss_get_by_ssh(array('file' => 'samples/vmstat-001.txt', 'type' => 'vmstat', 'host' => 'localhost', 'items' => 'oo,op')), 'oo:32 op:1274', 'main(samples/vmstat-001.txt)');
$ra = new Regexp_Assemble();
foreach ($list as $p) {
    $ra->insert(str_split($p));
}
$ra->_reduce();
is_deeply($ra->__path, ['t', ['' => 0, 'h' => ['h', ['' => 0, 'o' => ['o', 'r']]], 'r' => ['r']], 'o', 'u', 'g', 'h'], join(' ', $list));
$list = ['tough', 'though', 'trough', 'through', 'thorough'];
$ra = new Regexp_Assemble();
foreach ($list as $p) {
    $ra->insert(str_split($p));
}
$ra->_reduce();
is_deeply($ra->__path, ['t', ['' => 0, 'h' => ['h', ['o' => [['' => 0, 'o' => ['o', 'r']]], 'r' => ['r']]], 'r' => ['r']], 'o', 'u', 'g', 'h'], join(' ', $list));
$list = ['tit', 'titanate', 'titania', 'titanite', 'titano', 'tite', 'titi', 'titian', 'titien', 'tittie'];
$ra = new Regexp_Assemble();
foreach ($list as $p) {
    $ra->insert(str_split($p));
}
$ra->_reduce();
is_deeply($ra->__path, ['t', 'i', 't', ['' => 0, 'a' => ['a', 'n', ['a' => ['a', 't', 'e'], 'i' => ['i', ['a' => ['a'], 't' => ['t', 'e']]], 'o' => ['o']]], 'i' => ['i', ['' => 0, 'a' => [['e' => ['e'], 'a' => ['a']], 'n']]], 't' => [['' => 0, 't' => ['t', 'i']], 'e']]], join(' ', $list));
$ra = new Regexp_Assemble();
$ra->add('dasin');
$ra->add('dosin');
$ra->add('dastin');
$ra->add('dostin');
$ra->_reduce();
is_deeply($ra->__path, ['d', ['a' => ['a'], 'o' => ['o']], 's', ['' => 0, 't' => ['t']], 'i', 'n'], 'dasin/dosin/dastin/dosting');
/*
is( $_, $fixed, '$_ has not been altered' );
*/
echo "===OK===\n";
      'read_views'                => '1',
      'rows_inserted'             => '169',
      'rows_updated'              => '336',
      'rows_deleted'              => '4',
      'rows_read'                 => '3713963',
      'innodb_transactions'       => '8799060',
      'unpurged_txns'             => '28',
      'history_list'              => '9',
      'current_transactions'      => '54',
      'hash_index_cells_total'    => '1155127',
      'hash_index_cells_used'     => '0',
      'total_mem_alloc'           => '288139706',
      'additional_pool_alloc'     => '2118912',
      'last_checkpoint'           => '3068940702',
      'uncheckpointed_bytes'      => '0',
      'ibuf_used_cells'           => '1',
      'ibuf_free_cells'           => '0',
      'ibuf_cell_count'           => '2',
      'adaptive_hash_memory'      => NULL,
      'page_hash_memory'          => NULL,
      'dictionary_cache_memory'   => NULL,
      'file_system_memory'        => NULL,
      'lock_system_memory'        => NULL,
      'recovery_system_memory'    => NULL,
      'thread_hash_memory'        => NULL,
   ),
   'samples/innodb-014.txt'
);
*/
is_deeply(get_innodb_array(file_get_contents('samples/innodb-015.txt')), array('spin_waits' => '134636510', 'spin_rounds' => '388647989', 'os_waits' => '8556235', 'pending_normal_aio_reads' => '1', 'file_reads' => '11270830', 'file_writes' => '396961428', 'file_fsyncs' => '10365267', 'ibuf_inserts' => '20810519', 'ibuf_merged' => '20809068', 'ibuf_merges' => '3467306', 'log_bytes_written' => '1022011878586', 'unflushed_log' => '3960491', 'log_bytes_flushed' => '1022007918095', 'log_writes' => '172229872', 'pool_size' => '2621440', 'free_pages' => '0', 'database_pages' => '2158986', 'modified_pages' => '10421', 'pages_read' => '11286955', 'pages_created' => '972067', 'pages_written' => '238644796', 'read_views' => '7', 'rows_inserted' => '175281166', 'rows_updated' => '0', 'rows_deleted' => '175454578', 'rows_read' => '312925603', 'innodb_transactions' => '1825236616', 'unpurged_txns' => '9960', 'history_list' => '67', 'current_transactions' => '1', 'hash_index_cells_total' => '84999163', 'total_mem_alloc' => '43914362880', 'additional_pool_alloc' => '0', 'last_checkpoint' => '1022005836378', 'uncheckpointed_bytes' => '6042208', 'ibuf_used_cells' => '9', 'ibuf_free_cells' => '3061', 'ibuf_cell_count' => '3071', 'innodb_tables_in_use' => '0', 'innodb_locked_tables' => '0', 'active_transactions' => '0', 'innodb_lock_structs' => '0', 'innodb_sem_waits' => '671', 'innodb_sem_wait_time_ms' => '647000', 'pending_normal_aio_writes' => '0', 'pending_ibuf_aio_reads' => '0', 'pending_aio_log_ios' => '0', 'pending_aio_sync_ios' => '0', 'pending_log_flushes' => '0', 'pending_buf_pool_flushes' => '0', 'pending_log_writes' => '0', 'pending_chkp_writes' => '0', 'queries_inside' => '0', 'queries_queued' => '0', 'hash_index_cells_used' => '0', 'adaptive_hash_memory' => NULL, 'page_hash_memory' => NULL, 'dictionary_cache_memory' => NULL, 'file_system_memory' => NULL, 'lock_system_memory' => NULL, 'recovery_system_memory' => NULL, 'thread_hash_memory' => NULL), 'samples/innodb-015.txt');
      'rows_inserted'             => '169',
      'rows_updated'              => '336',
      'rows_deleted'              => '4',
      'rows_read'                 => '3713963',
      'innodb_transactions'       => '8799060',
      'unpurged_txns'             => '28',
      'history_list'              => '9',
      'current_transactions'      => '54',
      'hash_index_cells_total'    => '1155127',
      'hash_index_cells_used'     => '0',
      'total_mem_alloc'           => '288139706',
      'additional_pool_alloc'     => '2118912',
      'last_checkpoint'           => '3068940702',
      'uncheckpointed_bytes'      => '0',
      'ibuf_used_cells'           => '1',
      'ibuf_free_cells'           => '0',
      'ibuf_cell_count'           => '2',
      'adaptive_hash_memory'      => NULL,
      'page_hash_memory'          => NULL,
      'dictionary_cache_memory'   => NULL,
      'file_system_memory'        => NULL,
      'lock_system_memory'        => NULL,
      'recovery_system_memory'    => NULL,
      'thread_hash_memory'        => NULL,
   ),
   'samples/innodb-014.txt'
);
*/
is_deeply(get_innodb_array(file_get_contents('samples/innodb-015.txt')), array('spin_waits' => '134636510', 'spin_rounds' => '388647989', 'os_waits' => '8556235', 'pending_normal_aio_reads' => '1', 'file_reads' => '11270830', 'file_writes' => '396961428', 'file_fsyncs' => '10365267', 'ibuf_inserts' => '20810519', 'ibuf_merged' => '20809068', 'ibuf_merges' => '3467306', 'log_bytes_written' => '1022011878586', 'unflushed_log' => '3960491', 'log_bytes_flushed' => '1022007918095', 'log_writes' => '172229872', 'pool_size' => '2621440', 'free_pages' => '0', 'database_pages' => '2158986', 'modified_pages' => '10421', 'pages_read' => '11286955', 'pages_created' => '972067', 'pages_written' => '238644796', 'read_views' => '7', 'rows_inserted' => '175281166', 'rows_updated' => '0', 'rows_deleted' => '175454578', 'rows_read' => '312925603', 'innodb_transactions' => '1825236616', 'unpurged_txns' => '9960', 'history_list' => '67', 'current_transactions' => '1', 'hash_index_cells_total' => '84999163', 'total_mem_alloc' => '43914362880', 'additional_pool_alloc' => '0', 'last_checkpoint' => '1022005836378', 'uncheckpointed_bytes' => '6042208', 'ibuf_used_cells' => '9', 'ibuf_free_cells' => '3061', 'ibuf_cell_count' => '3071', 'innodb_tables_in_use' => '0', 'innodb_locked_tables' => '0', 'active_transactions' => '0', 'innodb_lock_structs' => '0', 'innodb_sem_waits' => '671', 'innodb_sem_wait_time_ms' => '647000', 'pending_normal_aio_writes' => '0', 'pending_ibuf_aio_reads' => '0', 'pending_aio_log_ios' => '0', 'pending_aio_sync_ios' => '0', 'pending_log_flushes' => '0', 'pending_buf_pool_flushes' => '0', 'pending_log_writes' => '0', 'pending_chkp_writes' => '0', 'queries_inside' => '0', 'queries_queued' => '0', 'hash_index_cells_used' => '0', 'adaptive_hash_memory' => NULL, 'page_hash_memory' => NULL, 'dictionary_cache_memory' => NULL, 'file_system_memory' => NULL, 'lock_system_memory' => NULL, 'recovery_system_memory' => NULL, 'thread_hash_memory' => NULL), 'samples/innodb-015.txt');
is_deeply(get_innodb_array(file_get_contents('samples/innodb-016.txt')), array('spin_waits' => '15', 'spin_rounds' => '11', 'os_waits' => '108', 'pending_normal_aio_reads' => '0', 'file_reads' => '153', 'file_writes' => '3', 'file_fsyncs' => '3', 'ibuf_inserts' => '4', 'ibuf_merged' => '17', 'ibuf_merges' => '9', 'log_bytes_written' => '1595675', 'unflushed_log' => '0', 'log_bytes_flushed' => '1595675', 'log_writes' => '8', 'pool_size' => '8192', 'free_pages' => '8050', 'database_pages' => '142', 'modified_pages' => '0', 'pages_read' => '142', 'pages_created' => '0', 'pages_written' => '0', 'read_views' => '1', 'rows_inserted' => '0', 'rows_updated' => '0', 'rows_deleted' => '0', 'rows_read' => '0', 'innodb_transactions' => '1280', 'unpurged_txns' => '1280', 'history_list' => '0', 'current_transactions' => '1', 'hash_index_cells_total' => '276707', 'total_mem_alloc' => '137363456', 'additional_pool_alloc' => '0', 'last_checkpoint' => '1595675', 'uncheckpointed_bytes' => '0', 'ibuf_used_cells' => '1', 'ibuf_free_cells' => '0', 'ibuf_cell_count' => '2', 'innodb_tables_in_use' => '0', 'innodb_locked_tables' => '0', 'active_transactions' => '0', 'innodb_lock_structs' => '0', 'innodb_sem_waits' => null, 'innodb_sem_wait_time_ms' => null, 'pending_normal_aio_writes' => '0', 'pending_ibuf_aio_reads' => '0', 'pending_aio_log_ios' => '0', 'pending_aio_sync_ios' => '0', 'pending_log_flushes' => '0', 'pending_buf_pool_flushes' => '0', 'pending_log_writes' => '0', 'pending_chkp_writes' => '0', 'queries_inside' => '0', 'queries_queued' => '0', 'hash_index_cells_used' => '0', 'adaptive_hash_memory' => NULL, 'page_hash_memory' => NULL, 'dictionary_cache_memory' => NULL, 'file_system_memory' => NULL, 'lock_system_memory' => NULL, 'recovery_system_memory' => NULL, 'thread_hash_memory' => NULL), 'samples/innodb-016.txt');
<?php

$lib = isset($_SERVER['TESTLIB']) ? $_SERVER['TESTLIB'] : 'Test-More.php';
require_once $lib;
plan('no_plan');
diag("Assertions:");
is_deeply(NULL, NULL);
is_deeply(TRUE, TRUE);
is_deeply(FALSE, FALSE);
is_deeply(42, 42);
is_deeply('abcdef', 'abcdef');
is_deeply(array(), array());
is_deeply(array(1), array(1));
is_deeply(array(array()), array(array()));
is_deeply(array(array(123)), array(array(123)));
is_deeply(array(1, 'abc'), array(0 => 1, 1 => 'abc'));
diag("Denials:");
isnt_deeply(NULL, TRUE, 'NULL !== TRUE');
isnt_deeply(NULL, FALSE, 'NULL !== FALSE');
isnt_deeply(NULL, 0, 'NULL !== 0');
isnt_deeply(NULL, '', "NULL !== ''");
isnt_deeply(0, FALSE, '0 !== FALSE');
isnt_deeply(1, TRUE, '1 !== TRUE');
Esempio n. 11
0
	can_ok($test_obj, array('foo', 'bar', 'baz'));
	check_capture(false);

	isa_ok($test_obj, 'TestClass2');
	check_capture(false);

	fail('fail()');
	check_capture(false);

	include_ok($dir.'/inc_false.php');
	check_capture(false);

	require_ok($dir.'/inc_false.php');
	check_capture(false);

	is_deeply($struct_1, $struct_2, 'is_deeply()');
	check_capture(false);

	todo_begin("Testing");

	fail("example unimplemented todo test");
	check_capture(false);

	todo_end();

        // in 5.3 we would pass an anonymous function
	function ex_todo_fail() {
		fail("example fail in subroutine");
	}
	todo( "Testing", "ex_todo_fail" );
	check_capture(false);
function lcmp($a, $b)
{
    $r = new Regexp_Assemble();
    is_deeply($r->_lex($a), array($a), "_lex {$a} source line {$b}");
}