test treewide: iwyu
These changes are done by running iwyu manually under clang14.
Suppressed some obvious impl or details headers. Kept the recommended
public headers.
IWYU can increase readability, make maintenance easier, and avoid errors
in some cases. See details in
https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/WhyIWYU.md.
This commit also uses its best effort to correct obvious errors through
iwyu pragma.
See reference here:
https://github.com/include-what-you-use/include-what-you-use#how-to-correct-iwyu-mistakes
Tested: unit test passed.
Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Change-Id: I983b6f75601707cbb0f2f04546c3362ff4ba7fee
diff --git a/http/ut/router_test.cpp b/http/ut/router_test.cpp
index a08a810..4d1a744 100644
--- a/http/ut/router_test.cpp
+++ b/http/ut/router_test.cpp
@@ -1,8 +1,9 @@
-#include "async_resp.hpp"
+#include "async_resp.hpp" // IWYU pragma: keep
#include "http_request.hpp"
#include "routing.hpp"
#include "utility.hpp"
+#include <boost/beast/http/message.hpp> // IWYU pragma: keep
#include <boost/beast/http/verb.hpp>
#include <memory>
@@ -10,7 +11,14 @@
#include <string_view>
#include <system_error>
-#include <gtest/gtest.h>
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+// IWYU pragma: no_include <boost/beast/http/impl/message.hpp>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
+// IWYU pragma: no_include <boost/intrusive/detail/list_iterator.hpp>
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_forward_declare bmcweb::AsyncResp
namespace crow
{
diff --git a/http/ut/utility_test.cpp b/http/ut/utility_test.cpp
index 23e8ae3..c774996 100644
--- a/http/ut/utility_test.cpp
+++ b/http/ut/utility_test.cpp
@@ -14,7 +14,10 @@
#include <string>
#include <string_view>
-#include <gtest/gtest.h>
+#include <gtest/gtest.h> // IWYU pragma: keep
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
namespace crow::utility
{
diff --git a/include/dbus_utility.hpp b/include/dbus_utility.hpp
index d9d59f7..4ee7eaf 100644
--- a/include/dbus_utility.hpp
+++ b/include/dbus_utility.hpp
@@ -17,16 +17,25 @@
#include "dbus_singleton.hpp"
-#include <sdbusplus/message.hpp>
+#include <boost/system/error_code.hpp> // IWYU pragma: keep
+#include <sdbusplus/message/native_types.hpp>
#include <array>
+#include <cstddef>
+#include <cstdint>
#include <filesystem>
#include <regex>
+#include <sstream>
#include <string>
#include <tuple>
+#include <utility>
#include <variant>
#include <vector>
+// IWYU pragma: no_include <stddef.h>
+// IWYU pragma: no_include <stdint.h>
+// IWYU pragma: no_include <boost/system/detail/error_code.hpp>
+
namespace dbus
{
diff --git a/include/http_utility.hpp b/include/http_utility.hpp
index c150943..46742a0 100644
--- a/include/http_utility.hpp
+++ b/include/http_utility.hpp
@@ -1,8 +1,20 @@
#pragma once
-#include "http_request.hpp"
#include <boost/algorithm/string/classification.hpp>
+#include <boost/algorithm/string/constants.hpp>
#include <boost/algorithm/string/split.hpp>
+#include <boost/iterator/iterator_facade.hpp>
+#include <boost/type_index/type_index_facade.hpp>
+
+#include <cctype>
+#include <iomanip>
+#include <ostream>
+#include <string>
+#include <string_view>
+#include <vector>
+
+// IWYU pragma: no_include <ctype.h>
+// IWYU pragma: no_include <boost/algorithm/string/detail/classification.hpp>
namespace http_helpers
{
diff --git a/include/human_sort.hpp b/include/human_sort.hpp
index 02018b1..f4dfbe0 100644
--- a/include/human_sort.hpp
+++ b/include/human_sort.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <charconv>
+#include <iterator>
#include <string_view>
namespace details
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index cf07f76..d4700a3 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -13,6 +13,13 @@
// limitations under the License.
#pragma once
+#include "http_request.hpp"
+#include "http_response.hpp"
+#include "logging.hpp"
+#include "routing.hpp"
+
+#include <systemd/sd-bus-protocol.h>
+#include <systemd/sd-bus.h>
#include <tinyxml2.h>
#include <app.hpp>
@@ -20,15 +27,48 @@
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/split.hpp>
-#include <boost/container/flat_set.hpp>
+#include <boost/beast/http/status.hpp>
+#include <boost/beast/http/verb.hpp>
+#include <boost/container/flat_map.hpp>
+#include <boost/container/vector.hpp>
+#include <boost/iterator/iterator_facade.hpp>
#include <dbus_singleton.hpp>
#include <dbus_utility.hpp>
-#include <sdbusplus/message/types.hpp>
+#include <nlohmann/json.hpp>
+#include <sdbusplus/asio/connection.hpp>
+#include <sdbusplus/exception.hpp>
+#include <sdbusplus/message.hpp>
+#include <sdbusplus/message/native_types.hpp>
+#include <algorithm>
+#include <array>
+#include <cerrno>
+#include <cstdint>
+#include <cstring>
#include <filesystem>
#include <fstream>
+#include <functional>
+#include <initializer_list>
+#include <iterator>
+#include <limits>
+#include <map>
+#include <memory>
#include <regex>
+#include <string>
+#include <string_view>
+#include <type_traits>
#include <utility>
+#include <variant>
+#include <vector>
+
+// IWYU pragma: no_include <boost/algorithm/string/detail/classification.hpp>
+// IWYU pragma: no_include <boost/system/detail/error_code.hpp>
+// IWYU pragma: no_include <boost/system/detail/error_category.hpp>
+// IWYU pragma: no_include <errno.h>
+// IWYU pragma: no_include <string.h>
+// IWYU pragma: no_include <ext/alloc_traits.h>
+// IWYU pragma: no_include <exception>
+// IWYU pragma: no_include <boost/type_index/type_index_facade.hpp>
namespace crow
{
diff --git a/include/ut/dbus_utility_test.cpp b/include/ut/dbus_utility_test.cpp
index a8fad63..71978d0 100644
--- a/include/ut/dbus_utility_test.cpp
+++ b/include/ut/dbus_utility_test.cpp
@@ -2,7 +2,11 @@
#include <string>
-#include <gtest/gtest.h>
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
namespace dbus::utility
{
diff --git a/include/ut/http_utility_test.cpp b/include/ut/http_utility_test.cpp
index c92bf1e..e412e17 100644
--- a/include/ut/http_utility_test.cpp
+++ b/include/ut/http_utility_test.cpp
@@ -1,6 +1,10 @@
#include "http_utility.hpp"
-#include <gtest/gtest.h>
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
namespace http_helpers
{
diff --git a/include/ut/human_sort_test.cpp b/include/ut/human_sort_test.cpp
index 938b582..be21a19 100644
--- a/include/ut/human_sort_test.cpp
+++ b/include/ut/human_sort_test.cpp
@@ -3,8 +3,13 @@
#include <set>
#include <string>
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
+#include <gmock/gmock.h> // IWYU pragma: keep
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
+// IWYU pragma: no_include <gmock/gmock-matchers.h>
namespace
{
diff --git a/include/ut/multipart_test.cpp b/include/ut/multipart_test.cpp
index 154f018..7ad7d98 100644
--- a/include/ut/multipart_test.cpp
+++ b/include/ut/multipart_test.cpp
@@ -1,13 +1,23 @@
#include "http/http_request.hpp"
#include "multipart_parser.hpp"
+#include <boost/beast/http/fields.hpp>
#include <boost/beast/http/message.hpp>
#include <boost/beast/http/string_body.hpp>
-#include <map>
+#include <memory>
+#include <string_view>
#include <system_error>
+#include <vector>
-#include <gtest/gtest.h>
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
+// IWYU pragma: no_include <boost/beast/http/impl/fields.hpp>
+// IWYU pragma: no_include <boost/intrusive/detail/list_iterator.hpp>
+// IWYU pragma: no_include <boost/intrusive/detail/tree_iterator.hpp>
namespace
{
diff --git a/include/ut/openbmc_dbus_rest_test.cpp b/include/ut/openbmc_dbus_rest_test.cpp
index 7efd10d..b01e92a 100644
--- a/include/ut/openbmc_dbus_rest_test.cpp
+++ b/include/ut/openbmc_dbus_rest_test.cpp
@@ -1,7 +1,12 @@
#include "openbmc_dbus_rest.hpp"
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
+#include <gmock/gmock.h> // IWYU pragma: keep
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
+// IWYU pragma: no_include <gmock/gmock-matchers.h>
namespace crow::openbmc_mapper
{
diff --git a/redfish-core/include/privileges.hpp b/redfish-core/include/privileges.hpp
index f20cede..6227681 100644
--- a/redfish-core/include/privileges.hpp
+++ b/redfish-core/include/privileges.hpp
@@ -15,15 +15,25 @@
*/
#pragma once
+#include "logging.hpp"
+
#include <boost/beast/http/verb.hpp>
#include <boost/container/flat_map.hpp>
-#include <logging.hpp>
+#include <boost/container/vector.hpp>
+#include <boost/move/algo/move.hpp>
#include <array>
#include <bitset>
-#include <cstdint>
+#include <cstddef>
+#include <functional>
+#include <initializer_list>
+#include <string>
+#include <string_view>
+#include <utility>
#include <vector>
+// IWYU pragma: no_include <stddef.h>
+
namespace redfish
{
diff --git a/redfish-core/include/registries.hpp b/redfish-core/include/registries.hpp
index 26e1941..a995d76 100644
--- a/redfish-core/include/registries.hpp
+++ b/redfish-core/include/registries.hpp
@@ -15,9 +15,14 @@
*/
#pragma once
+#include <array>
+#include <cstddef>
#include <span>
#include <string>
#include <string_view>
+#include <utility>
+
+// IWYU pragma: no_include <stddef.h>
namespace redfish::registries
{
diff --git a/redfish-core/include/utils/hex_utils.hpp b/redfish-core/include/utils/hex_utils.hpp
index 0b3be2b..f3728ea 100644
--- a/redfish-core/include/utils/hex_utils.hpp
+++ b/redfish-core/include/utils/hex_utils.hpp
@@ -2,6 +2,7 @@
#include <array>
#include <cstddef>
+#include <cstdint>
#include <string>
#include <vector>
diff --git a/redfish-core/include/utils/ip_utils.hpp b/redfish-core/include/utils/ip_utils.hpp
index ff65eb6..815243e 100644
--- a/redfish-core/include/utils/ip_utils.hpp
+++ b/redfish-core/include/utils/ip_utils.hpp
@@ -1,6 +1,8 @@
#pragma once
#include <boost/asio/ip/address.hpp>
+#include <boost/asio/ip/address_v4.hpp>
+#include <boost/asio/ip/address_v6.hpp>
#include <string>
diff --git a/redfish-core/include/utils/json_utils.hpp b/redfish-core/include/utils/json_utils.hpp
index 3ae57fb..66e0619 100644
--- a/redfish-core/include/utils/json_utils.hpp
+++ b/redfish-core/include/utils/json_utils.hpp
@@ -15,12 +15,33 @@
*/
#pragma once
-#include <error_messages.hpp>
-#include <http_request.hpp>
-#include <http_response.hpp>
-#include <nlohmann/json.hpp>
+#include "error_messages.hpp"
+#include "http_request.hpp"
+#include "http_response.hpp"
+#include "logging.hpp"
+#include "nlohmann/json.hpp"
+#include <array>
+#include <cmath>
+#include <cstddef>
+#include <cstdint>
+#include <limits>
+#include <map>
+#include <optional>
#include <span>
+#include <string>
+#include <string_view>
+#include <type_traits>
+#include <utility>
+#include <variant>
+#include <vector>
+
+// IWYU pragma: no_include <stdint.h>
+
+namespace crow
+{
+struct Request;
+} // namespace crow
namespace redfish
{
diff --git a/redfish-core/include/utils/query_param.hpp b/redfish-core/include/utils/query_param.hpp
index 0e86ec5..3a70c6c 100644
--- a/redfish-core/include/utils/query_param.hpp
+++ b/redfish-core/include/utils/query_param.hpp
@@ -1,17 +1,41 @@
#pragma once
+#include "bmcweb_config.h"
+
#include "app.hpp"
#include "async_resp.hpp"
#include "error_messages.hpp"
#include "http_request.hpp"
#include "http_response.hpp"
-#include "routing.hpp"
+#include "logging.hpp"
+#include <sys/types.h>
+
+#include <boost/beast/http/message.hpp> // IWYU pragma: keep
+#include <boost/beast/http/status.hpp>
+#include <boost/beast/http/verb.hpp>
+#include <boost/url/params_view.hpp>
+#include <boost/url/string.hpp>
+#include <nlohmann/json.hpp>
+
+#include <algorithm>
#include <charconv>
+#include <cstdint>
+#include <functional>
+#include <limits>
+#include <map>
+#include <memory>
+#include <optional>
#include <string>
#include <string_view>
+#include <system_error>
#include <utility>
#include <vector>
+// IWYU pragma: no_include <boost/url/impl/params_view.hpp>
+// IWYU pragma: no_include <boost/beast/http/impl/message.hpp>
+// IWYU pragma: no_include <boost/intrusive/detail/list_iterator.hpp>
+// IWYU pragma: no_include <stdint.h>
+
namespace redfish
{
namespace query_param
diff --git a/redfish-core/include/utils/query_param_test.cpp b/redfish-core/include/utils/query_param_test.cpp
index 077447f..2d8cfbb 100644
--- a/redfish-core/include/utils/query_param_test.cpp
+++ b/redfish-core/include/utils/query_param_test.cpp
@@ -4,10 +4,16 @@
#include <boost/url/url_view.hpp>
#include <nlohmann/json.hpp>
-#include <cstddef>
+#include <new>
-#include <gmock/gmock-matchers.h>
-#include <gtest/gtest.h>
+#include <gmock/gmock.h> // IWYU pragma: keep
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
+// IWYU pragma: no_include <boost/url/impl/url_view.hpp>
+// IWYU pragma: no_include <gmock/gmock-matchers.h>
namespace redfish::query_param
{
diff --git a/redfish-core/include/utils/time_utils.hpp b/redfish-core/include/utils/time_utils.hpp
index b4bc778..e814c51 100644
--- a/redfish-core/include/utils/time_utils.hpp
+++ b/redfish-core/include/utils/time_utils.hpp
@@ -8,12 +8,16 @@
#include <cmath>
#include <compare>
#include <cstddef>
+#include <cstdint>
#include <optional>
#include <ratio>
#include <string>
#include <string_view>
#include <system_error>
+// IWYU pragma: no_include <stddef.h>
+// IWYU pragma: no_include <stdint.h>
+
namespace redfish
{
diff --git a/redfish-core/lib/ut/service_root_test.cpp b/redfish-core/lib/ut/service_root_test.cpp
index ab0e660..9b8744a 100644
--- a/redfish-core/lib/ut/service_root_test.cpp
+++ b/redfish-core/lib/ut/service_root_test.cpp
@@ -1,15 +1,21 @@
#include "bmcweb_config.h"
-#include "http_request.hpp"
+#include "http_response.hpp"
#include "include/async_resp.hpp"
#include "nlohmann/json.hpp"
-#include "redfish-core/lib/service_root.hpp"
+#include "service_root.hpp"
#include <memory>
-#include <string>
+#include <vector>
-#include "gmock/gmock.h"
-#include "gtest/gtest.h"
+#include <gmock/gmock.h> // IWYU pragma: keep
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
+// IWYU pragma: no_include <gmock/gmock-matchers.h>
+// IWYU pragma: no_include <gtest/gtest-matchers.h>
namespace redfish
{
diff --git a/redfish-core/ut/configfile_test.cpp b/redfish-core/ut/configfile_test.cpp
index 2c68c0b..1d95a79 100644
--- a/redfish-core/ut/configfile_test.cpp
+++ b/redfish-core/ut/configfile_test.cpp
@@ -1,9 +1,13 @@
+#include "http_response.hpp"
#include "ibm/management_console_rest.hpp"
-#include "nlohmann/json.hpp"
#include <string>
-#include "gmock/gmock.h"
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
namespace crow
{
diff --git a/redfish-core/ut/hex_utils_test.cpp b/redfish-core/ut/hex_utils_test.cpp
index 506dc5a..8fd4638 100644
--- a/redfish-core/ut/hex_utils_test.cpp
+++ b/redfish-core/ut/hex_utils_test.cpp
@@ -1,7 +1,15 @@
#include "utils/hex_utils.hpp"
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
+#include <cctype>
+#include <limits>
+
+#include <gmock/gmock.h> // IWYU pragma: keep
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
namespace
{
diff --git a/redfish-core/ut/ip_utils_test.cpp b/redfish-core/ut/ip_utils_test.cpp
index c7d600b..f358c51 100644
--- a/redfish-core/ut/ip_utils_test.cpp
+++ b/redfish-core/ut/ip_utils_test.cpp
@@ -1,6 +1,10 @@
#include "utils/ip_utils.hpp"
-#include "gtest/gtest.h"
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
namespace redfish::ip_util
{
diff --git a/redfish-core/ut/json_utils_test.cpp b/redfish-core/ut/json_utils_test.cpp
index a284428..826d437 100644
--- a/redfish-core/ut/json_utils_test.cpp
+++ b/redfish-core/ut/json_utils_test.cpp
@@ -1,10 +1,23 @@
+#include "http_request.hpp"
+#include "http_response.hpp"
#include "utils/json_utils.hpp"
+#include <boost/beast/http/status.hpp>
+#include <nlohmann/json.hpp>
+
+#include <cstdint>
+#include <optional>
#include <string>
+#include <system_error>
#include <vector>
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
+#include <gmock/gmock.h> // IWYU pragma: keep
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
+// IWYU pragma: no_include <boost/intrusive/detail/list_iterator.hpp>
namespace redfish::json_util
{
diff --git a/redfish-core/ut/lock_test.cpp b/redfish-core/ut/lock_test.cpp
index 5c0df1f..c27ba68 100644
--- a/redfish-core/ut/lock_test.cpp
+++ b/redfish-core/ut/lock_test.cpp
@@ -1,9 +1,19 @@
#include "ibm/locks.hpp"
+#include <cstdint>
+#include <memory>
#include <string>
+#include <tuple>
+#include <utility>
+#include <variant>
+#include <vector>
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
+#include <gmock/gmock.h> // IWYU pragma: keep
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
namespace crow::ibm_mc_lock
{
diff --git a/redfish-core/ut/privileges_test.cpp b/redfish-core/ut/privileges_test.cpp
index c5a7a87..2d0da02 100644
--- a/redfish-core/ut/privileges_test.cpp
+++ b/redfish-core/ut/privileges_test.cpp
@@ -1,10 +1,17 @@
-#include "nlohmann/json.hpp"
#include "privileges.hpp"
-#include <fstream>
-#include <string>
+#include <boost/beast/http/verb.hpp>
-#include "gmock/gmock.h"
+#include <array>
+
+#include <gmock/gmock.h> // IWYU pragma: keep
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
+// IWYU pragma: no_include <gmock/gmock-matchers.h>
+// IWYU pragma: no_include <gmock/gmock-more-matchers.h>
namespace redfish
{
diff --git a/redfish-core/ut/registries_test.cpp b/redfish-core/ut/registries_test.cpp
index 758d8b3..87b92dc 100644
--- a/redfish-core/ut/registries_test.cpp
+++ b/redfish-core/ut/registries_test.cpp
@@ -1,6 +1,10 @@
#include "registries.hpp"
-#include "gmock/gmock.h"
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
namespace redfish::registries
{
diff --git a/redfish-core/ut/stl_utils_test.cpp b/redfish-core/ut/stl_utils_test.cpp
index 0c8e8c1..f1febd0 100644
--- a/redfish-core/ut/stl_utils_test.cpp
+++ b/redfish-core/ut/stl_utils_test.cpp
@@ -2,8 +2,12 @@
#include <string>
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
+#include <gmock/gmock.h> // IWYU pragma: keep
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
namespace redfish::stl_utils
{
diff --git a/redfish-core/ut/time_utils_test.cpp b/redfish-core/ut/time_utils_test.cpp
index e97e9a7..e390fbd 100644
--- a/redfish-core/ut/time_utils_test.cpp
+++ b/redfish-core/ut/time_utils_test.cpp
@@ -1,6 +1,13 @@
#include "utils/time_utils.hpp"
-#include <gmock/gmock.h>
+#include <gmock/gmock.h> // IWYU pragma: keep
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
+// IWYU pragma: no_include <gmock/gmock-matchers.h>
+// IWYU pragma: no_include <gtest/gtest-matchers.h>
namespace redfish::time_utils
{
diff --git a/src/crow_getroutes_test.cpp b/src/crow_getroutes_test.cpp
index f4d375b..58b745b 100644
--- a/src/crow_getroutes_test.cpp
+++ b/src/crow_getroutes_test.cpp
@@ -1,7 +1,19 @@
#include "app.hpp"
+#include "routing.hpp"
-#include "gmock/gmock.h"
-#include "gtest/gtest.h"
+#include <boost/beast/http/status.hpp>
+
+#include <memory>
+
+#include <gmock/gmock.h> // IWYU pragma: keep
+#include <gtest/gtest.h> // IWYU pragma: keep
+
+// IWYU pragma: no_include <gtest/gtest-message.h>
+// IWYU pragma: no_include <gtest/gtest-test-part.h>
+// IWYU pragma: no_include "gtest/gtest_pred_impl.h"
+// IWYU pragma: no_include <gmock/gmock-matchers.h>
+// IWYU pragma: no_include <gmock/gmock-more-matchers.h>
+// IWYU pragma: no_include <gtest/gtest-matchers.h>
namespace crow
{