public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Shuah Khan <shuahkh@osg.samsung.com>
To: Davidlohr Bueso <dave@stgolabs.net>
Cc: akpm@linux-foundation.org, gregkh@linuxfoundation.org,
	colin.king@canonical.com, ebiederm@xmission.com,
	serge.hallyn@ubuntu.com, thierry@linux.vnet.ibm.com,
	luto@amacapital.net, linux-api@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Shuah Khan <shuahkh@osg.samsung.com>
Subject: Re: [PATCH v2 1/7] selftests: add kselftest framework for uniform test reporting
Date: Wed, 24 Sep 2014 16:06:03 -0600	[thread overview]
Message-ID: <5423404B.2050400@osg.samsung.com> (raw)
In-Reply-To: <1411546144.30630.10.camel@linux-t7sj.site>

On 09/24/2014 02:09 AM, Davidlohr Bueso wrote:

>> +/* counters */
>> +static int ksft_pass;
>> +static int ksft_fail;
>> +static int ksft_xfail;
>> +static int ksft_xpass;
>> +static int ksft_xskip;
> 
> unsigned int?

Yes unsigned int is a better choice.

> 
>> +static inline void ksft_inc_pass_cnt(void) { ksft_pass++; }
>> +static inline void ksft_inc_fail_cnt(void) { ksft_fail++; }
>> +static inline void ksft_inc_xfail_cnt(void) { ksft_xfail++; }
>> +static inline void ksft_inc_xpass_cnt(void) { ksft_xpass++; }
>> +static inline void ksft_inc_xskip_cnt(void) { ksft_xskip++; }
> 
> It would probably make sense to have the counters in a structures,
> something like: struct ksft_counter { ... } ksft_cnt;
> 
> Then just pass it around the proposed functions as arguments. That also
> minimizes a bit the global variables and would allow you to easily
> change it in the future.

How does the following look?

struct ksft_count
{
        unsigned int ksft_pass;
        unsigned int ksft_fail;
        unsigned int ksft_xfail;
        unsigned int ksft_xpass;
        unsigned int ksft_xskip;
};

static ksft_count ksft_cnt;

static inline void ksft_inc_pass_cnt(void) { ksft_cnt.ksft_pass++; }
static inline void ksft_inc_fail_cnt(void) { ksft_cnt.ksft_fail++; }
static inline void ksft_inc_xfail_cnt(void) { ksft_cnt.ksft_xfail++; }
static inline void ksft_inc_xpass_cnt(void) { ksft_cnt.ksft_xpass++; }
static inline void ksft_inc_xskip_cnt(void) { ksft_cnt.ksft_xskip++; }

With this approach, tests don't have to define their own counter
variable and pass it in. I am looking to abstract the framework
as much as possible.

thanks,
-- Shuah


-- 
Shuah Khan
Sr. Linux Kernel Developer
Samsung Research America (Silicon Valley)
shuahkh@osg.samsung.com | (970) 217-8978

  reply	other threads:[~2014-09-24 22:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-23 21:32 [PATCH v2 0/7] kselftest framework and test changes to use it Shuah Khan
2014-09-23 21:32 ` [PATCH v2 1/7] selftests: add kselftest framework for uniform test reporting Shuah Khan
2014-09-24  8:09   ` Davidlohr Bueso
2014-09-24 22:06     ` Shuah Khan [this message]
2014-09-23 21:32 ` [PATCH v2 2/7] selftests/breakpoints: change test to use ksft framework Shuah Khan
2014-09-23 21:32 ` [PATCH v2 3/7] selftests/ipc: " Shuah Khan
2014-09-23 21:32 ` [PATCH v2 4/7] selftests/kcmp: " Shuah Khan
2014-09-23 21:32 ` [PATCH v2 5/7] selftests/mount: " Shuah Khan
2014-09-23 22:41   ` Eric W. Biederman
2014-09-23 22:56     ` Shuah Khan
2014-09-23 23:07       ` Eric W. Biederman
2014-09-23 23:18         ` Shuah Khan
2014-09-23 21:32 ` [PATCH v2 6/7] selftests/ptrace: " Shuah Khan
2014-09-23 21:33 ` [PATCH v2 7/7] selftests/timers: " Shuah Khan

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=5423404B.2050400@osg.samsung.com \
    --to=shuahkh@osg.samsung.com \
    --cc=akpm@linux-foundation.org \
    --cc=colin.king@canonical.com \
    --cc=dave@stgolabs.net \
    --cc=ebiederm@xmission.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=serge.hallyn@ubuntu.com \
    --cc=thierry@linux.vnet.ibm.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