diff --git a/tests/tests_i915_gpu.rs b/tests/tests_i915_gpu.rs index 88a35c0..b651c69 100644 --- a/tests/tests_i915_gpu.rs +++ b/tests/tests_i915_gpu.rs @@ -126,4 +126,12 @@ fn test_i915_gpu_gem_has_tiling() { let device = i915::find_device().expect("Failed to find i915 device"); let gem = i915::GemHandle::new(&device.node, 4096).expect("Failed to create gem handle"); assert!(gem.has_tiling().unwrap()); +} + +#[test] +fn test_i915_gpu_fences() { + let device = i915::find_device().expect("Failed to find i915 device"); + let num_fences = device.get_param(native::I915_PARAM_NUM_FENCES_AVAIL).expect("Failed to get fences"); + println!("Number of fences: {}", num_fences); + assert!(num_fences > 0); } \ No newline at end of file diff --git a/tests/tests_raw.rs b/tests/tests_raw.rs index 6eecdae..81499ce 100644 --- a/tests/tests_raw.rs +++ b/tests/tests_raw.rs @@ -1,6 +1,5 @@ use intel_gpu::*; use std::ffi::c_void; -use std::ffi::CStr; use nix::{self}; #[test] @@ -28,13 +27,6 @@ fn test_raw_drm_version() { desc_len: 128, }; assert!(libc::ioctl(fd, native::DRM_IOCTL_VERSION, &mut version) == 0); - println!("version_major: {}, version_minor: {}, version_patchlevel: {}, name: {:?}, date: {:?}, desc: {:?}", - version.version_major, - version.version_minor, - version.version_patchlevel, - CStr::from_ptr(version.name), - CStr::from_ptr(version.date), - CStr::from_ptr(version.desc)); } } diff --git a/tests/tests_uapi.rs b/tests/tests_uapi.rs index beaefed..359ab35 100644 --- a/tests/tests_uapi.rs +++ b/tests/tests_uapi.rs @@ -1,9 +1,11 @@ #![allow(unused_imports)] +use gpu::i915::GemHandle; use intel_gpu::*; -use uapi::i915; +use uapi::i915::{self, DrmGemHandle}; use std::fs; use std::{fs::File, os::fd::{AsRawFd, RawFd}}; +use std::thread; #[test] fn test_i915_uapi_get_version() { @@ -78,4 +80,26 @@ fn test_i915_uapi_gem_tiling() { // 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"); +} + +#[test] +fn test_i915_uapi_gem_caching() { + 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"); + let caching = i915::gem_get_caching(node.fd.as_raw_fd(), &gem).expect("Failed to get caching"); + assert!(caching > 0); + i915::close_gem(node.fd.as_raw_fd(), gem).expect("Failed to close gem"); +} + +#[test] +fn test_i915_uapi_gem_thread() { + 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"); + thread::scope(|s| { + let handle = s.spawn(|| { + assert!(i915::gem_is_valid(node.fd.as_raw_fd(), &gem).unwrap()); + }); + assert!(i915::gem_is_valid(node.fd.as_raw_fd(), &gem).unwrap()); + handle.join().expect("Failed to join thread"); + }); } \ No newline at end of file