CMakeLists.txt 2.8 KB
Newer Older
1 2 3 4 5
file(
  GLOB TEST_OPS
  RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
  "test_*.py")
string(REPLACE ".py" "" TEST_OPS "${TEST_OPS}")
Z
Zheng-Bicheng 已提交
6

7 8 9 10 11
file(
  GLOB DIST_TEST_OPS
  RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
  "test_dist_*.py")
string(REPLACE ".py" "" DIST_TEST_OPS "${DIST_TEST_OPS}")
Z
Zheng-Bicheng 已提交
12

13 14 15
foreach(TEST_OP ${DIST_TEST_OPS})
  list(REMOVE_ITEM TEST_OPS ${TEST_OP})
endforeach()
Z
Zheng-Bicheng 已提交
16

17 18 19
if(NOT WITH_COVERAGE)
  list(REMOVE_ITEM TEST_OPS test_hapi_hub)
endif()
Z
Zheng-Bicheng 已提交
20

21 22 23
foreach(src ${TEST_OPS})
  py_test(${src} SRCS ${src}.py)
endforeach()
Z
Zheng-Bicheng 已提交
24

25 26 27 28 29 30 31
function(py_dist_test TARGET_NAME)
  if(WITH_TESTING)
    set(options "")
    set(oneValueArgs "")
    set(multiValueArgs SRCS DEPS ARGS ENVS)
    cmake_parse_arguments(py_dist_test "${options}" "${oneValueArgs}"
                          "${multiValueArgs}" ${ARGN})
Z
Zheng-Bicheng 已提交
32

33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
    if(WITH_COVERAGE
       AND (WITH_GPU OR WITH_ROCM)
       AND (WITH_NCCL OR WITH_RCCL)
       AND NOT WIN32)
      add_test(
        NAME ${TARGET_NAME}
        COMMAND
          ${CMAKE_COMMAND} -E env FLAGS_init_allocated_mem=true
          FLAGS_cudnn_deterministic=true FLAGS_cpu_deterministic=true
          NCCL_P2P_DISABLE=1 NCCL_SHM_DISABLE=1
          PYTHONPATH=${PADDLE_BINARY_DIR}/python ${py_dist_test_ENVS}
          COVERAGE_FILE=${PADDLE_BINARY_DIR}/python-coverage.data
          ${PYTHON_EXECUTABLE} -u ${py_dist_test_SRCS} ${py_dist_test_ARGS}
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
      # No unit test should exceed 10 minutes.
      set_tests_properties(${TARGET_NAME} PROPERTIES TIMEOUT 600 LABELS
                                                     "RUN_TYPE=DIST")
Z
Zheng-Bicheng 已提交
50 51 52
    endif()

  endif()
53
endfunction()
Z
Zheng-Bicheng 已提交
54

55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
foreach(src ${DIST_TEST_OPS})
  message(STATUS ${src})
  py_dist_test(${src} SRCS ${src}.py)
endforeach()
set_tests_properties(test_dataset_cifar PROPERTIES TIMEOUT 120)
set_tests_properties(test_pretrained_model PROPERTIES TIMEOUT 120)
set_tests_properties(test_model PROPERTIES TIMEOUT 300)
set_tests_properties(test_dataset_movielens PROPERTIES TIMEOUT 120)
set_tests_properties(test_datasets PROPERTIES TIMEOUT 300)
set_tests_properties(test_dataset_wmt PROPERTIES TIMEOUT 120)
set_tests_properties(test_vision_models PROPERTIES TIMEOUT 120)
set_tests_properties(test_dataset_uci_housing PROPERTIES TIMEOUT 120)
set_tests_properties(test_dataset_imdb PROPERTIES TIMEOUT 300)
set_tests_properties(test_pretrained_model PROPERTIES TIMEOUT 600)
set_tests_properties(test_callback_wandb PROPERTIES TIMEOUT 60)
if(WITH_COVERAGE)
  set_tests_properties(test_hapi_hub PROPERTIES TIMEOUT 300)
endif()

if(APPLE)
  set_tests_properties(test_callback_early_stop PROPERTIES TIMEOUT 300)
  set_tests_properties(test_callback_reduce_lr_on_plateau PROPERTIES TIMEOUT
                                                                     300)
  set_tests_properties(test_vision_models PROPERTIES TIMEOUT 300)
Z
Zheng-Bicheng 已提交
79
endif()
80
set_tests_properties(test_decorator PROPERTIES TIMEOUT 120)