test: Use /usr/bin/perf for perf
PATCH 1/1 test: Use /usr/bin/perf for perf
From: Eugene Loh <[email protected]>
The testsuite package has a dependency on the perf package. But that package installs perf in /usr/bin. Meanwhile, there is a /sbin/perf, which is likely to appear earlier in the search path for dtrace users. That perf is a wrapper for an executable that might not exist, causing some silent, unexpected behaviors with the test suite.
Change references to "perf" to be explicitly "/usr/bin/perf".
--- test/unittest/cpc/tst.branches.x | 4 ++-- test/unittest/cpc/tst.instructions.x | 4 ++-- test/utils/cpc_get_events.sh | 4 ++-- test/utils/perf_count_event.sh | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-)
test/unittest/cpc/tst.branches.x +2 -2
@@ -1,11 +1,11 @@ #!/bin/bash # # Oracle Linux DTrace. -# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. # Licensed under the Universal Permissive License v 1.0 as shown at # http://oss.oracle.com/licenses/upl. -if ! perf list hw | grep -qw branches; then +if ! /usr/bin/perf list hw | grep -qw branches; then echo 'no "branches" event on this system' exit 2 fi
test/unittest/cpc/tst.instructions.x +2 -2
@@ -1,11 +1,11 @@ #!/bin/bash # # Oracle Linux DTrace. -# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. # Licensed under the Universal Permissive License v 1.0 as shown at # http://oss.oracle.com/licenses/upl. -if ! perf list hw | grep -qw instructions; then +if ! /usr/bin/perf list hw | grep -qw instructions; then echo 'no "instructions" event on this system' exit 2 fi
test/utils/cpc_get_events.sh +2 -2
@@ -1,7 +1,7 @@ #!/bin/bash # # Oracle Linux DTrace. -# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. # Licensed under the Universal Permissive License v 1.0 as shown at # http://oss.oracle.com/licenses/upl.
@@ -13,7 +13,7 @@ eventnamelist="cpu-clock" $(dirname $0)/cpc_temp_skip_bug.sh > /dev/null if [ $? -eq 0 ]; then for eventname in branches instructions; do - if perf list hw | grep -qw $eventname; then + if /usr/bin/perf list hw | grep -qw $eventname; then eventnamelist="$eventnamelist $eventname" fi done
test/utils/perf_count_event.sh +2 -2
@@ -1,7 +1,7 @@ #!/bin/bash # # Oracle Linux DTrace. -# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. # Licensed under the Universal Permissive License v 1.0 as shown at # http://oss.oracle.com/licenses/upl.
@@ -20,7 +20,7 @@ shift # If the output is no good, report -1. # If the output is time in msec, convert to nsec. # Otherwise, just report the count. -perf stat -e $event --no-big-num -x\ $utils/$* |& gawk ' +/usr/bin/perf stat -e $event --no-big-num -x\ $utils/$* |& gawk ' /^[^0-9]/ { print -1; exit 1 } / msec / { print int(1000000. * $1); exit 0 } { print $1; exit 0 }'
Signature · 1 line
2.47.3
Quoted 11 lines · On Mon, Oct 20, 2025 at 11:19:07PM -0400, [email protected] wrote:
From: Eugene Loh <[email protected]>
The testsuite package has a dependency on the perf package. But that package installs perf in
/usr/bin. Meanwhile, there is a/sbin/perf, which is likely to appear earlier in the search path for dtrace users. That perf is a wrapper for an executable that might not exist, causing some silent, unexpected behaviors with the test suite.Change references to "perf" to be explicitly "
/usr/bin/perf".Signed-off-by Eugene Loh <[email protected]>
Quoted 90 lines
--- test/unittest/cpc/tst.branches.x | 4 ++-- test/unittest/cpc/tst.instructions.x | 4 ++-- test/utils/cpc_get_events.sh | 4 ++-- test/utils/perf_count_event.sh | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-)test/unittest/cpc/tst.branches.x +2
-2@@ -1,11 +1,11 @@ #!/bin/bash # # Oracle Linux DTrace. -# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. # Licensed under the Universal Permissive License v 1.0 as shown at # http://oss.oracle.com/licenses/upl. -if ! perf list hw | grep -qw branches; then +if ! /usr/bin/perf list hw | grep -qw branches; then echo 'no "branches" event on this system' exit 2 fitest/unittest/cpc/tst.instructions.x +2
-2@@ -1,11 +1,11 @@ #!/bin/bash # # Oracle Linux DTrace. -# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. # Licensed under the Universal Permissive License v 1.0 as shown at # http://oss.oracle.com/licenses/upl. -if ! perf list hw | grep -qw instructions; then +if ! /usr/bin/perf list hw | grep -qw instructions; then echo 'no "instructions" event on this system' exit 2 fitest/utils/cpc_get_events.sh +2
-2@@ -1,7 +1,7 @@ #!/bin/bash # # Oracle Linux DTrace. -# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. # Licensed under the Universal Permissive License v 1.0 as shown at # http://oss.oracle.com/licenses/upl.@@ -13,7 +13,7 @@ eventnamelist="cpu-clock" $(dirname $0)/cpc_temp_skip_bug.sh > /dev/null if [ $? -eq 0 ]; then for eventname in branches instructions; do - if perf list hw | grep -qw $eventname; then + if /usr/bin/perf list hw | grep -qw $eventname; then eventnamelist="$eventnamelist $eventname" fi donetest/utils/perf_count_event.sh +2
-2@@ -1,7 +1,7 @@ #!/bin/bash # # Oracle Linux DTrace. -# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. # Licensed under the Universal Permissive License v 1.0 as shown at # http://oss.oracle.com/licenses/upl.@@ -20,7 +20,7 @@ shift # If the output is no good, report -1. # If the output is time in msec, convert to nsec. # Otherwise, just report the count. -perf stat -e $event --no-big-num -x\ $utils/$* |& gawk ' +/usr/bin/perf stat -e $event --no-big-num -x\ $utils/$* |& gawk ' /^[^0-9]/ { print -1; exit 1 } / msec / { print int(1000000. * $1); exit 0 } { print $1; exit 0 }'Signature · 1 line
2.47.3
Quoted 7 lines · eugene.loh--- via DTrace-devel
From: Eugene Loh <[email protected]>
The testsuite package has a dependency on the perf package. But that package installs perf in
/usr/bin. Meanwhile, there is a/sbin/perf, which is likely to appear earlier in the search path for dtrace users. That perf is a wrapper for an executable that might not exist, causing some silent, unexpected behaviors with the test suite.
Just for my own curiosity: what exactly is /sbin/perf? I've never heard of this "collision" before, so want to know if I should be aware of it in other contexts.
Quoted 91 lines
Change references to "perf" to be explicitly "
/usr/bin/perf".Signed-off-by Eugene Loh <[email protected]>--- test/unittest/cpc/tst.branches.x | 4 ++-- test/unittest/cpc/tst.instructions.x | 4 ++-- test/utils/cpc_get_events.sh | 4 ++-- test/utils/perf_count_event.sh | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-)test/unittest/cpc/tst.branches.x +2
-2@@ -1,11 +1,11 @@ #!/bin/bash # # Oracle Linux DTrace. -# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. # Licensed under the Universal Permissive License v 1.0 as shown at # http://oss.oracle.com/licenses/upl. -if ! perf list hw | grep -qw branches; then +if ! /usr/bin/perf list hw | grep -qw branches; then echo 'no "branches" event on this system' exit 2 fitest/unittest/cpc/tst.instructions.x +2
-2@@ -1,11 +1,11 @@ #!/bin/bash # # Oracle Linux DTrace. -# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. # Licensed under the Universal Permissive License v 1.0 as shown at # http://oss.oracle.com/licenses/upl. -if ! perf list hw | grep -qw instructions; then +if ! /usr/bin/perf list hw | grep -qw instructions; then echo 'no "instructions" event on this system' exit 2 fitest/utils/cpc_get_events.sh +2
-2@@ -1,7 +1,7 @@ #!/bin/bash # # Oracle Linux DTrace. -# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. # Licensed under the Universal Permissive License v 1.0 as shown at # http://oss.oracle.com/licenses/upl.@@ -13,7 +13,7 @@ eventnamelist="cpu-clock" $(dirname $0)/cpc_temp_skip_bug.sh > /dev/null if [ $? -eq 0 ]; then for eventname in branches instructions; do - if perf list hw | grep -qw $eventname; then + if /usr/bin/perf list hw | grep -qw $eventname; then eventnamelist="$eventnamelist $eventname" fi donetest/utils/perf_count_event.sh +2
-2@@ -1,7 +1,7 @@ #!/bin/bash # # Oracle Linux DTrace. -# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. # Licensed under the Universal Permissive License v 1.0 as shown at # http://oss.oracle.com/licenses/upl.@@ -20,7 +20,7 @@ shift # If the output is no good, report -1. # If the output is time in msec, convert to nsec. # Otherwise, just report the count. -perf stat -e $event --no-big-num -x\ $utils/$* |& gawk ' +/usr/bin/perf stat -e $event --no-big-num -x\ $utils/$* |& gawk ' /^[^0-9]/ { print -1; exit 1 } / msec / { print int(1000000. * $1); exit 0 } { print $1; exit 0 }'