diff options
author | Steve Muckle <smuckle@google.com> | 2019-07-30 11:58:11 -0700 |
---|---|---|
committer | Steve Muckle <smuckle@google.com> | 2019-08-06 13:58:13 -0700 |
commit | bb58b0157454ad4f066f098977e37d0494312bae (patch) | |
tree | e9295a610fedca5e2593b7d473dd7b36bf8911da /libmodprobe/libmodprobe_test.cpp | |
parent | 73b2928b9400ce679a1482fc072be9fa55d7a8cd (diff) |
libmodprobe: add support to remove modules
Add a remove method which will unload a given module from the kernel,
along with any modules it depended on, assuming those modules are now
unused.
Change-Id: Ie66dc153ef1771f50e26421d38d3656e95954780
Diffstat (limited to 'libmodprobe/libmodprobe_test.cpp')
-rw-r--r-- | libmodprobe/libmodprobe_test.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libmodprobe/libmodprobe_test.cpp b/libmodprobe/libmodprobe_test.cpp index 481658d14..d5a7d6f15 100644 --- a/libmodprobe/libmodprobe_test.cpp +++ b/libmodprobe/libmodprobe_test.cpp @@ -56,6 +56,14 @@ TEST(libmodprobe, Test) { "/test13.ko", }; + std::vector<std::string> expected_after_remove = { + "/test14.ko", "/test15.ko", "/test1.ko", + "/test6.ko", "/test2.ko", "/test5.ko", + "/test8.ko", "/test7.ko param1=4", "/test9.ko param_x=1 param_y=2 param_z=3", + "/test10.ko", "/test12.ko", "/test11.ko", + "/test13.ko", + }; + const std::string modules_dep = "test1.ko:\n" "test2.ko:\n" @@ -131,4 +139,18 @@ TEST(libmodprobe, Test) { } EXPECT_TRUE(modules_loaded == expected_modules_loaded); + + EXPECT_TRUE(m.Remove("test4")); + + GTEST_LOG_(INFO) << "Expected modules loaded after removing test4 (in order):"; + for (auto i = expected_after_remove.begin(); i != expected_after_remove.end(); ++i) { + *i = dir.path + *i; + GTEST_LOG_(INFO) << "\"" << *i << "\""; + } + GTEST_LOG_(INFO) << "Actual modules loaded after removing test4 (in order):"; + for (auto i = modules_loaded.begin(); i != modules_loaded.end(); ++i) { + GTEST_LOG_(INFO) << "\"" << *i << "\""; + } + + EXPECT_TRUE(modules_loaded == expected_after_remove); } |