Build gtest output paths correctly 23/23323/2
authorMats Wichmann <mats@linux.com>
Sun, 5 Nov 2017 16:08:49 +0000 (09:08 -0700)
committerMats Wichmann <mats@linux.com>
Thu, 25 Jan 2018 18:30:17 +0000 (18:30 +0000)
Currently, when the run_tests function is called twice from the
the same scons script (that is, the script has more than one unit
test binary to register), the GTEST_OUTPUT environment variable
becomes malformed.  This is because the string to add is added
to a list instead of just being appended as a string.  The result
is that while all the test output binaries are expected to go to
BUILD_DIR/test_out, in these cases they go deep down underneath
that directory.  Here are the unexpected paths in an unmodified
testing run:

out/linux/x86_64/debug/test_out/:xml:
out/linux/x86_64/debug/test_out/:xml:/home
out/linux/x86_64/debug/test_out/:xml:/home/mats
out/linux/x86_64/debug/test_out/:xml:/home/mats/iotivity.work
out/linux/x86_64/debug/test_out/:xml:/home/mats/iotivity.work/out
out/linux/x86_64/debug/test_out/:xml:/home/mats/iotivity.work/out/linux
out/linux/x86_64/debug/test_out/:xml:/home/mats/iotivity.work/out/linux/x86_64
out/linux/x86_64/debug/test_out/:xml:/home/mats/iotivity.work/out/linux/x86_64/debug
out/linux/x86_64/debug/test_out/:xml:/home/mats/iotivity.work/out/linux/x86_64/debug/test_out
out/linux/x86_64/debug/test_out/:xml:/home/mats/iotivity.work/out/linux/x86_64/debug/test_out/unittest.xml
out/linux/x86_64/debug/test_out/:xml:/home/mats/iotivity.work/out/linux/x86_64/debug/test_out/stacktests.xml
out/linux/x86_64/debug/test_out/:xml:/home/mats/iotivity.work/out/linux/x86_64/debug/test_out/cbortests.xml
out/linux/x86_64/debug/test_out/:xml:/home/mats/iotivity.work/out/linux/x86_64/debug/test_out/provisiontests.xml

The :xml: is intended as a tag used to signal gtest, it is never
supposed to be part of the real filesystem path.

Note fix was already proposed as part of
https://gerrit.iotivity.org/gerrit/#/c/22275/ but since it's a
distinct error with a very simple fix, wanted to get it pushed
through by itself while that one is under consideration.

Change-Id: I05c57d54034686a7c77c783eab758e7f501e86ea
Signed-off-by: Mats Wichmann <mats@linux.com>
(cherry picked from commit 0d010e4b64ff853fefb6e55038e6ecaa072fc760)

tools/scons/RunTest.py

index 1cd516c..54c3aae 100644 (file)
@@ -34,8 +34,7 @@ def run_test(env, xml_file, test, test_targets = ['test']):
     if not os.path.isdir(result_dir):
         os.makedirs(result_dir)
 
-    # Dump test report in XML format to the results directory.
-    env.AppendENVPath('GTEST_OUTPUT', ['xml:' + result_dir])
+    env.AppendENVPath('GTEST_OUTPUT', 'xml:' + result_dir, delete_existing=0)
 
     # Make sure the Google Test libraries are in the dynamic
     # linker/loader path.