From: Hiraku Toyooka <hiraku.toyooka.gu-FCd8Q96Dh0JBDgjK7y7TUQ@public.gmane.org>
To: Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Cc: LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Tony Luck <tony.luck-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Linux API <linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Anton Vorontsov <anton-9xeibp6oKSgdnm+yROfE0A@public.gmane.org>,
Shuah Khan <shuahkh-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org>,
Mark Salyzyn <salyzyn-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>,
Colin Cross <ccross-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>,
seiji.aguchi.tr-FCd8Q96Dh0JBDgjK7y7TUQ@public.gmane.org
Subject: Re: [PATCH 1/2] selftests/pstore: add pstore test script for pre-reboot
Date: Tue, 15 Sep 2015 11:31:04 +0900 [thread overview]
Message-ID: <55F782E8.80508@hitachi.com> (raw)
In-Reply-To: <CAGXu5jKLaoAjE5uYkbQW-o6TcjwDL-PS3=HndjD1LpTnN-rnAg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
Hello, Kees,
Thank you for your advise.
>> +be_msg=`dmesg | grep "pstore: Registered [a-zA-Z0-9]\+ as
persistent store backend$"`
...
> This seems unstable if the system hasn't booted recently or if stuff
> is spamming dmesg. What about examining /sys/module/pstore instead?
OK, I'll update in that way.
Best regards,
Hiraku Toyooka
Kees Cook wrote:
> On Tue, Sep 8, 2015 at 4:06 AM, Hiraku Toyooka
> <hiraku.toyooka.gu-FCd8Q96Dh0JBDgjK7y7TUQ@public.gmane.org> wrote:
>> The pstore_tests script includes test cases which check pstore's
>> behavior before crash (and reboot).
>>
>> The test cases are currently following.
>>
>> - Check pstore backend is registered
>> - Check pstore console is registered
>> - Check /dev/pmsg0 exists
>> - Write string to /dev/pmsg0
>>
>> Example usage is following.
>>
>> make: Entering directory '/home/root/selftests/pstore'
>> === Pstore unit tests (pstore_tests)===
>> Checking pstore backend is registered ... ok
>> Checking pstore console is registered ... ok
>> Checking /dev/pmsg0 exists ... ok
>> Writing TEST_STRING to /dev/pmsg0 ... ok
>> selftests: pstore_tests [PASS]
>> === Pstore unit tests (pstore_post_reboot_tests)===
>> Checking pstore backend is registered ... ok
>> pstore_crash_test has not been executed yet. we skip further tests.
>> selftests: pstore_post_reboot_tests [PASS]
>> make: Leaving directory '/home/root/selftests/pstore'
>>
>> We can also see test logs later.
>>
>> Signed-off-by: Hiraku Toyooka <hiraku.toyooka.gu-FCd8Q96Dh0JBDgjK7y7TUQ@public.gmane.org>
>> Cc: Shuah Khan <shuahkh-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org>
>> Cc: Tony Luck <tony.luck-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>> Cc: Anton Vorontsov <anton-9xeibp6oKSgdnm+yROfE0A@public.gmane.org>
>> Cc: Colin Cross <ccross-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>
>> Cc: Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
>> Cc: Mark Salyzyn <salyzyn-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>
>> Cc: Seiji Aguchi <seiji.aguchi-7rDLJAbr9SE@public.gmane.org>
>> Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>> Cc: linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>> ---
>> tools/testing/selftests/Makefile | 1 +
>> tools/testing/selftests/pstore/Makefile | 12 +++++++
>> tools/testing/selftests/pstore/common_tests | 45 +++++++++++++++++++++++++++
>> tools/testing/selftests/pstore/pstore_tests | 42 +++++++++++++++++++++++++
>> 4 files changed, 100 insertions(+)
>> create mode 100644 tools/testing/selftests/pstore/Makefile
>> create mode 100755 tools/testing/selftests/pstore/common_tests
>> create mode 100755 tools/testing/selftests/pstore/pstore_tests
>>
>> diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
>> index 24ae9e8..b58c72e 100644
>> --- a/tools/testing/selftests/Makefile
>> +++ b/tools/testing/selftests/Makefile
>> @@ -12,6 +12,7 @@ TARGETS += mount
>> TARGETS += mqueue
>> TARGETS += net
>> TARGETS += powerpc
>> +TARGETS += pstore
>> TARGETS += ptrace
>> TARGETS += seccomp
>> TARGETS += size
>> diff --git a/tools/testing/selftests/pstore/Makefile b/tools/testing/selftests/pstore/Makefile
>> new file mode 100644
>> index 0000000..40b887d
>> --- /dev/null
>> +++ b/tools/testing/selftests/pstore/Makefile
>> @@ -0,0 +1,12 @@
>> +# Makefile for pstore selftests.
>> +# Expects pstore backend is registered.
>> +
>> +all:
>> +
>> +TEST_PROGS := pstore_tests
>> +TEST_FILES := common_tests
>> +
>> +include ../lib.mk
>> +
>> +clean:
>> + rm -rf logs/*
>> diff --git a/tools/testing/selftests/pstore/common_tests b/tools/testing/selftests/pstore/common_tests
>> new file mode 100755
>> index 0000000..98611c5
>> --- /dev/null
>> +++ b/tools/testing/selftests/pstore/common_tests
>> @@ -0,0 +1,45 @@
>> +#!/bin/sh
>> +
>> +# common_tests - Shell script commonly used by pstore test scripts
>> +#
>> +# Copyright (C) Hitachi Ltd., 2015
>> +# Written by Hiraku Toyooka <hiraku.toyooka.gu-FCd8Q96Dh0JBDgjK7y7TUQ@public.gmane.org>
>> +#
>> +# Released under the terms of the GPL v2.
>> +
>> +# Utilities
>> +errexit() { # message
>> + echo "Error: $1" 1>&2
>> + exit 1
>> +}
>> +
>> +absdir() { # file_path
>> + (cd `dirname $1`; pwd)
>> +}
>> +
>> +# Parameters
>> +TOP_DIR=`absdir $0`
>> +LOG_DIR=$TOP_DIR/logs/`date +%Y%m%d-%H%M%S`/
>> +TEST_STRING="Testing pstore"
>> +
>> +# Preparing logs
>> +LOG_FILE=$LOG_DIR/`basename $0`.log
>> +mkdir -p $LOG_DIR || errexit "Failed to make a log directory: $LOG_DIR"
>> +date > $LOG_FILE
>> +prlog() { # messages
>> + /bin/echo "$@" | tee -a $LOG_FILE
>> +}
>> +prlog "=== Pstore unit tests (`basename $0`)==="
>> +
>> +# Starting tests
>> +rc=0
>> +
>> +prlog -n "Checking pstore backend is registered ... "
>> +be_msg=`dmesg | grep "pstore: Registered [a-zA-Z0-9]\+ as persistent store backend$"`
>> +if [ $? -eq 0 ]; then
>> + backend=`echo ${be_msg} | sed -e 's/^.*Registered\ \([a-zA-z0-9-]\+\)\ as.*$/\1/g'`
>> + prlog "ok"
>> +else
>> + prlog "FAIL"
>> + exit 1
>> +fi
>
> This seems unstable if the system hasn't booted recently or if stuff
> is spamming dmesg. What about examining /sys/module/pstore instead?
>
>> diff --git a/tools/testing/selftests/pstore/pstore_tests b/tools/testing/selftests/pstore/pstore_tests
>> new file mode 100755
>> index 0000000..cbf613c
>> --- /dev/null
>> +++ b/tools/testing/selftests/pstore/pstore_tests
>> @@ -0,0 +1,42 @@
>> +#!/bin/sh
>> +
>> +# pstore_tests - Check pstore's behavior before crash/reboot
>> +#
>> +# Copyright (C) Hitachi Ltd., 2015
>> +# Written by Hiraku Toyooka <hiraku.toyooka.gu-FCd8Q96Dh0JBDgjK7y7TUQ@public.gmane.org>
>> +#
>> +# Released under the terms of the GPL v2.
>> +
>> +. ./common_tests
>> +
>> +prlog -n "Checking pstore console is registered ... "
>> +dmesg | grep -q "console \[pstore"
>> +if [ $? -eq 0 ]; then
>> + prlog "ok"
>> +else
>> + prlog "FAIL"
>> +fi
>> +
>> +prlog -n "Checking /dev/pmsg0 exists ... "
>> +if [ -e "/dev/pmsg0" ]; then
>> + prlog "ok"
>> +else
>> + prlog "FAIL"
>> + rc=1
>> +fi
>> +
>> +prlog -n "Writing TEST_STRING to /dev/pmsg0 ... "
>> +if [ -e "/dev/pmsg0" ]; then
>> + echo "${TEST_STRING}" > /dev/pmsg0
>> + if [ $? -eq 0 ]; then
>> + prlog "ok"
>> + else
>> + prlog "FAIL"
>> + rc=1
>> + fi
>> +else
>> + prlog "FAIL"
>> + rc=1
>> +fi
>> +
>> +exit $rc
>>
>
> -Kees
>
--
Hiraku Toyooka
Systems Productivity Research Dept. / Linux Technology Center
Center for Technology Innovation - Systems Engineering, Hitachi Ltd.
WARNING: multiple messages have this Message-ID (diff)
From: Hiraku Toyooka <hiraku.toyooka.gu@hitachi.com>
To: Kees Cook <keescook@chromium.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Tony Luck <tony.luck@intel.com>,
Linux API <linux-api@vger.kernel.org>,
Anton Vorontsov <anton@enomsg.org>,
Shuah Khan <shuahkh@osg.samsung.com>,
Mark Salyzyn <salyzyn@android.com>,
Colin Cross <ccross@android.com>, <seiji.aguchi.tr@hitachi.com>
Subject: Re: [PATCH 1/2] selftests/pstore: add pstore test script for pre-reboot
Date: Tue, 15 Sep 2015 11:31:04 +0900 [thread overview]
Message-ID: <55F782E8.80508@hitachi.com> (raw)
In-Reply-To: <CAGXu5jKLaoAjE5uYkbQW-o6TcjwDL-PS3=HndjD1LpTnN-rnAg@mail.gmail.com>
Hello, Kees,
Thank you for your advise.
>> +be_msg=`dmesg | grep "pstore: Registered [a-zA-Z0-9]\+ as
persistent store backend$"`
...
> This seems unstable if the system hasn't booted recently or if stuff
> is spamming dmesg. What about examining /sys/module/pstore instead?
OK, I'll update in that way.
Best regards,
Hiraku Toyooka
Kees Cook wrote:
> On Tue, Sep 8, 2015 at 4:06 AM, Hiraku Toyooka
> <hiraku.toyooka.gu@hitachi.com> wrote:
>> The pstore_tests script includes test cases which check pstore's
>> behavior before crash (and reboot).
>>
>> The test cases are currently following.
>>
>> - Check pstore backend is registered
>> - Check pstore console is registered
>> - Check /dev/pmsg0 exists
>> - Write string to /dev/pmsg0
>>
>> Example usage is following.
>>
>> make: Entering directory '/home/root/selftests/pstore'
>> === Pstore unit tests (pstore_tests)===
>> Checking pstore backend is registered ... ok
>> Checking pstore console is registered ... ok
>> Checking /dev/pmsg0 exists ... ok
>> Writing TEST_STRING to /dev/pmsg0 ... ok
>> selftests: pstore_tests [PASS]
>> === Pstore unit tests (pstore_post_reboot_tests)===
>> Checking pstore backend is registered ... ok
>> pstore_crash_test has not been executed yet. we skip further tests.
>> selftests: pstore_post_reboot_tests [PASS]
>> make: Leaving directory '/home/root/selftests/pstore'
>>
>> We can also see test logs later.
>>
>> Signed-off-by: Hiraku Toyooka <hiraku.toyooka.gu@hitachi.com>
>> Cc: Shuah Khan <shuahkh@osg.samsung.com>
>> Cc: Tony Luck <tony.luck@intel.com>
>> Cc: Anton Vorontsov <anton@enomsg.org>
>> Cc: Colin Cross <ccross@android.com>
>> Cc: Kees Cook <keescook@chromium.org>
>> Cc: Mark Salyzyn <salyzyn@android.com>
>> Cc: Seiji Aguchi <seiji.aguchi@hds.com>
>> Cc: linux-kernel@vger.kernel.org
>> Cc: linux-api@vger.kernel.org
>> ---
>> tools/testing/selftests/Makefile | 1 +
>> tools/testing/selftests/pstore/Makefile | 12 +++++++
>> tools/testing/selftests/pstore/common_tests | 45 +++++++++++++++++++++++++++
>> tools/testing/selftests/pstore/pstore_tests | 42 +++++++++++++++++++++++++
>> 4 files changed, 100 insertions(+)
>> create mode 100644 tools/testing/selftests/pstore/Makefile
>> create mode 100755 tools/testing/selftests/pstore/common_tests
>> create mode 100755 tools/testing/selftests/pstore/pstore_tests
>>
>> diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
>> index 24ae9e8..b58c72e 100644
>> --- a/tools/testing/selftests/Makefile
>> +++ b/tools/testing/selftests/Makefile
>> @@ -12,6 +12,7 @@ TARGETS += mount
>> TARGETS += mqueue
>> TARGETS += net
>> TARGETS += powerpc
>> +TARGETS += pstore
>> TARGETS += ptrace
>> TARGETS += seccomp
>> TARGETS += size
>> diff --git a/tools/testing/selftests/pstore/Makefile b/tools/testing/selftests/pstore/Makefile
>> new file mode 100644
>> index 0000000..40b887d
>> --- /dev/null
>> +++ b/tools/testing/selftests/pstore/Makefile
>> @@ -0,0 +1,12 @@
>> +# Makefile for pstore selftests.
>> +# Expects pstore backend is registered.
>> +
>> +all:
>> +
>> +TEST_PROGS := pstore_tests
>> +TEST_FILES := common_tests
>> +
>> +include ../lib.mk
>> +
>> +clean:
>> + rm -rf logs/*
>> diff --git a/tools/testing/selftests/pstore/common_tests b/tools/testing/selftests/pstore/common_tests
>> new file mode 100755
>> index 0000000..98611c5
>> --- /dev/null
>> +++ b/tools/testing/selftests/pstore/common_tests
>> @@ -0,0 +1,45 @@
>> +#!/bin/sh
>> +
>> +# common_tests - Shell script commonly used by pstore test scripts
>> +#
>> +# Copyright (C) Hitachi Ltd., 2015
>> +# Written by Hiraku Toyooka <hiraku.toyooka.gu@hitachi.com>
>> +#
>> +# Released under the terms of the GPL v2.
>> +
>> +# Utilities
>> +errexit() { # message
>> + echo "Error: $1" 1>&2
>> + exit 1
>> +}
>> +
>> +absdir() { # file_path
>> + (cd `dirname $1`; pwd)
>> +}
>> +
>> +# Parameters
>> +TOP_DIR=`absdir $0`
>> +LOG_DIR=$TOP_DIR/logs/`date +%Y%m%d-%H%M%S`/
>> +TEST_STRING="Testing pstore"
>> +
>> +# Preparing logs
>> +LOG_FILE=$LOG_DIR/`basename $0`.log
>> +mkdir -p $LOG_DIR || errexit "Failed to make a log directory: $LOG_DIR"
>> +date > $LOG_FILE
>> +prlog() { # messages
>> + /bin/echo "$@" | tee -a $LOG_FILE
>> +}
>> +prlog "=== Pstore unit tests (`basename $0`)==="
>> +
>> +# Starting tests
>> +rc=0
>> +
>> +prlog -n "Checking pstore backend is registered ... "
>> +be_msg=`dmesg | grep "pstore: Registered [a-zA-Z0-9]\+ as persistent store backend$"`
>> +if [ $? -eq 0 ]; then
>> + backend=`echo ${be_msg} | sed -e 's/^.*Registered\ \([a-zA-z0-9-]\+\)\ as.*$/\1/g'`
>> + prlog "ok"
>> +else
>> + prlog "FAIL"
>> + exit 1
>> +fi
>
> This seems unstable if the system hasn't booted recently or if stuff
> is spamming dmesg. What about examining /sys/module/pstore instead?
>
>> diff --git a/tools/testing/selftests/pstore/pstore_tests b/tools/testing/selftests/pstore/pstore_tests
>> new file mode 100755
>> index 0000000..cbf613c
>> --- /dev/null
>> +++ b/tools/testing/selftests/pstore/pstore_tests
>> @@ -0,0 +1,42 @@
>> +#!/bin/sh
>> +
>> +# pstore_tests - Check pstore's behavior before crash/reboot
>> +#
>> +# Copyright (C) Hitachi Ltd., 2015
>> +# Written by Hiraku Toyooka <hiraku.toyooka.gu@hitachi.com>
>> +#
>> +# Released under the terms of the GPL v2.
>> +
>> +. ./common_tests
>> +
>> +prlog -n "Checking pstore console is registered ... "
>> +dmesg | grep -q "console \[pstore"
>> +if [ $? -eq 0 ]; then
>> + prlog "ok"
>> +else
>> + prlog "FAIL"
>> +fi
>> +
>> +prlog -n "Checking /dev/pmsg0 exists ... "
>> +if [ -e "/dev/pmsg0" ]; then
>> + prlog "ok"
>> +else
>> + prlog "FAIL"
>> + rc=1
>> +fi
>> +
>> +prlog -n "Writing TEST_STRING to /dev/pmsg0 ... "
>> +if [ -e "/dev/pmsg0" ]; then
>> + echo "${TEST_STRING}" > /dev/pmsg0
>> + if [ $? -eq 0 ]; then
>> + prlog "ok"
>> + else
>> + prlog "FAIL"
>> + rc=1
>> + fi
>> +else
>> + prlog "FAIL"
>> + rc=1
>> +fi
>> +
>> +exit $rc
>>
>
> -Kees
>
--
Hiraku Toyooka
Systems Productivity Research Dept. / Linux Technology Center
Center for Technology Innovation - Systems Engineering, Hitachi Ltd.
next prev parent reply other threads:[~2015-09-15 2:31 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-08 11:06 [PATCH 0/2] selftests/pstore: add pstore test script Hiraku Toyooka
2015-09-08 11:06 ` [PATCH 1/2] selftests/pstore: add pstore test script for pre-reboot Hiraku Toyooka
2015-09-08 23:22 ` Mark Salyzyn
2015-09-08 23:22 ` Mark Salyzyn
[not found] ` <55EF6DC5.2080207-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>
2015-09-15 2:30 ` Hiraku Toyooka
2015-09-15 2:30 ` Hiraku Toyooka
2015-09-21 21:04 ` Mark Salyzyn
[not found] ` <560070D0.90709-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>
2015-09-29 7:18 ` Hiraku Toyooka
2015-09-29 7:18 ` Hiraku Toyooka
2015-09-08 23:37 ` Kees Cook
2015-09-08 23:37 ` Kees Cook
[not found] ` <CAGXu5jKLaoAjE5uYkbQW-o6TcjwDL-PS3=HndjD1LpTnN-rnAg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-09-15 2:31 ` Hiraku Toyooka [this message]
2015-09-15 2:31 ` Hiraku Toyooka
[not found] ` <55F782E8.80508-FCd8Q96Dh0JBDgjK7y7TUQ@public.gmane.org>
2015-09-16 12:02 ` 阿口誠司 / AGUCHI,SEIJI
2015-09-16 12:02 ` 阿口誠司 / AGUCHI,SEIJI
[not found] ` <753241EEF6DFAB4CAF20F32F515C4E358B33C3-RKwZE6o2dOX6mtb5pcma++hNMziWB107FCd8Q96Dh0LR7s880joybQ@public.gmane.org>
2015-09-17 5:54 ` Hiraku Toyooka
2015-09-17 5:54 ` Hiraku Toyooka
2015-09-08 11:06 ` [PATCH 2/2] selftests/pstore: add pstore test scripts going with reboot Hiraku Toyooka
2015-09-08 11:06 ` Hiraku Toyooka
2015-09-08 23:40 ` Kees Cook
[not found] ` <CAGXu5j+Ha0t-acFc+morgUiDRCHGdx8QHySX29PYpnj4QFiJhA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-09-15 2:41 ` Hiraku Toyooka
2015-09-15 2:41 ` Hiraku Toyooka
2015-09-16 12:11 ` 阿口誠司 / AGUCHI,SEIJI
2015-09-16 12:11 ` 阿口誠司 / AGUCHI,SEIJI
[not found] ` <753241EEF6DFAB4CAF20F32F515C4E358B347A-RKwZE6o2dOX6mtb5pcma++hNMziWB107FCd8Q96Dh0LR7s880joybQ@public.gmane.org>
2015-09-17 5:54 ` Hiraku Toyooka
2015-09-17 5:54 ` Hiraku Toyooka
2015-09-08 23:42 ` [PATCH 0/2] selftests/pstore: add pstore test script Kees Cook
2015-09-08 23:42 ` Kees Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55F782E8.80508@hitachi.com \
--to=hiraku.toyooka.gu-fcd8q96dh0jbdgjk7y7tuq@public.gmane.org \
--cc=anton-9xeibp6oKSgdnm+yROfE0A@public.gmane.org \
--cc=ccross-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org \
--cc=keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
--cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=salyzyn-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org \
--cc=seiji.aguchi.tr-FCd8Q96Dh0JBDgjK7y7TUQ@public.gmane.org \
--cc=shuahkh-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org \
--cc=tony.luck-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.