You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
3.1 KiB
80 lines
3.1 KiB
#![allow(unused_imports)]
|
|
|
|
use intel_gpu::*;
|
|
use uapi::i915;
|
|
use std::fs;
|
|
use std::{fs::File, os::fd::{AsRawFd, RawFd}};
|
|
|
|
#[test]
|
|
fn test_i915_uapi_get_version() {
|
|
let node = i915::find_node().expect("Failed to find i915 fd");
|
|
let drm_version = uapi::get_drm_version(node.fd.as_raw_fd()).expect("Failed to get drm version");
|
|
assert_eq!(drm_version.name.to_str().unwrap(), "i915");
|
|
assert_eq!(drm_version.desc.to_str().unwrap(), "Intel Graphics");
|
|
}
|
|
|
|
#[test]
|
|
fn test_i915_uapi_get_engines() {
|
|
let node = i915::find_node().expect("Failed to find i915 fd");
|
|
let _engines = i915::get_engines(node.fd.as_raw_fd()).expect("Failed to get engines");
|
|
let fail_fd = File::open("/dev/null").expect("Failed to open /dev/null");
|
|
assert!(i915::get_engines(fail_fd.as_raw_fd()).is_none());
|
|
}
|
|
|
|
#[test]
|
|
fn test_i915_uapi_get_param_fail() {
|
|
let fd = File::open("/dev/null").expect("Failed to open /dev/null");
|
|
let param = i915::get_param(fd.as_raw_fd(), native::I915_PARAM_CHIPSET_ID as i32);
|
|
assert!(param.is_none());
|
|
}
|
|
|
|
#[test]
|
|
fn test_i915_uapi_native_engine_info() {
|
|
let node = i915::find_node().expect("Failed to find i915 fd");
|
|
let engines = i915::get_engines(node.fd.as_raw_fd()).expect("Failed to get engines");
|
|
for engine in engines {
|
|
let native_engine = engine.to_native();
|
|
let from_native = i915::EngineInfo::from_native(native_engine);
|
|
assert_eq!(&engine, &from_native);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn test_i915_find_fd() {
|
|
let fd = i915::find_fd().expect("Failed to find i915 fd");
|
|
let drm_version = uapi::get_drm_version(fd.as_raw_fd()).expect("Failed to get drm version");
|
|
assert_eq!(drm_version.name.to_str().unwrap(), "i915");
|
|
assert_eq!(drm_version.desc.to_str().unwrap(), "Intel Graphics");
|
|
}
|
|
|
|
#[test]
|
|
fn test_i915_uapi_get_context_param() {
|
|
let node = i915::find_node().expect("Failed to find i915 fd");
|
|
// Mesa uses context id of 0 for init so it's surely okay, right?
|
|
let param = i915::get_context_param(node.fd.as_raw_fd(),
|
|
0,
|
|
native::I915_CONTEXT_PARAM_GTT_SIZE as u32)
|
|
.expect("Failed to get context param");
|
|
assert!(param > 0);
|
|
}
|
|
|
|
#[test]
|
|
fn test_i915_uapi_gem_lifecycle() {
|
|
let node = i915::find_node().expect("Failed to find i915 fd");
|
|
let gem = i915::make_gem(node.fd.as_raw_fd(), 4096).expect("Failed to make gem");
|
|
assert!(gem.handle > 0);
|
|
assert!(i915::gem_is_valid(node.fd.as_raw_fd(), gem).unwrap());
|
|
i915::close_gem(node.fd.as_raw_fd(), gem).expect("Failed to close gem");
|
|
assert!(!i915::gem_is_valid(node.fd.as_raw_fd(), gem).unwrap());
|
|
let invalid_fd = File::open("/dev/null").expect("Failed to open /dev/null");
|
|
assert!(i915::make_gem(invalid_fd.as_raw_fd(), 4096).is_none());
|
|
}
|
|
|
|
#[test]
|
|
fn test_i915_uapi_gem_tiling() {
|
|
let node = i915::find_node().expect("Failed to find i915 fd");
|
|
let gem = i915::make_gem(node.fd.as_raw_fd(), 4096).expect("Failed to make gem");
|
|
// TODO figure out which devices this holds for
|
|
assert!(i915::gem_has_tiling(node.fd.as_raw_fd(), gem).is_ok_and(|e| e == true));
|
|
i915::close_gem(node.fd.as_raw_fd(), gem).expect("Failed to close gem");
|
|
} |