|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +# pstore_post_reboot_tests - Check pstore's behavior after crash/reboot |
| 4 | +# |
| 5 | +# Copyright (C) Hitachi Ltd., 2015 |
| 6 | +# Written by Hiraku Toyooka <[email protected]> |
| 7 | +# |
| 8 | +# Released under the terms of the GPL v2. |
| 9 | + |
| 10 | +. ./common_tests |
| 11 | + |
| 12 | +if [ -e $REBOOT_FLAG ]; then |
| 13 | + rm $REBOOT_FLAG |
| 14 | +else |
| 15 | + prlog "pstore_crash_test has not been executed yet. we skip further tests." |
| 16 | + exit 0 |
| 17 | +fi |
| 18 | + |
| 19 | +prlog -n "Mounting pstore filesystem ... " |
| 20 | +mount_info=`grep pstore /proc/mounts` |
| 21 | +if [ $? -eq 0 ]; then |
| 22 | + mount_point=`echo ${mount_info} | cut -d' ' -f2 | head -n1` |
| 23 | + prlog "ok" |
| 24 | +else |
| 25 | + mount none /sys/fs/pstore -t pstore |
| 26 | + if [ $? -eq 0 ]; then |
| 27 | + mount_point=`grep pstore /proc/mounts | cut -d' ' -f2 | head -n1` |
| 28 | + prlog "ok" |
| 29 | + else |
| 30 | + prlog "FAIL" |
| 31 | + exit 1 |
| 32 | + fi |
| 33 | +fi |
| 34 | + |
| 35 | +cd ${mount_point} |
| 36 | + |
| 37 | +prlog -n "Checking dmesg files exist in pstore filesystem ... " |
| 38 | +check_files_exist dmesg |
| 39 | + |
| 40 | +prlog -n "Checking console files exist in pstore filesystem ... " |
| 41 | +check_files_exist console |
| 42 | + |
| 43 | +prlog -n "Checking pmsg files exist in pstore filesystem ... " |
| 44 | +check_files_exist pmsg |
| 45 | + |
| 46 | +prlog -n "Checking dmesg files contain oops end marker" |
| 47 | +grep_end_trace() { |
| 48 | + grep -q "\---\[ end trace" $1 |
| 49 | +} |
| 50 | +files=`ls dmesg-${backend}-*` |
| 51 | +operate_files $? "$files" grep_end_trace |
| 52 | + |
| 53 | +prlog -n "Checking console file contains oops end marker ... " |
| 54 | +grep -q "\---\[ end trace" console-${backend}-0 |
| 55 | +show_result $? |
| 56 | + |
| 57 | +prlog -n "Checking pmsg file properly keeps the content written before crash ... " |
| 58 | +prev_uuid=`cat $TOP_DIR/prev_uuid` |
| 59 | +if [ $? -eq 0 ]; then |
| 60 | + nr_matched=`grep -c "$TEST_STRING_PATTERN" pmsg-${backend}-0` |
| 61 | + if [ $nr_matched -eq 1 ]; then |
| 62 | + grep -q "$TEST_STRING_PATTERN"$prev_uuid pmsg-${backend}-0 |
| 63 | + show_result $? |
| 64 | + else |
| 65 | + prlog "FAIL" |
| 66 | + rc=1 |
| 67 | + fi |
| 68 | +else |
| 69 | + prlog "FAIL" |
| 70 | + rc=1 |
| 71 | +fi |
| 72 | + |
| 73 | +prlog -n "Removing all files in pstore filesystem " |
| 74 | +files=`ls *-${backend}-*` |
| 75 | +operate_files $? "$files" rm |
| 76 | + |
| 77 | +exit $rc |
0 commit comments