Bug 2290

Summary: cannot run click examples from test.py
Product: ns-3 Reporter: Tom Henderson <tomh>
Component: clickAssignee: Lalith Suresh <suresh.lalith>
Status: RESOLVED FIXED    
Severity: normal CC: ns-bugs, tommaso.pecorella
Priority: P5    
Version: unspecified   
Hardware: PC   
OS: Linux   

Description Tom Henderson 2016-02-09 02:10:54 UTC
when running an example, test.py runs it from an execution directory within testpy-output directory, not from the top level directory.  As a result, the click configuration files, specified with relative directory paths, cannot be found and the programs exit with error.

One possible solution is to add a command-line option to allow specification of the click configuration file path.  This could be done for all of the click examples.

the test disabled in changeset d424a522c2fc should be re-enabled when this is fixed (also should enable other examples too).
Comment 1 Tommaso Pecorella 2016-02-09 17:36:58 UTC
A little more bit of info.

Weird enough, the test doesn't run on Mac. I mean, it doesn't show among the available ones. No idea if it's failing or not.

MacOS:
23:29:44:~/Development/workspace/ns-3-dev pecos$ ./test.py -l | grep click
bridge                    buildings                 click                     
23:33:08:~/Development/workspace/ns-3-dev pecos$ 

Linux:

pecos@nightwatch ~/workspace/ns-3-allinone/ns-3-dev $ ./test.py -l | grep click
bridge                    buildings                 click                     
unit         routing-click
example      nsclick-simple-lan

Another wird thing is the example. If I try to run it (forcefully), it tries it best, but it crashes. The crash doesn't seems to be strictly related to a configuration path tho...

Enabling verbose mode shows the reason:

os.environ["PYTHONPATH"] == /Users/pecos/Development/workspace/ns-3-dev/build/bindings/python
os.environ["DYLD_LIBRARY_PATH"] == :/Users/pecos/Development/workspace/ns-3-dev/build:/Users/pecos/Development/workspace/click/lib:/Users/pecos/Development/workspace/click/ns
Synchronously execute /Users/pecos/Development/workspace/ns-3-dev/build/utils/ns3-dev-test-runner-debug --print-test-name-list --test-type=performance
Return code =  -5
stderr =  dyld: Library not loaded: libnsclick.dylib
  Referenced from: /Users/pecos/Development/workspace/ns-3-dev/build/utils/ns3-dev-test-runner-debug
  Reason: image not found


In other terms, the library is not found, because it's not in the right place.
Note that the examples are working if I run click from the main directory...
Comment 2 Tom Henderson 2016-02-09 17:53:41 UTC
> In other terms, the library is not found, because it's not in the right
> place.
> Note that the examples are working if I run click from the main directory...

I think that if you get past that problem, you will hit the configuration file path issue next.

Perhaps there is an issue of test.py inheriting DYLD_LIBRARY_PATH environment value (vs. LD_LIBRARY_PATH)?  I haven't tried on OS X so am unsure.
Comment 3 Tommaso Pecorella 2016-02-09 18:15:00 UTC
(In reply to Tom Henderson from comment #2)
> > In other terms, the library is not found, because it's not in the right
> > place.
> > Note that the examples are working if I run click from the main directory...
> 
> I think that if you get past that problem, you will hit the configuration
> file path issue next.
> 
> Perhaps there is an issue of test.py inheriting DYLD_LIBRARY_PATH
> environment value (vs. LD_LIBRARY_PATH)?  I haven't tried on OS X so am
> unsure.

I'm sure that I'll face the path problem next, but 1st things first.
I tried to launch test-runner directly, with the same result. This is after opening a waf shell (so the environment variables are set).

PYTHONPATH=/Users/pecos/Development/workspace/ns-3-dev/build/bindings/python:/Users/pecos/Development/workspace/ns-3-dev/src/visualizer
MACOSX_DEPLOYMENT_TARGET=10.11
LOGNAME=pecos
VERSIONER_PYTHON_PREFER_32_BIT=no
DISPLAY=/private/tmp/com.apple.launchd.XyV6kJ51qN/org.macosforge.xquartz:0
SECURITYSESSIONID=186a8
NS3_MODULE_PATH=/Users/pecos/Development/workspace/ns-3-dev/build:/Users/pecos/Development/workspace/click/lib:/Users/pecos/Development/workspace/click/ns
23:57:56:~/Development/workspace/ns-3-dev pecos$ ./build/utils/ns3-dev-test-runner-debug --test-name=routing-click
dyld: Library not loaded: libnsclick.dylib
  Referenced from: /Users/pecos/Development/workspace/ns-3-dev/./build/utils/ns3-dev-test-runner-debug
  Reason: image not found
Trace/BPT trap: 5
23:59:43:~/Development/workspace/ns-3-dev pecos$ ls ../click/ns/*.dylib
../click/ns/libnsclick.dylib
00:01:17:~/Development/workspace/ns-3-dev pecos$ 

Adding this line seems to fix the problem, but only if you use test-runner directly:
export DYLD_LIBRARY_PATH=/Users/pecos/Development/workspace/click/ns/
test.py seems to clean up the DYLD environment 

Sorry, but I'm not very good with environment and path stuff...
Comment 4 Lalith Suresh 2016-02-10 07:34:16 UTC
Fixed.

changeset:   11874:a3411e1a604d
tag:         tip
user:        Lalith Suresh <suresh.lalith@gmail.com>
date:        Wed Feb 10 13:31:30 2016 +0100
summary:     click: fixes Bug 2290 - cannot run click examples from test.py

@Tommaso: I don't have a fix for what you found, since I don't have a mac to try this out on. Do you want to open another bug report?