LCOV - code coverage report
Current view: top level - drivers/gpu/drm/tests - drm_managed_test.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 22 0.0 %
Date: 2023-08-24 13:40:31 Functions: 0 2 0.0 %

          Line data    Source code
       1             : // SPDX-License-Identifier: GPL-2.0
       2             : 
       3             : #include <drm/drm_drv.h>
       4             : #include <drm/drm_kunit_helpers.h>
       5             : #include <drm/drm_managed.h>
       6             : 
       7             : #include <kunit/resource.h>
       8             : 
       9             : #include <linux/device.h>
      10             : 
      11             : /* Ought to be enough for anybody */
      12             : #define TEST_TIMEOUT_MS 100
      13             : 
      14             : struct managed_test_priv {
      15             :         bool action_done;
      16             :         wait_queue_head_t action_wq;
      17             : };
      18             : 
      19           0 : static void drm_action(struct drm_device *drm, void *ptr)
      20             : {
      21           0 :         struct managed_test_priv *priv = ptr;
      22             : 
      23           0 :         priv->action_done = true;
      24           0 :         wake_up_interruptible(&priv->action_wq);
      25           0 : }
      26             : 
      27           0 : static void drm_test_managed_run_action(struct kunit *test)
      28             : {
      29             :         struct managed_test_priv *priv;
      30             :         struct drm_device *drm;
      31             :         struct device *dev;
      32             :         int ret;
      33             : 
      34           0 :         priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL);
      35           0 :         KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv);
      36           0 :         init_waitqueue_head(&priv->action_wq);
      37             : 
      38           0 :         dev = drm_kunit_helper_alloc_device(test);
      39           0 :         KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev);
      40             : 
      41           0 :         drm = __drm_kunit_helper_alloc_drm_device(test, dev, sizeof(*drm), 0, DRIVER_MODESET);
      42           0 :         KUNIT_ASSERT_NOT_ERR_OR_NULL(test, drm);
      43             : 
      44           0 :         ret = drmm_add_action_or_reset(drm, drm_action, priv);
      45           0 :         KUNIT_EXPECT_EQ(test, ret, 0);
      46             : 
      47           0 :         ret = drm_dev_register(drm, 0);
      48           0 :         KUNIT_ASSERT_EQ(test, ret, 0);
      49             : 
      50           0 :         drm_dev_unregister(drm);
      51           0 :         drm_kunit_helper_free_device(test, dev);
      52             : 
      53           0 :         ret = wait_event_interruptible_timeout(priv->action_wq, priv->action_done,
      54             :                                                msecs_to_jiffies(TEST_TIMEOUT_MS));
      55           0 :         KUNIT_EXPECT_GT(test, ret, 0);
      56           0 : }
      57             : 
      58             : static struct kunit_case drm_managed_tests[] = {
      59             :         KUNIT_CASE(drm_test_managed_run_action),
      60             :         {}
      61             : };
      62             : 
      63             : static struct kunit_suite drm_managed_test_suite = {
      64             :         .name = "drm-test-managed",
      65             :         .test_cases = drm_managed_tests
      66             : };
      67             : 
      68             : kunit_test_suite(drm_managed_test_suite);
      69             : 
      70             : MODULE_AUTHOR("Maxime Ripard <maxime@cerno.tech>");
      71             : MODULE_LICENSE("GPL");

Generated by: LCOV version 1.14