blob: e63faa2b27bf7ca2ee13a2e3009529bb20eb8b18 [file] [log] [blame]
Rickard Bolinbc6ee582022-11-04 08:24:29 +00001# SPDX-FileCopyrightText: Copyright 2020 Arm Limited and/or its affiliates <open-source-office@arm.com>
Louis Verhaard7db78962020-05-25 15:05:26 +02002#
3# SPDX-License-Identifier: Apache-2.0
4#
5# Licensed under the Apache License, Version 2.0 (the License); you may
6# not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an AS IS BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
Rickard Bolinbc6ee582022-11-04 08:24:29 +000016#
Louis Verhaard7db78962020-05-25 15:05:26 +020017# Description:
18# Unit tests for model_reader.
19import pytest
Louis Verhaard0b8268a2020-08-05 16:11:29 +020020
Louis Verhaard7db78962020-05-25 15:05:26 +020021from ethosu.vela import model_reader
22from ethosu.vela.errors import InputFileError
23
24
25def test_read_model_incorrect_extension(tmpdir):
26 # Tests read_model with a file name that does not end with .tflite
27 with pytest.raises(InputFileError):
28 model_reader.read_model("no_tflite_file.txt", model_reader.ModelReaderOptions())
29
30
Louis Verhaard7db78962020-05-25 15:05:26 +020031def test_read_model_file_not_found(tmpdir):
32 # Tests read_model with a .tflite file that does not exist
Tim Hallc8310b12020-06-17 14:53:11 +010033 with pytest.raises(FileNotFoundError):
Louis Verhaard7db78962020-05-25 15:05:26 +020034 model_reader.read_model("non_existing.tflite", model_reader.ModelReaderOptions())