brintos

brintos / linux-shallow public Read only

0
0
Text · 1.5 KiB · 9c23ad9 Raw
64 lines · c
1/* SPDX-License-Identifier: GPL-2.0 AND MIT */2/*3 * Copyright © 2022 Intel Corporation4 */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 id17 * 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 info26 * @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) x33#define XE_TEST_ONLY(x) unlikely(x)34 35/**36 * xe_cur_kunit_priv - Obtain the struct xe_test_priv pointed to by37 * 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 the41 * current kunit->priv pointer is not pointing to an object of the expected42 * 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) 060#define xe_cur_kunit_priv(_id) NULL61 62#endif63#endif64