/
hwtest.c
105 lines (101 loc) · 3.01 KB
/
hwtest.c
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
99
100
101
102
103
104
105
/*
* Copyright (C) 2012 Marcin Kościelnicki <koriakin@0x04.net>
* All Rights Reserved.
*
* 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 "hwtest.h"
#include "nva.h"
#include <unistd.h>
#include <stdio.h>
#include <pciaccess.h>
int hwtest_root_prep(struct hwtest_ctx *ctx) {
return HWTEST_RES_PASS;
}
HWTEST_DEF_GROUP(hwtest_root,
HWTEST_GROUP(nv01_pgraph),
HWTEST_GROUP(nv10_tile),
HWTEST_GROUP(mpeg_crypt),
HWTEST_GROUP(nv50_ptherm),
HWTEST_GROUP(nv84_ptherm),
HWTEST_GROUP(vp2_macro),
HWTEST_GROUP(pvcomp_isa),
)
int main(int argc, char **argv) {
struct hwtest_ctx sctx;
struct hwtest_ctx *ctx = &sctx;
if (nva_init()) {
fprintf (stderr, "PCI init failure!\n");
return 1;
}
int c, force = 0;
ctx->cnum = 0;
ctx->colors = 1;
ctx->noslow = 0;
ctx->indent = 0;
ctx->rand48[0] = 0xdead;
ctx->rand48[1] = 0xbeef;
ctx->rand48[2] = 0xcafe;
while ((c = getopt (argc, argv, "c:nsf")) != -1)
switch (c) {
case 'c':
sscanf(optarg, "%d", &ctx->cnum);
break;
case 'n':
ctx->colors = 0;
break;
case 's':
ctx->noslow = 1;
break;
case 'f':
force = 1;
break;
}
if (ctx->cnum >= nva_cardsnum) {
if (nva_cardsnum)
fprintf (stderr, "No such card.\n");
else
fprintf (stderr, "No cards found.\n");
return 1;
}
ctx->chipset = nva_cards[ctx->cnum].chipset.chipset;
ctx->card_type = nva_cards[ctx->cnum].chipset.card_type;
if (pci_device_has_kernel_driver(nva_cards[ctx->cnum].pci)) {
if (force) {
fprintf(stderr, "WARNING: Kernel driver in use.\n");
} else {
fprintf(stderr, "ERROR: Kernel driver in use. If you know what you are doing, use -f option.\n");
return 1;
}
}
int worst = 0;
if (optind == argc) {
printf("Running all tests...\n");
worst = hwtest_run_group(ctx, &hwtest_root_group, 0);
} else while (optind < argc) {
int res = hwtest_run_group(ctx, &hwtest_root_group, argv[optind++]);
if (res > worst)
worst = res;
}
if (worst == HWTEST_RES_PASS)
return 0;
else
return worst + 1;
}