Skip to content

Instantly share code, notes, and snippets.

@notro
Created September 11, 2016 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save notro/4f42ec20e1be1d47c98fa749ca53c805 to your computer and use it in GitHub Desktop.
Save notro/4f42ec20e1be1d47c98fa749ca53c805 to your computer and use it in GitHub Desktop.
drm_panic test script
#!/bin/bash
cols=228
rows=61
DRM_PANIC_MAX_KMSGS=4096
function pr_emerg {
echo "<2>"$1 > /dev/kmsg
}
function drm_panic_clear_kmsgs {
echo 100 > /sys/kernel/debug/dri/panic-test
}
function drm_panic_test {
echo 101 > /sys/kernel/debug/dri/panic-test
}
function drm_panic_test_cleanup {
echo 102 > /sys/kernel/debug/dri/panic-test
}
function test_full_screen {
drm_panic_clear_kmsgs
pr_emerg 'Append line test - this should stay as the top line'
drm_panic_test
h=$((rows - 2))
w=$((cols - 23))
for i in `seq 1 $h`;
do
printf "<2>%-3u%*s%3u\n" $i $w ' ' $i > /dev/kmsg
done
pr_emerg 'Append line test - this should be the bottom line'
drm_panic_test_cleanup
}
function test_scroll_up {
drm_panic_clear_kmsgs
pr_emerg 'Scroll up test - this line should scroll out'
pr_emerg 'Scroll up test - this line should stay'
drm_panic_test
h=$((rows - 3))
for i in `seq 1 $h`;
do
printf "<2>%3u\n" $i > /dev/kmsg
done
pr_emerg 'Scroll up test - second last line'
pr_emerg 'Scroll up test - this should be the last line'
drm_panic_test_cleanup
}
function test_line_wrap {
drm_panic_clear_kmsgs
pr_emerg 'Line wrap test - this should stay as the top line'
drm_panic_test
h=$((rows / 2))
w=$(((cols * 3 / 2) - 23))
for ((i = 1 ; i < h ; i++))
do
printf "<2>%-3u%*s%3u\n" $i $w ' ' $i > /dev/kmsg
done
if (( rows % 2 )); then
pr_emerg 'Second last line'
fi
pr_emerg 'Line wrap test - this should be the last line'
drm_panic_test_cleanup
}
# test the situation where the buffer has just wrapped around
function test_precise_wrap_around {
drm_panic_clear_kmsgs
# use strings that are 64 characters long when outputted including newline
# format: [ 0.000000] Booting Linux on physical CPU 0x0
pr_emerg 'Test kmsg buffer wrap around with pos=0.........'
lines=$((DRM_PANIC_MAX_KMSGS / 64))
for ((i = 1 ; i < lines ; i++))
do
printf "<2>%-4u 123456789 123456789 123456789 123456789 123\n" $i > /dev/kmsg
done
drm_panic_test
pr_emerg 'drm_panic_kmsgs_pos should be zero after the previous message'
drm_panic_test_cleanup
}
# Use to enable pipeline if fbdev is disabled
#coproc ./libdrm/tests/modetest/modetest -M "simpledrm" -s 23:1824x984
#sleep 2
case $1 in
1)
test_full_screen
;;
2)
test_scroll_up
;;
3)
test_line_wrap
;;
4)
test_precise_wrap_around
;;
*)
echo "No such test"
;;
esac
#echo >&${COPROC[1]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment