public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: chrubis@suse.cz
To: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH v2] lib/tst_sig.c: output signal name when got unexpected signal
Date: Mon, 12 May 2014 16:56:46 +0200	[thread overview]
Message-ID: <20140512145646.GF4741@rei> (raw)
In-Reply-To: <1399616591-32662-1-git-send-email-wangxg.fnst@cn.fujitsu.com>

Hi!
> When testcase is killed by unexpected signal, usually it just prints
> signal's value.
> 	fcntl30     1  TBROK  :  unexpected signal 2 received (pid = 6714).
> 	fcntl30     2  TBROK  :  Remaining cases broken
> 
> Here we also print signal's name to output more informative message.
> 	fcntl30     1  TBROK  :  unexpected signal SIGINT(2) received (pid = 9872).
> 	fcntl30     2  TBROK  :  Remaining cases broken

Please add a note about the two new tst_ functions here as well,
something as:

This also adds two new tst_ functions to convert errno or signal to its
name.

const char *tst_strsig(int sig) returns signal name given signal number

const char *tst_strerrno(int err) returns errno name given errno number

> +const char *tst_strsig(int sig)
> +{
> +	static const struct pair signal_pairs[] = {
> +		STRPAIR(SIGHUP, "SIGHUP")
> +		STRPAIR(SIGINT, "SIGINT")
> +		STRPAIR(SIGQUIT, "SIGQUIT")
> +		STRPAIR(SIGILL, "SIGILL")
> +	#ifdef SIGTRAP
> +		STRPAIR(SIGTRAP, "SIGTRAP")
> +	#endif
> +
> +	#ifdef SIGIOT
> +		/* SIGIOT same as SIGABRT */
> +		STRPAIR(SIGABRT, "SIGIOT/SIGABRT")
> +	#else
> +		STRPAIR(SIGABRT, "SIGABRT")
> +	#endif
> +
> +	#ifdef SIGEMT
> +		STRPAIR(SIGEMT, "SIGEMT")
> +	#endif
> +	#ifdef SIGBUS
> +		STRPAIR(SIGBUS, "SIGBUS")
> +	#endif
> +		STRPAIR(SIGFPE, "SIGFPE")
> +		STRPAIR(SIGKILL, "SIGKILL")
> +		STRPAIR(SIGUSR1, "SIGUSR1")
> +		STRPAIR(SIGSEGV, "SIGSEGV")
> +		STRPAIR(SIGUSR2, "SIGUSR2")
> +		STRPAIR(SIGPIPE, "SIGPIPE")
> +		STRPAIR(SIGALRM, "SIGALRM")
> +		STRPAIR(SIGTERM, "SIGTERM")

Ah, I wasn't clear enough, I guess, sorry.

What I had in mind was to use STRPAIR() in cases that the string is different
from the symbolic name and use PAIR() in the rest of the cases.

I.e. use STRPAIR(SIGABRT, "SIGIOT/SIGABRT") but PAIR(SIGEMT).

> +#define STRPAIR(key, value)  {.val = (key), .name = (value)},

This would be:

#define STRPAIR(key, value) [key] = {.name = value, .val = key}

Then you can mix PAIR() with STRPAIR() and use PARI_LOOKUP().

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

      reply	other threads:[~2014-05-12 14:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-09  6:23 [LTP] [PATCH v2] lib/tst_sig.c: output signal name when got unexpected signal Xiaoguang Wang
2014-05-12 14:56 ` chrubis [this message]

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=20140512145646.GF4741@rei \
    --to=chrubis@suse.cz \
    --cc=ltp-list@lists.sourceforge.net \
    --cc=wangxg.fnst@cn.fujitsu.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox