Re: [PATCH 1/2] selftests/pstore: add pstore test script for pre-reboot

From: Hiraku Toyooka
Date: Tue Sep 29 2015 - 03:19:04 EST


Hello,

I'm sorry for my late reply.

Mark Salyzyn wrote:
Perfectly match is an issue, since something else might be using pmsg.
For instance, one of the applications that uses this interface
packetizes the messages so they can be picked out from other sources
that do not comply with the header (count, magic number etc). In this
case, should that daemon be active, your content would be ignores, but
your content would also be buried, but can be needled out with grep.

What you should do is grep for your string pattern within some
acceptable regex, and one should be found and no other, and it should
match perfectly. This would prevent another daemon's content from
disrupting your test and causing a false negative.

OK. I think that the following method suit your intention.
By splitting unique test string into TEST_STRING_PATTERN part and UUID
part, we can check both the non-existence of previous content and the
unique match on reboot-comparison run.
I'll include this in v2.

# before crash
TEST_STRING_PATTERN="Testing pstore: uuid="
UUID=`cat /proc/sys/kernel/random/uuid`
echo "$TEST_STRING_PATTERN""$UUID" > /dev/pmsg0
echo "$UUID" > uuid

# after crash
prlog -n "Checking pmsg file properly keeps the content written before crash ... "
nr_matched=`grep -c "$TEST_STRING_PATTERN" pmsg-${backend}-0`
if [ $nr_matched -eq 1 ]; then
grep -q "$TEST_STRING_PATTERN"`cat uuid` pmsg-${backend}-0
if [ $? -eq 0 ]; then
prlog "ok"
else
prlog "FAIL"
else
prlog "FAIL"
fi


Best regards,
Hiraku Toyooka

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/