1# Copyright 2020 Google LLC 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14# 15################################################################################ 16"""Tests test_all.py""" 17import unittest 18from unittest import mock 19 20import test_all 21 22 23class TestTestAll(unittest.TestCase): 24 """Tests for the test_all_function.""" 25 26 @mock.patch('test_all.find_fuzz_targets', return_value=[]) 27 @mock.patch('builtins.print') 28 def test_test_all_no_fuzz_targets(self, mock_print, _): 29 """Tests that test_all returns False when there are no fuzz targets.""" 30 outdir = '/out' 31 allowed_broken_targets_percentage = 0 32 self.assertFalse( 33 test_all.test_all(outdir, allowed_broken_targets_percentage)) 34 mock_print.assert_called_with('ERROR: No fuzz targets found.') 35 36 37if __name__ == '__main__': 38 unittest.main() 39