mirror of
				https://github.com/tiagovignatti/intel-gpu-tools.git
				synced 2025-11-03 19:47:15 +00:00 
			
		
		
		
	lib/drmtest: igt_skip when drm_get_card fails
Also add printf support to igt_skip to make sure there's always a reason why we fail a testcase. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
		
							parent
							
								
									9ad062d0b3
								
							
						
					
					
						commit
						8dbd1fb9d4
					
				@ -181,23 +181,24 @@ int drm_get_card(void)
 | 
			
		||||
		int ret;
 | 
			
		||||
 | 
			
		||||
		ret = asprintf(&name, "/dev/dri/card%u", i);
 | 
			
		||||
		if (ret == -1)
 | 
			
		||||
			return -1;
 | 
			
		||||
		igt_assert(ret != -1);
 | 
			
		||||
 | 
			
		||||
		fd = open(name, O_RDWR);
 | 
			
		||||
		free(name);
 | 
			
		||||
 | 
			
		||||
		if (fd == -1)
 | 
			
		||||
			continue;
 | 
			
		||||
 | 
			
		||||
		if (is_intel(fd)) {
 | 
			
		||||
			close(fd);
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
		if (!is_intel(fd))
 | 
			
		||||
			continue;
 | 
			
		||||
 | 
			
		||||
		close(fd);
 | 
			
		||||
		return i;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return i;
 | 
			
		||||
	igt_skip("No intel gpu found\n");
 | 
			
		||||
 | 
			
		||||
	return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Open the first DRM device we can find, searching up to 16 device nodes */
 | 
			
		||||
@ -756,10 +757,17 @@ static void exit_subtest(const char *result)
 | 
			
		||||
	longjmp(igt_subtest_jmpbuf, 1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void igt_skip(void)
 | 
			
		||||
void igt_skip(const char *f, ...)
 | 
			
		||||
{
 | 
			
		||||
	va_list args;
 | 
			
		||||
	skipped_one = true;
 | 
			
		||||
 | 
			
		||||
	if (!igt_only_list_subtests()) {
 | 
			
		||||
		va_start(args, f);
 | 
			
		||||
		vprintf(f, args);
 | 
			
		||||
		va_end(args);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (in_subtest) {
 | 
			
		||||
		exit_subtest("SKIP");
 | 
			
		||||
	} else if (test_with_subtests) {
 | 
			
		||||
@ -774,12 +782,9 @@ void igt_skip(void)
 | 
			
		||||
void __igt_skip_check(const char *file, const int line,
 | 
			
		||||
		      const char *func, const char *check)
 | 
			
		||||
{
 | 
			
		||||
	if (!igt_only_list_subtests()) {
 | 
			
		||||
		printf("Test requirement not met in function %s, file %s:%i:\n"
 | 
			
		||||
		       "Test requirement: (%s)\n",
 | 
			
		||||
		       func, file, line, check);
 | 
			
		||||
	}
 | 
			
		||||
	igt_skip();
 | 
			
		||||
	igt_skip("Test requirement not met in function %s, file %s:%i:\n"
 | 
			
		||||
		 "Test requirement: (%s)\n",
 | 
			
		||||
		 func, file, line, check);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void igt_success(void)
 | 
			
		||||
 | 
			
		||||
@ -132,7 +132,7 @@ const char *igt_subtest_name(void);
 | 
			
		||||
 *
 | 
			
		||||
 * For normal tests without subtest it will directly exit.
 | 
			
		||||
 */
 | 
			
		||||
void igt_skip(void);
 | 
			
		||||
__attribute__((format(printf, 1, 2))) void igt_skip(const char *f, ...);
 | 
			
		||||
void __igt_skip_check(const char *file, const int line,
 | 
			
		||||
		      const char *func, const char *check);
 | 
			
		||||
/**
 | 
			
		||||
 | 
			
		||||
@ -51,9 +51,8 @@ int main(int argc, char *argv[])
 | 
			
		||||
 | 
			
		||||
	ret = drmIoctl(fd, CONTEXT_CREATE_IOCTL, &create);
 | 
			
		||||
	if (ret != 0 && (errno == ENODEV || errno == EINVAL)) {
 | 
			
		||||
		printf("Kernel is too old, or contexts not supported: %s\n",
 | 
			
		||||
			strerror(errno));
 | 
			
		||||
		igt_skip();
 | 
			
		||||
		igt_skip("Kernel is too old, or contexts not supported: %s\n",
 | 
			
		||||
			 strerror(errno));
 | 
			
		||||
	} else if (ret != 0) {
 | 
			
		||||
		fprintf(stderr, "%s\n", strerror(errno));
 | 
			
		||||
		igt_fail(1);
 | 
			
		||||
 | 
			
		||||
@ -644,7 +644,6 @@ int main(int argc, char **argv)
 | 
			
		||||
	parse_options(argc, argv);
 | 
			
		||||
 | 
			
		||||
	card_index = drm_get_card();
 | 
			
		||||
	igt_assert(card_index != -1);
 | 
			
		||||
 | 
			
		||||
	srandom(time(NULL));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -628,8 +628,6 @@ static void hang_gpu(struct test_output *o)
 | 
			
		||||
	int fd;
 | 
			
		||||
	ssize_t r;
 | 
			
		||||
 | 
			
		||||
	igt_assert(card_index != -1);
 | 
			
		||||
 | 
			
		||||
	snprintf(fname, FILENAME_MAX, "%s/%i/%s",
 | 
			
		||||
		 dfs_base, card_index, dfs_entry);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user