@@ -37,7 +37,7 @@ Adding tests
See the common functions.sh file for the existing collection of utility
functions, most importantly setup_config(), start_test() and
check_result(). The latter function greps the kernel's ring buffer for
-"livepatch:" and "test_klp" strings, so tests be sure to include one of
-those strings for result comparison. Other utility functions include
-general module loading and livepatch loading helpers (waiting for patch
-transitions, sysfs entries, etc.)
+the "^livepatch:" subsystem prefix and also any "test_klp" strings.
+Test log entries need include one of those for result comparison. Other
+utility functions include general module loading and livepatch loading
+helpers (waiting for patch transitions, sysfs entries, etc.)
@@ -248,7 +248,7 @@ function start_test {
# Save existing dmesg so we can detect new content below
SAVED_DMESG=$(mktemp --tmpdir -t klp-dmesg-XXXXXX)
- dmesg > "$SAVED_DMESG"
+ dmesg --notime > "$SAVED_DMESG"
echo -n "TEST: $test ... "
}
@@ -259,9 +259,8 @@ function check_result {
local expect="$*"
local result
- result=$(dmesg | diff --changed-group-format='%>' --unchanged-group-format='' "$SAVED_DMESG" - | \
- grep -v 'tainting' | grep -e 'livepatch:' -e 'test_klp' | \
- sed 's/^\[[ 0-9.]*\] //')
+ result=$(dmesg --notime | diff --changed-group-format='%>' --unchanged-group-format='' "$SAVED_DMESG" - | \
+ grep -v 'tainting' | grep -e '^livepatch:' -e 'test_klp')
if [[ "$expect" == "$result" ]] ; then
echo "ok"
The dmesg utility already comes with a command line switch to omit kernel timestamps, let's use it instead of applying an extra regex to filter them out. Now without the '[timestamp]: ' prefix at the beginning of the log entry, revise the filtering regex to search for the 'livepatch:' subsystem prefix at the beginning of the line. Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com> --- tools/testing/selftests/livepatch/README | 8 ++++---- tools/testing/selftests/livepatch/functions.sh | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-)