From b7a3cb6b74850ef71fbbeacbee63df791caba626 Mon Sep 17 00:00:00 2001 From: Martin Klozik Date: Wed, 9 Dec 2015 12:53:43 +0000 Subject: bugfix: Fix failure caused by unset locale In case, that VSPERF detects missing locale settings, it will set language and encodding settings to default values specified by configuration parameter DEFAULT_LOCALE. Localized external commands with output parsed by VSPERF are executed with modified locale to ensure correct VSPERF function. Locale settings for such commands is specified by configuration parameter DEFAULT_CMD_LOCALE. Change-Id: If5c15115b778ce90046e390f10438b780f82695b JIRA: VSPERF-132 Signed-off-by: Martin Klozik Reviewed-by: Maryam Tahhan Reviewed-by: Al Morton Reviewed-by: Brian Castelli Reviewed-by: Gurpreet Singh Reviewed-by: Tv Rao --- vsperf | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'vsperf') diff --git a/vsperf b/vsperf index f6ddc637..2f85fba5 100755 --- a/vsperf +++ b/vsperf @@ -26,6 +26,7 @@ import datetime import shutil import unittest import xmlrunner +import locale sys.dont_write_bytecode = True @@ -237,6 +238,17 @@ def apply_filter(tests, tc_filter): return result +def check_and_set_locale(): + """ Function will check locale settings. In case, that it isn't configured + properly, then default values specified by DEFAULT_LOCALE will be used. + """ + + system_locale = locale.getdefaultlocale() + if None in system_locale: + os.environ['LC_ALL'] = settings.getValue('DEFAULT_LOCALE') + logging.warning("Locale was not properly configured. Default values were set. Old locale: %s, New locale: %s", + system_locale, locale.getdefaultlocale()) + class MockTestCase(unittest.TestCase): """Allow use of xmlrunner to generate Jenkins compatible output without using xmlrunner to actually run tests. @@ -309,6 +321,9 @@ def main(): configure_logging(settings.getValue('VERBOSITY')) logger = logging.getLogger() + # check and fix locale + check_and_set_locale() + # configure trafficgens if args['trafficgen']: -- cgit 1.2.3-korg