php.net |  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: ch@php.net Assigned: lytboris (profile)
Status: Closed Package: SNMP related
PHP Version: 5.4.0alpha3 OS: Debian Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ch@php.net
New email:
PHP Version: OS:

 

 [2011-08-21 22:55 UTC] ch@php.net
Description:
------------
Hello

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
ZEND_VERSION: 2.4.0
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
=====================================================================

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
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:
  Environment

  Variable => Value
  SCRIPT_FILENAME => /srv/home/james/workspace/php-src-5.4/ext/snmp/tests/snmp_read_mib.php
  USE_ZEND_ALLOC => 1
  PWD => /srv/home/james/workspace/php-src-5.4
  TEST_PHP_EXECUTABLE => ./sapi/cli/php
  REDIRECT_STATUS => 1
  PATH_TRANSLATED => /srv/home/james/workspace/php-src-5.4/ext/snmp/tests    /snmp_read_mib.php
  SHLVL => 1
  REQUEST_METHOD => GET
  _ => ./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:127.0.0.1:161,udp6:[::1]:161

 rocommunity public 127.0.0.1
 rwcommunity private 127.0.0.1

 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



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-23 19:13 UTC] lytboris@php.net
Automatic comment from SVN on behalf of lytboris
Revision: http://svn.php.net/viewvc/?view=revision&revision=315386
Log: apply docs fixes suggested in BR #55474
 [2011-08-23 19:14 UTC] lytboris@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: lytboris
 [2011-08-23 19:14 UTC] lytboris@php.net
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] lytboris@php.net
Automatic comment from SVN on behalf of lytboris
Revision: http://svn.php.net/viewvc/?view=revision&revision=315387
Log: apply docs fixes suggested in BR #55474
 [2011-08-24 22:40 UTC] ch@php.net
"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] lytboris@php.net
Automatic comment from SVN on behalf of lytboris
Revision: http://svn.php.net/viewvc/?view=revision&revision=315461
Log: tune test's README more per FR #55474
 [2011-08-25 06:01 UTC] lytboris@php.net
-Status: Feedback +Status: Closed
 [2011-08-25 06:01 UTC] lytboris@php.net
Commited, thanks.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 13 00:01:32 2024 UTC