diff mbox

[1/2] vsp-lib: Capture the kernel log messages in test log files

Message ID 20180519203426.25711-2-laurent.pinchart@ideasonboard.com (mailing list archive)
State Not Applicable
Delegated to: Geert Uytterhoeven
Headers show

Commit Message

Laurent Pinchart May 19, 2018, 8:34 p.m. UTC
It can be useful to capture kernel log messages in test log files for
diagnostic purpose. Add a simple mechanism to do so by capturing the
full kernel log at the end of the test. The kernel log is cleared first
before starting the test to avoid capturing unrelated messages.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 scripts/vsp-lib.sh | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Niklas Söderlund May 20, 2018, 10:47 a.m. UTC | #1
Hi Laurent,

Thanks for your patch.

On 2018-05-19 23:34:25 +0300, Laurent Pinchart wrote:
> It can be useful to capture kernel log messages in test log files for
> diagnostic purpose. Add a simple mechanism to do so by capturing the
> full kernel log at the end of the test. The kernel log is cleared first
> before starting the test to avoid capturing unrelated messages.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  scripts/vsp-lib.sh | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/scripts/vsp-lib.sh b/scripts/vsp-lib.sh
> index 0f3992a7827e..e672686a377e 100755
> --- a/scripts/vsp-lib.sh
> +++ b/scripts/vsp-lib.sh
> @@ -1075,6 +1075,9 @@ test_init() {
>  	echo "Using device $mdev ($dev)" | ./logger.sh config >> $logfile
>  
>  	vsp_runner=./vsp-runner.sh
> +
> +	# Clear the kernel log
> +	dmesg -c > /dev/null

I agree it's useful to capture the kernel log messages during a test, I 
did the same thing in vin-tests. What I did learn was that when 
something do go wrong you kind of want the whole kernel log from boot 
and truncating it could be annoying. Just the other day I got feed up 
with this in vin-tests and found a different way, as it's still fresh in 
my memory maybe it could be useful for you too, or not :-)

    marker=$(dmesg | tail -n 1 | sed 's/^\[\([^]]*\)\].*/\1/g')


>  }
>  
>  test_start() {
> @@ -1086,6 +1089,8 @@ test_complete() {
>  	echo "Done: $1" | ./logger.sh >> $logfile
>  	echo $1 >&2
>  
> +	dmesg -c | ./logger.sh kernel >> $logfile
> +

        dmesg | sed "1,/$marker/d" | ./logger.sh kernel >> $logfile

>  	rm -f ${frames_dir}frame-*.bin
>  	rm -f ${frames_dir}histo-*.bin
>  	rm -f ${frames_dir}rpf.*.bin
> -- 
> Regards,
> 
> Laurent Pinchart
>
Laurent Pinchart May 21, 2018, 8:59 a.m. UTC | #2
Hi Niklas,

On Sunday, 20 May 2018 13:47:53 EEST Niklas Söderlund wrote:
> On 2018-05-19 23:34:25 +0300, Laurent Pinchart wrote:
> > It can be useful to capture kernel log messages in test log files for
> > diagnostic purpose. Add a simple mechanism to do so by capturing the
> > full kernel log at the end of the test. The kernel log is cleared first
> > before starting the test to avoid capturing unrelated messages.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> > 
> >  scripts/vsp-lib.sh | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/scripts/vsp-lib.sh b/scripts/vsp-lib.sh
> > index 0f3992a7827e..e672686a377e 100755
> > --- a/scripts/vsp-lib.sh
> > +++ b/scripts/vsp-lib.sh
> > @@ -1075,6 +1075,9 @@ test_init() {
> > 
> >  	echo "Using device $mdev ($dev)" | ./logger.sh config >> $logfile
> >  	
> >  	vsp_runner=./vsp-runner.sh
> > 
> > +
> > +	# Clear the kernel log
> > +	dmesg -c > /dev/null
> 
> I agree it's useful to capture the kernel log messages during a test, I
> did the same thing in vin-tests. What I did learn was that when
> something do go wrong you kind of want the whole kernel log from boot
> and truncating it could be annoying. Just the other day I got feed up
> with this in vin-tests and found a different way, as it's still fresh in
> my memory maybe it could be useful for you too, or not :-)
> 
>     marker=$(dmesg | tail -n 1 | sed 's/^\[\([^]]*\)\].*/\1/g')
> 
> >  }
> >  
> >  test_start() {
> > 
> > @@ -1086,6 +1089,8 @@ test_complete() {
> > 
> >  	echo "Done: $1" | ./logger.sh >> $logfile
> >  	echo $1 >&2
> > 
> > +	dmesg -c | ./logger.sh kernel >> $logfile
> > +
> 
>         dmesg | sed "1,/$marker/d" | ./logger.sh kernel >> $logfile

That's a good idea. I gave it a try and it worked, I'll send a v2.

> >  	rm -f ${frames_dir}frame-*.bin
> >  	rm -f ${frames_dir}histo-*.bin
> >  	rm -f ${frames_dir}rpf.*.bin
diff mbox

Patch

diff --git a/scripts/vsp-lib.sh b/scripts/vsp-lib.sh
index 0f3992a7827e..e672686a377e 100755
--- a/scripts/vsp-lib.sh
+++ b/scripts/vsp-lib.sh
@@ -1075,6 +1075,9 @@  test_init() {
 	echo "Using device $mdev ($dev)" | ./logger.sh config >> $logfile
 
 	vsp_runner=./vsp-runner.sh
+
+	# Clear the kernel log
+	dmesg -c > /dev/null
 }
 
 test_start() {
@@ -1086,6 +1089,8 @@  test_complete() {
 	echo "Done: $1" | ./logger.sh >> $logfile
 	echo $1 >&2
 
+	dmesg -c | ./logger.sh kernel >> $logfile
+
 	rm -f ${frames_dir}frame-*.bin
 	rm -f ${frames_dir}histo-*.bin
 	rm -f ${frames_dir}rpf.*.bin