Németh Márton wrote:
> I also attached a simple test environment to test this change.

The test always printed PASSED in case of tc_01, corrected. The
corrected test cases also PASS.

Regards,

        Márton Németh
/* Written by Márton Németh <[email protected]> */
/* v0.2  13 Dec 2008 Corrected test result printout */
/* v0.1  12 Dec 2008 Initial version */
/* Released under GPL */

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <string.h>

#include <linux/videodev2.h>
#include <linux/errno.h>

#define U32_MAX		0xFFFFFFFF

#define MAX_EM28XX_TVNORMS	10

#define TC_PASSED	1
#define TC_FAILED	2

void print_tc_result(int tc_result) {
	switch (tc_result) {
	case TC_PASSED:
		printf("PASSED\n");
		break;
	case TC_FAILED:
		printf("FAILED\n");
		break;
	default:
		printf("Internal error: tc_result=%i\n", tc_result);
	}

	printf("\n");
}

void tc01(int f) {
	int ret;
	struct v4l2_standard std;
	__u32 i;
	int tc_result = TC_PASSED;

	printf("Test Case 1: VIDIOC_ENUMSTD\n");

	i = 0;
	do {
		memset(&std, 0xff, sizeof(std));
		std.index = i;
		ret = ioctl(f, VIDIOC_ENUMSTD, &std);
		printf("VIDIOC_ENUMSTD, ret=%i\n", ret);
		if (ret == 0) {
			printf("\tstd = {.index=%u, .name=\"%s\" }\n", std.index, std.name);
			//std.id
			//std.frameperiod
			//std.framelines
			//std.reserved[0]
			//std.reserved[1]
			//std.reserved[2]
			//std.reserved[3]
		} else {
			printf("\terrno=%i\n", errno);
		}
		if ( ! ((ret == 0) || (ret == -1 && errno == EINVAL)) ) {
			tc_result = TC_FAILED;
		}
		i++;
	} while (ret == 0);

	print_tc_result(tc_result);
}

void tc02(int f) {
	int ret;
	int tc_result = TC_PASSED;
	struct v4l2_standard std;

	printf("Test Case 2: VIDIOC_ENUMSTD, index=MAX_EM28XX_TVNORMS\n");
	memset(&std, 0xff, sizeof(std));
	std.index = MAX_EM28XX_TVNORMS;
	ret = ioctl(f, VIDIOC_ENUMSTD, &std);
	printf("VIDIOC_ENUMSTD, ret=%i\n", ret);
	if (ret != 0) {
		printf("\terrno=%i\n", errno);
	}
	if (ret != -1 || errno != EINVAL) {
		tc_result = TC_FAILED;
	}

	print_tc_result(tc_result);
}

void tc03(int f) {
	int ret;
	int tc_result = TC_PASSED;
	struct v4l2_standard std;

	printf("Test Case 3: VIDIOC_ENUMSTD, index=U32_MAX\n");
	memset(&std, 0xff, sizeof(std));
	std.index = U32_MAX;
	ret = ioctl(f, VIDIOC_ENUMSTD, &std);
	printf("VIDIOC_ENUMSTD, ret=%i\n", ret);
	if (ret != 0) {
		printf("\terrno=%i\n", errno);
	}
	if (ret != -1 || errno != EINVAL) {
		tc_result = TC_FAILED;
	}

	print_tc_result(tc_result);
}


int main() {
	int f;
	int ret;

	f = open("/dev/video0", O_RDWR);
	if (f < 0) {
		perror("cannot open /dev/video0");
		return 1;
	}

	tc01(f);
	tc02(f);
	tc03(f);

	ret = close(f);
	if (ret < 0) {
		perror("cannot open close");
		return 1;
	}

	return 0;
}
_______________________________________________
Em28xx mailing list
[email protected]
http://mcentral.de/mailman/listinfo/em28xx

Reply via email to