1#!/bin/bash -eu 2# Copyright 2019 The ChromiumOS Authors 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6# This script returns BAD_STATUS if '2' is in the top line of 'func_a's profile 7# and good otherwise 8 9GOOD_STATUS=0 10BAD_STATUS=1 11SKIP_STATUS=125 12PROBLEM_STATUS=127 13 14tmp_dir=$(pwd)/afdo_test_tmp 15count_file=${tmp_dir}/.count 16 17# keep count for purpose of filenames 18if [ -f "${count_file}" ]; then 19 num_call=$(cat "${count_file}") 20else 21 num_call=0 22fi 23 24echo -n $(( ${num_call}+1 )) > "${count_file}" 25 26tmp_file=$(mktemp) 27trap "rm -f '${tmp_file}'" EXIT 28grep -v '^ ' "$1" > "${tmp_file}" 29 30# copy prof to specific file for later test 31if [[ $# -eq 2 ]]; then 32 cp "$1" "${tmp_dir}/.second_run_${num_call}" 33else 34 cp "$1" "${tmp_dir}/.first_run_${num_call}" 35fi 36 37if grep -q 'func_a.*2' "${tmp_file}"; then 38 exit "${BAD_STATUS}" 39fi 40exit "${GOOD_STATUS}" 41