Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/sched/tests: Add unit test for cancel_job()

The scheduler unit tests now provide a new callback, cancel_job(). This
callback gets used by drm_sched_fini() for all still pending jobs to
cancel them.

Implement a new unit test to test this.

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Signed-off-by: Philipp Stanner <phasta@kernel.org>
Link: https://lore.kernel.org/r/20250710125412.128476-6-phasta@kernel.org

+42
+42
drivers/gpu/drm/scheduler/tests/tests_basic.c
··· 204 204 .test_cases = drm_sched_basic_tests, 205 205 }; 206 206 207 + static void drm_sched_basic_cancel(struct kunit *test) 208 + { 209 + struct drm_mock_sched_entity *entity; 210 + struct drm_mock_scheduler *sched; 211 + struct drm_mock_sched_job *job; 212 + bool done; 213 + 214 + /* 215 + * Check that drm_sched_fini() uses the cancel_job() callback to cancel 216 + * jobs that are still pending. 217 + */ 218 + 219 + sched = drm_mock_sched_new(test, MAX_SCHEDULE_TIMEOUT); 220 + entity = drm_mock_sched_entity_new(test, DRM_SCHED_PRIORITY_NORMAL, 221 + sched); 222 + 223 + job = drm_mock_sched_job_new(test, entity); 224 + 225 + drm_mock_sched_job_submit(job); 226 + 227 + done = drm_mock_sched_job_wait_scheduled(job, HZ); 228 + KUNIT_ASSERT_TRUE(test, done); 229 + 230 + drm_mock_sched_entity_free(entity); 231 + drm_mock_sched_fini(sched); 232 + 233 + KUNIT_ASSERT_EQ(test, job->hw_fence.error, -ECANCELED); 234 + } 235 + 236 + static struct kunit_case drm_sched_cancel_tests[] = { 237 + KUNIT_CASE(drm_sched_basic_cancel), 238 + {} 239 + }; 240 + 241 + static struct kunit_suite drm_sched_cancel = { 242 + .name = "drm_sched_basic_cancel_tests", 243 + .init = drm_sched_basic_init, 244 + .exit = drm_sched_basic_exit, 245 + .test_cases = drm_sched_cancel_tests, 246 + }; 247 + 207 248 static void drm_sched_basic_timeout(struct kunit *test) 208 249 { 209 250 struct drm_mock_scheduler *sched = test->priv; ··· 512 471 513 472 kunit_test_suites(&drm_sched_basic, 514 473 &drm_sched_timeout, 474 + &drm_sched_cancel, 515 475 &drm_sched_priority, 516 476 &drm_sched_modify_sched, 517 477 &drm_sched_credits);