aboutsummaryrefslogtreecommitdiffstats
path: root/utils/v4l2-compliance/v4l2-test-debug.cpp
blob: 732c7ee36273e76d0596c34c58cc8d6ebd555b59 (plain)
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
/*
    V4L2 API compliance debug ioctl tests.

    Copyright (C) 2008, 2010  Hans Verkuil <hverkuil@xs4all.nl>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335  USA
 */

#include <map>
#include <set>

#include <sys/types.h>

#include "v4l2-compliance.h"

int testRegister(struct node *node)
{
	struct v4l2_dbg_register reg;
	struct v4l2_dbg_chip_info chip = {};
	int ret;
	int uid = getuid();

	reg.match.type = V4L2_CHIP_MATCH_BRIDGE;
	reg.match.addr = 0;
	reg.reg = 0;
	ret = doioctl(node, VIDIOC_DBG_G_REGISTER, &reg);
	if (ret == ENOTTY)
		return ret;
	// Not allowed to call VIDIOC_DBG_G_REGISTER unless root
	fail_on_test(uid && ret != EPERM);
	fail_on_test(uid == 0 && ret && ret != EINVAL);
	fail_on_test(uid == 0 && !ret && reg.size == 0);
	chip.match.type = V4L2_CHIP_MATCH_BRIDGE;
	chip.match.addr = 0;
	fail_on_test(doioctl(node, VIDIOC_DBG_G_CHIP_INFO, &chip));
	if (uid) {
		// Don't test S_REGISTER as root, don't want to risk
		// messing with registers in the compliance test.
		reg.reg = reg.val = 0;
		ret = doioctl(node, VIDIOC_DBG_S_REGISTER, &reg);
		fail_on_test(ret != ENOTTY && ret != EINVAL && ret != EPERM);
	}
	return 0;
}

int testLogStatus(struct node *node)
{
	return doioctl(node, VIDIOC_LOG_STATUS, nullptr);
}

Privacy Policy