X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=tests%2Futils%2Futils.sh;h=3e1a81ce5f03e3c7a8aa405b7e2ce29ead2abfb3;hb=03f7bb03e6c63b16e2992a53b4d9abab80fce07f;hp=a6f9a8b6c05cad9b0d5c6dd20ccc5d64792d3b71;hpb=3bfde48aceec7b73b8fe74e5c75fad0f795e67d6;p=lttng-tools.git diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index a6f9a8b6c..3e1a81ce5 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -148,7 +148,7 @@ function lttng_pgrep () while IFS= read -r pid ; do # /proc/pid/cmdline is null separated. - if full_command_no_argument=$(tr '\0' '\n' < /proc/"$pid"/cmdline 2>/dev/null | head -n1); then + if full_command_no_argument=$( (tr '\0' '\n' < /proc/"$pid"/cmdline) 2>/dev/null | head -n1); then command_basename=$(basename "$full_command_no_argument") if grep -q "$pattern" <<< "$command_basename"; then echo "$pid" @@ -282,6 +282,16 @@ function get_exposed_cpus_list() echo "${list[@]}" } +# Return any available CPU found. Do not make assumption about the returned +# value, e.g. that it could be 0. +function get_any_available_cpu() +{ + for cpu in /sys/devices/system/cpu/cpu[0-9]*; do + echo "${cpu#/sys/devices/system/cpu/cpu}" + break; + done +} + # Return the number of _configured_ CPUs. function conf_proc_count() {