Skip to content

Commit

Permalink
Merge pull request PaddlePaddle#1003 from hedaoyuan/remove_main
Browse files Browse the repository at this point in the history
Remove the main function inside the test file
  • Loading branch information
hedaoyuan authored Dec 29, 2016
2 parents 48b4c30 + 97f4153 commit 54a2b1f
Show file tree
Hide file tree
Showing 27 changed files with 12 additions and 146 deletions.
6 changes: 3 additions & 3 deletions cmake/util.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ function(link_paddle_exe TARGET_NAME)
paddle_parameter
paddle_proto
paddle_cuda
paddle_test_main
${METRIC_LIBS}
${PROTOBUF_LIBRARY}
${LIBGLOG_LIBRARY}
Expand Down Expand Up @@ -155,8 +154,9 @@ endfunction()
# Rest Arguemnts: not used.
function(link_paddle_test TARGET_NAME)
link_paddle_exe(${TARGET_NAME})
target_link_libraries(${TARGET_NAME} ${GTEST_MAIN_LIBRARIES}
${GTEST_LIBRARIES})
target_link_libraries(${TARGET_NAME}
paddle_test_main
${GTEST_LIBRARIES})
endfunction()

# add_unittest_without_exec
Expand Down
1 change: 1 addition & 0 deletions paddle/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
add_subdirectory(cuda)
add_subdirectory(function)
add_subdirectory(utils)
add_subdirectory(testing)
add_subdirectory(math)
add_subdirectory(parameter)
add_subdirectory(gserver)
Expand Down
4 changes: 2 additions & 2 deletions paddle/function/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ endif()

add_library(paddle_function STATIC ${cpp_files} ${cu_objs})

add_library(paddle_test_main STATIC TestMain.cpp)

if(WITH_GPU)
if(WITH_TESTING)
# TODO:
# file(GLOB test_files . *OpTest.cpp)
# add_executable(${test_bin} EXCLUDE_FROM_ALL ${test_files})
add_simple_unittest(CrossMapNormalOpTest)
endif()
endif()

add_style_check_target(paddle_function ${h_files})
add_style_check_target(paddle_function ${cpp_files})
Expand Down
6 changes: 0 additions & 6 deletions paddle/gserver/tests/test_LinearChainCRF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,3 @@ TEST(LinearChainCRF, decoding) {
}
}
}

int main(int argc, char** argv) {
initMain(argc, argv);
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
6 changes: 0 additions & 6 deletions paddle/gserver/tests/test_ProtoDataProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -730,9 +730,3 @@ TEST(ProtoSequenceDataProvider, test) {
} // end for (int numIdSlots : numSlotsArray)
} // end for (int numSparseNonValueVecSlots : numSlotsArray)
}

int main(int argc, char** argv) {
initMain(argc, argv);
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
6 changes: 0 additions & 6 deletions paddle/gserver/tests/test_WarpCTCLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,3 @@ TEST(Layer, WarpCTCLayer) {
}
}
}

int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
initMain(argc, argv);
return RUN_ALL_TESTS();
}
6 changes: 0 additions & 6 deletions paddle/math/tests/test_Allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,3 @@ TEST(MemoryHandle, Gpu) {
}
}
#endif

int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
initMain(argc, argv);
return RUN_ALL_TESTS();
}
6 changes: 0 additions & 6 deletions paddle/math/tests/test_BaseMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,4 @@ TEST(BaseMatrix, Other) {
}
}

int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
paddle::initMain(argc, argv);
return RUN_ALL_TESTS();
}

#endif
7 changes: 0 additions & 7 deletions paddle/math/tests/test_CpuGpuVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,4 @@ TEST(CpuGpuVector, subCreate) {
checkDataEqual(v1Check->getData() + offset, v2Check->getData(), size2);
}

int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
initMain(argc, argv);
int ret = RUN_ALL_TESTS();
return ret;
}

#endif
6 changes: 0 additions & 6 deletions paddle/math/tests/test_ExecViaCpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,3 @@ TEST(ExecViaCpu, test1) {
testWrapper(functor);
}
#endif

int main(int argc, char** argv) {
paddle::initMain(argc, argv);
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
6 changes: 0 additions & 6 deletions paddle/math/tests/test_Matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,4 @@ TEST(Matrix, multiBinaryCrossEntropy) {
}
}

int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
paddle::initMain(argc, argv);
return RUN_ALL_TESTS();
}

#endif
6 changes: 0 additions & 6 deletions paddle/math/tests/test_SIMDFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,3 @@ TEST(SIMDFunction, decayL1_WithoutLR) {
ASSERT_NEAR(dest[i], simd_dest[i], EPSILON);
}
}

