UT cleanup and path update
**run tests script**: cleanup before UT starts; usage of regular ocf_env files by symlinks. **tests conifg**: add path to regular ocf_env files. Signed-off-by: Slawomir_Jankowski <slawomir.jankowski@intel.com>
This commit is contained in:
parent
e248c68846
commit
5d0a6fa05a
@ -19,10 +19,46 @@ def run_command(args):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def rmv_cmd(trgt):
|
||||||
|
"""Remove target with force"""
|
||||||
|
result = run_command(["rm", "-rf", trgt])
|
||||||
|
if result.returncode != 0:
|
||||||
|
raise Exception("Removing {} before testing failed!".
|
||||||
|
format(os.path.dirname(os.path.realpath(__file__))
|
||||||
|
+ trgt))
|
||||||
|
|
||||||
|
|
||||||
|
def cleanup():
|
||||||
|
"""Delete files created by unit tests"""
|
||||||
|
script_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
test_dir = os.path.join(script_path, tests_config.MAIN_DIRECTORY_OF_UNIT_TESTS)
|
||||||
|
result = run_command(["cd", test_dir])
|
||||||
|
if result.returncode != 0:
|
||||||
|
raise Exception("Cleanup before testing failed!")
|
||||||
|
|
||||||
|
# r=root, d=directories, f = files
|
||||||
|
for r, d, f in os.walk(test_dir):
|
||||||
|
for file in f:
|
||||||
|
if '_generated_wrap' in file:
|
||||||
|
rmv_cmd(file)
|
||||||
|
|
||||||
|
rmv_cmd("preprocessed_sources_repository")
|
||||||
|
rmv_cmd("sources_to_test_repository")
|
||||||
|
rmv_cmd("build")
|
||||||
|
|
||||||
|
result = run_command(["cd", script_path])
|
||||||
|
if result.returncode != 0:
|
||||||
|
raise Exception("Cleanup before testing failed!")
|
||||||
|
|
||||||
|
|
||||||
|
cleanup()
|
||||||
|
|
||||||
script_path = os.path.dirname(os.path.realpath(__file__))
|
script_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
main_UT_dir = os.path.join(script_path, tests_config.MAIN_DIRECTORY_OF_UNIT_TESTS)
|
main_UT_dir = os.path.join(script_path, tests_config.MAIN_DIRECTORY_OF_UNIT_TESTS)
|
||||||
|
|
||||||
|
main_env_dir = os.path.join(script_path, tests_config.MAIN_DIRECTORY_OF_ENV_FILES)
|
||||||
|
|
||||||
main_tested_dir = os.path.join(script_path, tests_config.MAIN_DIRECTORY_OF_TESTED_PROJECT)
|
main_tested_dir = os.path.join(script_path, tests_config.MAIN_DIRECTORY_OF_TESTED_PROJECT)
|
||||||
|
|
||||||
if not os.path.isdir(os.path.join(main_UT_dir, "ocf_env", "ocf")):
|
if not os.path.isdir(os.path.join(main_UT_dir, "ocf_env", "ocf")):
|
||||||
@ -31,6 +67,12 @@ if not os.path.isdir(os.path.join(main_UT_dir, "ocf_env", "ocf")):
|
|||||||
except Exception:
|
except Exception:
|
||||||
raise Exception("Cannot create ocf_env/ocf directory!")
|
raise Exception("Cannot create ocf_env/ocf directory!")
|
||||||
|
|
||||||
|
result = run_command(["ln", "-fs",
|
||||||
|
os.path.join(main_env_dir, "*"),
|
||||||
|
os.path.join(main_UT_dir, "ocf_env")])
|
||||||
|
if result.returncode != 0:
|
||||||
|
raise Exception("Preparing env sources for testing failed!")
|
||||||
|
|
||||||
result = run_command(["cp", "-r",
|
result = run_command(["cp", "-r",
|
||||||
os.path.join(main_tested_dir, "inc", "*"),
|
os.path.join(main_tested_dir, "inc", "*"),
|
||||||
os.path.join(main_UT_dir, "ocf_env", "ocf")])
|
os.path.join(main_UT_dir, "ocf_env", "ocf")])
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
MAIN_DIRECTORY_OF_TESTED_PROJECT = "../../../"
|
MAIN_DIRECTORY_OF_TESTED_PROJECT = "../../../"
|
||||||
|
|
||||||
|
MAIN_DIRECTORY_OF_ENV_FILES = MAIN_DIRECTORY_OF_TESTED_PROJECT + "env/posix/"
|
||||||
|
|
||||||
MAIN_DIRECTORY_OF_UNIT_TESTS = "../tests/"
|
MAIN_DIRECTORY_OF_UNIT_TESTS = "../tests/"
|
||||||
|
|
||||||
# Paths to all directories, in which tests are stored. All paths should be relative to
|
# Paths to all directories, in which tests are stored. All paths should be relative to
|
||||||
|
Loading…
Reference in New Issue
Block a user