gdb/testsuite: check the python module is available before using it

The gdb.python/py-inferior-leak.exp test makes use of the tracemalloc
module.  When running the Python tests with a GDB built against Python
2 I ran into a test failure due to the tracemalloc module not being
available.

This commit adds a new helper function to lib/gdb-python.exp that
checks if a named module is available.  Using this we can then skip
the py-inferior-leak.exp test when the tracemalloc module is not
available.
2 files changed