diff options
Diffstat (limited to 'ext/snmp/tests')
| -rw-r--r-- | ext/snmp/tests/README | 5 | ||||
| -rw-r--r-- | ext/snmp/tests/generic_timeout_error.phpt | 5 | ||||
| -rw-r--r-- | ext/snmp/tests/ipv6.phpt | 24 | ||||
| -rw-r--r-- | ext/snmp/tests/snmp-object-errno-errstr.phpt | 2 | ||||
| -rw-r--r-- | ext/snmp/tests/snmp_include.inc | 6 | ||||
| -rw-r--r-- | ext/snmp/tests/wrong_hostname.phpt | 2 |
6 files changed, 40 insertions, 4 deletions
diff --git a/ext/snmp/tests/README b/ext/snmp/tests/README index d87d17ad1b..74258ec27f 100644 --- a/ext/snmp/tests/README +++ b/ext/snmp/tests/README @@ -9,7 +9,9 @@ To enable these tests, you must have : ** How to test ** You need to give credentials with environment vars if default ones are not sutable (see snmp_include.inc for more info): -SNMP_HOSTNAME : IP or IP:PORT to connect to +SNMP_HOSTNAME : IPv4 of remote SNMP agent +SNMP_HOSTNAME : IPv6 or remote SNMP agent +SNMP_PORT : SNMP port for queries SNMP_COMMUNITY : community name SNMP_COMMUNITY_WRITE : community used for write tests (snmpset()). SNMP_MIBDIR : Directory containing MIBS @@ -26,6 +28,7 @@ On Linux/FreeBSD ###### Config file ##### rocommunity public 127.0.0.1 +rocommunity6 public ::1 rwcommunity private 127.0.0.1 Do not enable them - being set here they make appropriate OID switch into r/o diff --git a/ext/snmp/tests/generic_timeout_error.phpt b/ext/snmp/tests/generic_timeout_error.phpt index 0f5101a439..c333a0d20b 100644 --- a/ext/snmp/tests/generic_timeout_error.phpt +++ b/ext/snmp/tests/generic_timeout_error.phpt @@ -15,8 +15,13 @@ snmp_set_quick_print(false); snmp_set_valueretrieval(SNMP_VALUE_PLAIN); var_dump(snmpget($hostname, 'timeout_community_432', '.1.3.6.1.2.1.1.1.0', $timeout, $retries)); +var_dump(snmpget($hostname, 'timeout_community_432', array('.1.3.6.1.2.1.1.1.0'), $timeout, $retries)); ?> --EXPECTF-- Warning: snmpget(): No response from %s in %s on line %d bool(false) + +Warning: snmpget(): No response from %s in %s on line %d +bool(false) + diff --git a/ext/snmp/tests/ipv6.phpt b/ext/snmp/tests/ipv6.phpt new file mode 100644 index 0000000000..78119d1575 --- /dev/null +++ b/ext/snmp/tests/ipv6.phpt @@ -0,0 +1,24 @@ +--TEST-- +IPv6 support +--CREDITS-- +Boris Lytochkin +--SKIPIF-- +<?php + require_once(dirname(__FILE__).'/skipif.inc'); + + if (!function_exists("inet_ntop")) die("skip no inet_ntop()"); +?> +--FILE-- +<?php +require_once(dirname(__FILE__).'/snmp_include.inc'); + +$default_port = 161; + +//EXPECTF format is quickprint OFF +snmp_set_quick_print(false); +snmp_set_valueretrieval(SNMP_VALUE_PLAIN); + +var_dump(snmpget($hostname6_port, $community, '.1.3.6.1.2.1.1.1.0')); +?> +--EXPECTF-- +%unicode|string%(%d) "%s" diff --git a/ext/snmp/tests/snmp-object-errno-errstr.phpt b/ext/snmp/tests/snmp-object-errno-errstr.phpt index 923fb856e0..427a754b08 100644 --- a/ext/snmp/tests/snmp-object-errno-errstr.phpt +++ b/ext/snmp/tests/snmp-object-errno-errstr.phpt @@ -42,6 +42,7 @@ $session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', $priv_pass); var_dump(@$session->get('.1.3.6.1.2.1.1.1.0')); var_dump($session->getErrno() == SNMP::ERRNO_GENERIC); var_dump($session->getError()); +var_dump(@$session->get(array('.1.3.6.1.2.1.1.1.0'))); $session->close(); ?> --EXPECTF-- @@ -61,3 +62,4 @@ SNMP::ERRNO_GENERIC bool(false) bool(true) %string|unicode%(%d) "Fatal error: Unknown user name" +bool(false) diff --git a/ext/snmp/tests/snmp_include.inc b/ext/snmp/tests/snmp_include.inc index c91499078d..caa0721890 100644 --- a/ext/snmp/tests/snmp_include.inc +++ b/ext/snmp/tests/snmp_include.inc @@ -6,9 +6,11 @@ requests and 'private' community for write requests. Default timeout is 1000ms and there will be one request performed. */ -$hostname = getenv('SNMP_HOSTNAME') ? getenv('SNMP_HOSTNAME') : '127.0.0.1'; +$hostname4 = getenv('SNMP_HOSTNAME') ? getenv('SNMP_HOSTNAME') : '127.0.0.1'; +$hostname6 = getenv('SNMP_HOSTNAME6') ? getenv('SNMP_HOSTNAME6') : '::1'; $port = getenv('SNMP_PORT') ? getenv('SNMP_PORT') : '161'; -$hostname .= ":$port"; +$hostname = "$hostname4:$port"; +$hostname6_port = "[$hostname6]:$port"; $community = getenv('SNMP_COMMUNITY') ? getenv('SNMP_COMMUNITY') : 'public'; $communityWrite = getenv('SNMP_COMMUNITY_WRITE')? getenv('SNMP_COMMUNITY_WRITE'):'private'; diff --git a/ext/snmp/tests/wrong_hostname.phpt b/ext/snmp/tests/wrong_hostname.phpt index e0bfa8a54d..4ab087e41f 100644 --- a/ext/snmp/tests/wrong_hostname.phpt +++ b/ext/snmp/tests/wrong_hostname.phpt @@ -18,5 +18,5 @@ var_dump(snmpget('192.168..6.1', 'community', '.1.3.6.1.2.1.1.1.0', $timeout, $r ?> --EXPECTF-- -Warning: snmpget(): Could not open snmp connection: Unknown host (192.168..6.1) (%s) in %s on line %d +Warning: snmpget(): php_network_getaddresses: getaddrinfo failed: hostname nor servname provided, or not known in %s on line %d bool(false) |
