Bugzilla – Bug 1120
NS_LOG environment variable not working with test.py
Last modified: 2011-07-05 16:29:12 UTC
Currently it is not possible to do the following: NS_LOG=MyLogComponent ./test.py -s my-test-suite Hence, to turn on loggin in test programs I have to hardcode "LogComponentEnable" statements in the test code. This makes it more time consuming to debug tests. This is an enhancement request, but I think we should give it high priority, because based on my opinion if writing tests is too complex then people won't write many tests.
Here is what test.py says and does: # If lots of logging is enabled, we can crash Python when it tries to # save all of the text. We just don't allow logging to be turned on when # test.py runs. If you want to see logging output from your tests, you # have to run them using the test-runner directly. # os.environ["NS_LOG"] = "" Try running the test using the test-runner like this: ./waf --run "test-runner --basedir=`pwd` --suite=my-test-suite" and see if logging works . If you want to see what happened when your test ran, send the output to an XML file like this: ./waf --run "test-runner --basedir=`pwd` --suite=my-test-suite --out=my-test-suite-result.xml" Does this let you do the logging you need?
(In reply to comment #1) > Here is what test.py says and does: > > # If lots of logging is enabled, we can crash Python when it tries to > # save all of the text. We just don't allow logging to be turned on when > # test.py runs. If you want to see logging output from your tests, you > # have to run them using the test-runner directly. > # > os.environ["NS_LOG"] = "" > > Try running the test using the test-runner like this: > > ./waf --run "test-runner --basedir=`pwd` --suite=my-test-suite" > > and see if logging works . > > If you want to see what happened when your test ran, send the output to an XML > file like this: > > ./waf --run "test-runner --basedir=`pwd` --suite=my-test-suite > --out=my-test-suite-result.xml" > > Does this let you do the logging you need? This is exactly right. We used to have logging possible during tests, but it led to other bugs. See https://www.nsnam.org/bugzilla/0
I understand, but this behavior is not documented at all. My experience is that for people that are writing a test for the first time it is a pain to find out how to debug it. Hence I think we should document this feature.
Created attachment 1186 [details] document how to debug tests by enabling logging here is a proposed patch to the documentation that adds some minimum of information regarding this issue.
Patch applied. Thanks. Bug closed. ns-3-dev changeset: 99762b541ef9