File: dmabuf.c

package info (click to toggle)
intel-gpu-tools 2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 64,504 kB
  • sloc: xml: 781,458; ansic: 378,272; python: 8,407; yacc: 2,781; perl: 1,196; sh: 1,177; lex: 487; asm: 227; lisp: 35; makefile: 30
file content (98 lines) | stat: -rw-r--r-- 2,901 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
 * Copyright © 2019 Intel Corporation
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */

#include "igt.h"
#include "igt_kmod.h"
/**
 * TEST: dmabuf
 * Description: Kernel selftests for the dmabuf API
 * Category: Core
 * Mega feature: General Core features
 * Functionality: drm_mm
 * Sub-category: Memory management tests
 * Feature: mapping, prime
 * Test category: GEM_Legacy
 *
 * SUBTEST: all-tests
 *
 * SUBTEST: all-tests@dma_fence
 *
 * SUBTEST: all-tests@sanitycheck
 */

IGT_TEST_DESCRIPTION("Kernel selftests for the dmabuf API");

static unsigned int bogomips(void)
{
	unsigned int bogomips, ret = 0;
	char *line = NULL;
	size_t size = 0;
	FILE *cpuinfo;

	cpuinfo = fopen("/proc/cpuinfo", "r");
	if (igt_debug_on(!cpuinfo))
		return UINT_MAX;

	while (getline(&line, &size, cpuinfo) != -1) {
		char *colon;

		if (strncmp(line, "bogomips", 8))
			continue;

		colon = strchr(line, ':');
		if (igt_debug_on(!colon))
			bogomips = 0;
		else
			bogomips = atoi(colon + 1);

		if (igt_debug_on(!bogomips))
			break;

		ret += bogomips;
	}
	free(line);
	fclose(cpuinfo);

	return igt_debug_on(!bogomips) ? UINT_MAX : ret;
}

static int wrapper(const char *dynamic_name,
		   struct igt_ktest *tst,
		   struct igt_kselftest_list *tl)
{
	/*
	 * Test case wait-backward of dma_fence_chain selftest can trigger soft
	 * lockups on slow machines.  Since that slowness is not recognized as
	 * a bug on the kernel side, the issue is not going to be fixed.  Based
	 * on analysis of CI results, skip that selftest on machines slower than
	 * 25000 BogoMIPS to avoid ever returning CI reports on that failure.
	 */
	igt_skip_on(!strcmp(dynamic_name, "dma_fence_chain") && bogomips() < 25000);

	return igt_kselftest_execute(tst, tl, NULL, NULL);
}

int igt_main()
{
	igt_kselftests("dmabuf_selftests", NULL, NULL, NULL, wrapper);
}