Merge branches 'work.misc' and 'work.dcache' of git://git.kernel.org/pub/scm/linux...
[sfrench/cifs-2.6.git] / tools / testing / selftests / pstore / pstore_post_reboot_tests
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 <hiraku.toyooka.gu@hitachi.com>
7 #
8 # Released under the terms of the GPL v2.
9
10 # Kselftest framework requirement - SKIP code is 4.
11 ksft_skip=4
12
13 . ./common_tests
14
15 if [ -e $REBOOT_FLAG  ]; then
16     rm $REBOOT_FLAG
17 else
18     prlog "pstore_crash_test has not been executed yet. we skip further tests."
19     exit $ksft_skip
20 fi
21
22 prlog -n "Mounting pstore filesystem ... "
23 mount_info=`grep pstore /proc/mounts`
24 if [ $? -eq 0 ]; then
25     mount_point=`echo ${mount_info} | cut -d' ' -f2 | head -n1`
26     prlog "ok"
27 else
28     mount none /sys/fs/pstore -t pstore
29     if [ $? -eq 0 ]; then
30         mount_point=`grep pstore /proc/mounts | cut -d' ' -f2 | head -n1`
31         prlog "ok"
32     else
33         prlog "FAIL"
34         exit 1
35     fi
36 fi
37
38 cd ${mount_point}
39
40 prlog -n "Checking dmesg files exist in pstore filesystem ... "
41 check_files_exist dmesg
42
43 prlog -n "Checking console files exist in pstore filesystem ... "
44 check_files_exist console
45
46 prlog -n "Checking pmsg files exist in pstore filesystem ... "
47 check_files_exist pmsg
48
49 prlog -n "Checking dmesg files contain oops end marker"
50 grep_end_trace() {
51     grep -q "\---\[ end trace" $1
52 }
53 files=`ls dmesg-${backend}-*`
54 operate_files $? "$files" grep_end_trace
55
56 prlog -n "Checking console file contains oops end marker ... "
57 grep -q "\---\[ end trace" console-${backend}-0
58 show_result $?
59
60 prlog -n "Checking pmsg file properly keeps the content written before crash ... "
61 prev_uuid=`cat $TOP_DIR/prev_uuid`
62 if [ $? -eq 0 ]; then
63     nr_matched=`grep -c "$TEST_STRING_PATTERN" pmsg-${backend}-0`
64     if [ $nr_matched -eq 1 ]; then
65         grep -q "$TEST_STRING_PATTERN"$prev_uuid pmsg-${backend}-0
66         show_result $?
67     else
68         prlog "FAIL"
69         rc=1
70     fi
71 else
72     prlog "FAIL"
73     rc=1
74 fi
75
76 prlog -n "Removing all files in pstore filesystem "
77 files=`ls *-${backend}-*`
78 operate_files $? "$files" rm
79
80 exit $rc