#!/usr/bin/sh
# SPDX-License-Identifier: GPL-2.0-only

# pstore_tests - Check pstore's behavior before crash/reboot
#
# Copyright (C) Hitachi Ltd., 2015
#  Written by Hiraku Toyooka <hiraku.toyooka.gu@hitachi.com>
#

. ./common_tests

# The frontends are separate options, a backend does not bring them in
prlog -n "Checking pstore console is registered ... "
if dmesg | grep -Eq "console \[(pstore|${backend})"; then
    show_result 0
else
    prlog "SKIP (no pstore console, needs CONFIG_PSTORE_CONSOLE)"
fi

prlog -n "Checking /dev/pmsg0 exists ... "
if [ -e /dev/pmsg0 ]; then
    show_result 0
else
    prlog "SKIP (no /dev/pmsg0, needs CONFIG_PSTORE_PMSG)"
fi

prlog -n "Writing unique string to /dev/pmsg0 ... "
if [ -e "/dev/pmsg0" ]; then
    echo "${TEST_STRING_PATTERN}""$UUID" > /dev/pmsg0
    show_result $?
    echo "$UUID" > $TOP_DIR/uuid
else
    prlog "SKIP (no /dev/pmsg0)"
fi

exit $rc
