fi
fi
+stat_output=$(mktemp /tmp/__perf_test.stat_output.json.XXXXX)
+
+cleanup() {
+ rm -f "${stat_output}"
+
+ trap - EXIT TERM INT
+}
+
+trap_cleanup() {
+ cleanup
+ exit 1
+}
+trap trap_cleanup EXIT TERM INT
+
# Return true if perf_event_paranoid is > $1 and not running as root.
function ParanoidAndNotRoot()
{
check_no_args()
{
echo -n "Checking json output: no args "
- perf stat -j true 2>&1 | $PYTHON $pythonchecker --no-args
+ perf stat -j -o "${stat_output}" true
+ $PYTHON $pythonchecker --no-args --file "${stat_output}"
echo "[Success]"
}
echo "[Skip] paranoia and not root"
return
fi
- perf stat -j -a true 2>&1 | $PYTHON $pythonchecker --system-wide
+ perf stat -j -a -o "${stat_output}" true
+ $PYTHON $pythonchecker --system-wide --file "${stat_output}"
echo "[Success]"
}
check_system_wide_no_aggr()
{
- echo -n "Checking json output: system wide "
+ echo -n "Checking json output: system wide no aggregation "
if ParanoidAndNotRoot 0
then
echo "[Skip] paranoia and not root"
return
fi
- echo -n "Checking json output: system wide no aggregation "
- perf stat -j -A -a --no-merge true 2>&1 | $PYTHON $pythonchecker --system-wide-no-aggr
+ perf stat -j -A -a --no-merge -o "${stat_output}" true
+ $PYTHON $pythonchecker --system-wide-no-aggr --file "${stat_output}"
echo "[Success]"
}
check_interval()
{
echo -n "Checking json output: interval "
- perf stat -j -I 1000 true 2>&1 | $PYTHON $pythonchecker --interval
+ perf stat -j -I 1000 -o "${stat_output}" true
+ $PYTHON $pythonchecker --interval --file "${stat_output}"
echo "[Success]"
}
check_event()
{
echo -n "Checking json output: event "
- perf stat -j -e cpu-clock true 2>&1 | $PYTHON $pythonchecker --event
+ perf stat -j -e cpu-clock -o "${stat_output}" true
+ $PYTHON $pythonchecker --event --file "${stat_output}"
echo "[Success]"
}
echo "[Skip] paranoia and not root"
return
fi
- perf stat -j --per-core -a true 2>&1 | $PYTHON $pythonchecker --per-core
+ perf stat -j --per-core -a -o "${stat_output}" true
+ $PYTHON $pythonchecker --per-core --file "${stat_output}"
echo "[Success]"
}
echo "[Skip] paranoia and not root"
return
fi
- perf stat -j --per-thread -a true 2>&1 | $PYTHON $pythonchecker --per-thread
+ perf stat -j --per-thread -a -o "${stat_output}" true
+ $PYTHON $pythonchecker --per-thread --file "${stat_output}"
echo "[Success]"
}
echo "[Skip] paranoia and not root"
return
fi
- perf stat -j --per-die -a true 2>&1 | $PYTHON $pythonchecker --per-die
+ perf stat -j --per-die -a -o "${stat_output}" true
+ $PYTHON $pythonchecker --per-die --file "${stat_output}"
echo "[Success]"
}
echo "[Skip] paranoia and not root"
return
fi
- perf stat -j --per-node -a true 2>&1 | $PYTHON $pythonchecker --per-node
+ perf stat -j --per-node -a -o "${stat_output}" true
+ $PYTHON $pythonchecker --per-node --file "${stat_output}"
echo "[Success]"
}
echo "[Skip] paranoia and not root"
return
fi
- perf stat -j --per-socket -a true 2>&1 | $PYTHON $pythonchecker --per-socket
+ perf stat -j --per-socket -a -o "${stat_output}" true
+ $PYTHON $pythonchecker --per-socket --file "${stat_output}"
echo "[Success]"
}
else
echo "[Skip] Skipping tests for system_wide_no_aggr, per_core, per_die and per_socket since socket id exposed via topology is invalid"
fi
+cleanup
exit 0