>From 63edcefbd719255786fc3ff68801a8ea103141e8 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Thu, 21 May 2015 13:20:35 +0200 Subject: [PATCH] SSSDConfigTest: Use unique temporary directory Test SSSDConfigTest is executed twice with make check if python2 and python3 are available. Tests are executed in parallel with new automake and therefore it caused sometimes failures e.g. ERROR: testModifyExistingConfig (__main__.SSSDConfigTestValid) ---------------------------------------------------------------------- Traceback (most recent call last): File "/tmp/sssd/src/config/SSSDConfigTest.py", line 215, in testModifyExistingConfig mode = os.stat(of)[ST_MODE] FileNotFoundError: [Errno 2] No such file or directory: '/tmp/testModifyExistingConfig.conf' --- Makefile.am | 1 + src/config/SSSDConfigTest.py | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index 8a318c2ffcaabc7c21117cef20b9621d75516382..04726b1d931b6708f5d0791c1684b691e53d11a4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1277,6 +1277,7 @@ endif # Feature Tests # ################# TESTS_ENVIRONMENT = LDB_MODULES_PATH=$(abs_top_builddir)/ldb_mod_test_dir \ + SSS_TEST_DIR=$(TEST_DIR) \ $(AUX_TESTS_ENVIRONMENT) ldb_mod_test_dir: memberof.la diff --git a/src/config/SSSDConfigTest.py b/src/config/SSSDConfigTest.py index db16bc433cf4c47c6a15760d85b322a6655aa0c1..f65353e74271fb50a0a3e48a65dd17b10227d29c 100755 --- a/src/config/SSSDConfigTest.py +++ b/src/config/SSSDConfigTest.py @@ -6,6 +6,7 @@ Created on Sep 18, 2009 ''' import unittest import os +import tempfile from stat import * import sys @@ -132,7 +133,7 @@ class SSSDConfigTestValid(unittest.TestCase): local_domain.set_active(True) sssdconfig.save_domain(local_domain) - of = '/tmp/testCreateNewLocalConfig.conf' + of = tmp_dir + '/testCreateNewLocalConfig.conf' #Ensure the output file doesn't exist try: @@ -166,7 +167,7 @@ class SSSDConfigTestValid(unittest.TestCase): ldap_domain.set_active(True) sssdconfig.save_domain(ldap_domain) - of = '/tmp/testCreateNewLDAPConfig.conf' + of = tmp_dir + '/testCreateNewLDAPConfig.conf' #Ensure the output file doesn't exist try: @@ -200,7 +201,7 @@ class SSSDConfigTestValid(unittest.TestCase): ldap_domain.set_active(True) sssdconfig.save_domain(ldap_domain) - of = '/tmp/testModifyExistingConfig.conf' + of = tmp_dir + '/testModifyExistingConfig.conf' #Ensure the output file doesn't exist try: @@ -1753,7 +1754,7 @@ class SSSDConfigTestSSSDConfig(unittest.TestCase): sssdconfig.save_domain(domain) - of = '/tmp/testSaveDomain.out' + of = tmp_dir + '/testSaveDomain.out' #Ensure the output file doesn't exist try: @@ -1856,6 +1857,9 @@ class SSSDConfigTestSSSDConfig(unittest.TestCase): if __name__ == "__main__": error = 0 + test_dir = os.environ.get('SSS_TEST_DIR') or "." + tmp_dir = tempfile.mkdtemp(dir=test_dir) + suite = unittest.TestLoader().loadTestsFromTestCase(SSSDConfigTestSSSDService) res = unittest.TextTestRunner().run(suite) if not res.wasSuccessful(): @@ -1881,4 +1885,6 @@ if __name__ == "__main__": if not res.wasSuccessful(): error |= 0x10 + os.rmdir(tmp_dir) + sys.exit(error) -- 2.4.1