--- /dev/null
+if(NOT TARGET nni)
+ return()
+endif(NOT TARGET nni)
+
+if(NOT TARGET nnkit_tflite_backend)
+ return()
+endif(NOT TARGET nnkit_tflite_backend)
+
+file(GLOB RECIPES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*/test.recipe")
+
+foreach(RECIPE IN ITEMS ${RECIPES})
+ get_filename_component(RECIPE_PREFIX ${RECIPE} DIRECTORY)
+
+ set(RECIPE_SOURCE_FILE "${RECIPE_PREFIX}.recipe")
+ set(RECIPE_SOURCE_TARGET tflchef_${PREFIX}_recipe)
+
+ set(RECIPE_OUTPUT_FILE "${RECIPE_PREFIX}.tflite")
+ set(RECIPE_OUTPUT_TARGET tflchef_${PREFIX}_tflite)
+
+ # Copy .recipe
+ add_custom_target(${RECIPE_SOURCE_TARGET}
+ ALL ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/${RECIPE}"
+ "${CMAKE_CURRENT_BINARY_DIR}/${RECIPE_SOURCE_FILE}"
+ COMMENT "Generate ${RECIPE_PREFIX}.recipe")
+
+ # Generate .tflite
+ add_custom_target(${RECIPE_OUTPUT_TARGET}
+ ALL $<TARGET_FILE:tflchef-file> ${RECIPE_SOURCE_FILE} ${RECIPE_OUTPUT_FILE}
+ DEPENDS ${RECIPE_SOURCE_TARGET}
+ COMMENT "Generate ${RECIPE_PREFIX}.tflite")
+
+ list(APPEND TESTS ${RECIPE_PREFIX})
+endforeach(RECIPE)
+
+add_test(NAME tflchef_test
+ COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/runall"
+ $<TARGET_FILE:nni>
+ $<TARGET_FILE:nnkit_tflite_backend>
+ "${CMAKE_CURRENT_BINARY_DIR}"
+ ${TESTS})
--- /dev/null
+#!/bin/bash
+
+if [[ $# -le 3 ]]; then
+ echo "USAGE: $0 [nni path] [tflite backend path] [working directory] [prefix 0] [prefix 1] ..."
+ exit 255
+fi
+
+NNI_PATH="$1"; shift
+TFLITE_BACKEND_PATH="$1"; shift
+WORKDIR="$1"; shift
+
+echo "-- Found nni: ${NNI_PATH}"
+echo "-- Found tflite backend: ${TFLITE_BACKEND_PATH}"
+echo "-- Found workdir: ${WORKDIR}"
+
+TESTED=()
+PASSED=()
+FAILED=()
+
+pushd "${WORKDIR}"
+while [[ $# -ne 0 ]]; do
+ PREFIX="$1"; shift
+
+ TESTED+=("${PREFIX}")
+
+ "${NNI_PATH}" --backend "${TFLITE_BACKEND_PATH}" --backend-arg "${PREFIX}.tflite"
+
+ if [[ $? -eq 0 ]]; then
+ PASSED+=("$PREFIX")
+ else
+ FAILED+=("$PREFIX")
+ fi
+done
+popd
+
+echo "SUMMARY: ${#PASSED[@]} PASS AND ${#FAILED[@]} FAIL AMONG ${#TESTED[@]} TESTS"
+
+if [[ ${#TESTED[@]} -ne ${#PASSED[@]} ]]; then
+ exit 255
+fi
+
+exit 0