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.

at v6.15-rc4 63 lines 1.5 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 AND MIT */ 2/* 3 * Copyright © 2022 Intel Corporation 4 */ 5 6#ifndef _XE_TEST_H_ 7#define _XE_TEST_H_ 8 9#include <linux/types.h> 10 11#if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST) 12#include <kunit/test.h> 13#include <kunit/test-bug.h> 14 15/* 16 * Each test that provides a kunit private test structure, place a test id 17 * here and point the kunit->priv to an embedded struct xe_test_priv. 18 */ 19enum xe_test_priv_id { 20 XE_TEST_LIVE_DMA_BUF, 21 XE_TEST_LIVE_MIGRATE, 22}; 23 24/** 25 * struct xe_test_priv - Base class for test private info 26 * @id: enum xe_test_priv_id to identify the subclass. 27 */ 28struct xe_test_priv { 29 enum xe_test_priv_id id; 30}; 31 32#define XE_TEST_DECLARE(x) x 33#define XE_TEST_ONLY(x) unlikely(x) 34 35/** 36 * xe_cur_kunit_priv - Obtain the struct xe_test_priv pointed to by 37 * current->kunit->priv if it exists and is embedded in the expected subclass. 38 * @id: Id of the expected subclass. 39 * 40 * Return: NULL if the process is not a kunit test, and NULL if the 41 * current kunit->priv pointer is not pointing to an object of the expected 42 * subclass. A pointer to the embedded struct xe_test_priv otherwise. 43 */ 44static inline struct xe_test_priv * 45xe_cur_kunit_priv(enum xe_test_priv_id id) 46{ 47 struct xe_test_priv *priv; 48 49 if (!kunit_get_current_test()) 50 return NULL; 51 52 priv = kunit_get_current_test()->priv; 53 return priv->id == id ? priv : NULL; 54} 55 56#else /* if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST) */ 57 58#define XE_TEST_DECLARE(x) 59#define XE_TEST_ONLY(x) 0 60#define xe_cur_kunit_priv(_id) NULL 61 62#endif 63#endif