5 nncc_find_resource(TensorFlowTests)
8 # Copy [PREFIX]/test.pbtxt to PREFIX.pbtxt in binary folder
9 # Copy [PREFIX]/test.info to PREFIX.info in binary folder
10 # Encode PREFIX.pbtxt to PREFIX.pb
12 set(TEST_REPO "${TensorFlowTests_DIR}")
13 set(TEST_PBTXT_FILENAME "test.pbtxt")
14 set(TEST_INFO_FILENAME "test.info")
19 list(APPEND TESTCASES ${NAME})
24 # Read "test.local.lst" if exists
25 include("test.local.lst" OPTIONAL)
30 foreach(PREFIX IN ITEMS ${TESTCASES})
31 if(NOT IS_DIRECTORY "${TEST_REPO}/${PREFIX}")
32 message(FATAL_ERROR "Missing '${PREFIX}' test")
35 set(PBTXT_SOURCE_PATH "${TEST_REPO}/${PREFIX}/${TEST_PBTXT_FILENAME}")
36 set(INFO_SOURCE_PATH "${TEST_REPO}/${PREFIX}/${TEST_INFO_FILENAME}")
38 set(PBTXT_FILE "${PREFIX}.pbtxt")
39 set(PBTXT_PATH "${CMAKE_CURRENT_BINARY_DIR}/${PBTXT_FILE}")
41 set(INFO_FILE "${PREFIX}.info")
42 set(INFO_PATH "${CMAKE_CURRENT_BINARY_DIR}/${INFO_FILE}")
45 add_custom_command(OUTPUT ${PBTXT_PATH}
46 COMMAND ${CMAKE_COMMAND} -E copy "${PBTXT_SOURCE_PATH}" "${PBTXT_PATH}"
47 DEPENDS ${PBTXT_SOURCE_PATH}
48 COMMENT "Generate ${PBTXT_FILE}"
52 add_custom_command(OUTPUT ${INFO_PATH}
53 COMMAND ${CMAKE_COMMAND} -E copy "${INFO_SOURCE_PATH}" "${INFO_PATH}"
54 DEPENDS ${INFO_SOURCE_PATH}
55 COMMENT "Generate ${INFO_FILE}"
58 list(APPEND TEST_DEPS ${INFO_PATH} ${PBTXT_PATH})
59 list(APPEND TEST_NAMES ${PREFIX})
65 set(TEST_RUNNER "${CMAKE_CURRENT_BINARY_DIR}/testall.sh")
66 set(TEST_RUNNER_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/testall.sh")
70 COMMAND ${CMAKE_COMMAND} -E copy "${TEST_RUNNER_SOURCE}" "${TEST_RUNNER}"
71 DEPENDS ${TEST_RUNNER_SOURCE}
72 COMMENT "Generate test runner"
75 list(APPEND TEST_DEPS "${TEST_RUNNER}")
77 get_target_property(ARTIFACTS_BIN_PATH testDataGenerator BINARY_DIR)
79 set(VIRTUALENV "${NNCC_OVERLAY_DIR}/venv_2_12_1")
82 ### Generate test.config
84 set(TEST_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/test.config")
86 # Get tf2tfliteV2 binary path
87 get_target_property(TF2TFLITEV2_BIN_DIR tf2tfliteV2 BINARY_DIR)
88 set(TF2TFLITEV2_PATH "${TF2TFLITEV2_BIN_DIR}/tf2tfliteV2.py")
92 COMMAND ${CMAKE_COMMAND} -E remove -f ${TEST_CONFIG}
93 COMMAND ${CMAKE_COMMAND} -E echo 'TF2TFLITEV2_PATH=\"${TF2TFLITEV2_PATH}\"' >> ${TEST_CONFIG}
94 COMMAND ${CMAKE_COMMAND} -E echo 'VIRTUALENV=\"${VIRTUALENV}\"' >> ${TEST_CONFIG}
97 COMMENT "Generate test configuration"
100 list(APPEND TEST_DEPS "${TEST_CONFIG}")
102 # This "tf2tfliteV2_conversion_test_deps" target enforces CMake to generate all the dependencies during "build" phase
103 add_custom_target(tf2tfliteV2_conversion_test_deps ALL DEPENDS ${TEST_DEPS})
105 # TODO This test takes a long time and will only be tested once a day.
108 # NAME tf2tfliteV2_conversion_test
109 # COMMAND "${TEST_RUNNER}"
111 # "${CMAKE_CURRENT_BINARY_DIR}"