Skip to content
Snippets Groups Projects
Commit d45b2e7c authored by Monty Brandenberg's avatar Monty Brandenberg
Browse files

SH-3183 Use valgrind on the library.

Using http_texture_load as the test subject, library looks clean.  Did
some better shutdown in the program itself and it looks better.  Libcurl
itself is making a lot of noise.  Adapted testrunner to run valgrind as
well but the memory allocation tester in the tools themselves grossly
interferes with Valgrind operations.
parent 7010459f
No related branches found
No related tags found
No related merge requests found
...@@ -269,7 +269,10 @@ int main(int argc, char** argv) ...@@ -269,7 +269,10 @@ int main(int argc, char** argv)
<< std::endl; << std::endl;
// Clean up // Clean up
hr->requestStopThread(NULL);
ms_sleep(1000);
delete hr; delete hr;
LLCore::HttpRequest::destroyService();
term_curl(); term_curl();
return 0; return 0;
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
import sys import sys
import time import time
import select import select
import getopt
from threading import Thread from threading import Thread
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from SocketServer import ThreadingMixIn from SocketServer import ThreadingMixIn
...@@ -152,6 +153,13 @@ class Server(ThreadingMixIn, HTTPServer): ...@@ -152,6 +153,13 @@ class Server(ThreadingMixIn, HTTPServer):
allow_reuse_address = False allow_reuse_address = False
if __name__ == "__main__": if __name__ == "__main__":
do_valgrind = False
path_search = False
options, args = getopt.getopt(sys.argv[1:], "V", ["valgrind"])
for option, value in options:
if option == "-V" or option == "--valgrind":
do_valgrind = True
# Instantiate a Server(TestHTTPRequestHandler) on the first free port # Instantiate a Server(TestHTTPRequestHandler) on the first free port
# in the specified port range. Doing this inline is better than in a # in the specified port range. Doing this inline is better than in a
# daemon thread: if it blows up here, we'll get a traceback. If it blew up # daemon thread: if it blows up here, we'll get a traceback. If it blew up
...@@ -159,10 +167,14 @@ class Server(ThreadingMixIn, HTTPServer): ...@@ -159,10 +167,14 @@ class Server(ThreadingMixIn, HTTPServer):
# subject test program anyway. # subject test program anyway.
httpd, port = freeport(xrange(8000, 8020), httpd, port = freeport(xrange(8000, 8020),
lambda port: Server(('127.0.0.1', port), TestHTTPRequestHandler)) lambda port: Server(('127.0.0.1', port), TestHTTPRequestHandler))
# Pass the selected port number to the subject test program via the # Pass the selected port number to the subject test program via the
# environment. We don't want to impose requirements on the test program's # environment. We don't want to impose requirements on the test program's
# command-line parsing -- and anyway, for C++ integration tests, that's # command-line parsing -- and anyway, for C++ integration tests, that's
# performed in TUT code rather than our own. # performed in TUT code rather than our own.
os.environ["LL_TEST_PORT"] = str(port) os.environ["LL_TEST_PORT"] = str(port)
debug("$LL_TEST_PORT = %s", port) debug("$LL_TEST_PORT = %s", port)
sys.exit(run(server=Thread(name="httpd", target=httpd.serve_forever), *sys.argv[1:])) if do_valgrind:
args = ["valgrind", "--log-file=./valgrind.log"] + args
path_search = True
sys.exit(run(server=Thread(name="httpd", target=httpd.serve_forever), use_path=path_search, *args))
...@@ -168,7 +168,10 @@ def run(*args, **kwds): ...@@ -168,7 +168,10 @@ def run(*args, **kwds):
# executable passed as our first arg, # executable passed as our first arg,
# - [no e] child should inherit this process's environment. # - [no e] child should inherit this process's environment.
debug("Running %s...", " ".join(args)) debug("Running %s...", " ".join(args))
rc = os.spawnv(os.P_WAIT, args[0], args) if kwds.get("use_path", False):
rc = os.spawnvp(os.P_WAIT, args[0], args)
else:
rc = os.spawnv(os.P_WAIT, args[0], args)
debug("%s returned %s", args[0], rc) debug("%s returned %s", args[0], rc)
return rc return rc
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment