Commit 83701838 authored by davidgow@google.com's avatar davidgow@google.com Committed by Shuah Khan

overflow: Replace fake root_device with kunit_device

Using struct root_device to create fake devices for tests is something
of a hack. The new struct kunit_device is meant for this purpose, so use
it instead.
Reviewed-by: default avatarMatti Vaittinen <mazziesaccount@gmail.com>
Acked-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarDavid Gow <davidgow@google.com>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent 46ee8f68
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <kunit/device.h>
#include <kunit/test.h> #include <kunit/test.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -618,7 +619,7 @@ static void overflow_allocation_test(struct kunit *test) ...@@ -618,7 +619,7 @@ static void overflow_allocation_test(struct kunit *test)
} while (0) } while (0)
/* Create dummy device for devm_kmalloc()-family tests. */ /* Create dummy device for devm_kmalloc()-family tests. */
dev = root_device_register(device_name); dev = kunit_device_register(test, device_name);
KUNIT_ASSERT_FALSE_MSG(test, IS_ERR(dev), KUNIT_ASSERT_FALSE_MSG(test, IS_ERR(dev),
"Cannot register test device\n"); "Cannot register test device\n");
...@@ -634,8 +635,6 @@ static void overflow_allocation_test(struct kunit *test) ...@@ -634,8 +635,6 @@ static void overflow_allocation_test(struct kunit *test)
check_allocation_overflow(devm_kmalloc); check_allocation_overflow(devm_kmalloc);
check_allocation_overflow(devm_kzalloc); check_allocation_overflow(devm_kzalloc);
device_unregister(dev);
kunit_info(test, "%d allocation overflow tests finished\n", count); kunit_info(test, "%d allocation overflow tests finished\n", count);
#undef check_allocation_overflow #undef check_allocation_overflow
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment