1#!/usr/bin/env python3 2# Copyright 2021 Google LLC 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"""Does bad_build_check on a fuzz target in $OUT.""" 18import os 19import sys 20 21import test_all 22 23 24def test_one(fuzz_target): 25 """Does bad_build_check on one fuzz target. Returns True on success.""" 26 with test_all.use_different_out_dir(): 27 fuzz_target_path = os.path.join(os.environ['OUT'], fuzz_target) 28 return test_all.do_bad_build_check(fuzz_target_path).returncode == 0 29 30 31def main(): 32 """Does bad_build_check on one fuzz target. Returns 1 on failure, 0 on 33 success.""" 34 if len(sys.argv) != 2: 35 print('Usage: %d <fuzz_target>', sys.argv[0]) 36 return 1 37 38 fuzz_target_binary = sys.argv[1] 39 return 0 if test_one(fuzz_target_binary) else 1 40 41 42if __name__ == '__main__': 43 sys.exit(main()) 44