int main(int argc, char** argv) {
paddle::initMain(argc, argv);
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
6 changes: 0 additions & 6 deletions paddle/math/tests/test_SparseMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,3 @@ TEST(Matrix, SparseMatrixCSCFormatTrimFrom) {
checkSMatrixEqual2(matA, matD);
#endif
}

int main(int argc, char** argv) {
paddle::initMain(argc, argv);
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
8 changes: 0 additions & 8 deletions paddle/math/tests/test_Tensor.cu
Original file line number Diff line number Diff line change
Expand Up @@ -1163,11 +1163,3 @@ TEST(Quaternary, CompareOp) {
TestQuaternaryMatrix<GpuMatrix> testGpu(testQuaternaryCompareOp<GpuMatrix>);
#endif
}

int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
hl_start();
hl_init(0);
return RUN_ALL_TESTS();
}

8 changes: 0 additions & 8 deletions paddle/math/tests/test_TrainingAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,11 +459,3 @@ void testSparseMomentum(size_t size, bool useGpu) {
}

TEST(Training, SparseMomentum) { testCase(testSparseMomentum); }

int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
initMain(argc, argv);
hl_start();
hl_init(FLAGS_gpu_id);
return RUN_ALL_TESTS();
}
6 changes: 0 additions & 6 deletions paddle/math/tests/test_batchTranspose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,3 @@ TEST(MatrixBatchTransTest, test_batch_matrix_transpose) {
checkMatrixEqual(cBatchTransMat, cMat_d2h);
}
#endif

int main(int argc, char** argv) {
paddle::initMain(argc, argv);
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
8 changes: 0 additions & 8 deletions paddle/math/tests/test_lazyAssign.cu
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,3 @@ TEST(sgdUpdate, GPU) {
testMatrixCase(testSgdUpdate<GpuMatrix>);
}
#endif

int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
hl_start();
hl_init(0);
return RUN_ALL_TESTS();
}

6 changes: 0 additions & 6 deletions paddle/math/tests/test_matrixCompare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1262,10 +1262,4 @@ TEST(Matrix, MaxOutFwdBwd) {
}
}

int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
initMain(argc, argv);
return RUN_ALL_TESTS();
}

#endif
7 changes: 0 additions & 7 deletions paddle/math/tests/test_sparseMatrixCompare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,4 @@ TEST(SMatrix, sMatrixCollectBias) {
}
}

int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
initMain(argc, argv);
int ret = RUN_ALL_TESTS();
return ret;
}

#endif
9 changes: 0 additions & 9 deletions paddle/parameter/tests/test_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@ limitations under the License. */

using namespace paddle; // NOLINT

int main(int argc, char** argv) {
paddle::initMain(argc, argv);
testing::InitGoogleTest(&argc, argv);

int ret = RUN_ALL_TESTS();

return ret;
}

class CommonTest : public ::testing::Test {
protected:
CommonTest() : testStat_("test") {}
Expand Down
6 changes: 6 additions & 0 deletions paddle/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# for paddle test case

if(WITH_TESTING)
add_library(paddle_test_main STATIC TestMain.cpp)
add_dependencies(paddle_test_main gen_proto_cpp)
endif()
File renamed without changes.
6 changes: 0 additions & 6 deletions paddle/utils/tests/test_CustomStackTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,3 @@ TEST(CustomStackTrace, normalTest) {
}
});
}

int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
paddle::initMain(argc, argv);
return RUN_ALL_TESTS();
}
5 changes: 0 additions & 5 deletions paddle/utils/tests/test_SIMDFlags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,3 @@ TEST(SIMDFlags, normalPrint) {
LOG(INFO) << "Has AVX2: " << std::boolalpha << HAS_AVX2;
LOG(INFO) << "Has AVX512: " << std::boolalpha << HAS_AVX512;
}

int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
6 changes: 0 additions & 6 deletions paddle/utils/tests/test_SpinLock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,3 @@ TEST(ThreadSpinLock, normalTest) {
});
}
}

int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
paddle::initMain(argc, argv);
return RUN_ALL_TESTS();
}
5 changes: 0 additions & 5 deletions paddle/utils/tests/test_Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,3 @@ TEST(AsyncThreadPool, addBatchJobWithResults) {
ASSERT_EQ(res[i], i);
}
}

int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
6 changes: 0 additions & 6 deletions paddle/utils/tests/test_ThreadBarrier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,3 @@ TEST(ThreadBarrier, normalTest) {
});
}
}

int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
paddle::initMain(argc, argv);
return RUN_ALL_TESTS();
}

0 comments on commit 54a2b1f

Please sign in to comment.