1b71c9ffbSNicholas Piggin#!/bin/bash
2b71c9ffbSNicholas Piggin
3b71c9ffbSNicholas Pigginset -e
4b71c9ffbSNicholas Pigginset -o pipefail
5b71c9ffbSNicholas Piggin
6b71c9ffbSNicholas Piggin# To debug, uncomment the following line
7b71c9ffbSNicholas Piggin# set -x
8b71c9ffbSNicholas Piggin
9b71c9ffbSNicholas Piggin# Test whether the compile option -mprofile-kernel exists and generates
10b71c9ffbSNicholas Piggin# profiling code (ie. a call to _mcount()).
11b71c9ffbSNicholas Pigginecho "int func() { return 0; }" | \
12b71c9ffbSNicholas Piggin    $* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \
13b71c9ffbSNicholas Piggin    grep -q "_mcount"
14b71c9ffbSNicholas Piggin
15b71c9ffbSNicholas Piggin# Test whether the notrace attribute correctly suppresses calls to _mcount().
16b71c9ffbSNicholas Piggin
17b71c9ffbSNicholas Pigginecho -e "#include <linux/compiler.h>\nnotrace int func() { return 0; }" | \
18b71c9ffbSNicholas Piggin    $* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \
19b71c9ffbSNicholas Piggin    grep -q "_mcount" && \
20b71c9ffbSNicholas Piggin    exit 1
21b71c9ffbSNicholas Piggin
22b71c9ffbSNicholas Pigginecho "OK"
23b71c9ffbSNicholas Pigginexit 0
24