1#!/bin/bash
2# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15# ==============================================================================
16#
17# Bash unit tests for the TensorFlow Lite Micro project generator.
18
19set -e
20
21INPUT_TEMPLATE=${TEST_SRCDIR}/tensorflow/lite/micro/tools/make/templates/keil_project.uvprojx.tpl
22OUTPUT_FILE=${TEST_TMPDIR}/keil_project.uvprojx
23EXECUTABLE=test_executable
24
25${TEST_SRCDIR}/tensorflow/lite/micro/tools/make/generate_keil_project \
26  --input_template=${INPUT_TEMPLATE} \
27  --output_file=${OUTPUT_FILE} \
28  --executable=${EXECUTABLE} \
29  --hdrs="foo.h bar.h" \
30  --srcs="foo.c bar.cc some/bad<xml.cc" \
31  --include_paths=". include"
32
33if ! grep -q "${EXECUTABLE}" ${OUTPUT_FILE}; then
34  echo "ERROR: No executable name '${EXECUTABLE}' found in project file '${OUTPUT_FILE}'."
35  exit 1
36fi
37
38if ! grep -q "foo\.h" ${OUTPUT_FILE}; then
39  echo "ERROR: No header 'foo.h' found in project file '${OUTPUT_FILE}'."
40  exit 1
41fi
42
43if ! grep -q "bar\.h" ${OUTPUT_FILE}; then
44  echo "ERROR: No header 'bar.h' found in project file '${OUTPUT_FILE}'."
45  exit 1
46fi
47
48if ! grep -q "foo\.c" ${OUTPUT_FILE}; then
49  echo "ERROR: No source 'foo.c' found in project file '${OUTPUT_FILE}'."
50  exit 1
51fi
52
53if ! grep -q "bar\.cc" ${OUTPUT_FILE}; then
54  echo "ERROR: No source 'bar.cc' found in project file '${OUTPUT_FILE}'."
55  exit 1
56fi
57
58if ! grep -q "some/badxml\.cc" ${OUTPUT_FILE}; then
59  echo "ERROR: No source 'some/badxml.cc' found in project file '${OUTPUT_FILE}'."
60  exit 1
61fi
62
63if ! grep -q "\.;include" ${OUTPUT_FILE}; then
64  echo "ERROR: No include paths '.;include' found in project file '${OUTPUT_FILE}'."
65  exit 1
66fi
67
68echo
69echo "SUCCESS: generate_keil_project test PASSED"
70