summaryrefslogtreecommitdiff
path: root/ext/snmp/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ext/snmp/tests')
-rw-r--r--ext/snmp/tests/README46
-rw-r--r--ext/snmp/tests/bug60749.phpt28
-rw-r--r--ext/snmp/tests/bug64124.phpt40
-rw-r--r--ext/snmp/tests/clean.inc4
-rw-r--r--ext/snmp/tests/generic_timeout_error.phpt27
-rw-r--r--ext/snmp/tests/ipv6.phpt25
-rw-r--r--ext/snmp/tests/skipif.inc13
-rw-r--r--ext/snmp/tests/snmp-object-errno-errstr.phpt147
-rw-r--r--ext/snmp/tests/snmp-object-error.phpt122
-rw-r--r--ext/snmp/tests/snmp-object-properties.phpt208
-rw-r--r--ext/snmp/tests/snmp-object-setSecurity_error.phpt66
-rw-r--r--ext/snmp/tests/snmp-object.phpt234
-rw-r--r--ext/snmp/tests/snmp2_get.phpt104
-rw-r--r--ext/snmp/tests/snmp2_getnext.phpt39
-rw-r--r--ext/snmp/tests/snmp2_real_walk.phpt86
-rw-r--r--ext/snmp/tests/snmp2_set-nomib.phpt59
-rw-r--r--ext/snmp/tests/snmp2_set.phpt248
-rw-r--r--ext/snmp/tests/snmp2_walk.phpt99
-rw-r--r--ext/snmp/tests/snmp3-error.phpt76
-rw-r--r--ext/snmp/tests/snmp3.phpt127
-rw-r--r--ext/snmp/tests/snmp_get_quick_print.phpt41
-rw-r--r--ext/snmp/tests/snmp_get_valueretrieval.phpt53
-rw-r--r--ext/snmp/tests/snmp_getvalue.phpt83
-rw-r--r--ext/snmp/tests/snmp_include.inc31
-rw-r--r--ext/snmp/tests/snmp_read_mib.phpt34
-rw-r--r--ext/snmp/tests/snmp_set_enum_print.phpt28
-rw-r--r--ext/snmp/tests/snmp_set_oid_output_format.phpt32
-rw-r--r--ext/snmp/tests/snmpd.conf25
-rw-r--r--ext/snmp/tests/snmpget.phpt106
-rw-r--r--ext/snmp/tests/snmpgetnext.phpt39
-rw-r--r--ext/snmp/tests/snmprealwalk.phpt86
-rw-r--r--ext/snmp/tests/snmpset-nomib.phpt60
-rw-r--r--ext/snmp/tests/snmpset.phpt248
-rw-r--r--ext/snmp/tests/snmpwalk.phpt99
-rw-r--r--ext/snmp/tests/wrong_hostname.phpt22
35 files changed, 2785 insertions, 0 deletions
diff --git a/ext/snmp/tests/README b/ext/snmp/tests/README
new file mode 100644
index 0000000..819a50d
--- /dev/null
+++ b/ext/snmp/tests/README
@@ -0,0 +1,46 @@
+SNMP Tests
+----------
+
+To enable these tests, you must have :
+- PHP compiled with SNMP (--with-snmp)
+- an SNMP server running.
+
+
+** 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 : 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
+
+To run test suite you may use this command (presuming that you pwd is where
+this README file is located):
+> make -C ../../.. test TESTS="`cd ../../..; /bin/ls -1 ext/snmp/tests/*.phpt | xargs echo`"
+Running run-tests.php directly will clear your environment and therefore
+tests will fail if your SNMP configuration does not fit into default values
+specified in snmp_include.inc.
+
+** Configuring the SNMPD server **
+
+On Linux/FreeBSD
+--------
+
+- Install package net-snmpd (name may differ based on your distribution).
+- Replace config file (by default this is /etc/snmp/snmpd.conf on Linux and
+ /usr/local/etc/snmp/snmpd.conf on FreeBSD) with snmpd.conf supplied.
+
+Before launching daemon make sure that there is no file /var/net-snmp/snmpd.conf
+Delete it if exists. Ingoring to to so will fail SNMPv3 tests.
+
+- Launch snmpd (service snmpd start or /etc/init.d/snmpd start).
+ Alternatively you can start snmpd daemon using following command line:
+ sudo snmpd -C -c ./snmpd.conf -f -Le
+
+
+On Windows
+----------
+
+[to be completed]
diff --git a/ext/snmp/tests/bug60749.phpt b/ext/snmp/tests/bug60749.phpt
new file mode 100644
index 0000000..302f351
--- /dev/null
+++ b/ext/snmp/tests/bug60749.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Bug #60749: SNMP module should not strip non-standard SNMP port from hostname
+--CREDITS--
+Boris Lytochkin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+$hostname = "php.net";
+$ip = gethostbyname($hostname);
+if (ip2long($ip) === FALSE) {
+ echo "Could not resolve $hostname properly!\n";
+ exit(1);
+}
+$port = 1161;
+$session = new SNMP(SNMP::VERSION_1, "$hostname:$port", $community, $timeout, $retries);
+$info = $session->info;
+if (strcmp($info["hostname"], "$ip:$port") !== 0) {
+ echo "'" . $info["hostname"] . "' != '$ip:$port'\n";
+}
+var_dump($session->close());
+?>
+--EXPECTF--
+bool(true)
diff --git a/ext/snmp/tests/bug64124.phpt b/ext/snmp/tests/bug64124.phpt
new file mode 100644
index 0000000..454b06d
--- /dev/null
+++ b/ext/snmp/tests/bug64124.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Bug #64124 IPv6 malformed
+--CREDITS--
+Boris Lytochkin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+
+$packed = str_repeat(chr(0), 15) . chr(1);
+if (@inet_ntop($packed) === false) {
+ die("skip no IPv6 support");
+}
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+# hostname variable was modified inline in netsnmp_session_init()
+# Should be checked with IPv6 since IPv4 processing code do not alter pointer position
+
+//EXPECTF format is quickprint OFF
+snmp_set_quick_print(false);
+snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
+
+$checkvar = "$hostname6_port";
+
+var_dump(snmpget($checkvar, $community, '.1.3.6.1.2.1.1.1.0'));
+var_dump(($checkvar === $hostname6_port));
+var_dump(snmpget($checkvar, $community, '.1.3.6.1.2.1.1.1.0'));
+var_dump(($checkvar === $hostname6_port));
+var_dump(snmpget($checkvar, $community, '.1.3.6.1.2.1.1.1.0'));
+var_dump(($checkvar === $hostname6_port));
+?>
+--EXPECTF--
+%unicode|string%(%d) "%s"
+bool(true)
+%unicode|string%(%d) "%s"
+bool(true)
+%unicode|string%(%d) "%s"
+bool(true)
diff --git a/ext/snmp/tests/clean.inc b/ext/snmp/tests/clean.inc
new file mode 100644
index 0000000..70ac0f5
--- /dev/null
+++ b/ext/snmp/tests/clean.inc
@@ -0,0 +1,4 @@
+<?php
+include_once(dirname(__FILE__) . '/snmp_include.inc');
+
+// To be completed if necessary
diff --git a/ext/snmp/tests/generic_timeout_error.phpt b/ext/snmp/tests/generic_timeout_error.phpt
new file mode 100644
index 0000000..c333a0d
--- /dev/null
+++ b/ext/snmp/tests/generic_timeout_error.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Generic timeout (wrong community)
+--CREDITS--
+Boris Lytochkin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+//EXPECTF format is quickprint OFF
+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 0000000..1287941
--- /dev/null
+++ b/ext/snmp/tests/ipv6.phpt
@@ -0,0 +1,25 @@
+--TEST--
+IPv6 support
+--CREDITS--
+Boris Lytochkin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+
+$packed = str_repeat(chr(0), 15) . chr(1);
+if (@inet_ntop($packed) === false) {
+ die("skip no IPv6 support");
+}
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+//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/skipif.inc b/ext/snmp/tests/skipif.inc
new file mode 100644
index 0000000..4d37902
--- /dev/null
+++ b/ext/snmp/tests/skipif.inc
@@ -0,0 +1,13 @@
+<?php
+extension_loaded('snmp') or die('skip snmp extension not available in this build');
+
+require_once (dirname(__FILE__).'/snmp_include.inc');
+
+//test server is available
+// this require snmpget to work ...
+//snmpget ( string $hostname , string $community ,
+//string $object_id [, int $timeout [, int $retries ]] )
+
+if (snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout) === false)
+ die('NO SNMPD on this host or community invalid');
+
diff --git a/ext/snmp/tests/snmp-object-errno-errstr.phpt b/ext/snmp/tests/snmp-object-errno-errstr.phpt
new file mode 100644
index 0000000..b6047af
--- /dev/null
+++ b/ext/snmp/tests/snmp-object-errno-errstr.phpt
@@ -0,0 +1,147 @@
+--TEST--
+OO API: getErrno & getError methods
+--CREDITS--
+Boris Lytochkin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+//EXPECTF format is quickprint OFF
+snmp_set_enum_print(false);
+snmp_set_quick_print(false);
+snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
+snmp_set_oid_output_format(SNMP_OID_OUTPUT_FULL);
+
+echo "SNMP::ERRNO_NOERROR\n";
+$session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries);
+var_dump(@$session->get('.1.3.6.1.2.1.1.1.0'));
+var_dump($session->getErrno() == SNMP::ERRNO_NOERROR);
+var_dump($session->getError());
+$session->close();
+
+echo "SNMP::ERRNO_TIMEOUT\n";
+$session = new SNMP(SNMP::VERSION_2c, $hostname, 'timeout_community_432', $timeout, $retries);
+$session->valueretrieval = SNMP_VALUE_LIBRARY;
+var_dump(@$session->get('.1.3.6.1.2.1.1.1.0'));
+var_dump($session->getErrno() == SNMP::ERRNO_TIMEOUT);
+var_dump($session->getError());
+$session->close();
+
+echo "SNMP::ERRNO_ERROR_IN_REPLY\n";
+$session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries);
+var_dump(@$session->get('.1.3.6.1.2.1.1.1.110'));
+var_dump($session->getErrno() == SNMP::ERRNO_ERROR_IN_REPLY);
+var_dump($session->getError());
+$session->close();
+
+echo "SNMP::ERRNO_GENERIC\n";
+$session = new SNMP(SNMP::VERSION_3, $hostname, 'somebogususer', $timeout, $retries);
+$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();
+
+echo "SNMP::ERRNO_OID_PARSING_ERROR\n";
+echo "GET: Single wrong OID\n";
+$session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries);
+var_dump(@$session->get('.1.3.6.1.2..1.1.1.0'));
+var_dump($session->getErrno() == SNMP::ERRNO_OID_PARSING_ERROR);
+var_dump($session->getError());
+$session->close();
+echo "GET: Miltiple OID, one wrong\n";
+$session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries);
+var_dump(@$session->get(array('.1.3.6.1.2.1.1.1.0', '.1.3.6.1.2..1.1.1.0')));
+var_dump($session->getErrno() == SNMP::ERRNO_OID_PARSING_ERROR);
+var_dump($session->getError());
+$session->close();
+echo "WALK: Single wrong OID\n";
+$session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries);
+var_dump(@$session->walk('.1.3.6.1.2..1.1'));
+var_dump($session->getErrno() == SNMP::ERRNO_OID_PARSING_ERROR);
+var_dump($session->getError());
+$session->close();
+echo "SET: Wrong type\n";
+$session = new SNMP(SNMP::VERSION_3, $hostname, $rwuser, $timeout, $retries);
+$session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', $priv_pass);
+$oid1 = 'SNMPv2-MIB::sysContact.0';
+var_dump(@$session->set($oid1, 'q', 'blah'));
+var_dump($session->getErrno() == SNMP::ERRNO_OID_PARSING_ERROR);
+var_dump($session->getError());
+
+echo "SNMP::ERRNO_MULTIPLE_SET_QUERIES\n";
+$oid1 = 'SNMPv2-MIB::sysContact.0';
+$oid2 = 'SNMPv2-MIB::sysLocation.0';
+$session = new SNMP(SNMP::VERSION_3, $hostname, $rwuser, $timeout, $retries);
+$session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', $priv_pass);
+$session->max_oids = 1;
+$oldvalue1 = $session->get($oid1);
+$newvalue1 = $oldvalue1 . '0';
+$oldvalue2 = $session->get($oid2);
+$newvalue2 = $oldvalue2 . '0';
+$z = @$session->set(array($oid1, $oid2), array('s','s'), array($newvalue1, $newvalue2));
+var_dump($z);
+var_dump($session->getErrno() == SNMP::ERRNO_MULTIPLE_SET_QUERIES);
+var_dump($session->getError());
+var_dump(($session->get($oid1) === $newvalue1));
+var_dump(($session->get($oid2) === $newvalue2));
+$z = @$session->set(array($oid1, $oid2), array('s','s'), array($oldvalue1, $oldvalue2));
+var_dump($z);
+var_dump($session->getErrno() == SNMP::ERRNO_MULTIPLE_SET_QUERIES);
+var_dump($session->getError());
+var_dump(($session->get($oid1) === $oldvalue1));
+var_dump(($session->get($oid2) === $oldvalue2));
+var_dump($session->close());
+?>
+--EXPECTF--
+SNMP::ERRNO_NOERROR
+%string|unicode%(%d) "%s"
+bool(true)
+%string|unicode%(0) ""
+SNMP::ERRNO_TIMEOUT
+bool(false)
+bool(true)
+%string|unicode%(%d) "No response from %s"
+SNMP::ERRNO_ERROR_IN_REPLY
+bool(false)
+bool(true)
+%string|unicode%(%d) "Error in packet %s"
+SNMP::ERRNO_GENERIC
+bool(false)
+bool(true)
+%string|unicode%(%d) "Fatal error: Unknown user name"
+bool(false)
+SNMP::ERRNO_OID_PARSING_ERROR
+GET: Single wrong OID
+bool(false)
+bool(true)
+string(46) "Invalid object identifier: .1.3.6.1.2..1.1.1.0"
+GET: Miltiple OID, one wrong
+bool(false)
+bool(true)
+string(46) "Invalid object identifier: .1.3.6.1.2..1.1.1.0"
+WALK: Single wrong OID
+bool(false)
+bool(true)
+string(42) "Invalid object identifier: .1.3.6.1.2..1.1"
+SET: Wrong type
+bool(false)
+bool(true)
+string(129) "Could not add variable: OID='.iso.org.dod.internet.mgmt.mib-2.system.sysContact.0' type='q' value='blah': Bad variable type ("q")"
+SNMP::ERRNO_MULTIPLE_SET_QUERIES
+bool(true)
+bool(true)
+string(74) "Can not fit all OIDs for SET query into one packet, using multiple queries"
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+string(74) "Can not fit all OIDs for SET query into one packet, using multiple queries"
+bool(true)
+bool(true)
+bool(true)
diff --git a/ext/snmp/tests/snmp-object-error.phpt b/ext/snmp/tests/snmp-object-error.phpt
new file mode 100644
index 0000000..b2fed9f
--- /dev/null
+++ b/ext/snmp/tests/snmp-object-error.phpt
@@ -0,0 +1,122 @@
+--TEST--
+OO API: Generic errors
+--CREDITS--
+Boris Lytochkin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+//EXPECTF format is quickprint OFF
+snmp_set_quick_print(false);
+snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
+
+try {
+var_dump(new SNMP(SNMP::VERSION_1, $hostname));
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+try {
+var_dump(new SNMP(SNMP::VERSION_1, $hostname, $community, ''));
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+try {
+var_dump(new SNMP(SNMP::VERSION_1, $hostname, $community, $timeout, ''));
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+try {
+var_dump(new SNMP(7, $hostname, $community));
+} catch (Exception $e) {
+ print $e->getMessage() . "\n";
+}
+
+echo "Exception handling\n";
+$session = new SNMP(SNMP::VERSION_3, $hostname, $user_noauth, $timeout, $retries);
+try {
+ var_dump($session->get('.1.3.6.1.2.1.1.1..0'));
+} catch (SNMPException $e) {
+ var_dump($e->getCode());
+ var_dump($e->getMessage());
+}
+$session->exceptions_enabled = SNMP::ERRNO_ANY;
+try {
+ var_dump($session->get('.1.3.6.1.2.1.1.1..0'));
+} catch (SNMPException $e) {
+ var_dump($e->getCode());
+ var_dump($e->getMessage());
+}
+var_dump($session->close());
+
+echo "Open normal session\n";
+$session = new SNMP(SNMP::VERSION_3, $hostname, $user_noauth, $timeout, $retries);
+$session->valueretrieval = 67;
+var_dump($session->valueretrieval);
+echo "Closing session\n";
+var_dump($session->close(''));
+var_dump($session->close());
+var_dump($session->get('.1.3.6.1.2.1.1.1.0'));
+var_dump($session->close());
+
+$session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries);
+var_dump($session->walk('.1.3.6.1.2.1.1', FALSE, ''));
+var_dump($session->walk('.1.3.6.1.2.1.1', FALSE, 30, ''));
+var_dump($session->get());
+var_dump($session->getnext());
+var_dump($session->set());
+
+var_dump($session->max_oids);
+$session->max_oids = "ttt";
+$session->max_oids = 0;
+var_dump($session->max_oids);
+?>
+--EXPECTF--
+SNMP::__construct() expects at least 3 parameters, 2 given
+SNMP::__construct() expects parameter 4 to be long, string given
+SNMP::__construct() expects parameter 5 to be long, string given
+Unknown SNMP protocol version
+Exception handling
+
+Warning: SNMP::get(): Invalid object identifier: .1.3.6.1.2.1.1.1..0 in %s on line %d
+bool(false)
+int(32)
+string(46) "Invalid object identifier: .1.3.6.1.2.1.1.1..0"
+bool(true)
+Open normal session
+
+Warning: main(): Unknown SNMP value retrieval method '67' in %s on line %d
+int(%d)
+Closing session
+
+Warning: SNMP::close() expects exactly 0 parameters, 1 given in %s on line %d
+bool(false)
+bool(true)
+
+Warning: SNMP::get(): Invalid or uninitialized SNMP object in %s on line %d
+bool(false)
+bool(true)
+
+Warning: SNMP::walk() expects parameter 3 to be long, string given in %s on line %d
+bool(false)
+
+Warning: SNMP::walk() expects parameter 4 to be long, string given in %s on line %d
+bool(false)
+
+Warning: SNMP::get() expects at least 1 parameter, 0 given in %s on line %d
+bool(false)
+
+Warning: SNMP::getnext() expects exactly 1 parameter, 0 given in %s on line %d
+bool(false)
+
+Warning: SNMP::set() expects exactly 3 parameters, 0 given in %s on line %d
+bool(false)
+NULL
+
+Warning: main(): max_oids should be positive integer or NULL, got 0 in %s on line %d
+
+Warning: main(): max_oids should be positive integer or NULL, got 0 in %s on line %d
+NULL
diff --git a/ext/snmp/tests/snmp-object-properties.phpt b/ext/snmp/tests/snmp-object-properties.phpt
new file mode 100644
index 0000000..40b6968
--- /dev/null
+++ b/ext/snmp/tests/snmp-object-properties.phpt
@@ -0,0 +1,208 @@
+--TEST--
+OO API: SNMP object properties
+--CREDITS--
+Boris Lytochkin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+//EXPECTF format is quickprint OFF
+snmp_set_enum_print(false);
+snmp_set_quick_print(false);
+snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
+snmp_set_oid_output_format(SNMP_OID_OUTPUT_FULL);
+
+echo "Check working\n";
+
+$session = new SNMP(SNMP::VERSION_1, $hostname, $community, $timeout, $retries);
+var_dump($session);
+
+$session->max_oids = 40;
+$session->enum_print = TRUE;
+$session->quick_print = TRUE;
+$session->valueretrieval = SNMP_VALUE_LIBRARY;
+$session->oid_output_format = SNMP_OID_OUTPUT_NUMERIC;
+$session->oid_increasing_check = FALSE;
+
+var_dump($session);
+
+$session->max_oids = "40";
+$session->enum_print = "1";
+$session->quick_print = "1";
+$session->valueretrieval = "1";
+$session->oid_output_format = "3";
+$session->oid_increasing_check = "45";
+
+var_dump($session);
+
+var_dump(property_exists($session, "enum_print"));
+var_dump(isset($session->enum_print));
+var_dump(empty($session->enum_print));
+
+$param=123;
+$session->$param = "param_value";
+var_dump($session);
+var_dump($session->$param);
+var_dump(property_exists($session, $param));
+
+echo "Error handling\n";
+$param = 'there is no such parameter';
+var_dump($session->$param);
+var_dump(property_exists($session, $param));
+
+$session->valueretrieval = 67;
+var_dump($session->valueretrieval);
+$session->oid_output_format = 78;
+var_dump($session->oid_output_format);
+
+$session->info = array("blah" => 2);
+var_dump($session->info);
+
+$session->max_oids = NULL;
+var_dump($session->max_oids);
+?>
+--EXPECTF--
+Check working
+object(SNMP)#%d (%d) {
+ ["info"]=>
+ array(4) {
+ ["hostname"]=>
+ %string|unicode%(%d) "%s"
+ ["port"]=>
+ int(%d)
+ ["timeout"]=>
+ int(%i)
+ ["retries"]=>
+ int(%d)
+ }
+ ["max_oids"]=>
+ NULL
+ ["valueretrieval"]=>
+ int(1)
+ ["quick_print"]=>
+ bool(false)
+ ["enum_print"]=>
+ bool(false)
+ ["oid_output_format"]=>
+ int(3)
+ ["oid_increasing_check"]=>
+ bool(true)
+ ["exceptions_enabled"]=>
+ int(0)
+}
+object(SNMP)#%d (%d) {
+ ["info"]=>
+ array(4) {
+ ["hostname"]=>
+ %string|unicode%(%d) "%s"
+ ["port"]=>
+ int(%d)
+ ["timeout"]=>
+ int(%i)
+ ["retries"]=>
+ int(%d)
+ }
+ ["max_oids"]=>
+ int(40)
+ ["valueretrieval"]=>
+ int(0)
+ ["quick_print"]=>
+ bool(true)
+ ["enum_print"]=>
+ bool(true)
+ ["oid_output_format"]=>
+ int(4)
+ ["oid_increasing_check"]=>
+ bool(false)
+ ["exceptions_enabled"]=>
+ int(0)
+}
+object(SNMP)#%d (%d) {
+ ["info"]=>
+ array(4) {
+ ["hostname"]=>
+ %string|unicode%(%d) "%s"
+ ["port"]=>
+ int(%d)
+ ["timeout"]=>
+ int(%i)
+ ["retries"]=>
+ int(%d)
+ }
+ ["max_oids"]=>
+ int(40)
+ ["valueretrieval"]=>
+ int(1)
+ ["quick_print"]=>
+ bool(true)
+ ["enum_print"]=>
+ bool(true)
+ ["oid_output_format"]=>
+ int(3)
+ ["oid_increasing_check"]=>
+ bool(true)
+ ["exceptions_enabled"]=>
+ int(0)
+}
+bool(true)
+bool(true)
+bool(false)
+object(SNMP)#%d (%d) {
+ ["info"]=>
+ array(4) {
+ ["hostname"]=>
+ %string|unicode%(%d) "%s"
+ ["port"]=>
+ int(%d)
+ ["timeout"]=>
+ int(%i)
+ ["retries"]=>
+ int(%d)
+ }
+ ["max_oids"]=>
+ int(40)
+ ["valueretrieval"]=>
+ int(1)
+ ["quick_print"]=>
+ bool(true)
+ ["enum_print"]=>
+ bool(true)
+ ["oid_output_format"]=>
+ int(3)
+ ["oid_increasing_check"]=>
+ bool(true)
+ ["exceptions_enabled"]=>
+ int(0)
+ ["123"]=>
+ string(11) "param_value"
+}
+string(11) "param_value"
+bool(true)
+Error handling
+
+Notice: Undefined property: SNMP::$there is no such parameter in %s on line %d
+NULL
+bool(false)
+
+Warning: main(): Unknown SNMP value retrieval method '67' in %s on line %d
+int(1)
+
+Warning: main(): Unknown SNMP output print format '78' in %s on line %d
+int(3)
+
+Warning: main(): info property is read-only in %s on line %d
+array(4) {
+ ["hostname"]=>
+ %string|unicode%(%d) "%s"
+ ["port"]=>
+ int(%d)
+ ["timeout"]=>
+ int(%i)
+ ["retries"]=>
+ int(%d)
+}
+NULL
diff --git a/ext/snmp/tests/snmp-object-setSecurity_error.phpt b/ext/snmp/tests/snmp-object-setSecurity_error.phpt
new file mode 100644
index 0000000..fc3a1b2
--- /dev/null
+++ b/ext/snmp/tests/snmp-object-setSecurity_error.phpt
@@ -0,0 +1,66 @@
+--TEST--
+OO API: SNMP::setSecurity (errors)
+--CREDITS--
+Boris Lytochkin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+//EXPECTF format is quickprint OFF
+snmp_set_quick_print(false);
+snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
+
+$session = new SNMP(SNMP::VERSION_3, $hostname, $user_noauth, $timeout, $retries);
+$session->setSecurity('noAuthNoPriv');
+
+#echo "Checking error handling\n";
+var_dump($session->setSecurity());
+var_dump($session->setSecurity(''));
+var_dump($session->setSecurity('bugusPriv'));
+var_dump($session->setSecurity('authNoPriv', 'TTT'));
+var_dump($session->setSecurity('authNoPriv', 'MD5', ''));
+var_dump($session->setSecurity('authNoPriv', 'MD5', 'te'));
+var_dump($session->setSecurity('authPriv', 'MD5', $auth_pass, 'BBB'));
+var_dump($session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', ''));
+var_dump($session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', 'ty'));
+var_dump($session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', 'test12345', 'context', 'dsa'));
+
+var_dump($session->close());
+
+?>
+--EXPECTF--
+
+Warning: SNMP::setSecurity() expects at least 1 parameter, 0 given in %s on line %d
+bool(false)
+
+Warning: SNMP::setSecurity(): Invalid security level '' in %s on line %d
+bool(false)
+
+Warning: SNMP::setSecurity(): Invalid security level 'bugusPriv' in %s on line %d
+bool(false)
+
+Warning: SNMP::setSecurity(): Unknown authentication protocol 'TTT' in %s on line %d
+bool(false)
+
+Warning: SNMP::setSecurity(): Error generating a key for authentication pass phrase '': Generic error (The supplied password length is too short.) in %s on line %d
+bool(false)
+
+Warning: SNMP::setSecurity(): Error generating a key for authentication pass phrase 'te': Generic error (The supplied password length is too short.) in %s on line %d
+bool(false)
+
+Warning: SNMP::setSecurity(): Unknown security protocol 'BBB' in %s on line %d
+bool(false)
+
+Warning: SNMP::setSecurity(): Error generating a key for privacy pass phrase '': Generic error (The supplied password length is too short.) in %s on line %d
+bool(false)
+
+Warning: SNMP::setSecurity(): Error generating a key for privacy pass phrase 'ty': Generic error (The supplied password length is too short.) in %s on line %d
+bool(false)
+
+Warning: SNMP::setSecurity(): Bad engine ID value 'dsa' in %s on line %d
+bool(false)
+bool(true)
diff --git a/ext/snmp/tests/snmp-object.phpt b/ext/snmp/tests/snmp-object.phpt
new file mode 100644
index 0000000..06b6492
--- /dev/null
+++ b/ext/snmp/tests/snmp-object.phpt
@@ -0,0 +1,234 @@
+--TEST--
+OO API
+--CREDITS--
+Boris Lytochkin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+//EXPECTF format is quickprint OFF
+snmp_set_enum_print(false);
+snmp_set_quick_print(false);
+snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
+snmp_set_oid_output_format(SNMP_OID_OUTPUT_FULL);
+
+echo "SNMPv1\n";
+$session = new SNMP(SNMP::VERSION_1, $hostname, $community, $timeout, $retries);
+$session->valueretrieval = SNMP_VALUE_LIBRARY;
+var_dump($session->get('.1.3.6.1.2.1.1.1.0'));
+var_dump($session->get(array('.1.3.6.1.2.1.1.1.0', '.1.3.6.1.2.1.1.3.0')));
+var_dump($session->getnext('.1.3.6.1.2.1.1.1.0'));
+var_dump($session->close());
+
+echo "SNMPv2\n";
+$session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries);
+var_dump($session->get('.1.3.6.1.2.1.1.1.0'));
+var_dump($session->getnext('.1.3.6.1.2.1.1.1.0'));
+var_dump($session->close());
+
+echo "GET with preserving original OID names\n";
+$session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries);
+$orig = array('.1.3.6.1.2.1.1.1.0', '.1.3.6.1.2.1.1.5.0');
+$result = $session->get($orig, TRUE);
+foreach($orig as $oid){
+ var_dump($result[$oid]);
+}
+var_dump($session->close());
+
+echo "WALK multiple on single OID\n";
+$session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries);
+$z = $session->walk('.1.3.6.1.2.1.1');
+var_dump(gettype($z));
+var_dump(count($z));
+var_dump(key($z));
+var_dump(array_shift($z));
+var_dump($session->close());
+
+echo "WALK multiple on single OID, max_repetitions set to 30\n";
+$session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries);
+$z = $session->walk('.1.3.6.1.2.1.1', FALSE, 30);
+var_dump(gettype($z));
+var_dump(count($z));
+var_dump(key($z));
+var_dump(array_shift($z));
+var_dump($session->close());
+
+echo "WALK multiple on single OID, max_repetitions set to 30, non_repeaters set to 0\n";
+$session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries);
+$z = $session->walk('.1.3.6.1.2.1.1', FALSE, 30, 0);
+var_dump(gettype($z));
+var_dump(count($z));
+var_dump(key($z));
+var_dump(array_shift($z));
+var_dump($session->close());
+
+echo "WALK multiple on single OID, max_oids set to 30\n";
+$session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries);
+$session->max_oids = 30;
+$z = $session->walk('.1.3.6.1.2.1.1');
+var_dump(gettype($z));
+var_dump(count($z));
+var_dump(key($z));
+var_dump(array_shift($z));
+var_dump($session->close());
+
+echo "WALK multiple on single OID with OID suffix as keys\n";
+$session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries);
+$z = $session->walk('.1.3.6.1.2.1.1', TRUE);
+var_dump(gettype($z));
+var_dump(count($z));
+var_dump(key($z));
+var_dump(array_shift($z));
+var_dump($session->close());
+
+echo "SNMPv3 (default security settings)\n";
+$session = new SNMP(SNMP::VERSION_3, $hostname, $user_noauth, $timeout, $retries);
+#$session->setSecurity($user_noauth, 'noAuthNoPriv', '', '', '', '', '', '');
+var_dump($session->get('.1.3.6.1.2.1.1.1.0'));
+var_dump($session->getnext('.1.3.6.1.2.1.1.1.0'));
+var_dump($session->close());
+
+echo "SNMPv3 (noAuthNoPriv)\n";
+$session = new SNMP(SNMP::VERSION_3, $hostname, $user_noauth, $timeout, $retries);
+$session->setSecurity('noAuthNoPriv');
+var_dump($session->get('.1.3.6.1.2.1.1.1.0'));
+var_dump($session->getnext('.1.3.6.1.2.1.1.1.0'));
+var_dump($session->close());
+
+echo "SNMPv3 (authPriv)\n";
+$session = new SNMP(SNMP::VERSION_3, $hostname, $rwuser, $timeout, $retries);
+$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->getnext('.1.3.6.1.2.1.1.1.0'));
+var_dump($session->walk('.1.3.6.1.2.1.1.1.0'));
+var_dump($session->close());
+
+echo "SET single OID\n";
+$session = new SNMP(SNMP::VERSION_3, $hostname, $rwuser, $timeout, $retries);
+$session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', $priv_pass);
+$oid1 = 'SNMPv2-MIB::sysContact.0';
+$oldvalue1 = $session->get($oid1);
+$newvalue1 = $oldvalue1 . '0';
+
+$z = $session->set($oid1, 's', $newvalue1);
+var_dump($z);
+var_dump(($session->get($oid1) === $newvalue1));
+$z = $session->set($oid1, 's', $oldvalue1);
+var_dump($z);
+var_dump(($session->get($oid1) === $oldvalue1));
+var_dump($session->close());
+
+echo "Multiple OID with max_oids = 1\n";
+$oid2 = 'SNMPv2-MIB::sysLocation.0';
+$session = new SNMP(SNMP::VERSION_3, $hostname, $rwuser, $timeout, $retries);
+$session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', $priv_pass);
+$session->max_oids = 1;
+$oldvalue2 = $session->get($oid2);
+$newvalue2 = $oldvalue2 . '0';
+$z = $session->set(array($oid1, $oid2), array('s','s'), array($newvalue1, $newvalue2));
+var_dump($z);
+var_dump(($session->get($oid1) === $newvalue1));
+var_dump(($session->get($oid2) === $newvalue2));
+$z = $session->set(array($oid1, $oid2), array('s','s'), array($oldvalue1, $oldvalue2));
+var_dump($z);
+var_dump(($session->get($oid1) === $oldvalue1));
+var_dump(($session->get($oid2) === $oldvalue2));
+var_dump($session->close());
+
+echo "SNMPv3, setting contextEngineID (authPriv)\n";
+$session = new SNMP(SNMP::VERSION_3, $hostname, $rwuser, $timeout, $retries);
+$session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES', $priv_pass, '', 'aeeeff');
+var_dump($session->get('.1.3.6.1.2.1.1.1.0'));
+var_dump($session->close());
+
+?>
+--EXPECTF--
+SNMPv1
+string(%d) "%S"
+array(2) {
+ ["%s"]=>
+ string(%d) "%S"
+ ["%s"]=>
+ string(%d) "%S"
+}
+string(%d) "%S"
+bool(true)
+SNMPv2
+string(%d) "%S"
+string(%d) "%S"
+bool(true)
+GET with preserving original OID names
+string(%d) "%s"
+string(%d) "%s"
+bool(true)
+WALK multiple on single OID
+string(5) "array"
+int(%d)
+string(%d) "%S"
+string(%d) "%S"
+bool(true)
+WALK multiple on single OID, max_repetitions set to 30
+string(5) "array"
+int(%d)
+string(%d) "%S"
+string(%d) "%S"
+bool(true)
+WALK multiple on single OID, max_repetitions set to 30, non_repeaters set to 0
+string(5) "array"
+int(%d)
+string(%d) "%S"
+string(%d) "%S"
+bool(true)
+WALK multiple on single OID, max_oids set to 30
+string(5) "array"
+int(%d)
+string(%d) "%S"
+string(%d) "%S"
+bool(true)
+WALK multiple on single OID with OID suffix as keys
+string(5) "array"
+int(%d)
+string(3) "1.0"
+string(%d) "%s"
+bool(true)
+SNMPv3 (default security settings)
+string(%d) "%S"
+string(%d) "%S"
+bool(true)
+SNMPv3 (noAuthNoPriv)
+string(%d) "%S"
+string(%d) "%S"
+bool(true)
+SNMPv3 (authPriv)
+string(%d) "%S"
+string(%d) "%S"
+array(1) {
+ [%s]=>
+ string(%d) "%S"
+}
+bool(true)
+SET single OID
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+Multiple OID with max_oids = 1
+
+Warning: SNMP::set(): Can not fit all OIDs for SET query into one packet, using multiple queries in %s on line %d
+bool(true)
+bool(true)
+bool(true)
+
+Warning: SNMP::set(): Can not fit all OIDs for SET query into one packet, using multiple queries in %s on line %d
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+SNMPv3, setting contextEngineID (authPriv)
+string(%d) "%S"
+bool(true)
diff --git a/ext/snmp/tests/snmp2_get.phpt b/ext/snmp/tests/snmp2_get.phpt
new file mode 100644
index 0000000..b6b50ce
--- /dev/null
+++ b/ext/snmp/tests/snmp2_get.phpt
@@ -0,0 +1,104 @@
+--TEST--
+Function snmp2_get
+--CREDITS--
+Olivier Doucet & Boris Lytochkin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+//EXPECTF format is quickprint OFF
+snmp_set_quick_print(false);
+snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
+
+echo "Checking error handling\n";
+var_dump(snmp2_get($hostname, $community, '.1.3.6.1.2.1.1.1.0', ''));
+var_dump(snmp2_get($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout, ''));
+echo "Empty OID array\n";
+var_dump(snmp2_get($hostname, $community, array(), $timeout, $retries));
+
+echo "Checking working\n";
+echo "Single OID\n";
+var_dump(snmp2_get($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout, $retries));
+echo "Single OID in array\n";
+var_dump(snmp2_get($hostname, $community, array('.1.3.6.1.2.1.1.1.0'), $timeout, $retries));
+echo "Multiple OID\n";
+var_dump(snmp2_get($hostname, $community, array('.1.3.6.1.2.1.1.1.0', '.1.3.6.1.2.1.1.3.0'), $timeout, $retries));
+
+echo "More error handling\n";
+echo "Single OID\n";
+var_dump(snmp2_get($hostname, $community, '.1.3.6.1.2..1.1.1.0', $timeout, $retries));
+echo "Single OID in array\n";
+var_dump(snmp2_get($hostname, $community, array('.1.3.6.1.2.1...1.1.0'), $timeout, $retries));
+echo "Multiple OID\n";
+var_dump(snmp2_get($hostname, $community, array('.1.3.6.1.2.1...1.1.0', '.1.3.6.1.2.1.1.3.0'), $timeout, $retries));
+
+echo "noSuchName checks\n";
+echo "Single OID\n";
+var_dump(snmp2_get($hostname, $community, '.1.3.6.1.2.1.1.1.110', $timeout, $retries));
+echo "Single OID in array\n";
+var_dump(snmp2_get($hostname, $community, array('.1.3.6.1.2.1.1.1.110'), $timeout, $retries));
+echo "Multiple OID\n";
+var_dump(snmp2_get($hostname, $community, array('.1.3.6.1.2.1.1.1.0', '.1.3.6.1.2.1.1.3.220'), $timeout, $retries));
+
+
+?>
+--EXPECTF--
+Checking error handling
+
+Warning: snmp2_get() expects parameter 4 to be long,%s given in %s on line %d
+bool(false)
+
+Warning: snmp2_get() expects parameter 5 to be long,%s given in %s on line %d
+bool(false)
+Empty OID array
+
+Warning: snmp2_get(): Got empty OID array in %s on line %d
+bool(false)
+Checking working
+Single OID
+%unicode|string%(%d) "%s"
+Single OID in array
+array(1) {
+ ["%s"]=>
+ %unicode|string%(%d) "%s"
+}
+Multiple OID
+array(2) {
+ ["%s"]=>
+ %unicode|string%(%d) "%s"
+ ["%s"]=>
+ %unicode|string%(%d) "%d"
+}
+More error handling
+Single OID
+
+Warning: snmp2_get(): Invalid object identifier: .1.3.6.1.2..1.1.1.0 in %s on line %d
+bool(false)
+Single OID in array
+
+Warning: snmp2_get(): Invalid object identifier: .1.3.6.1.2.1...1.1.0 in %s on line %d
+bool(false)
+Multiple OID
+
+Warning: snmp2_get(): Invalid object identifier: .1.3.6.1.2.1...1.1.0 in %s on line %d
+bool(false)
+noSuchName checks
+Single OID
+
+Warning: snmp2_get(): Error in packet at 'SNMPv2-MIB::sysDescr.110': No Such Instance currently exists at this OID in %s on line %d
+bool(false)
+Single OID in array
+
+Warning: snmp2_get(): Error in packet at 'SNMPv2-MIB::sysDescr.110': No Such Instance currently exists at this OID in %s on line %d
+bool(false)
+Multiple OID
+
+Warning: snmp2_get(): Error in packet at 'SNMPv2-MIB::sysUpTime.220': No Such Instance currently exists at this OID in %s on line %d
+array(1) {
+ ["%s"]=>
+ %unicode|string%(%d) "%s"
+}
diff --git a/ext/snmp/tests/snmp2_getnext.phpt b/ext/snmp/tests/snmp2_getnext.phpt
new file mode 100644
index 0000000..5c5abf4
--- /dev/null
+++ b/ext/snmp/tests/snmp2_getnext.phpt
@@ -0,0 +1,39 @@
+--TEST--
+Function snmp2_getnext
+--CREDITS--
+Olivier Doucet & Boris Lytochkin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+//EXPECTF format is quickprint OFF
+snmp_set_quick_print(false);
+snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
+
+echo "Single OID\n";
+var_dump(snmp2_getnext($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout, $retries));
+echo "Single OID in array\n";
+var_dump(snmp2_getnext($hostname, $community, array('.1.3.6.1.2.1.1.1.0'), $timeout, $retries));
+echo "Multiple OID\n";
+var_dump(snmp2_getnext($hostname, $community, array('.1.3.6.1.2.1.1.1.0', '.1.3.6.1.2.1.1.6.0'), $timeout, $retries));
+
+?>
+--EXPECTF--
+Single OID
+%unicode|string%(%d) "%s"
+Single OID in array
+array(1) {
+ ["%s"]=>
+ %unicode|string%(%d) "%s"
+}
+Multiple OID
+array(2) {
+ ["%s"]=>
+ %unicode|string%(%d) "%s"
+ ["%s"]=>
+ %unicode|string%(%d) "%d"
+}
diff --git a/ext/snmp/tests/snmp2_real_walk.phpt b/ext/snmp/tests/snmp2_real_walk.phpt
new file mode 100644
index 0000000..afaabd4
--- /dev/null
+++ b/ext/snmp/tests/snmp2_real_walk.phpt
@@ -0,0 +1,86 @@
+--TEST--
+Function snmp2_real_walk
+--CREDITS--
+Olivier Doucet Olivier Doucet Boris Lytochkin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+//EXPECTF format is quickprint OFF
+snmp_set_quick_print(false);
+snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
+
+echo "Checking error handling\n";
+var_dump(snmp2_real_walk($hostname, $community, '.1.3.6.1.2.1.1', ''));
+var_dump(snmp2_real_walk($hostname, $community, '.1.3.6.1.2.1.1', $timeout, ''));
+
+echo "Checking working\n";
+echo "Single OID\n";
+$return = snmp2_real_walk($hostname, $community, '.1.3.6.1.2.1.1', $timeout, $retries);
+var_dump(gettype($return));
+var_dump(sizeof($return));
+var_dump(key($return));
+var_dump(array_shift($return));
+
+echo "Single OID in array\n";
+$return = snmp2_real_walk($hostname, $community, array('.1.3.6.1.2.1.1'), $timeout, $retries);
+var_dump(gettype($return));
+var_dump(sizeof($return));
+var_dump(key($return));
+var_dump(array_shift($return));
+
+echo "More error handling\n";
+echo "Multiple correct OID\n";
+$return = snmp2_real_walk($hostname, $community, array('.1.3.6.1.2.1.1', '.1.3.6'), $timeout, $retries);
+var_dump($return);
+
+echo "Multiple OID with wrong OID\n";
+$return = snmp2_real_walk($hostname, $community, array('.1.3.6.1.2.1.1', '.1.3.6...1'), $timeout, $retries);
+var_dump($return);
+$return = snmp2_real_walk($hostname, $community, array('.1.3.6...1', '.1.3.6.1.2.1.1'), $timeout, $retries);
+var_dump($return);
+
+echo "Single nonexisting OID\n";
+$return = snmp2_real_walk($hostname, $community, array('.1.3.6.99999.0.99999.111'), $timeout, $retries);
+var_dump($return);
+
+?>
+--EXPECTF--
+Checking error handling
+
+Warning: snmp2_real_walk() expects parameter 4 to be long, %s given in %s on line %d
+bool(false)
+
+Warning: snmp2_real_walk() expects parameter 5 to be long, %s given in %s on line %d
+bool(false)
+Checking working
+Single OID
+%unicode|string%(5) "array"
+int(%d)
+string(%d) "%s"
+string(%d) "%s"
+Single OID in array
+%unicode|string%(5) "array"
+int(%d)
+string(%d) "%s"
+string(%d) "%s"
+More error handling
+Multiple correct OID
+
+Warning: snmp2_real_walk(): Multi OID walks are not supported! in %s on line %d
+bool(false)
+Multiple OID with wrong OID
+
+Warning: snmp2_real_walk(): Multi OID walks are not supported! in %s on line %d
+bool(false)
+
+Warning: snmp2_real_walk(): Multi OID walks are not supported! in %s on line %d
+bool(false)
+Single nonexisting OID
+
+Warning: snmp2_real_walk(): Error in packet at '%s': No more variables left in this MIB View (It is past the end of the MIB tree) in %s on line %d
+bool(false)
diff --git a/ext/snmp/tests/snmp2_set-nomib.phpt b/ext/snmp/tests/snmp2_set-nomib.phpt
new file mode 100644
index 0000000..af0baa3
--- /dev/null
+++ b/ext/snmp/tests/snmp2_set-nomib.phpt
@@ -0,0 +1,59 @@
+--TEST--
+Function snmp2_set (without MIBs loading)
+--CREDITS--
+Boris Lytockin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--ENV--
+return <<<END
+MIBS=
+END;
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+//EXPECTF format is quickprint OFF
+snmp_set_quick_print(false);
+snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
+
+echo "Check error handing\n";
+echo "Nonexisting OID\n";
+$z = snmp2_set($hostname, $communityWrite, '.1.3.6.777.888.999.444.0', 's', 'bbb', $timeout, $retries);
+var_dump($z);
+
+echo "Bogus OID\n";
+$z = snmp2_set($hostname, $communityWrite, '.1.3.6...777.888.999.444.0', 's', 'bbb', $timeout, $retries);
+var_dump($z);
+
+echo "Checking working\n";
+$oid1 = '.1.3.6.1.2.1.1.4.0';
+$oldvalue1 = snmpget($hostname, $communityWrite, $oid1, $timeout, $retries);
+$newvalue1 = $oldvalue1 . '0';
+
+echo "Single OID\n";
+$z = snmp2_set($hostname, $communityWrite, $oid1, 's', $newvalue1, $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $newvalue1));
+$z = snmp2_set($hostname, $communityWrite, $oid1, 's', $oldvalue1, $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+
+?>
+--EXPECTF--
+Check error handing
+Nonexisting OID
+
+Warning: snmp2_set(): Error in packet at '%s': notWritable (That object does not support modification) in %s on line %d
+bool(false)
+Bogus OID
+
+Warning: snmp2_set(): Invalid object identifier: %s in %s on line %d
+bool(false)
+Checking working
+Single OID
+bool(true)
+bool(true)
+bool(true)
+bool(true)
diff --git a/ext/snmp/tests/snmp2_set.phpt b/ext/snmp/tests/snmp2_set.phpt
new file mode 100644
index 0000000..b833b9b
--- /dev/null
+++ b/ext/snmp/tests/snmp2_set.phpt
@@ -0,0 +1,248 @@
+--TEST--
+Function snmp2_set
+--CREDITS--
+Boris Lytochkin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+//EXPECTF format is quickprint OFF
+snmp_set_quick_print(false);
+snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
+
+echo "Check error handing\n";
+echo "4args (5 needed)\n";
+$z = snmp2_set($hostname, $communityWrite, 'SNMPv2-MIB::sysLocation.0');
+var_dump($z);
+
+echo "No type & no value (timeout & retries instead)\n";
+$z = snmp2_set($hostname, $communityWrite, 'SNMPv2-MIB::sysLocation.0', $timeout, $retries);
+var_dump($z);
+
+echo "No value (timeout instead), retries instead of timeout\n";
+$z = snmp2_set($hostname, $communityWrite, 'SNMPv2-MIB::sysLocation.0', 'q', $timeout, $retries);
+var_dump($z);
+
+echo "Bogus OID\n";
+$z = snmp2_set($hostname, $communityWrite, '.1.3.6.777.888.999.444.0', 's', 'bbb', $timeout, $retries);
+var_dump($z);
+
+echo "Checking working\n";
+$oid1 = 'SNMPv2-MIB::sysContact.0';
+$oldvalue1 = snmpget($hostname, $communityWrite, $oid1, $timeout, $retries);
+$newvalue1 = $oldvalue1 . '0';
+$oid2 = 'SNMPv2-MIB::sysLocation.0';
+$oldvalue2 = snmpget($hostname, $communityWrite, $oid1, $timeout, $retries);
+$newvalue2 = $oldvalue2 . '0';
+
+echo "Single OID\n";
+$z = snmp2_set($hostname, $communityWrite, $oid1, 's', $newvalue1, $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $newvalue1));
+$z = snmp2_set($hostname, $communityWrite, $oid1, 's', $oldvalue1, $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+
+echo "Multiple OID\n";
+$z = snmp2_set($hostname, $communityWrite, array($oid1, $oid2), array('s','s'), array($newvalue1, $newvalue2), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $newvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $newvalue2));
+$z = snmp2_set($hostname, $communityWrite, array($oid1, $oid2), array('s','s'), array($oldvalue1, $oldvalue2), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
+
+echo "Multiple OID, single type & value\n";
+$z = snmp2_set($hostname, $communityWrite, array($oid1, $oid2), 's', $newvalue1, $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $newvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $newvalue1));
+$z = snmp2_set($hostname, $communityWrite, array($oid1, $oid2), array('s','s'), array($oldvalue1, $oldvalue2), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
+
+echo "Multiple OID, single type, multiple value\n";
+$z = snmp2_set($hostname, $communityWrite, array($oid1, $oid2), 's', array($newvalue1, $newvalue2), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $newvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $newvalue2));
+$z = snmp2_set($hostname, $communityWrite, array($oid1, $oid2), array('s','s'), array($oldvalue1, $oldvalue2), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
+
+
+echo "More error handing\n";
+echo "Single OID, single type in array, single value\n";
+$z = snmp2_set($hostname, $communityWrite, $oid1, array('s'), $newvalue1, $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
+
+echo "Single OID, single type, single value in array\n";
+$z = snmp2_set($hostname, $communityWrite, $oid1, 's', array($newvalue1), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
+
+echo "Multiple OID, 1st wrong type\n";
+$z = snmp2_set($hostname, $communityWrite, array($oid1, $oid2), array('sw','s'), array($newvalue1, $newvalue2), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
+
+echo "Multiple OID, 2nd wrong type\n";
+$z = snmp2_set($hostname, $communityWrite, array($oid1, $oid2), array('s','sb'), array($newvalue1, $newvalue2), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
+
+echo "Multiple OID, single type in array, multiple value\n";
+$z = snmp2_set($hostname, $communityWrite, array($oid1, $oid2), array('s'), array($newvalue1, $newvalue2), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
+
+echo "Multiple OID & type, singe value in array\n";
+$z = snmp2_set($hostname, $communityWrite, array($oid1, $oid2), array('s', 's'), array($newvalue1), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
+
+echo "Multiple OID, 1st bogus, single type, multiple value\n";
+$z = snmp2_set($hostname, $communityWrite, array($oid1 . '44.55.66.77', $oid2), 's', array($newvalue1, $newvalue2), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
+
+echo "Multiple OID, 2nd bogus, single type, multiple value\n";
+$z = snmp2_set($hostname, $communityWrite, array($oid1, $oid2 . '44.55.66.77'), 's', array($newvalue1, $newvalue2), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
+
+echo "Multiple OID, single multiple type (1st bogus), multiple value\n";
+$z = snmp2_set($hostname, $communityWrite, array($oid1, $oid2), array('q', 's'), array($newvalue1, $newvalue2), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
+
+echo "Multiple OID, single multiple type (2nd bogus), multiple value\n";
+$z = snmp2_set($hostname, $communityWrite, array($oid1, $oid2), array('s', 'w'), array($newvalue1, $newvalue2), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
+
+?>
+--EXPECTF--
+Check error handing
+4args (5 needed)
+
+Warning: snmp2_set() expects at least 5 parameters, 3 given in %s on line %d
+bool(false)
+No type & no value (timeout & retries instead)
+
+Warning: snmp2_set(): Bogus type '-1', should be single char, got 2 in %s on line %d
+bool(false)
+No value (timeout instead), retries instead of timeout
+
+Warning: snmp2_set(): Could not add variable: OID='%s' type='q' value='%i': Bad variable type ("q") in %s on line %d
+bool(false)
+Bogus OID
+
+Warning: snmp2_set(): Error in packet at '%s': notWritable (That object does not support modification) in %s on line %d
+bool(false)
+Checking working
+Single OID
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+Multiple OID
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+Multiple OID, single type & value
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+Multiple OID, single type, multiple value
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+More error handing
+Single OID, single type in array, single value
+
+Warning: snmp2_set(): Single objid and multiple type or values are not supported in %s on line %s
+bool(false)
+bool(true)
+bool(true)
+Single OID, single type, single value in array
+
+Warning: snmp2_set(): Single objid and multiple type or values are not supported in %s on line %s
+bool(false)
+bool(true)
+bool(true)
+Multiple OID, 1st wrong type
+
+Warning: snmp2_set(): '%s': bogus type 'sw', should be single char, got 2 in %s on line %s
+bool(false)
+bool(true)
+bool(true)
+Multiple OID, 2nd wrong type
+
+Warning: snmp2_set(): '%s': bogus type 'sb', should be single char, got 2 in %s on line %s
+bool(false)
+bool(true)
+bool(true)
+Multiple OID, single type in array, multiple value
+
+Warning: snmp2_set(): '%s': no type set in %s on line %d
+bool(false)
+bool(true)
+bool(true)
+Multiple OID & type, singe value in array
+
+Warning: snmp2_set(): '%s': no value set in %s on line %d
+bool(false)
+bool(true)
+bool(true)
+Multiple OID, 1st bogus, single type, multiple value
+
+Warning: snmp2_set(): Error in packet at '%s': %rnoCreation|notWritable%r (%s) in %s on line %d
+bool(false)
+bool(true)
+bool(true)
+Multiple OID, 2nd bogus, single type, multiple value
+
+Warning: snmp2_set(): Error in packet at '%s': %rnoCreation|notWritable%r (%s) in %s on line %d
+bool(false)
+bool(true)
+bool(true)
+Multiple OID, single multiple type (1st bogus), multiple value
+
+Warning: snmp2_set(): Could not add variable: OID='%s' type='q' value='%s': Bad variable type ("q") in %s on line %d
+bool(false)
+bool(true)
+bool(true)
+Multiple OID, single multiple type (2nd bogus), multiple value
+
+Warning: snmp2_set(): Could not add variable: OID='%s' type='w' value='%s': Bad variable type ("w") in %s on line %d
+bool(false)
+bool(true)
+bool(true)
diff --git a/ext/snmp/tests/snmp2_walk.phpt b/ext/snmp/tests/snmp2_walk.phpt
new file mode 100644
index 0000000..3981676
--- /dev/null
+++ b/ext/snmp/tests/snmp2_walk.phpt
@@ -0,0 +1,99 @@
+--TEST--
+Function snmp2_walk
+--CREDITS--
+Olivier Doucet Olivier Doucet Boris Lytochkin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+//EXPECTF format is quickprint OFF
+snmp_set_quick_print(false);
+snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
+
+echo "Checking error handling\n";
+var_dump(snmp2_walk($hostname, $community, '.1.3.6.1.2.1.1', ''));
+var_dump(snmp2_walk($hostname, $community, '.1.3.6.1.2.1.1', $timeout, ''));
+
+echo "Checking working\n";
+echo "Single OID\n";
+$return = snmp2_walk($hostname, $community, '.1.3.6.1.2.1.1', $timeout, $retries);
+
+var_dump(gettype($return));
+var_dump(sizeof($return));
+var_dump(gettype($return[0]));
+var_dump(gettype($return[1]));
+
+echo "Single OID in array\n";
+$return = snmp2_walk($hostname, $community, array('.1.3.6.1.2.1.1'), $timeout, $retries);
+var_dump(gettype($return));
+var_dump(gettype($return[0]));
+
+echo "Default OID\n";
+$return = snmpwalk($hostname, $community, '', $timeout, $retries);
+var_dump(gettype($return));
+var_dump(gettype($return[0]));
+
+echo "More error handling\n";
+echo "Single incorrect OID\n";
+$return = snmpwalk($hostname, $community, '.1.3.6...1', $timeout, $retries);
+var_dump($return);
+
+echo "Multiple correct OID\n";
+$return = snmp2_walk($hostname, $community, array('.1.3.6.1.2.1.1', '.1.3.6'), $timeout, $retries);
+var_dump($return);
+
+echo "Multiple OID with wrong OID\n";
+$return = snmp2_walk($hostname, $community, array('.1.3.6.1.2.1.1', '.1.3.6...1'), $timeout, $retries);
+var_dump($return);
+$return = snmp2_walk($hostname, $community, array('.1.3.6...1', '.1.3.6.1.2.1.1'), $timeout, $retries);
+var_dump($return);
+
+echo "Single nonexisting OID\n";
+$return = snmp2_walk($hostname, $community, array('.1.3.6.99999.0.99999.111'), $timeout, $retries);
+var_dump($return);
+
+?>
+--EXPECTF--
+Checking error handling
+
+Warning: snmp2_walk() expects parameter 4 to be long, %s given in %s on line %d
+bool(false)
+
+Warning: snmp2_walk() expects parameter 5 to be long, %s given in %s on line %d
+bool(false)
+Checking working
+Single OID
+%unicode|string%(5) "array"
+int(%d)
+%unicode|string%(6) "string"
+%unicode|string%(6) "string"
+Single OID in array
+%unicode|string%(5) "array"
+%unicode|string%(6) "string"
+Default OID
+%unicode|string%(5) "array"
+%unicode|string%(6) "string"
+More error handling
+Single incorrect OID
+
+Warning: snmpwalk(): Invalid object identifier: %s in %s on line %d
+bool(false)
+Multiple correct OID
+
+Warning: snmp2_walk(): Multi OID walks are not supported! in %s on line %d
+bool(false)
+Multiple OID with wrong OID
+
+Warning: snmp2_walk(): Multi OID walks are not supported! in %s on line %d
+bool(false)
+
+Warning: snmp2_walk(): Multi OID walks are not supported! in %s on line %d
+bool(false)
+Single nonexisting OID
+
+Warning: snmp2_walk(): Error in packet at '%s': No more variables left in this MIB View (It is past the end of the MIB tree) in %s on line %d
+bool(false)
diff --git a/ext/snmp/tests/snmp3-error.phpt b/ext/snmp/tests/snmp3-error.phpt
new file mode 100644
index 0000000..3c0c499
--- /dev/null
+++ b/ext/snmp/tests/snmp3-error.phpt
@@ -0,0 +1,76 @@
+--TEST--
+SNMPv3 Support (errors)
+--CREDITS--
+Boris Lytochkin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+echo "Checking error handling\n";
+
+//int snmp3_get(string host, string sec_name, string sec_level, string auth_protocol,
+// string auth_passphrase, string priv_protocol, string priv_passphrase,
+// string object_id [, int timeout [, int retries]]);
+
+var_dump(snmp3_get($hostname, $community, '', '', '', '', ''));
+var_dump(snmp3_get($hostname, $community, '', '', '', '', '', '.1.3.6.1.2.1.1.1.0'));
+var_dump(snmp3_get($hostname, $community, 'bugusPriv', '', '', '', '', '.1.3.6.1.2.1.1.1.0'));
+var_dump(snmp3_get($hostname, $community, 'authNoPriv', 'TTT', '', '', '', '.1.3.6.1.2.1.1.1.0'));
+var_dump(snmp3_get($hostname, $community, 'authNoPriv', 'MD5', '', '', '', '.1.3.6.1.2.1.1.1.0'));
+var_dump(snmp3_get($hostname, $community, 'authNoPriv', 'MD5', 'te', '', '', '.1.3.6.1.2.1.1.1.0'));
+var_dump(snmp3_get($hostname, $community, 'authPriv', 'MD5', $auth_pass, 'BBB', '', '.1.3.6.1.2.1.1.1.0'));
+var_dump(snmp3_get($hostname, $community, 'authPriv', 'MD5', $auth_pass, 'AES', '', '.1.3.6.1.2.1.1.1.0'));
+var_dump(snmp3_get($hostname, $community, 'authPriv', 'MD5', $auth_pass, 'AES', 'ty', '.1.3.6.1.2.1.1.1.0'));
+var_dump(snmp3_get($hostname, 'somebogususer', 'authPriv', 'MD5', $auth_pass, 'AES', $priv_pass, '.1.3.6.1.2.1.1.1.0', $timeout, $retries));
+
+var_dump(snmp3_set($hostname, $community, 'authPriv', 'MD5', $auth_pass, 'AES', $priv_pass, '', 's'));
+
+var_dump(snmp3_set($hostname, $rwuser, 'authPriv', 'MD5', $auth_pass, 'AES', $priv_pass, '.1.3.6.777...7.5.3', 's', 'ttt', $timeout, $retries));
+var_dump(snmp3_set($hostname, $rwuser, 'authPriv', 'MD5', $auth_pass, 'AES', $priv_pass, '.1.3.6.777.7.5.3', array('s'), 'yyy', $timeout, $retries));
+
+?>
+--EXPECTF--
+Checking error handling
+
+Warning: snmp3_get() expects at least 8 parameters, 7 given in %s on line %d
+bool(false)
+
+Warning: snmp3_get(): Invalid security level '' in %s on line %d
+bool(false)
+
+Warning: snmp3_get(): Invalid security level 'bugusPriv' in %s on line %d
+bool(false)
+
+Warning: snmp3_get(): Unknown authentication protocol 'TTT' in %s on line %d
+bool(false)
+
+Warning: snmp3_get(): Error generating a key for authentication pass phrase '': Generic error (The supplied password length is too short.) in %s on line %d
+bool(false)
+
+Warning: snmp3_get(): Error generating a key for authentication pass phrase 'te': Generic error (The supplied password length is too short.) in %s on line %d
+bool(false)
+
+Warning: snmp3_get(): Unknown security protocol 'BBB' in %s on line %d
+bool(false)
+
+Warning: snmp3_get(): Error generating a key for privacy pass phrase '': Generic error (The supplied password length is too short.) in %s on line %d
+bool(false)
+
+Warning: snmp3_get(): Error generating a key for privacy pass phrase 'ty': Generic error (The supplied password length is too short.) in %s on line %d
+bool(false)
+
+Warning: snmp3_get(): Fatal error: Unknown user name in %s on line %d
+bool(false)
+
+Warning: snmp3_set() expects at least 10 parameters, 9 given in %s on line %d
+bool(false)
+
+Warning: snmp3_set(): Invalid object identifier: .1.3.6.777...7.5.3 in %s on line %d
+bool(false)
+
+Warning: snmp3_set(): Single objid and multiple type or values are not supported in %s on line %d
+bool(false)
diff --git a/ext/snmp/tests/snmp3.phpt b/ext/snmp/tests/snmp3.phpt
new file mode 100644
index 0000000..49d205f
--- /dev/null
+++ b/ext/snmp/tests/snmp3.phpt
@@ -0,0 +1,127 @@
+--TEST--
+SNMPv3 Support
+--CREDITS--
+Boris Lytochkin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+//int snmp3_get(string host, string sec_name, string sec_level, string auth_protocol,
+// string auth_passphrase, string priv_protocol, string priv_passphrase,
+// string object_id [, int timeout [, int retries]]);
+
+echo "Working version\n";
+snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
+echo "GET single: noAuthNoPriv\n";
+var_dump(snmp3_get($hostname, $user_noauth, 'noAuthNoPriv', '', '', '', '', '.1.3.6.1.2.1.1.1.0', $timeout, $retries));
+
+foreach(array('MD5', 'SHA') as $signalg) {
+ echo "GET single: $signalg\n";
+ var_dump(snmp3_get($hostname, $user_auth_prefix . $signalg, 'authNoPriv', $signalg, $auth_pass, '', '', '.1.3.6.1.2.1.1.1.0', $timeout, $retries));
+}
+
+foreach(array('AES', 'DES', 'AES128') as $chipher) {
+ echo "GET single: MD5/$chipher\n";
+ var_dump(snmp3_get($hostname, $user_auth_prefix . 'MD5' . $chipher, 'authPriv', 'MD5', $auth_pass, $chipher, $priv_pass, '.1.3.6.1.2.1.1.1.0', $timeout, $retries));
+}
+$username = $user_auth_prefix . 'MD5';
+echo "GET multiple\n";
+var_dump(snmp3_get($hostname, $username, 'authNoPriv', 'MD5', $auth_pass, '', '', array('.1.3.6.1.2.1.1.1.0', '.1.3.6.1.2.1.1.3.0'), $timeout, $retries));
+echo "GETNEXT single\n";
+var_dump(snmp3_getnext($hostname, $username, 'authNoPriv', 'MD5', $auth_pass, '', '', '.1.3.6.1.2.1.1.1.0', $timeout, $retries));
+
+echo "WALK single on single OID\n";
+$z = snmp3_walk($hostname, $username, 'authNoPriv', 'MD5', $auth_pass, '', '', '.1.3.6.1.2.1.1.1.0', $timeout, $retries);
+var_dump(gettype($z));
+var_dump(count($z));
+var_dump($z);
+
+echo "REALWALK single on single OID\n";
+$z = snmp3_real_walk($hostname, $username, 'authNoPriv', 'MD5', $auth_pass, '', '', '.1.3.6.1.2.1.1.1.0', $timeout, $retries);
+var_dump(gettype($z));
+var_dump(count($z));
+var_dump($z);
+
+echo "WALK multiple on single OID\n";
+$z = snmp3_walk($hostname, $username, 'authNoPriv', 'MD5', $auth_pass, '', '', '.1.3.6.1.2.1.1', $timeout, $retries);
+var_dump(gettype($z));
+var_dump(count($z));
+var_dump(key($z));
+var_dump(array_shift($z));
+
+echo "REALWALK multiple on single OID\n";
+$z = snmp3_real_walk($hostname, $username, 'authNoPriv', 'MD5', $auth_pass, 'AES', '', '.1.3.6.1.2.1.1', $timeout, $retries);
+var_dump(gettype($z));
+var_dump(count($z));
+var_dump(key($z));
+var_dump(array_shift($z));
+
+echo "SET single OID\n";
+$oid1 = 'SNMPv2-MIB::sysContact.0';
+$oldvalue1 = snmp3_get($hostname, $rwuser, 'authPriv', 'MD5', $auth_pass, 'AES', $priv_pass, $oid1, $timeout, $retries);
+$newvalue1 = $oldvalue1 . '0';
+
+$z = snmp3_set($hostname, $rwuser, 'authPriv', 'MD5', $auth_pass, 'AES', $priv_pass, $oid1, 's', $newvalue1, $timeout, $retries);
+var_dump($z);
+var_dump((snmp3_get($hostname, $rwuser, 'authPriv', 'MD5', $auth_pass, 'AES', $priv_pass, $oid1, $timeout, $retries) === $newvalue1));
+$z = snmp3_set($hostname, $rwuser, 'authPriv', 'MD5', $auth_pass, 'AES', $priv_pass, $oid1, 's', $oldvalue1, $timeout, $retries);
+var_dump($z);
+var_dump((snmp3_get($hostname, $rwuser, 'authPriv', 'MD5', $auth_pass, 'AES', $priv_pass, $oid1, $timeout, $retries) === $oldvalue1));
+
+?>
+--EXPECTF--
+Working version
+GET single: noAuthNoPriv
+%string|unicode%(%d) "%s"
+GET single: MD5
+%string|unicode%(%d) "%s"
+GET single: SHA
+%string|unicode%(%d) "%s"
+GET single: MD5/AES
+%string|unicode%(%d) "%s"
+GET single: MD5/DES
+%string|unicode%(%d) "%s"
+GET single: MD5/AES128
+%string|unicode%(%d) "%s"
+GET multiple
+array(2) {
+ ["%s"]=>
+ %string|unicode%(%d) "%s"
+ ["%s"]=>
+ %string|unicode%(%d) "%s"
+}
+GETNEXT single
+%string|unicode%(%d) "%s"
+WALK single on single OID
+%string|unicode%(5) "array"
+int(1)
+array(1) {
+ [0]=>
+ %string|unicode%(%d) "%s"
+}
+REALWALK single on single OID
+%string|unicode%(5) "array"
+int(1)
+array(1) {
+ ["%s"]=>
+ %string|unicode%(%d) "%s"
+}
+WALK multiple on single OID
+%string|unicode%(5) "array"
+int(%d)
+int(0)
+%string|unicode%(%d) "%s"
+REALWALK multiple on single OID
+%string|unicode%(5) "array"
+int(%d)
+%string|unicode%(%d) "%s"
+%string|unicode%(%d) "%s"
+SET single OID
+bool(true)
+bool(true)
+bool(true)
+bool(true)
diff --git a/ext/snmp/tests/snmp_get_quick_print.phpt b/ext/snmp/tests/snmp_get_quick_print.phpt
new file mode 100644
index 0000000..9abfd92
--- /dev/null
+++ b/ext/snmp/tests/snmp_get_quick_print.phpt
@@ -0,0 +1,41 @@
+--TEST--
+Function snmp_get_quick_print / snmp_set_quick_print
+--CREDITS--
+Olivier Doucet
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+echo "Checking error handling\n";
+var_dump(snmp_get_quick_print('noarg'));
+var_dump(snmp_set_quick_print('noarg'));
+var_dump(snmp_set_quick_print());
+
+echo "Checking working\n";
+var_dump(snmp_get_quick_print());
+snmp_set_quick_print(false);
+var_dump(snmp_get_quick_print());
+snmp_set_quick_print(true);
+var_dump(snmp_get_quick_print());
+
+?>
+--EXPECTF--
+Checking error handling
+
+Warning: snmp_get_quick_print() expects exactly 0 parameters, 1 given in %s on line %d
+NULL
+
+Warning: snmp_set_quick_print() expects parameter 1 to be long, %s given in %s on line %d
+bool(false)
+
+Warning: snmp_set_quick_print() expects exactly 1 parameter, 0 given in %s on line %d
+bool(false)
+Checking working
+bool(%s)
+bool(false)
+bool(true)
+
diff --git a/ext/snmp/tests/snmp_get_valueretrieval.phpt b/ext/snmp/tests/snmp_get_valueretrieval.phpt
new file mode 100644
index 0000000..660d643
--- /dev/null
+++ b/ext/snmp/tests/snmp_get_valueretrieval.phpt
@@ -0,0 +1,53 @@
+--TEST--
+Function snmp_get_valueretrieval / snmp_set_valueretrieval
+--CREDITS--
+Olivier Doucet
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+echo "Checking error handling\n";
+var_dump(snmp_get_valueretrieval('noarg'));
+var_dump(snmp_set_valueretrieval());
+var_dump(snmp_set_valueretrieval('noarg'));
+var_dump(snmp_set_valueretrieval(67));
+
+echo "Checking working\n";
+var_dump(snmp_get_valueretrieval());
+snmp_set_valueretrieval(SNMP_VALUE_LIBRARY);
+var_dump(snmp_get_valueretrieval() === SNMP_VALUE_LIBRARY);
+snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
+var_dump(snmp_get_valueretrieval() === SNMP_VALUE_PLAIN);
+snmp_set_valueretrieval(SNMP_VALUE_OBJECT);
+var_dump(snmp_get_valueretrieval() === SNMP_VALUE_OBJECT);
+snmp_set_valueretrieval(SNMP_VALUE_PLAIN|SNMP_VALUE_OBJECT);
+var_dump(snmp_get_valueretrieval() === (SNMP_VALUE_PLAIN|SNMP_VALUE_OBJECT));
+snmp_set_valueretrieval(SNMP_VALUE_LIBRARY|SNMP_VALUE_OBJECT);
+var_dump(snmp_get_valueretrieval() === (SNMP_VALUE_LIBRARY|SNMP_VALUE_OBJECT));
+
+?>
+--EXPECTF--
+Checking error handling
+
+Warning: snmp_get_valueretrieval() expects exactly 0 parameters, 1 given in %s on line %d
+bool(false)
+
+Warning: snmp_set_valueretrieval() expects exactly 1 parameter, 0 given in %s on line %d
+bool(false)
+
+Warning: snmp_set_valueretrieval() expects parameter 1 to be long, %s given in %s on line %d
+bool(false)
+
+Warning: snmp_set_valueretrieval(): Unknown SNMP value retrieval method '67' in %s on line %d
+bool(false)
+Checking working
+int(%d)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
diff --git a/ext/snmp/tests/snmp_getvalue.phpt b/ext/snmp/tests/snmp_getvalue.phpt
new file mode 100644
index 0000000..178354a
--- /dev/null
+++ b/ext/snmp/tests/snmp_getvalue.phpt
@@ -0,0 +1,83 @@
+--TEST--
+Function snmp_getvalue
+--CREDITS--
+Boris Lytochkin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+//EXPECTF format is quickprint OFF
+snmp_set_quick_print(false);
+
+echo "Get with SNMP_VALUE_LIBRARY\n";
+snmp_set_valueretrieval(SNMP_VALUE_LIBRARY);
+var_dump(snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout, $retries));
+
+echo "Get with SNMP_VALUE_PLAIN\n";
+snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
+var_dump(snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout, $retries));
+
+echo "Get with SNMP_VALUE_OBJECT\n";
+snmp_set_valueretrieval(SNMP_VALUE_OBJECT);
+$z = snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout, $retries);
+echo gettype($z)."\n";
+var_dump($z->type);
+var_dump($z->value);
+
+echo "Get with SNMP_VALUE_OBJECT | SNMP_VALUE_PLAIN\n";
+snmp_set_valueretrieval(SNMP_VALUE_OBJECT | SNMP_VALUE_PLAIN);
+$z = snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout, $retries);
+echo gettype($z)."\n";
+var_dump($z->type);
+var_dump($z->value);
+
+echo "Get with SNMP_VALUE_OBJECT for BITS OID\n";
+snmp_set_valueretrieval(SNMP_VALUE_OBJECT);
+$z = snmpget($hostname, $community, '.1.3.6.1.2.1.88.1.4.2.1.3.6.95.115.110.109.112.100.95.108.105.110.107.68.111.119.110', $timeout, $retries);
+echo gettype($z)."\n";
+var_dump($z->type);
+var_dump($z->value);
+
+echo "Get with SNMP_VALUE_OBJECT | SNMP_VALUE_PLAIN for BITS OID\n";
+snmp_set_valueretrieval(SNMP_VALUE_OBJECT | SNMP_VALUE_PLAIN);
+$z = snmpget($hostname, $community, '.1.3.6.1.2.1.88.1.4.2.1.3.6.95.115.110.109.112.100.95.108.105.110.107.68.111.119.110', $timeout, $retries);
+echo gettype($z)."\n";
+var_dump($z->type);
+var_dump(is_numeric($z->value));
+var_dump(is_string($z->value));
+var_dump(bin2hex($z->value));
+
+echo "Check parsing of different OID types\n";
+snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
+var_dump(count(snmp2_walk($hostname, $community, '.', $timeout, $retries)));
+
+?>
+--EXPECTF--
+Get with SNMP_VALUE_LIBRARY
+string(%d) "STRING: %s"
+Get with SNMP_VALUE_PLAIN
+string(%d) "%s"
+Get with SNMP_VALUE_OBJECT
+object
+int(4)
+string(%d) "STRING: %s"
+Get with SNMP_VALUE_OBJECT | SNMP_VALUE_PLAIN
+object
+int(4)
+string(%d) "%s"
+Get with SNMP_VALUE_OBJECT for BITS OID
+object
+int(4)
+string(25) "BITS: %d %s"
+Get with SNMP_VALUE_OBJECT | SNMP_VALUE_PLAIN for BITS OID
+object
+int(4)
+bool(false)
+bool(true)
+string(2) "%d"
+Check parsing of different OID types
+int(%d)
diff --git a/ext/snmp/tests/snmp_include.inc b/ext/snmp/tests/snmp_include.inc
new file mode 100644
index 0000000..caa0721
--- /dev/null
+++ b/ext/snmp/tests/snmp_include.inc
@@ -0,0 +1,31 @@
+<?php
+
+/*
+By default tests will try to access SNMP agent @ '127.0.0.1:161' and will use 'public' community for read
+requests and 'private' community for write requests.
+Default timeout is 1000ms and there will be one request performed.
+*/
+
+$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 = "$hostname4:$port";
+$hostname6_port = "[$hostname6]:$port";
+$community = getenv('SNMP_COMMUNITY') ? getenv('SNMP_COMMUNITY') : 'public';
+$communityWrite = getenv('SNMP_COMMUNITY_WRITE')? getenv('SNMP_COMMUNITY_WRITE'):'private';
+
+$timeout = getenv('SNMP_TIMEOUT') ? getenv('SNMP_TIMEOUT') : -1;
+$retries = getenv('SNMP_RETRIES') ? getenv('SNMP_RETRIES') : 1;
+
+if (stristr(PHP_OS, "FreeBSD")) {
+ $mibdir = getenv('SNMP_MIBDIR') ? getenv('SNMP_MIBDIR') : "/usr/local/share/snmp/mibs";
+} else {
+ $mibdir = getenv('SNMP_MIBDIR') ? getenv('SNMP_MIBDIR') : "/usr/share/snmp/mibs";
+}
+
+
+$user_noauth = getenv('SNMP_USER_NOAUTH') ? getenv('SNMP_USER_NOAUTH') : 'noAuthUser';
+$user_auth_prefix = getenv('SNMP_USER_PREFIX') ? getenv('SNMP_USER_PREFIX') : 'admin';
+$rwuser = getenv('SNMP_RWUSER') ? getenv('SNMP_RWUSER') : ($user_auth_prefix . 'MD5AES');
+$auth_pass = getenv('SNMP_AUTH_PASS') ? getenv('SNMP_AUTH_PASS') : 'test1234';
+$priv_pass = getenv('SNMP_PRIV_PASS') ? getenv('SNMP_PRIV_PASS') : 'test1234';
diff --git a/ext/snmp/tests/snmp_read_mib.phpt b/ext/snmp/tests/snmp_read_mib.phpt
new file mode 100644
index 0000000..b26ba5e
--- /dev/null
+++ b/ext/snmp/tests/snmp_read_mib.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Function snmp_read_mib
+--CREDITS--
+Olivier Doucet Olivier Doucet Boris Lytochkin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+if (!file_exists($mibdir . '/SNMPv2-MIB.txt')) die('MIB file not in the system');
+
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+echo "Checking error handling\n";
+var_dump(snmp_read_mib());
+var_dump(snmp_read_mib(dirname(__FILE__).'/cannotfindthisfile'));
+
+echo "Checking working\n";
+var_dump(snmp_read_mib($mibdir . '/SNMPv2-MIB.txt'));
+
+?>
+--EXPECTF--
+Checking error handling
+
+Warning: snmp_read_mib() expects exactly 1 parameter, 0 given in %s on line %d
+bool(false)
+
+Warning: snmp_read_mib(): Error while reading MIB file '%s': No such file or directory in %s on line %d
+bool(false)
+Checking working
+bool(true)
diff --git a/ext/snmp/tests/snmp_set_enum_print.phpt b/ext/snmp/tests/snmp_set_enum_print.phpt
new file mode 100644
index 0000000..9768344
--- /dev/null
+++ b/ext/snmp/tests/snmp_set_enum_print.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Function snmp_set_enum_print
+--CREDITS--
+Olivier Doucet
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+if (!function_exists('snmp_set_enum_print')) die('This function is only available if using NET_SNMP');
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+echo "Checking error handling\n";
+var_dump(snmp_set_enum_print());
+
+echo "Checking working\n";
+var_dump(snmp_set_enum_print(0));
+var_dump(snmp_set_enum_print(1));
+?>
+--EXPECTF--
+Checking error handling
+
+Warning: snmp_set_enum_print() expects exactly 1 parameter, 0 given in %s on line %d
+bool(false)
+Checking working
+bool(true)
+bool(true)
diff --git a/ext/snmp/tests/snmp_set_oid_output_format.phpt b/ext/snmp/tests/snmp_set_oid_output_format.phpt
new file mode 100644
index 0000000..20a48d4
--- /dev/null
+++ b/ext/snmp/tests/snmp_set_oid_output_format.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Function snmp_set_oid_output_format
+--CREDITS--
+Olivier Doucet
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+if (!function_exists('snmp_set_oid_output_format')) die('This function is only available if using NET_SNMP');
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+echo "Checking error handling\n";
+var_dump(snmp_set_oid_output_format());
+var_dump(snmp_set_oid_output_format(123));
+
+echo "Checking working\n";
+var_dump(snmp_set_oid_output_format(SNMP_OID_OUTPUT_FULL));
+var_dump(snmp_set_oid_output_format(SNMP_OID_OUTPUT_NUMERIC));
+?>
+--EXPECTF--
+Checking error handling
+
+Warning: snmp_set_oid_output_format() expects exactly 1 parameter, 0 given in %s on line %d
+bool(false)
+
+Warning: snmp_set_oid_output_format(): Unknown SNMP output print format '123' in %s on line %d
+bool(false)
+Checking working
+bool(true)
+bool(true)
diff --git a/ext/snmp/tests/snmpd.conf b/ext/snmp/tests/snmpd.conf
new file mode 100644
index 0000000..3e91372
--- /dev/null
+++ b/ext/snmp/tests/snmpd.conf
@@ -0,0 +1,25 @@
+# Listen for connections from the local system only
+agentaddress udp:127.0.0.1:161,udp6:[::1]:161
+
+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
+#syslocation "Somewhere in the world"
+#syscontact "root"
+
+#SNMPv3 credentials
+rouser adminMD5
+rouser adminSHA
+rwuser adminMD5AES
+rouser adminMD5AES128
+rouser adminMD5DES
+createUser adminMD5 MD5 test1234
+createUser adminSHA SHA test1234
+createUser adminMD5AES MD5 test1234 AES test1234
+createUser adminMD5AES128 MD5 test1234 AES test1234
+createUser adminMD5DES MD5 test1234 DES test1234
+
+createUser noAuthUser
+authuser read noAuthUser noauth
diff --git a/ext/snmp/tests/snmpget.phpt b/ext/snmp/tests/snmpget.phpt
new file mode 100644
index 0000000..e4514a2
--- /dev/null
+++ b/ext/snmp/tests/snmpget.phpt
@@ -0,0 +1,106 @@
+--TEST--
+Function snmpget
+--CREDITS--
+Olivier Doucet & Boris Lytochkin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+//EXPECTF format is quickprint OFF
+snmp_set_quick_print(false);
+snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
+
+echo "Checking error handling\n";
+var_dump(snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0', ''));
+var_dump(snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout, ''));
+
+echo "Checking working\n";
+echo "Single OID, default timeout and retries\n";
+var_dump(snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0'));
+echo "Single OID, default retries\n";
+var_dump(snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout));
+echo "Single OID\n";
+var_dump(snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout, $retries));
+echo "Single OID in array\n";
+var_dump(snmpget($hostname, $community, array('.1.3.6.1.2.1.1.1.0'), $timeout, $retries));
+echo "Multiple OID\n";
+var_dump(snmpget($hostname, $community, array('.1.3.6.1.2.1.1.1.0', '.1.3.6.1.2.1.1.3.0'), $timeout, $retries));
+
+echo "More error handling\n";
+echo "Single OID\n";
+var_dump(snmpget($hostname, $community, '.1.3.6.1.2.1..1.1.0', $timeout, $retries));
+echo "Single OID in array\n";
+var_dump(snmpget($hostname, $community, array('.1.3.6.1.2.1...1.1.0'), $timeout, $retries));
+echo "Multiple OID\n";
+var_dump(snmpget($hostname, $community, array('.1.3.6.1.2.1...1.1.0', '.1.3.6.1.2.1.1.3.0'), $timeout, $retries));
+
+echo "noSuchName checks\n";
+echo "Single OID\n";
+var_dump(snmpget($hostname, $community, '.1.3.6.1.2.1.1.1.110', $timeout, $retries));
+echo "Single OID in array\n";
+var_dump(snmpget($hostname, $community, array('.1.3.6.1.2.1.1.1.110'), $timeout, $retries));
+echo "Multiple OID\n";
+var_dump(snmpget($hostname, $community, array('.1.3.6.1.2.1.1.1.0', '.1.3.6.1.2.1.1.3.220'), $timeout, $retries));
+
+
+?>
+--EXPECTF--
+Checking error handling
+
+Warning: snmpget() expects parameter 4 to be long,%s given in %s on line %d
+bool(false)
+
+Warning: snmpget() expects parameter 5 to be long,%s given in %s on line %d
+bool(false)
+Checking working
+Single OID, default timeout and retries
+%unicode|string%(%d) "%s"
+Single OID, default retries
+%unicode|string%(%d) "%s"
+Single OID
+%unicode|string%(%d) "%s"
+Single OID in array
+array(1) {
+ ["%s"]=>
+ %unicode|string%(%d) "%s"
+}
+Multiple OID
+array(2) {
+ ["%s"]=>
+ %unicode|string%(%d) "%s"
+ ["%s"]=>
+ %unicode|string%(%d) "%d"
+}
+More error handling
+Single OID
+
+Warning: snmpget(): Invalid object identifier: .1.3.6.1.2.1..1.1.0 in %s on line %d
+bool(false)
+Single OID in array
+
+Warning: snmpget(): Invalid object identifier: .1.3.6.1.2.1...1.1.0 in %s on line %d
+bool(false)
+Multiple OID
+
+Warning: snmpget(): Invalid object identifier: .1.3.6.1.2.1...1.1.0 in %s on line %d
+bool(false)
+noSuchName checks
+Single OID
+
+Warning: snmpget(): Error in packet at 'SNMPv2-MIB::sysDescr.110': (noSuchName) There is no such variable name in this MIB. in %s on line %d
+bool(false)
+Single OID in array
+
+Warning: snmpget(): Error in packet at 'SNMPv2-MIB::sysDescr.110': (noSuchName) There is no such variable name in this MIB. in %s on line %d
+bool(false)
+Multiple OID
+
+Warning: snmpget(): Error in packet at 'SNMPv2-MIB::sysUpTime.220': (noSuchName) There is no such variable name in this MIB. in %s on line %d
+array(1) {
+ ["%s"]=>
+ %unicode|string%(%d) "%s"
+}
diff --git a/ext/snmp/tests/snmpgetnext.phpt b/ext/snmp/tests/snmpgetnext.phpt
new file mode 100644
index 0000000..af92d56
--- /dev/null
+++ b/ext/snmp/tests/snmpgetnext.phpt
@@ -0,0 +1,39 @@
+--TEST--
+Function snmpgetnext
+--CREDITS--
+Olivier Doucet & Boris Lytochkin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+//EXPECTF format is quickprint OFF
+snmp_set_quick_print(false);
+snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
+
+echo "Single OID\n";
+var_dump(snmpgetnext($hostname, $community, '.1.3.6.1.2.1.1.1.0', $timeout, $retries));
+echo "Single OID in array\n";
+var_dump(snmpgetnext($hostname, $community, array('.1.3.6.1.2.1.1.1.0'), $timeout, $retries));
+echo "Multiple OID\n";
+var_dump(snmpgetnext($hostname, $community, array('.1.3.6.1.2.1.1.1.0', '.1.3.6.1.2.1.1.6.0'), $timeout, $retries));
+
+?>
+--EXPECTF--
+Single OID
+%unicode|string%(%d) "%s"
+Single OID in array
+array(1) {
+ ["%s"]=>
+ %unicode|string%(%d) "%s"
+}
+Multiple OID
+array(2) {
+ ["%s"]=>
+ %unicode|string%(%d) "%s"
+ ["%s"]=>
+ %unicode|string%(%d) "%d"
+}
diff --git a/ext/snmp/tests/snmprealwalk.phpt b/ext/snmp/tests/snmprealwalk.phpt
new file mode 100644
index 0000000..d1e343e
--- /dev/null
+++ b/ext/snmp/tests/snmprealwalk.phpt
@@ -0,0 +1,86 @@
+--TEST--
+Function snmprealwalk
+--CREDITS--
+Olivier Doucet Olivier Doucet Boris Lytochkin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+//EXPECTF format is quickprint OFF
+snmp_set_quick_print(false);
+snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
+
+echo "Checking error handling\n";
+var_dump(snmprealwalk($hostname, $community, '.1.3.6.1.2.1.1', ''));
+var_dump(snmprealwalk($hostname, $community, '.1.3.6.1.2.1.1', $timeout, ''));
+
+echo "Checking working\n";
+echo "Single OID\n";
+$return = snmprealwalk($hostname, $community, '.1.3.6.1.2.1.1', $timeout, $retries);
+var_dump(gettype($return));
+var_dump(sizeof($return));
+var_dump(key($return));
+var_dump(array_shift($return));
+
+echo "Single OID in array\n";
+$return = snmprealwalk($hostname, $community, array('.1.3.6.1.2.1.1'), $timeout, $retries);
+var_dump(gettype($return));
+var_dump(sizeof($return));
+var_dump(key($return));
+var_dump(array_shift($return));
+
+echo "More error handling\n";
+echo "Multiple correct OID\n";
+$return = snmprealwalk($hostname, $community, array('.1.3.6.1.2.1.1', '.1.3.6'), $timeout, $retries);
+var_dump($return);
+
+echo "Multiple OID with wrong OID\n";
+$return = snmprealwalk($hostname, $community, array('.1.3.6.1.2.1.1', '.1.3.6...1'), $timeout, $retries);
+var_dump($return);
+$return = snmprealwalk($hostname, $community, array('.1.3.6...1', '.1.3.6.1.2.1.1'), $timeout, $retries);
+var_dump($return);
+
+echo "Single nonexisting OID\n";
+$return = snmprealwalk($hostname, $community, array('.1.3.6.99999.0.99999.111'), $timeout, $retries);
+var_dump($return);
+
+?>
+--EXPECTF--
+Checking error handling
+
+Warning: snmprealwalk() expects parameter 4 to be long, %s given in %s on line %d
+bool(false)
+
+Warning: snmprealwalk() expects parameter 5 to be long, %s given in %s on line %d
+bool(false)
+Checking working
+Single OID
+%unicode|string%(5) "array"
+int(%d)
+string(%d) "%s"
+string(%d) "%s"
+Single OID in array
+%unicode|string%(5) "array"
+int(%d)
+string(%d) "%s"
+string(%d) "%s"
+More error handling
+Multiple correct OID
+
+Warning: snmprealwalk(): Multi OID walks are not supported! in %s on line %d
+bool(false)
+Multiple OID with wrong OID
+
+Warning: snmprealwalk(): Multi OID walks are not supported! in %s on line %d
+bool(false)
+
+Warning: snmprealwalk(): Multi OID walks are not supported! in %s on line %d
+bool(false)
+Single nonexisting OID
+
+Warning: snmprealwalk(): Error in packet at '%s': (noSuchName) There is no such variable name in this MIB. in %s on line %d
+bool(false)
diff --git a/ext/snmp/tests/snmpset-nomib.phpt b/ext/snmp/tests/snmpset-nomib.phpt
new file mode 100644
index 0000000..7428e57
--- /dev/null
+++ b/ext/snmp/tests/snmpset-nomib.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Function snmpset (without MIBs loading)
+--CREDITS--
+Boris Lytochkin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--ENV--
+return <<<END
+MIBS=
+END;
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+//EXPECTF format is quickprint OFF
+snmp_set_quick_print(false);
+snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
+
+echo "Check error handing\n";
+echo "Nonexisting OID\n";
+$z = snmpset($hostname, $communityWrite, '.1.3.6.777.888.999.444.0', 's', 'bbb', $timeout, $retries);
+var_dump($z);
+
+echo "Bogus OID\n";
+$z = snmpset($hostname, $communityWrite, '.1.3...6.777.888.999.444.0', 's', 'bbb', $timeout, $retries);
+var_dump($z);
+
+
+echo "Checking working\n";
+$oid1 = '.1.3.6.1.2.1.1.4.0';
+$oldvalue1 = snmpget($hostname, $communityWrite, $oid1, $timeout, $retries);
+$newvalue1 = $oldvalue1 . '0';
+
+echo "Single OID\n";
+$z = snmpset($hostname, $communityWrite, $oid1, 's', $newvalue1, $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $newvalue1));
+$z = snmpset($hostname, $communityWrite, $oid1, 's', $oldvalue1, $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+
+?>
+--EXPECTF--
+Check error handing
+Nonexisting OID
+
+Warning: snmpset(): Error in packet at '%s': (noSuchName) There is no such variable name in this MIB. in %s on line %d
+bool(false)
+Bogus OID
+
+Warning: snmpset(): Invalid object identifier: %s in %s on line %d
+bool(false)
+Checking working
+Single OID
+bool(true)
+bool(true)
+bool(true)
+bool(true)
diff --git a/ext/snmp/tests/snmpset.phpt b/ext/snmp/tests/snmpset.phpt
new file mode 100644
index 0000000..055b789
--- /dev/null
+++ b/ext/snmp/tests/snmpset.phpt
@@ -0,0 +1,248 @@
+--TEST--
+Function snmpset
+--CREDITS--
+Olivier Doucet Olivier Doucet Boris Lytochkin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+//EXPECTF format is quickprint OFF
+snmp_set_quick_print(false);
+snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
+
+echo "Check error handing\n";
+echo "4args (5 needed)\n";
+$z = snmpset($hostname, $communityWrite, 'SNMPv2-MIB::sysLocation.0');
+var_dump($z);
+
+echo "No type & no value (timeout & retries instead)\n";
+$z = snmpset($hostname, $communityWrite, 'SNMPv2-MIB::sysLocation.0', $timeout, $retries);
+var_dump($z);
+
+echo "No value (timeout instead), retries instead of timeout\n";
+$z = snmpset($hostname, $communityWrite, 'SNMPv2-MIB::sysLocation.0', 'q', $timeout, $retries);
+var_dump($z);
+
+echo "Bogus OID\n";
+$z = snmpset($hostname, $communityWrite, '.1.3.6.777.888.999.444.0', 's', 'bbb', $timeout, $retries);
+var_dump($z);
+
+echo "Checking working\n";
+$oid1 = 'SNMPv2-MIB::sysContact.0';
+$oldvalue1 = snmpget($hostname, $communityWrite, $oid1, $timeout, $retries);
+$newvalue1 = $oldvalue1 . '0';
+$oid2 = 'SNMPv2-MIB::sysLocation.0';
+$oldvalue2 = snmpget($hostname, $communityWrite, $oid1, $timeout, $retries);
+$newvalue2 = $oldvalue2 . '0';
+
+echo "Single OID\n";
+$z = snmpset($hostname, $communityWrite, $oid1, 's', $newvalue1, $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $newvalue1));
+$z = snmpset($hostname, $communityWrite, $oid1, 's', $oldvalue1, $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+
+echo "Multiple OID\n";
+$z = snmpset($hostname, $communityWrite, array($oid1, $oid2), array('s','s'), array($newvalue1, $newvalue2), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $newvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $newvalue2));
+$z = snmpset($hostname, $communityWrite, array($oid1, $oid2), array('s','s'), array($oldvalue1, $oldvalue2), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
+
+echo "Multiple OID, single type & value\n";
+$z = snmpset($hostname, $communityWrite, array($oid1, $oid2), 's', $newvalue1, $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $newvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $newvalue1));
+$z = snmpset($hostname, $communityWrite, array($oid1, $oid2), array('s','s'), array($oldvalue1, $oldvalue2), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
+
+echo "Multiple OID, single type, multiple value\n";
+$z = snmpset($hostname, $communityWrite, array($oid1, $oid2), 's', array($newvalue1, $newvalue2), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $newvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $newvalue2));
+$z = snmpset($hostname, $communityWrite, array($oid1, $oid2), array('s','s'), array($oldvalue1, $oldvalue2), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
+
+
+echo "More error handing\n";
+echo "Single OID, single type in array, single value\n";
+$z = snmpset($hostname, $communityWrite, $oid1, array('s'), $newvalue1, $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
+
+echo "Single OID, single type, single value in array\n";
+$z = snmpset($hostname, $communityWrite, $oid1, 's', array($newvalue1), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
+
+echo "Multiple OID, 1st wrong type\n";
+$z = snmpset($hostname, $communityWrite, array($oid1, $oid2), array('sw','s'), array($newvalue1, $newvalue2), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
+
+echo "Multiple OID, 2nd wrong type\n";
+$z = snmpset($hostname, $communityWrite, array($oid1, $oid2), array('s','sb'), array($newvalue1, $newvalue2), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
+
+echo "Multiple OID, single type in array, multiple value\n";
+$z = snmpset($hostname, $communityWrite, array($oid1, $oid2), array('s'), array($newvalue1, $newvalue2), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
+
+echo "Multiple OID & type, singe value in array\n";
+$z = snmpset($hostname, $communityWrite, array($oid1, $oid2), array('s', 's'), array($newvalue1), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
+
+echo "Multiple OID, 1st bogus, single type, multiple value\n";
+$z = snmpset($hostname, $communityWrite, array($oid1 . '44.55.66.77', $oid2), 's', array($newvalue1, $newvalue2), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
+
+echo "Multiple OID, 2nd bogus, single type, multiple value\n";
+$z = snmpset($hostname, $communityWrite, array($oid1, $oid2 . '44.55.66.77'), 's', array($newvalue1, $newvalue2), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
+
+echo "Multiple OID, single multiple type (1st bogus), multiple value\n";
+$z = snmpset($hostname, $communityWrite, array($oid1, $oid2), array('q', 's'), array($newvalue1, $newvalue2), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
+
+echo "Multiple OID, single multiple type (2nd bogus), multiple value\n";
+$z = snmpset($hostname, $communityWrite, array($oid1, $oid2), array('s', 'w'), array($newvalue1, $newvalue2), $timeout, $retries);
+var_dump($z);
+var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
+var_dump((snmpget($hostname, $communityWrite, $oid2, $timeout, $retries) === $oldvalue2));
+
+?>
+--EXPECTF--
+Check error handing
+4args (5 needed)
+
+Warning: snmpset() expects at least 5 parameters, 3 given in %s on line %d
+bool(false)
+No type & no value (timeout & retries instead)
+
+Warning: snmpset(): Bogus type '-1', should be single char, got 2 in %s on line %d
+bool(false)
+No value (timeout instead), retries instead of timeout
+
+Warning: snmpset(): Could not add variable: OID='%s' type='q' value='%i': Bad variable type ("q") in %s on line %d
+bool(false)
+Bogus OID
+
+Warning: snmpset(): Error in packet at '%s': (noSuchName) There is no such variable name in this MIB. in %s on line %d
+bool(false)
+Checking working
+Single OID
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+Multiple OID
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+Multiple OID, single type & value
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+Multiple OID, single type, multiple value
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+More error handing
+Single OID, single type in array, single value
+
+Warning: snmpset(): Single objid and multiple type or values are not supported in %s on line %s
+bool(false)
+bool(true)
+bool(true)
+Single OID, single type, single value in array
+
+Warning: snmpset(): Single objid and multiple type or values are not supported in %s on line %s
+bool(false)
+bool(true)
+bool(true)
+Multiple OID, 1st wrong type
+
+Warning: snmpset(): '%s': bogus type 'sw', should be single char, got 2 in %s on line %s
+bool(false)
+bool(true)
+bool(true)
+Multiple OID, 2nd wrong type
+
+Warning: snmpset(): '%s': bogus type 'sb', should be single char, got 2 in %s on line %s
+bool(false)
+bool(true)
+bool(true)
+Multiple OID, single type in array, multiple value
+
+Warning: snmpset(): '%s': no type set in %s on line %d
+bool(false)
+bool(true)
+bool(true)
+Multiple OID & type, singe value in array
+
+Warning: snmpset(): '%s': no value set in %s on line %d
+bool(false)
+bool(true)
+bool(true)
+Multiple OID, 1st bogus, single type, multiple value
+
+Warning: snmpset(): Error in packet at '%s': (noSuchName) There is no such variable name in this MIB. in %s on line %d
+bool(false)
+bool(true)
+bool(true)
+Multiple OID, 2nd bogus, single type, multiple value
+
+Warning: snmpset(): Error in packet at '%s': (noSuchName) There is no such variable name in this MIB. in %s on line %d
+bool(false)
+bool(true)
+bool(true)
+Multiple OID, single multiple type (1st bogus), multiple value
+
+Warning: snmpset(): Could not add variable: OID='%s' type='q' value='%s': Bad variable type ("q") in %s on line %d
+bool(false)
+bool(true)
+bool(true)
+Multiple OID, single multiple type (2nd bogus), multiple value
+
+Warning: snmpset(): Could not add variable: OID='%s' type='w' value='%s': Bad variable type ("w") in %s on line %d
+bool(false)
+bool(true)
+bool(true)
diff --git a/ext/snmp/tests/snmpwalk.phpt b/ext/snmp/tests/snmpwalk.phpt
new file mode 100644
index 0000000..dd184d6
--- /dev/null
+++ b/ext/snmp/tests/snmpwalk.phpt
@@ -0,0 +1,99 @@
+--TEST--
+Function snmpwalk
+--CREDITS--
+Olivier Doucet Olivier Doucet Boris Lytochkin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+//EXPECTF format is quickprint OFF
+snmp_set_quick_print(false);
+snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
+
+echo "Checking error handling\n";
+var_dump(snmpwalk($hostname, $community, '.1.3.6.1.2.1.1', ''));
+var_dump(snmpwalk($hostname, $community, '.1.3.6.1.2.1.1', $timeout, ''));
+
+echo "Checking working\n";
+echo "Single OID\n";
+$return = snmpwalk($hostname, $community, '.1.3.6.1.2.1.1', $timeout, $retries);
+
+var_dump(gettype($return));
+var_dump(sizeof($return));
+var_dump(gettype($return[0]));
+var_dump(gettype($return[1]));
+
+echo "Single OID in array\n";
+$return = snmpwalk($hostname, $community, array('.1.3.6.1.2.1.1'), $timeout, $retries);
+var_dump(gettype($return));
+var_dump(gettype($return[0]));
+
+echo "Default OID\n";
+$return = snmpwalk($hostname, $community, '', $timeout, $retries);
+var_dump(gettype($return));
+var_dump(gettype($return[0]));
+
+echo "More error handling\n";
+echo "Single incorrect OID\n";
+$return = snmpwalk($hostname, $community, '.1.3.6...1', $timeout, $retries);
+var_dump($return);
+
+echo "Multiple correct OID\n";
+$return = snmpwalk($hostname, $community, array('.1.3.6.1.2.1.1', '.1.3.6'), $timeout, $retries);
+var_dump($return);
+
+echo "Multiple OID with wrong OID\n";
+$return = snmpwalk($hostname, $community, array('.1.3.6.1.2.1.1', '.1.3.6...1'), $timeout, $retries);
+var_dump($return);
+$return = snmpwalk($hostname, $community, array('.1.3.6...1', '.1.3.6.1.2.1.1'), $timeout, $retries);
+var_dump($return);
+
+echo "Single nonexisting OID\n";
+$return = snmpwalk($hostname, $community, array('.1.3.6.99999.0.99999.111'), $timeout, $retries);
+var_dump($return);
+
+?>
+--EXPECTF--
+Checking error handling
+
+Warning: snmpwalk() expects parameter 4 to be long, %s given in %s on line %d
+bool(false)
+
+Warning: snmpwalk() expects parameter 5 to be long, %s given in %s on line %d
+bool(false)
+Checking working
+Single OID
+%unicode|string%(5) "array"
+int(%d)
+%unicode|string%(6) "string"
+%unicode|string%(6) "string"
+Single OID in array
+%unicode|string%(5) "array"
+%unicode|string%(6) "string"
+Default OID
+%unicode|string%(5) "array"
+%unicode|string%(6) "string"
+More error handling
+Single incorrect OID
+
+Warning: snmpwalk(): Invalid object identifier: %s in %s on line %d
+bool(false)
+Multiple correct OID
+
+Warning: snmpwalk(): Multi OID walks are not supported! in %s on line %d
+bool(false)
+Multiple OID with wrong OID
+
+Warning: snmpwalk(): Multi OID walks are not supported! in %s on line %d
+bool(false)
+
+Warning: snmpwalk(): Multi OID walks are not supported! in %s on line %d
+bool(false)
+Single nonexisting OID
+
+Warning: snmpwalk(): Error in packet at '%s': (noSuchName) There is no such variable name in this MIB. in %s on line %d
+bool(false)
diff --git a/ext/snmp/tests/wrong_hostname.phpt b/ext/snmp/tests/wrong_hostname.phpt
new file mode 100644
index 0000000..53c6b22
--- /dev/null
+++ b/ext/snmp/tests/wrong_hostname.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Wrong hostname
+--CREDITS--
+Boris Lytochkin
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__).'/skipif.inc');
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__).'/snmp_include.inc');
+
+//EXPECTF format is quickprint OFF
+snmp_set_quick_print(false);
+snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
+
+var_dump(snmpget('192.168..6.1', 'community', '.1.3.6.1.2.1.1.1.0', $timeout, $retries));
+
+?>
+--EXPECTF--
+Warning: snmpget(): php_network_getaddresses:%snot known in %s on line %d
+bool(false)