#!/bin/bash -u # Copyright 2020 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ################################################################################ # Wrapper around bad_build_check that moves the /out directory to /tmp/not-out. # This is useful when bad_build_check isn't called from test_all which does the # same thing. function main { # Move the directory the fuzzer is located in to somewhere that doesn't exist # on the builder to make it more likely that hardcoding /out fails here (since # it will fail on ClusterFuzz). local fuzzer=$1 fuzzer=$(realpath $fuzzer) local initial_fuzzer_dir=$(dirname $fuzzer) local tmp_fuzzer_dir=/tmp/not-out rm -rf $tmp_fuzzer_dir mkdir $tmp_fuzzer_dir # Move the contents of $initial_fuzzer_dir rather than the directory itself in # case it is a mount. mv $initial_fuzzer_dir/* $tmp_fuzzer_dir fuzzer="$tmp_fuzzer_dir/$(basename $fuzzer)" # Change OUT to the temporary fuzzer dir. local initial_out=$OUT export OUT=$tmp_fuzzer_dir bad_build_check $fuzzer returncode=$? # Restore OUT and $initial_fuzzer_dir export OUT=$initial_out mv $tmp_fuzzer_dir/* $initial_fuzzer_dir return $returncode } if [ $# -ne 1 ]; then echo "Usage: $0 " exit 1 fi main $1 exit $?