linux/tools/testing/selftests/kselftest.h
<<
>>
Prefs
   1/*
   2 * kselftest.h: kselftest framework return codes to include from
   3 *              selftests.
   4 *
   5 * Copyright (c) 2014 Shuah Khan <shuahkh@osg.samsung.com>
   6 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
   7 *
   8 * This file is released under the GPLv2.
   9 */
  10#ifndef __KSELFTEST_H
  11#define __KSELFTEST_H
  12
  13#include <stdlib.h>
  14#include <unistd.h>
  15
  16/* define kselftest exit codes */
  17#define KSFT_PASS  0
  18#define KSFT_FAIL  1
  19#define KSFT_XFAIL 2
  20#define KSFT_XPASS 3
  21#define KSFT_SKIP  4
  22
  23/* counters */
  24struct ksft_count {
  25        unsigned int ksft_pass;
  26        unsigned int ksft_fail;
  27        unsigned int ksft_xfail;
  28        unsigned int ksft_xpass;
  29        unsigned int ksft_xskip;
  30};
  31
  32static struct ksft_count ksft_cnt;
  33
  34static inline void ksft_inc_pass_cnt(void) { ksft_cnt.ksft_pass++; }
  35static inline void ksft_inc_fail_cnt(void) { ksft_cnt.ksft_fail++; }
  36static inline void ksft_inc_xfail_cnt(void) { ksft_cnt.ksft_xfail++; }
  37static inline void ksft_inc_xpass_cnt(void) { ksft_cnt.ksft_xpass++; }
  38static inline void ksft_inc_xskip_cnt(void) { ksft_cnt.ksft_xskip++; }
  39
  40static inline void ksft_print_cnts(void)
  41{
  42        printf("Pass: %d Fail: %d Xfail: %d Xpass: %d, Xskip: %d\n",
  43                ksft_cnt.ksft_pass, ksft_cnt.ksft_fail,
  44                ksft_cnt.ksft_xfail, ksft_cnt.ksft_xpass,
  45                ksft_cnt.ksft_xskip);
  46}
  47
  48static inline int ksft_exit_pass(void)
  49{
  50        exit(KSFT_PASS);
  51}
  52static inline int ksft_exit_fail(void)
  53{
  54        exit(KSFT_FAIL);
  55}
  56static inline int ksft_exit_xfail(void)
  57{
  58        exit(KSFT_XFAIL);
  59}
  60static inline int ksft_exit_xpass(void)
  61{
  62        exit(KSFT_XPASS);
  63}
  64static inline int ksft_exit_skip(void)
  65{
  66        exit(KSFT_SKIP);
  67}
  68
  69#endif /* __KSELFTEST_H */
  70