|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #55474 Improve tests/README...
Submitted: 2011-08-21 22:55 UTC Modified: 2011-08-25 06:01 UTC
From: Assigned: lytboris (profile)
Status: Closed Package: SNMP related
PHP Version: 5.4.0alpha3 OS: Debian Linux
Private report: No CVE-ID: None
 [2011-08-21 22:55 UTC]

I tried to run the test suite to eventually create a test case with IPv6 IPs but found two problems:

a) The README says that I can specify certain environment variables but that does not seem to work:

$ TEST_PHP_EXECUTABLE="./sapi/cli/php" SNMP_MIBDIR="/var/lib/mibs/ietf/" ./run-tests.php ext/snmp/tests/snmp_read_mib.phpt

PHP         : ./sapi/cli/php 
PHP_SAPI    : cli
PHP_VERSION : 5.4.0alpha2
PHP_OS      : Linux - Linux james 3.0.0-1-amd64 #1 SMP Sun Jul 24 02:24:44 UTC 2011 x86_64
INI actual  : /srv/home/james/workspace/php-src-5.4
More .INIs  :  
CWD         : /srv/home/james/workspace/php-src-5.4
Extra dirs  : 
VALGRIND    : Not used
Running selected tests.
FAIL Function snmp_read_mib [ext/snmp/tests/snmp_read_mib.phpt] 
Number of tests :    1                 1
Tests skipped   :    0 (  0.0%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :    1 (100.0%) (100.0%)
Expected fail   :    0 (  0.0%) (  0.0%)
Tests passed    :    0 (  0.0%) (  0.0%)
Time taken      :    0 seconds

Function snmp_read_mib [ext/snmp/tests/snmp_read_mib.phpt]

The output of phpinfo() called from this .phpt file shows that the environment seems to be cleared:

  Variable => Value
  SCRIPT_FILENAME => /srv/home/james/workspace/php-src-5.4/ext/snmp/tests/snmp_read_mib.php
  PWD => /srv/home/james/workspace/php-src-5.4
  TEST_PHP_EXECUTABLE => ./sapi/cli/php
  PATH_TRANSLATED => /srv/home/james/workspace/php-src-5.4/ext/snmp/tests    /snmp_read_mib.php
  SHLVL => 1
  _ => ./sapi/cli/php

  Any other idea how to modify the MIB variable?

b) I propose to extract the snmpd config settings into a test-snmpd.conf and put the command line to execute the daemon with this file into the README. Saves the users from trying to figure out how to start snmpd.
In addition the below contains IPv6 IPs as well:

 $ cat ext/snmp/tests/test-snmpd.conf
 # Listen for connections from the local system only
 # Listen for connections on all interfaces (both IPv4 *and* IPv6)
 agentAddress udp:,udp6:[::1]:161

 rocommunity public
 rwcommunity private

 rwcommunity6 private ::1
 rocommunity6 public ::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

And the snmpd command line would be:
  sudo snmpd -C -c test-snmpd.conf -f -Le


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-23 19:13 UTC]
Automatic comment from SVN on behalf of lytboris
Log: apply docs fixes suggested in BR #55474
 [2011-08-23 19:14 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: lytboris
 [2011-08-23 19:14 UTC]
a) It is a strange command line for running tests, not sure it is quite correct.

It is better to use something like
make -C ../.. lcov TESTS="`cd ../..; /bin/ls -1 ext/snmp/tests/*.phpt | xargs echo`"
This honors your environment variables for sure.

b) Applied, thanks.
 [2011-08-23 19:15 UTC]
Automatic comment from SVN on behalf of lytboris
Log: apply docs fixes suggested in BR #55474
 [2011-08-24 22:40 UTC]
"run-tests.php" is the way described in /README.TESTS :) It's probably faster as it does not produce a coverage report and maybe more reproducible because it clears the environment variables.

As one of you tests (snmp_read_mibs.phpt) makes use of an environment variable though, it couldn't hurt to add your "make" line under "*** How to test ***".

Anyway thanks for applying the other pach, the bug report can be closed then.
 [2011-08-25 06:00 UTC]
Automatic comment from SVN on behalf of lytboris
Log: tune test's README more per FR #55474
 [2011-08-25 06:01 UTC]
-Status: Feedback +Status: Closed
 [2011-08-25 06:01 UTC]
Commited, thanks.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 15 20:01:29 2024 UTC