blob: 09be8887fb0806ef92a4baa9504279a1845f25fd [file] [log] [blame]
Paul E. McKenney51b11302014-01-27 11:49:39 -08001/*
2 * Common functions for in-kernel torture tests.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, you can access it online at
16 * http://www.gnu.org/licenses/gpl-2.0.html.
17 *
18 * Copyright IBM Corporation, 2014
19 *
20 * Author: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
21 */
22
23#ifndef __LINUX_TORTURE_H
24#define __LINUX_TORTURE_H
25
26#include <linux/types.h>
27#include <linux/cache.h>
28#include <linux/spinlock.h>
29#include <linux/threads.h>
30#include <linux/cpumask.h>
31#include <linux/seqlock.h>
32#include <linux/lockdep.h>
33#include <linux/completion.h>
34#include <linux/debugobjects.h>
35#include <linux/bug.h>
36#include <linux/compiler.h>
37
Paul E. McKenney9e250222014-01-27 16:27:00 -080038/* Definitions for a non-string torture-test module parameter. */
39#define torture_param(type, name, init, msg) \
40 static type name = init; \
41 module_param(name, type, 0444); \
42 MODULE_PARM_DESC(name, msg);
43
Paul E. McKenneyc2884de2014-01-29 07:30:50 -080044#define TORTURE_FLAG "-torture:"
45#define TOROUT_STRING(s) \
46 pr_alert("%s" TORTURE_FLAG s "\n", torture_type)
47#define VERBOSE_TOROUT_STRING(s) \
48 do { if (verbose) pr_alert("%s" TORTURE_FLAG s "\n", torture_type); } while (0)
49#define VERBOSE_TOROUT_ERRSTRING(s) \
50 do { if (verbose) pr_alert("%s" TORTURE_FLAG "!!! " s "\n", torture_type); } while (0)
51
Paul E. McKenney9e250222014-01-27 16:27:00 -080052/* Low-rider random number generator. */
Paul E. McKenney51b11302014-01-27 11:49:39 -080053struct torture_random_state {
54 unsigned long trs_state;
55 long trs_count;
56};
Paul E. McKenney51b11302014-01-27 11:49:39 -080057#define DEFINE_TORTURE_RANDOM(name) struct torture_random_state name = { 0, 0 }
Paul E. McKenney51b11302014-01-27 11:49:39 -080058unsigned long torture_random(struct torture_random_state *trsp);
59
60#endif /* __LINUX_TORTURE_H */