-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add tests for waitqueue helpers.
Signed-off-by: Imran Khan <imran.f.khan@oracle.com>
- Loading branch information
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright (c) 2023, Oracle and/or its affiliates. | ||
# SPDX-License-Identifier: LGPL-2.1-or-later | ||
|
||
from drgn.helpers.linux.wait import waitqueue_active, waitqueue_for_each_task | ||
from tests.linux_kernel import LinuxKernelTestCase, skip_unless_have_test_kmod | ||
|
||
|
||
def waiter_tasks(prog): | ||
return [ | ||
prog["drgn_test_waitq_kthread"], | ||
] | ||
|
||
|
||
@skip_unless_have_test_kmod | ||
class TestWaitqueue(LinuxKernelTestCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
cls.waitq = cls.prog["drgn_test_waitq"].address_of_() | ||
cls.empty_waitq = cls.prog["drgn_test_empty_waitq"].address_of_() | ||
|
||
def test_waitqueue_active(self): | ||
self.assertTrue(waitqueue_active(self.waitq)) | ||
self.assertFalse(waitqueue_active(self.empty_waitq)) | ||
|
||
def test_waitqueue_for_each_task(self): | ||
self.assertEqual(list(waitqueue_for_each_task(self.empty_waitq)), []) | ||
self.assertEqual( | ||
[task for task in waitqueue_for_each_task(self.waitq)], | ||
waiter_tasks(self.prog), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters