summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNan Zhou <nanzhoumails@gmail.com>2022-07-11 04:16:31 +0300
committerEd Tanous <ed@tanous.net>2022-07-23 18:17:11 +0300
commitd5c80ad9c07b94465d8ea62d2b6f87c30cac765e (patch)
tree7400b044cbca9299807facb5ab61b333a585d1b7
parent0d7702c0246c5948caf12a3e441f74952c7d0ccf (diff)
downloadbmcweb-d5c80ad9c07b94465d8ea62d2b6f87c30cac765e.tar.xz
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
-rw-r--r--http/ut/router_test.cpp12
-rw-r--r--http/ut/utility_test.cpp5
-rw-r--r--include/dbus_utility.hpp11
-rw-r--r--include/http_utility.hpp14
-rw-r--r--include/human_sort.hpp1
-rw-r--r--include/openbmc_dbus_rest.hpp46
-rw-r--r--include/ut/dbus_utility_test.cpp6
-rw-r--r--include/ut/http_utility_test.cpp6
-rw-r--r--include/ut/human_sort_test.cpp9
-rw-r--r--include/ut/multipart_test.cpp14
-rw-r--r--include/ut/openbmc_dbus_rest_test.cpp9
-rw-r--r--redfish-core/include/privileges.hpp14
-rw-r--r--redfish-core/include/registries.hpp5
-rw-r--r--redfish-core/include/utils/hex_utils.hpp1
-rw-r--r--redfish-core/include/utils/ip_utils.hpp2
-rw-r--r--redfish-core/include/utils/json_utils.hpp31
-rw-r--r--redfish-core/include/utils/query_param.hpp26
-rw-r--r--redfish-core/include/utils/query_param_test.cpp12
-rw-r--r--redfish-core/include/utils/time_utils.hpp4
-rw-r--r--redfish-core/lib/ut/service_root_test.cpp16
-rw-r--r--redfish-core/ut/configfile_test.cpp8
-rw-r--r--redfish-core/ut/hex_utils_test.cpp12
-rw-r--r--redfish-core/ut/ip_utils_test.cpp6
-rw-r--r--redfish-core/ut/json_utils_test.cpp17
-rw-r--r--redfish-core/ut/lock_test.cpp14
-rw-r--r--redfish-core/ut/privileges_test.cpp15
-rw-r--r--redfish-core/ut/registries_test.cpp6
-rw-r--r--redfish-core/ut/stl_utils_test.cpp8
-rw-r--r--redfish-core/ut/time_utils_test.cpp9
-rw-r--r--src/crow_getroutes_test.cpp16
30 files changed, 304 insertions, 51 deletions
diff --git a/http/ut/router_test.cpp b/http/ut/router_test.cpp
index a08a8109c8..4d1a7442c9 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 23e8ae34a2..c774996283 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 d9d59f7c1f..4ee7eaf763 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 c150943f8f..46742a0ce6 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 02018b1e14..f4dfbe03c7 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 cf07f76f33..d4700a379b 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 a8fad63f94..71978d01ba 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 c92bf1e4e5..e412e17536 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 938b58271f..be21a198b0 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 154f018e4b..7ad7d98f89 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 7efd10df3e..b01e92a505 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 f20cedee15..62276815c3 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 26e1941052..a995d765e5 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 0b3be2b53f..f3728ea892 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 ff65eb6793..815243eb1d 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 3ae57fb3ef..66e0619fc4 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 0e86ec5934..3a70c6c0b4 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 077447f626..2d8cfbb990 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 b4bc778c60..e814c5177e 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 ab0e660cb9..9b8744ac59 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 2c68c0bc64..1d95a79066 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 506dc5a131..8fd4638d09 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 c7d600b6e6..f358c51477 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 a28442823f..826d4375a6 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 5c0df1fa75..c27ba68926 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 c5a7a87964..2d0da021eb 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 758d8b3567..87b92dcf8c 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 0c8e8c1bba..f1febd088d 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 e97e9a7bce..e390fbd70b 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 f4d375b35b..58b745b430 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
{