Skip to content

Commit fa75ebe

Browse files
authored
link C++ tests to libpaddle.so (#56829)
* link C++ tests to libpaddle.so except windows * fix compile kill-9 bug * fix compile kill-9 bug * fix compile kill-9 bug * fix compile kill-9 bug
1 parent e110cbb commit fa75ebe

File tree

2 files changed

+127
-57
lines changed

2 files changed

+127
-57
lines changed
Lines changed: 122 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,154 @@
1+
get_property(paddle_lib GLOBAL PROPERTY PADDLE_LIB_NAME)
12
set_source_files_properties(
23
interceptor_ping_pong_test.cc PROPERTIES COMPILE_FLAGS
34
${DISTRIBUTE_COMPILE_FLAGS})
4-
cc_test_old(interceptor_ping_pong_test SRCS interceptor_ping_pong_test.cc DEPS
5-
fleet_executor ${BRPC_DEPS})
5+
if(WIN32 AND WITH_TESTING)
6+
cc_test_old(interceptor_ping_pong_test SRCS interceptor_ping_pong_test.cc
7+
DEPS fleet_executor ${BRPC_DEPS})
8+
else()
9+
cc_test_old(
10+
interceptor_ping_pong_test
11+
SRCS
12+
interceptor_ping_pong_test.cc
13+
DEPS
14+
${paddle_lib}
15+
python
16+
fleet_executor)
17+
endif()
618

719
set_source_files_properties(
820
compute_interceptor_test.cc PROPERTIES COMPILE_FLAGS
921
${DISTRIBUTE_COMPILE_FLAGS})
10-
cc_test_old(compute_interceptor_test SRCS compute_interceptor_test.cc DEPS
11-
fleet_executor ${BRPC_DEPS})
22+
23+
if(WIN32 AND WITH_TESTING)
24+
cc_test_old(compute_interceptor_test SRCS compute_interceptor_test.cc DEPS
25+
fleet_executor ${BRPC_DEPS})
26+
else()
27+
cc_test_old(
28+
compute_interceptor_test
29+
SRCS
30+
compute_interceptor_test.cc
31+
DEPS
32+
${paddle_lib}
33+
python
34+
fleet_executor)
35+
endif()
1236

1337
set_source_files_properties(
1438
source_interceptor_test.cc PROPERTIES COMPILE_FLAGS
1539
${DISTRIBUTE_COMPILE_FLAGS})
16-
cc_test_old(source_interceptor_test SRCS source_interceptor_test.cc DEPS
17-
fleet_executor ${BRPC_DEPS})
40+
if(WIN32 AND WITH_TESTING)
41+
cc_test_old(source_interceptor_test SRCS source_interceptor_test.cc DEPS
42+
fleet_executor ${BRPC_DEPS})
43+
else()
44+
cc_test_old(
45+
source_interceptor_test
46+
SRCS
47+
source_interceptor_test.cc
48+
DEPS
49+
${paddle_lib}
50+
python
51+
fleet_executor)
52+
endif()
1853

1954
set_source_files_properties(
2055
sink_interceptor_test.cc PROPERTIES COMPILE_FLAGS ${DISTRIBUTE_COMPILE_FLAGS})
21-
cc_test_old(sink_interceptor_test SRCS sink_interceptor_test.cc DEPS
22-
fleet_executor ${BRPC_DEPS})
56+
if(WIN32 AND WITH_TESTING)
57+
cc_test_old(sink_interceptor_test SRCS sink_interceptor_test.cc DEPS
58+
fleet_executor ${BRPC_DEPS})
59+
else()
60+
cc_test_old(
61+
sink_interceptor_test
62+
SRCS
63+
sink_interceptor_test.cc
64+
DEPS
65+
${paddle_lib}
66+
python
67+
fleet_executor)
68+
endif()
2369

2470
set_source_files_properties(
2571
interceptor_pipeline_short_path_test.cc
2672
PROPERTIES COMPILE_FLAGS ${DISTRIBUTE_COMPILE_FLAGS})
27-
cc_test_old(
28-
interceptor_pipeline_short_path_test SRCS
29-
interceptor_pipeline_short_path_test.cc DEPS fleet_executor ${BRPC_DEPS})
73+
if(WIN32 AND WITH_TESTING)
74+
cc_test_old(
75+
interceptor_pipeline_short_path_test SRCS
76+
interceptor_pipeline_short_path_test.cc DEPS fleet_executor ${BRPC_DEPS})
77+
else()
78+
cc_test_old(
79+
interceptor_pipeline_short_path_test
80+
SRCS
81+
interceptor_pipeline_short_path_test.cc
82+
DEPS
83+
${paddle_lib}
84+
python
85+
fleet_executor)
86+
endif()
3087

3188
set_source_files_properties(
3289
interceptor_pipeline_long_path_test.cc PROPERTIES COMPILE_FLAGS
3390
${DISTRIBUTE_COMPILE_FLAGS})
34-
cc_test_old(
35-
interceptor_pipeline_long_path_test SRCS
36-
interceptor_pipeline_long_path_test.cc DEPS fleet_executor ${BRPC_DEPS})
91+
if(WIN32 AND WITH_TESTING)
92+
cc_test_old(
93+
interceptor_pipeline_long_path_test SRCS
94+
interceptor_pipeline_long_path_test.cc DEPS fleet_executor ${BRPC_DEPS})
95+
else()
96+
cc_test_old(
97+
interceptor_pipeline_long_path_test
98+
SRCS
99+
interceptor_pipeline_long_path_test.cc
100+
DEPS
101+
${paddle_lib}
102+
python
103+
fleet_executor)
104+
endif()
37105

38106
set_source_files_properties(
39107
compute_interceptor_run_op_test.cc PROPERTIES COMPILE_FLAGS
40108
${DISTRIBUTE_COMPILE_FLAGS})
41-
cc_test_old(
42-
compute_interceptor_run_op_test
43-
SRCS
44-
compute_interceptor_run_op_test.cc
45-
DEPS
46-
fleet_executor
47-
naive_executor
48-
fill_constant_op
49-
op_registry
50-
elementwise_add_op
51-
scope
52-
device_context
53-
${BRPC_DEPS})
109+
if(WIN32 AND WITH_TESTING)
110+
cc_test_old(
111+
compute_interceptor_run_op_test
112+
SRCS
113+
compute_interceptor_run_op_test.cc
114+
DEPS
115+
fleet_executor
116+
naive_executor
117+
fill_constant_op
118+
op_registry
119+
elementwise_add_op
120+
scope
121+
device_context
122+
${BRPC_DEPS})
123+
else()
124+
cc_test_old(
125+
compute_interceptor_run_op_test
126+
SRCS
127+
compute_interceptor_run_op_test.cc
128+
DEPS
129+
${paddle_lib}
130+
python
131+
fleet_executor
132+
fill_constant_op
133+
elementwise_add_op)
134+
endif()
54135

55136
if(WITH_DISTRIBUTE AND NOT WITH_PSLIB)
56137
set_source_files_properties(
57138
interceptor_ping_pong_with_brpc_test.cc
58139
PROPERTIES COMPILE_FLAGS ${DISTRIBUTE_COMPILE_FLAGS})
59-
cc_test_old(
60-
interceptor_ping_pong_with_brpc_test SRCS
61-
interceptor_ping_pong_with_brpc_test.cc DEPS fleet_executor ${BRPC_DEPS})
140+
if(WIN32 AND WITH_TESTING)
141+
cc_test_old(
142+
interceptor_ping_pong_with_brpc_test SRCS
143+
interceptor_ping_pong_with_brpc_test.cc DEPS fleet_executor ${BRPC_DEPS})
144+
else()
145+
cc_test_old(
146+
interceptor_ping_pong_with_brpc_test
147+
SRCS
148+
interceptor_ping_pong_with_brpc_test.cc
149+
DEPS
150+
${paddle_lib}
151+
python
152+
fleet_executor)
153+
endif()
62154
endif()

test/cpp/fluid/mkldnn/CMakeLists.txt

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
get_property(paddle_lib GLOBAL PROPERTY PADDLE_LIB_NAME)
12
cc_test(
23
test_mkldnn_op_inplace
34
SRCS test_mkldnn_op_inplace.cc
@@ -41,33 +42,7 @@ cc_test(
4142
test_mkldnn_caching
4243
SRCS test_mkldnn_caching.cc
4344
DEPS ${TEST_MKLDNN_CACHING_DEPS})
44-
if(WITH_CINN)
45-
cc_test_old(
46-
test_mkldnn_op_nhwc
47-
SRCS
48-
test_mkldnn_op_nhwc.cc
49-
DEPS
50-
fleet_executor
51-
conditional_block_op
52-
standalone_executor
53-
executor
54-
recurrent_op_helper
55-
cinn_compiler
56-
recurrent_op
57-
op_registry
58-
generated_static_op
59-
crop_op
60-
activation_op
61-
generated_op
62-
generated_static_op
63-
phi
64-
transpose_op
65-
fused_transpose_op
66-
scope
67-
device_context
68-
enforce
69-
python)
70-
else()
45+
if(WIN32 AND WITH_TESTING)
7146
cc_test_old(
7247
test_mkldnn_op_nhwc
7348
SRCS
@@ -91,4 +66,7 @@ else()
9166
scope
9267
device_context
9368
enforce)
69+
else()
70+
cc_test_old(test_mkldnn_op_nhwc SRCS test_mkldnn_op_nhwc.cc DEPS
71+
${paddle_lib} python)
9472
endif()

0 commit comments

Comments
 (0)