3
3
import platform
4
4
from pathlib import Path
5
5
6
+
6
7
def init_cmd_args ():
7
8
import argparse
8
9
parser = argparse .ArgumentParser ()
@@ -22,11 +23,13 @@ def init_cmd_args():
22
23
_args_dict = vars (args )
23
24
return _args_dict
24
25
26
+
25
27
def get_project_path ():
26
28
script_path = Path (__file__ ).resolve () # Absolute path of the script
27
29
script_dir = script_path .parent # Directory containing the script
28
30
return script_dir .parent
29
31
32
+
30
33
def source_script (script_path ):
31
34
command = f"source { script_path } && env"
32
35
result = subprocess .run (command , shell = True , capture_output = True , text = True )
@@ -42,6 +45,7 @@ def source_script(script_path):
42
45
print (f"Failed to source script: { script_path } " )
43
46
return {}
44
47
48
+
45
49
def setup_env ():
46
50
ocv_script_path = "build/ppc_opencv/install/bin/setup_vars_opencv4.sh"
47
51
if os .path .isfile (Path (get_project_path ()) / ocv_script_path ):
@@ -54,17 +58,25 @@ def setup_env():
54
58
os .environ .update (env_vars )
55
59
return _executable_path
56
60
61
+
57
62
def run_exec_file (command ):
58
63
result = subprocess .run (command , shell = True , env = os .environ )
59
64
if result .returncode != 0 :
60
65
raise Exception (f"Subprocess return { result .returncode } ." )
61
66
67
+
62
68
def get_common_gtest_settings ():
63
- return "--gtest_also_run_disabled_tests --gtest_repeat=10 --gtest_recreate_environments_when_repeating --gtest_color=0"
69
+ command = "--gtest_also_run_disabled_tests "
70
+ command += "--gtest_repeat=10 "
71
+ command += "--gtest_recreate_environments_when_repeating "
72
+ command += "--gtest_color=0 "
73
+ return command
74
+
64
75
65
76
def run_threads ():
66
77
print (123 )
67
78
79
+
68
80
def run_common (install_bin_dir ):
69
81
valgrind_settings = "--error-exitcode=1 --leak-check=full --show-leak-kinds=all"
70
82
@@ -75,14 +87,17 @@ def run_common(install_bin_dir):
75
87
run_exec_file (f"{ Path (install_bin_dir ) / 'core_func_tests' } { get_common_gtest_settings ()} " )
76
88
run_exec_file (f"{ Path (install_bin_dir ) / 'ref_func_tests' } { get_common_gtest_settings ()} " )
77
89
90
+
78
91
def run_processes (install_bin_dir , additional_mpi_args ):
79
92
proc_count = os .environ .get ("PROC_COUNT" )
80
93
if proc_count is None :
81
94
raise EnvironmentError ("Required environment variable 'PROC_COUNT' is not set." )
82
95
96
+ mpi_running = f"mpirun { additional_mpi_args } -np { proc_count } "
83
97
if not os .environ .get ("ASAN_RUN" ):
84
- run_exec_file (f"mpirun { additional_mpi_args } -np { proc_count } { Path (install_bin_dir ) / 'all_func_tests' } { get_common_gtest_settings ()} " )
85
- run_exec_file (f"mpirun { additional_mpi_args } -np { proc_count } { Path (install_bin_dir ) / 'mpi_func_tests' } { get_common_gtest_settings ()} " )
98
+ run_exec_file (f"{ mpi_running } { Path (install_bin_dir ) / 'all_func_tests' } { get_common_gtest_settings ()} " )
99
+ run_exec_file (f"{ mpi_running } { Path (install_bin_dir ) / 'mpi_func_tests' } { get_common_gtest_settings ()} " )
100
+
86
101
87
102
if __name__ == "__main__" :
88
103
args_dict = init_cmd_args ()
0 commit comments