Bug 1325

Summary: Python examples get valgrind errors when build subdirectories are specified in waf
Product: ns-3 Reporter: Mitch Watrous <watrous>
Component: build systemAssignee: Gustavo J. A. M. Carneiro <gjcarneiro>
Status: RESOLVED FIXED    
Severity: normal CC: ns-bugs, watrous
Priority: P5    
Version: pre-release   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 1326    

Description Mitch Watrous 2011-12-28 15:24:51 UTC
In test.py, Python examples get valgrind errors when build subdirectories are specified in waf configure.

To reproduce this bug do the following steps:

    hg clone http://code.nsnam.org/ns-3-allinone
    cd ns-3-allinone/
    ./download.py 
    ./build.py --enable-examples --enable-tests
    cd ns-3-dev/
    rm -rf build
    ./waf configure --enable-examples --enable-tests --out=build/debug -d debug
    ./waf build
    ./test.py 

These Python tests fail in test.py:

    VALGR: Example examples/routing/simple-routing-ping6.py
    VALGR: Example examples/wireless/wifi-ap.py
    VALGR: Example examples/wireless/mixed-wireless.py
    VALGR: Example examples/tutorial/first.py
    VALGR: Example src/bridge/examples/csma-bridge.py
    VALGR: Example src/core/examples/sample-simulator.py
    VALGR: Example src/flow-monitor/examples/wifi-olsr-flowmon.py
    ...
    166 of 173 tests passed (166 passed, 0 skipped, 0 failed, 0 crashed, 7 valgrind errors)
Comment 1 Gustavo J. A. M. Carneiro 2011-12-29 05:57:20 UTC
I think, python examples get valgrind errors, period.  They always have and they always will.  It's a problem with valgrind/python interaction.  In the past, we had disabled valgrind for python programs, I don't know why they're using valgrind again...
Comment 2 Mitch Watrous 2011-12-29 12:07:59 UTC
The problem is that I am not running test.py using valgrind, i.e. I just did this

    ./test.py
Comment 3 Gustavo J. A. M. Carneiro 2012-02-15 10:58:36 UTC
It sounds like there is some logic bug in test.py that causes it to simply not find the correct path the python scripts to run.  It has nothing to do with valgrind.

---------- begin standard err ----------
/usr/bin/python: can't open file '/home/gjc/projects/ns/ns-3-allinone/ns-3-dev/build/examples/routing/simple-routing-ping6.py': [Errno 2] No such file or directory
Comment 4 Gustavo J. A. M. Carneiro 2012-02-15 12:24:20 UTC
The problem is here:

def run_job_synchronously(shell_command, directory, basedir, valgrind, is_python, build_path=""):
    (base, build) = os.path.split (NS3_BUILDDIR)

This test.py program could really use some refactoring: all the needed paths are in the Job object, this run_job_synchronously should be a method of Job, not a function, to get access to all the attributes.
Comment 5 Mitch Watrous 2012-02-16 22:31:07 UTC
(In reply to comment #4)
> The problem is here:
> 
> def run_job_synchronously(shell_command, directory, basedir, valgrind,
> is_python, build_path=""):
>     (base, build) = os.path.split (NS3_BUILDDIR)
> 
> This test.py program could really use some refactoring: all the needed paths
> are in the Job object, this run_job_synchronously should be a method of Job,
> not a function, to get access to all the attributes.

What exactly is the problem in that function?
Comment 6 Gustavo J. A. M. Carneiro 2012-02-17 06:10:11 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > The problem is here:
> > 
> > def run_job_synchronously(shell_command, directory, basedir, valgrind,
> > is_python, build_path=""):
> >     (base, build) = os.path.split (NS3_BUILDDIR)
> > 
> > This test.py program could really use some refactoring: all the needed paths
> > are in the Job object, this run_job_synchronously should be a method of Job,
> > not a function, to get access to all the attributes.
> 
> What exactly is the problem in that function?

With NS3_BUILDDIR=/foo/bar/ns-3-dev/build/debug,  the statement:

(base, build) = os.path.split (NS3_BUILDDIR)

gets:

base=/foo/bar/ns-3-dev/build
build=debug

This is why the python script is not found, it is constructed as <base>/python-script.py.

It is funny because the Job objects defined in test.py already have a base attribute which is correctly defined as /foo/bar/ns-3-dev.  It's just that the run_job_synchronously is not using the Job attributes, it is reinventing the wheel.
Comment 7 Mitch Watrous 2012-02-17 14:51:46 UTC
Bug closed.

ns-3-dev changeset: 6b3d1a5495f7