2 * Copyright © 2016 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 #include <linux/compiler.h>
26 #define selftest(name, func) __idx_##name,
32 #define selftest(n, f) [__idx_##n] = { .name = #n, .func = f },
33 static struct drm_selftest
{
42 /* Embed the line number into the parameter name so that we can order tests */
43 #define param(n) __PASTE(igt__, __PASTE(__PASTE(__LINE__, __), n))
44 #define selftest_0(n, func, id) \
45 module_param_named(id, selftests[__idx_##n].enabled, bool, 0400);
46 #define selftest(n, func) selftest_0(n, func, param(n))
50 static void set_default_test_all(struct drm_selftest
*st
, unsigned long count
)
54 for (i
= 0; i
< count
; i
++)
58 for (i
= 0; i
< count
; i
++)
62 static int run_selftests(struct drm_selftest
*st
,
68 set_default_test_all(st
, count
);
70 /* Tests are listed in natural order in drm_*_selftests.h */
71 for (; count
--; st
++) {
75 pr_debug("drm: Running %s\n", st
->name
);
81 if (WARN(err
> 0 || err
== -ENOTTY
,
82 "%s returned %d, conflicting with selftest's magic values!\n",
90 static int __maybe_unused
91 __drm_subtests(const char *caller
,
92 const struct drm_subtest
*st
,
98 for (; count
--; st
++) {
99 pr_debug("Running %s/%s\n", caller
, st
->name
);
100 err
= st
->func(data
);
102 pr_err("%s: %s failed with error %d\n",
103 caller
, st
->name
, err
);