From 5e11376609fb4a994fbf344e337cadcfc914c2c0 Mon Sep 17 00:00:00 2001 From: LeoHsiao Date: Sun, 18 Oct 2020 21:07:35 +0800 Subject: [PATCH 01/14] Supports setting EXIV2_HTTP or EXIV2_PORT to '' to ignore HTTP test --- tests/bash_tests/testcases.py | 22 ++++++++++++++-------- tests/bash_tests/utils.py | 2 +- tests/system_tests.py | 14 ++++++-------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/tests/bash_tests/testcases.py b/tests/bash_tests/testcases.py index e1ab86bb..951fb31b 100644 --- a/tests/bash_tests/testcases.py +++ b/tests/bash_tests/testcases.py @@ -564,22 +564,28 @@ set Exif.Photo.DateTimeDigitized 2020:05:26 07:31:42 def io_test(self): # Test driver for file i/o - test_files = ['table.jpg', 'smiley2.jpg', 'ext.dat'] + test_files = ['table.jpg', 'smiley2.jpg', 'ext.dat'] for f in test_files: BT.copyTestFile(f) BT.ioTest(f) # Test http I/O def sniff(*files): - result = [str(os.path.getsize(i)) for i in files] - result += [BT.md5sum(i) for i in files] + result = [str(os.path.getsize(i)) for i in files] + result += [BT.md5sum(i) for i in files] return ' '.join(result) - server_url = '{}:{}'.format(BT.Config.exiv2_http, - BT.Config.exiv2_port) - server = BT.HttpServer(bind=BT.Config.exiv2_http.lstrip('http://'), - port=BT.Config.exiv2_port, - work_dir=BT.Config.data_dir) + exiv2_http = BT.Config.exiv2_http + exiv2_port = BT.Config.exiv2_port + if not exiv2_http or not exiv2_port: + print('Skipped http test. Because of invalid environment variables: EXIV2_HTTP={} EXIV2_PORT={}'.format( + exiv2_http, exiv2_port)) + return + server_url = '{}:{}'.format(exiv2_http, + exiv2_port) + server = BT.HttpServer(bind=exiv2_http.lstrip('http://'), + port=exiv2_port, # It can be of type int or str + work_dir=BT.Config.data_dir) try: server.start() out = BT.Output() diff --git a/tests/bash_tests/utils.py b/tests/bash_tests/utils.py index baa6ee9a..92ac225c 100644 --- a/tests/bash_tests/utils.py +++ b/tests/bash_tests/utils.py @@ -27,7 +27,7 @@ class Config: tmp_dir = os.path.join(exiv2_dir, 'test/tmp') system_name = platform.system() or 'Unknown' # It could be Windows, Linux, etc. exiv2_http = 'http://127.0.0.1' - exiv2_port = 12760 + exiv2_port = '12760' @classmethod def init(cls): diff --git a/tests/system_tests.py b/tests/system_tests.py index 40dc1e77..e67c7c71 100644 --- a/tests/system_tests.py +++ b/tests/system_tests.py @@ -154,13 +154,12 @@ def configure_suite(config_file): ) ) - # extract variables from the environment + # Extract the environment variables according to config['ENV']. + # When an environment variable does not exist, set its default value according to config['ENV fallback']. for key in config['ENV']: - if key in config['ENV fallback']: - fallback = config['ENV fallback'][key] - else: - fallback = "" - config['ENV'][key] = os.getenv(config['ENV'][key]) or fallback + env_name = config['ENV'][key] + env_fallback = config['ENV fallback'].get(key, '') + config['ENV'][key] = os.environ.get(env_name, env_fallback) if 'variables' in config: for key in config['variables']: @@ -206,8 +205,7 @@ def configure_suite(config_file): BT.Config.data_dir = os.path.abspath(config['paths']['data_path']) BT.Config.tmp_dir = os.path.abspath(config['paths']['tmp_path']) BT.Config.exiv2_http = config['ENV']['exiv2_http'] - BT.Config.exiv2_port = int(config['ENV']['exiv2_port']) - # print(dict(config['ENV'])); exit(1) # for debug + BT.Config.exiv2_port = config['ENV']['exiv2_port'] class FileDecoratorBase(object): From ded2b3c9a32d77b6f218770bb0626aa8b74315f5 Mon Sep 17 00:00:00 2001 From: LeoHsiao Date: Wed, 21 Oct 2020 20:45:13 +0800 Subject: [PATCH 02/14] Support to display the command to execute --- tests/bash_tests/utils.py | 6 ++++++ tests/suite.conf | 5 ++++- tests/system_tests.py | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/bash_tests/utils.py b/tests/bash_tests/utils.py index 92ac225c..6a916a03 100644 --- a/tests/bash_tests/utils.py +++ b/tests/bash_tests/utils.py @@ -28,6 +28,8 @@ class Config: system_name = platform.system() or 'Unknown' # It could be Windows, Linux, etc. exiv2_http = 'http://127.0.0.1' exiv2_port = '12760' + exiv2_echo = '' + valgrind = '++' @classmethod def init(cls): @@ -453,6 +455,10 @@ class Executer: self.run() def run(self): + # Whether to display the command to execute + if Config.exiv2_echo: + print(Config.valgrind, ' '.join(self.args)) + # Check stdout if self.redirect_stderr_to_stdout: stderr = subprocess.STDOUT diff --git a/tests/suite.conf b/tests/suite.conf index 719d5096..319f60d0 100644 --- a/tests/suite.conf +++ b/tests/suite.conf @@ -4,14 +4,17 @@ memcheck: ${ENV:valgrind} [ENV] exiv2_path: EXIV2_BINDIR -valgrind: EXIV2_VALGRIND exiv2_http: EXIV2_HTTP exiv2_port: EXIV2_PORT +exiv2_echo: EXIV2_ECHO +valgrind: VALGRIND [ENV fallback] exiv2_path: ../build/bin exiv2_http: http://127.0.0.1 exiv2_port: 12760 +exiv2_echo: +valgrind: ++ [paths] exiv2: ${ENV:exiv2_path}/exiv2 diff --git a/tests/system_tests.py b/tests/system_tests.py index e67c7c71..5086578b 100644 --- a/tests/system_tests.py +++ b/tests/system_tests.py @@ -206,6 +206,8 @@ def configure_suite(config_file): BT.Config.tmp_dir = os.path.abspath(config['paths']['tmp_path']) BT.Config.exiv2_http = config['ENV']['exiv2_http'] BT.Config.exiv2_port = config['ENV']['exiv2_port'] + BT.Config.exiv2_echo = config['ENV']['exiv2_echo'] + BT.Config.valgrind = config['ENV']['valgrind'] class FileDecoratorBase(object): From 3aedb605130c767d214f397ae98274306e94cde0 Mon Sep 17 00:00:00 2001 From: LeoHsiao Date: Wed, 21 Oct 2020 20:58:51 +0800 Subject: [PATCH 03/14] Support variables: DYLD_LIBRARY_PATH, LD_LIBRARY_PATH --- tests/bash_tests/utils.py | 23 ++++++++++++++--------- tests/suite.conf | 6 ++++++ tests/system_tests.py | 16 +++++++++------- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/tests/bash_tests/utils.py b/tests/bash_tests/utils.py index 6a916a03..19d27441 100644 --- a/tests/bash_tests/utils.py +++ b/tests/bash_tests/utils.py @@ -21,15 +21,18 @@ Here is the configuration part of test cases. class Config: # The configuration parameters for bash test # When you run the test cases through `python3 runner.py`, the function configure_suite() in system_tests.py will override these parameters. - exiv2_dir = os.path.normpath(os.path.join(os.path.abspath(__file__), '../../../')) - bin_dir = os.path.join(exiv2_dir, 'build/bin') - data_dir = os.path.join(exiv2_dir, 'test/data') - tmp_dir = os.path.join(exiv2_dir, 'test/tmp') - system_name = platform.system() or 'Unknown' # It could be Windows, Linux, etc. - exiv2_http = 'http://127.0.0.1' - exiv2_port = '12760' - exiv2_echo = '' - valgrind = '++' + exiv2_dir = os.path.normpath(os.path.join(os.path.abspath(__file__), '../../../')) + bin_dir = os.path.join(exiv2_dir, 'build/bin') + dyld_library_path = os.path.join(bin_dir, '../lib') + ld_library_path = os.path.join(bin_dir, '../lib') + data_dir = os.path.join(exiv2_dir, 'test/data') + tmp_dir = os.path.join(exiv2_dir, 'test/tmp') + system_name = platform.system() or 'Unknown' # It could be Windows, Linux, etc. + exiv2_http = 'http://127.0.0.1' + exiv2_port = '12760' + exiv2_echo = '' + valgrind = '++' + # verbose: @classmethod def init(cls): @@ -424,6 +427,8 @@ class Executer: # set environment variables self.env = os.environ.copy() + self.env.update({'DYLD_LIBRARY_PATH': Config.dyld_library_path}) + self.env.update({'LD_LIBRARY_PATH': Config.ld_library_path}) self.env.update({'TZ': 'GMT-8'}) self.env.update(extra_env) diff --git a/tests/suite.conf b/tests/suite.conf index 319f60d0..9e993e6f 100644 --- a/tests/suite.conf +++ b/tests/suite.conf @@ -4,17 +4,23 @@ memcheck: ${ENV:valgrind} [ENV] exiv2_path: EXIV2_BINDIR +dyld_library_path: DYLD_LIBRARY_PATH +ld_library_path: LD_LIBRARY_PATH exiv2_http: EXIV2_HTTP exiv2_port: EXIV2_PORT exiv2_echo: EXIV2_ECHO valgrind: VALGRIND +# verbose: VERBOSE [ENV fallback] exiv2_path: ../build/bin +dyld_library_path: ${ENV:exiv2_path}/../lib +ld_library_path: ${ENV:exiv2_path}/../lib exiv2_http: http://127.0.0.1 exiv2_port: 12760 exiv2_echo: valgrind: ++ +# verbose: [paths] exiv2: ${ENV:exiv2_path}/exiv2 diff --git a/tests/system_tests.py b/tests/system_tests.py index 5086578b..d18e4df0 100644 --- a/tests/system_tests.py +++ b/tests/system_tests.py @@ -201,13 +201,15 @@ def configure_suite(config_file): ) # Configure the parameters for bash tests - BT.Config.bin_dir = os.path.abspath(config['ENV']['exiv2_path']) - BT.Config.data_dir = os.path.abspath(config['paths']['data_path']) - BT.Config.tmp_dir = os.path.abspath(config['paths']['tmp_path']) - BT.Config.exiv2_http = config['ENV']['exiv2_http'] - BT.Config.exiv2_port = config['ENV']['exiv2_port'] - BT.Config.exiv2_echo = config['ENV']['exiv2_echo'] - BT.Config.valgrind = config['ENV']['valgrind'] + BT.Config.bin_dir = os.path.abspath(config['ENV']['exiv2_path']) + BT.Config.dyld_library_path = os.path.abspath(config['ENV']['dyld_library_path']) + BT.Config.ld_library_path = os.path.abspath(config['ENV']['ld_library_path']) + BT.Config.data_dir = os.path.abspath(config['paths']['data_path']) + BT.Config.tmp_dir = os.path.abspath(config['paths']['tmp_path']) + BT.Config.exiv2_http = config['ENV']['exiv2_http'] + BT.Config.exiv2_port = config['ENV']['exiv2_port'] + BT.Config.exiv2_echo = config['ENV']['exiv2_echo'] + BT.Config.valgrind = config['ENV']['valgrind'] class FileDecoratorBase(object): From e0486ec063172d955ae6884c121f27fb6f58122b Mon Sep 17 00:00:00 2001 From: LeoHsiao Date: Wed, 21 Oct 2020 23:03:54 +0800 Subject: [PATCH 04/14] Set the variable EXIV2_ECHO when executing `make python_tests VERBOSE=1` --- test/Makefile | 4 ++-- tests/bash_tests/testcases.py | 4 ++++ tests/bash_tests/utils.py | 1 - tests/suite.conf | 2 -- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/test/Makefile b/test/Makefile index 8bf481eb..dde7667b 100644 --- a/test/Makefile +++ b/test/Makefile @@ -153,8 +153,8 @@ python_tests: @echo @echo ---- Running python_tests ---- @echo - @echo bash -c ' . functions.source ; cd ../tests ; if [ ! -z $$VERBOSE ]; then verbose=--verbose ;fi ; python3 runner.py $$verbose ' - @bash -c ' . functions.source ; cd ../tests ; if [ ! -z $$VERBOSE ]; then verbose=--verbose ;fi ; python3 runner.py $$verbose ' + @echo bash -c ' . functions.source ; cd ../tests ; if [ ! -z $$VERBOSE ]; then verbose=--verbose; export EXIV2_ECHO=true; fi; python3 runner.py $$verbose ' + @ bash -c ' . functions.source ; cd ../tests ; if [ ! -z $$VERBOSE ]; then verbose=--verbose; export EXIV2_ECHO=true; fi; python3 runner.py $$verbose ' mostlyclean clean: rm -rf $(top_srcdir)/test/tmp/* diff --git a/tests/bash_tests/testcases.py b/tests/bash_tests/testcases.py index 951fb31b..8d16be7d 100644 --- a/tests/bash_tests/testcases.py +++ b/tests/bash_tests/testcases.py @@ -11,6 +11,10 @@ class TestCases(unittest.TestCase): def setUp(self): BT.Config.init() + # When the details are displayed, add a newline + if BT.Config.exiv2_echo: + print() + def tearDown(self): pass diff --git a/tests/bash_tests/utils.py b/tests/bash_tests/utils.py index 19d27441..41ab7dff 100644 --- a/tests/bash_tests/utils.py +++ b/tests/bash_tests/utils.py @@ -32,7 +32,6 @@ class Config: exiv2_port = '12760' exiv2_echo = '' valgrind = '++' - # verbose: @classmethod def init(cls): diff --git a/tests/suite.conf b/tests/suite.conf index 9e993e6f..0164730a 100644 --- a/tests/suite.conf +++ b/tests/suite.conf @@ -10,7 +10,6 @@ exiv2_http: EXIV2_HTTP exiv2_port: EXIV2_PORT exiv2_echo: EXIV2_ECHO valgrind: VALGRIND -# verbose: VERBOSE [ENV fallback] exiv2_path: ../build/bin @@ -20,7 +19,6 @@ exiv2_http: http://127.0.0.1 exiv2_port: 12760 exiv2_echo: valgrind: ++ -# verbose: [paths] exiv2: ${ENV:exiv2_path}/exiv2 From 0c7d231752cee1ac32265c2c63e136f85f89e7fb Mon Sep 17 00:00:00 2001 From: LeoHsiao Date: Thu, 22 Oct 2020 19:23:13 +0800 Subject: [PATCH 05/14] let `make python_tests` runs in verbose mode --- test/Makefile | 4 ++-- tests/bash_tests/testcases.py | 2 +- tests/bash_tests/utils.py | 3 ++- tests/suite.conf | 2 ++ tests/system_tests.py | 1 + 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/test/Makefile b/test/Makefile index dde7667b..b768040b 100644 --- a/test/Makefile +++ b/test/Makefile @@ -153,8 +153,8 @@ python_tests: @echo @echo ---- Running python_tests ---- @echo - @echo bash -c ' . functions.source ; cd ../tests ; if [ ! -z $$VERBOSE ]; then verbose=--verbose; export EXIV2_ECHO=true; fi; python3 runner.py $$verbose ' - @ bash -c ' . functions.source ; cd ../tests ; if [ ! -z $$VERBOSE ]; then verbose=--verbose; export EXIV2_ECHO=true; fi; python3 runner.py $$verbose ' + @echo bash -c 'cd ../tests; export VERBOSE=1; python3 runner.py --verbose' + @bash -c 'cd ../tests; export VERBOSE=1; python3 runner.py --verbose' mostlyclean clean: rm -rf $(top_srcdir)/test/tmp/* diff --git a/tests/bash_tests/testcases.py b/tests/bash_tests/testcases.py index 8d16be7d..6865ba08 100644 --- a/tests/bash_tests/testcases.py +++ b/tests/bash_tests/testcases.py @@ -12,7 +12,7 @@ class TestCases(unittest.TestCase): BT.Config.init() # When the details are displayed, add a newline - if BT.Config.exiv2_echo: + if BT.Config.exiv2_echo or BT.Config.verbose: print() diff --git a/tests/bash_tests/utils.py b/tests/bash_tests/utils.py index 41ab7dff..837a432a 100644 --- a/tests/bash_tests/utils.py +++ b/tests/bash_tests/utils.py @@ -31,6 +31,7 @@ class Config: exiv2_http = 'http://127.0.0.1' exiv2_port = '12760' exiv2_echo = '' + verbose = '' valgrind = '++' @classmethod @@ -460,7 +461,7 @@ class Executer: def run(self): # Whether to display the command to execute - if Config.exiv2_echo: + if Config.exiv2_echo or Config.verbose: print(Config.valgrind, ' '.join(self.args)) # Check stdout diff --git a/tests/suite.conf b/tests/suite.conf index 0164730a..ca8daf29 100644 --- a/tests/suite.conf +++ b/tests/suite.conf @@ -9,6 +9,7 @@ ld_library_path: LD_LIBRARY_PATH exiv2_http: EXIV2_HTTP exiv2_port: EXIV2_PORT exiv2_echo: EXIV2_ECHO +verbose: VERBOSE valgrind: VALGRIND [ENV fallback] @@ -18,6 +19,7 @@ ld_library_path: ${ENV:exiv2_path}/../lib exiv2_http: http://127.0.0.1 exiv2_port: 12760 exiv2_echo: +verbose: valgrind: ++ [paths] diff --git a/tests/system_tests.py b/tests/system_tests.py index d18e4df0..e1e95186 100644 --- a/tests/system_tests.py +++ b/tests/system_tests.py @@ -209,6 +209,7 @@ def configure_suite(config_file): BT.Config.exiv2_http = config['ENV']['exiv2_http'] BT.Config.exiv2_port = config['ENV']['exiv2_port'] BT.Config.exiv2_echo = config['ENV']['exiv2_echo'] + BT.Config.verbose = config['ENV']['verbose'] BT.Config.valgrind = config['ENV']['valgrind'] From aa462f84d94aba4f525dd3be3f9b75a90298fcf1 Mon Sep 17 00:00:00 2001 From: clanmills Date: Thu, 22 Oct 2020 13:27:43 +0100 Subject: [PATCH 06/14] Fix handling of environment string VERBOSE --- test/Makefile | 4 ++-- tests/runner.py | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/test/Makefile b/test/Makefile index b768040b..415dd83f 100644 --- a/test/Makefile +++ b/test/Makefile @@ -153,8 +153,8 @@ python_tests: @echo @echo ---- Running python_tests ---- @echo - @echo bash -c 'cd ../tests; export VERBOSE=1; python3 runner.py --verbose' - @bash -c 'cd ../tests; export VERBOSE=1; python3 runner.py --verbose' + @echo bash -c 'cd ../tests; python3 runner.py --verbose' + @bash -c 'cd ../tests; python3 runner.py --verbose' mostlyclean clean: rm -rf $(top_srcdir)/test/tmp/* diff --git a/tests/runner.py b/tests/runner.py index c53bf1ca..941d7700 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -62,9 +62,10 @@ if __name__ == '__main__': nargs='?' ) - args = parser.parse_args() - conf_file = args.config_file[0] - DEFAULT_ROOT = os.path.abspath(os.path.dirname(conf_file)) + args = parser.parse_args() + args.verbose |= "VERBOSE" in os.environ + conf_file = args.config_file[0] + DEFAULT_ROOT = os.path.abspath(os.path.dirname(conf_file)) system_tests.set_debug_mode(args.debug) system_tests.configure_suite(conf_file) From da919e3d6843ef4e4b5a5d217d0d3cabd133578a Mon Sep 17 00:00:00 2001 From: LeoHsiao Date: Thu, 22 Oct 2020 22:14:51 +0800 Subject: [PATCH 07/14] Set the default value for the variable VALGRIN to empty --- tests/bash_tests/utils.py | 4 ++-- tests/suite.conf | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/bash_tests/utils.py b/tests/bash_tests/utils.py index 837a432a..f92cc9e8 100644 --- a/tests/bash_tests/utils.py +++ b/tests/bash_tests/utils.py @@ -32,7 +32,7 @@ class Config: exiv2_port = '12760' exiv2_echo = '' verbose = '' - valgrind = '++' + valgrind = '' @classmethod def init(cls): @@ -462,7 +462,7 @@ class Executer: def run(self): # Whether to display the command to execute if Config.exiv2_echo or Config.verbose: - print(Config.valgrind, ' '.join(self.args)) + print('++', ' '.join(self.args)) # Check stdout if self.redirect_stderr_to_stdout: diff --git a/tests/suite.conf b/tests/suite.conf index ca8daf29..d4fb4924 100644 --- a/tests/suite.conf +++ b/tests/suite.conf @@ -20,7 +20,7 @@ exiv2_http: http://127.0.0.1 exiv2_port: 12760 exiv2_echo: verbose: -valgrind: ++ +valgrind: [paths] exiv2: ${ENV:exiv2_path}/exiv2 From d6b029ad6e141d3b8e75b9a31d4c09585540656b Mon Sep 17 00:00:00 2001 From: clanmills Date: Thu, 22 Oct 2020 15:25:48 +0100 Subject: [PATCH 08/14] Don't set --verbose in makefile. Don't treat exiv2_echo == VERBOSE. --- test/Makefile | 4 ++-- tests/bash_tests/utils.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Makefile b/test/Makefile index 415dd83f..88a3bf18 100644 --- a/test/Makefile +++ b/test/Makefile @@ -153,8 +153,8 @@ python_tests: @echo @echo ---- Running python_tests ---- @echo - @echo bash -c 'cd ../tests; python3 runner.py --verbose' - @bash -c 'cd ../tests; python3 runner.py --verbose' + @echo bash -c 'cd ../tests; python3 runner.py' + @bash -c 'cd ../tests; python3 runner.py' mostlyclean clean: rm -rf $(top_srcdir)/test/tmp/* diff --git a/tests/bash_tests/utils.py b/tests/bash_tests/utils.py index f92cc9e8..41203492 100644 --- a/tests/bash_tests/utils.py +++ b/tests/bash_tests/utils.py @@ -461,7 +461,7 @@ class Executer: def run(self): # Whether to display the command to execute - if Config.exiv2_echo or Config.verbose: + if Config.exiv2_echo: print('++', ' '.join(self.args)) # Check stdout From 7abb8dbe0f339f7fe0f6a80ef9a83fe3f01285a9 Mon Sep 17 00:00:00 2001 From: LeoHsiao Date: Thu, 22 Oct 2020 22:52:14 +0800 Subject: [PATCH 09/14] Cancel adding a newline when testing --- tests/bash_tests/testcases.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/bash_tests/testcases.py b/tests/bash_tests/testcases.py index 6865ba08..951fb31b 100644 --- a/tests/bash_tests/testcases.py +++ b/tests/bash_tests/testcases.py @@ -11,10 +11,6 @@ class TestCases(unittest.TestCase): def setUp(self): BT.Config.init() - # When the details are displayed, add a newline - if BT.Config.exiv2_echo or BT.Config.verbose: - print() - def tearDown(self): pass From be62b4f4dbfaf3d51f7b3a1a09404e0ba92307cb Mon Sep 17 00:00:00 2001 From: clanmills Date: Thu, 22 Oct 2020 17:05:54 +0100 Subject: [PATCH 10/14] Fixing VERBOSE in environment (args.verbose==2 when set. args.verbose==0 when not set). --- tests/runner.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/runner.py b/tests/runner.py index 941d7700..57686f9e 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -63,7 +63,8 @@ if __name__ == '__main__': ) args = parser.parse_args() - args.verbose |= "VERBOSE" in os.environ + if 'VERBOSE' in os.environ: + args.verbose = 2 conf_file = args.config_file[0] DEFAULT_ROOT = os.path.abspath(os.path.dirname(conf_file)) system_tests.set_debug_mode(args.debug) From 9811c9d95cd9628642f6533aa0b32997d40491d9 Mon Sep 17 00:00:00 2001 From: clanmills Date: Fri, 23 Oct 2020 13:12:49 +0100 Subject: [PATCH 11/14] Fixing EXIV2_PORT on MinGW/msys2. --- test/functions.source | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/test/functions.source b/test/functions.source index d7609a66..7aef1e9c 100644 --- a/test/functions.source +++ b/test/functions.source @@ -375,17 +375,16 @@ checkSum() } ## -# startHttpServer - power up the python web server +# startServer - power up the python web server startHttpServer() { cd "${testdir}/.." # testdir is the tmp output directory - - if [ "$platform" == "cygwin" ]; then dport=12762 - elif [ "$platform" == "mingw" ]; then dport=12761 - else dport=12760 + if [ "$platform" == "platform=cygwin" ]; then dport=12762 + elif [ "$platform" == "platform=mingw64" ]; then dport=12761 + else dport=12760 fi - if [ ! -z $EXIV2_PORT ]; then port=$EXIV2_PORT ; else port=$dport ; fi - if [ ! -z $EXIV2_HTTP ]; then http=$EXIV2_HTTP ; else http=http://localhost; fi + if [ ! -z "$EXIV2_PORT" ]; then port=$EXIV2_PORT ; else port=$dport ; fi + if [ ! -z "$EXIV2_HTTP" ]; then http=$EXIV2_HTTP ; else http=http://localhost; fi exiv2_url=$http:$port python3 -m http.server $port & # start a background local HTTP server in the "real" test directory sleep 2 # wait for it to init or die! @@ -418,7 +417,7 @@ prepareTest() os=$(uname -o) if [ $os == Cygwin ]; then PLATFORM=cygwin - elif [ os == Msys ]; then + elif [ $os == Msys ]; then PLATFORM=mingw fi fi From 5d7b44dfafc0ff0c2e82b1d34ad30bcae9439026 Mon Sep 17 00:00:00 2001 From: clanmills Date: Fri, 23 Oct 2020 13:44:21 +0100 Subject: [PATCH 12/14] Disable OpenSUSE on CI. It's complaining about being unable to install the correct version of curl. --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index da665139..6881cb65 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -64,10 +64,10 @@ Ubuntu: # <<: *default_config # <<: *distro_build -OpenSUSE: - image: opensuse/tumbleweed - <<: *default_config - <<: *distro_build +# OpenSUSE: +# image: opensuse/tumbleweed +# <<: *default_config +# <<: *distro_build Install: image: fedora:latest From 43698f414bbabe62845e11d37778bb1d7e9ef3f1 Mon Sep 17 00:00:00 2001 From: clanmills Date: Fri, 23 Oct 2020 16:05:51 +0100 Subject: [PATCH 13/14] Adding support for environment strings EXIV2_HTTP and EXIV2_PORT --- tests/bash_tests/utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/bash_tests/utils.py b/tests/bash_tests/utils.py index 41203492..ce6e5a05 100644 --- a/tests/bash_tests/utils.py +++ b/tests/bash_tests/utils.py @@ -33,6 +33,10 @@ class Config: exiv2_echo = '' verbose = '' valgrind = '' + if 'EXIV2_PORT' in os.environ: + exiv2_port = os.environ['EXIV2_PORT'] + if 'EXIV2_HTTP' in os.environ: + exiv2_http = os.environ['EXIV2_HTTP'] @classmethod def init(cls): From 985617cdfc7e99e7be0da714217b76e4a233f366 Mon Sep 17 00:00:00 2001 From: clanmills Date: Fri, 23 Oct 2020 17:30:56 +0100 Subject: [PATCH 14/14] Adding support for VALGRIND and EXIV2_BINDIR --- tests/bash_tests/utils.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/bash_tests/utils.py b/tests/bash_tests/utils.py index ce6e5a05..c9fb6a81 100644 --- a/tests/bash_tests/utils.py +++ b/tests/bash_tests/utils.py @@ -23,6 +23,8 @@ class Config: # When you run the test cases through `python3 runner.py`, the function configure_suite() in system_tests.py will override these parameters. exiv2_dir = os.path.normpath(os.path.join(os.path.abspath(__file__), '../../../')) bin_dir = os.path.join(exiv2_dir, 'build/bin') + if 'EXIV2_BINDIR' in os.environ: + bin_dir = os.environ['EXIV2_BINDIR'] dyld_library_path = os.path.join(bin_dir, '../lib') ld_library_path = os.path.join(bin_dir, '../lib') data_dir = os.path.join(exiv2_dir, 'test/data') @@ -30,13 +32,13 @@ class Config: system_name = platform.system() or 'Unknown' # It could be Windows, Linux, etc. exiv2_http = 'http://127.0.0.1' exiv2_port = '12760' - exiv2_echo = '' - verbose = '' valgrind = '' if 'EXIV2_PORT' in os.environ: exiv2_port = os.environ['EXIV2_PORT'] if 'EXIV2_HTTP' in os.environ: exiv2_http = os.environ['EXIV2_HTTP'] + if 'VALGRIND' in os.environ: + valgrind = os.environ['VALGRIND'] @classmethod def init(cls): @@ -455,6 +457,9 @@ class Executer: self.args = args.replace('\'', '\"') else: self.args = shlex.split(args, posix=os.name == 'posix') + + if len(Config.valgrind)>0: + self.args = [ Config.valgrind ] + self.args # Check stdin if self.stdin: @@ -464,10 +469,6 @@ class Executer: self.run() def run(self): - # Whether to display the command to execute - if Config.exiv2_echo: - print('++', ' '.join(self.args)) - # Check stdout if self.redirect_stderr_to_stdout: stderr = subprocess.STDOUT