git » libfiu » commit 4c3fe05

tests/utils: Set LC_ALL=C for tests that are locale-dependant

author Alberto Bertogli
2015-09-24 03:46:00 UTC
committer Alberto Bertogli
2015-09-24 03:46:00 UTC
parent 6a7a14a04ace6cc9d9e6f3a31c8c055488cbaec6

tests/utils: Set LC_ALL=C for tests that are locale-dependant

The test-basic_ctrl.py test is locale dependant, as it checks the output
of cat for the word "error", which only works on certain locales.

This patch fixes the locale to "C" which should be more reliable and
reproducible, and while at it increase the logging in case of errors so
these kind of problems are easy to detect.

Thanks to Chris Lamb for finding and reporting the problem.

tests/utils/test-basic_ctrl.py +8 -4

diff --git a/tests/utils/test-basic_ctrl.py b/tests/utils/test-basic_ctrl.py
index e21cb35..4723d8d 100755
--- a/tests/utils/test-basic_ctrl.py
+++ b/tests/utils/test-basic_ctrl.py
@@ -1,5 +1,6 @@
 #!/usr/bin/env python
 
+import os
 import subprocess
 import time
 
@@ -11,9 +12,12 @@ def launch_sh():
     # straightforward (which helps debugging and troubleshooting), but at the
     # same time it is interactive and we can make it do the operations we
     # want.
+    # We also set LC_ALL=C as we test the output for the word "error", which
+    # does not necessarily appear in other languages.
     p = subprocess.Popen("./wrap fiu-run -x cat".split(),
             stdin=subprocess.PIPE, stdout=subprocess.PIPE,
-            stderr=subprocess.PIPE)
+            stderr=subprocess.PIPE,
+            env=dict(os.environ, LC_ALL="C"))
 
     # Give it a moment to initialize and create the control files.
     time.sleep(0.2)
@@ -45,19 +49,19 @@ p = launch_sh()
 fiu_ctrl(p, ["-c", "enable name=posix/io/*"])
 out, err = send_cmd(p, "test\n")
 assert out == '', out
-assert 'error' in err
+assert 'error' in err, err
 
 # Same, but with failinfo.
 p = launch_sh()
 fiu_ctrl(p, ["-c", "enable name=posix/io/*,failinfo=3"])
 out, err = send_cmd(p, "test\n")
 assert out == '', out
-assert 'error' in err
+assert 'error' in err, err
 
 # Same, but with probability.
 p = launch_sh()
 fiu_ctrl(p, ["-c", "enable_random name=posix/io/*,probability=0.999"])
 out, err = send_cmd(p, "test\n")
 assert out == '', out
-assert 'error' in err
+assert 'error' in err, err