diff --git a/src/linux/libnl-helpers/Netlink80211Interface.cxx b/src/linux/libnl-helpers/Netlink80211Interface.cxx index 3f661567..25ee8176 100644 --- a/src/linux/libnl-helpers/Netlink80211Interface.cxx +++ b/src/linux/libnl-helpers/Netlink80211Interface.cxx @@ -158,5 +158,5 @@ Nl80211Interface::Enumerate() std::optional Nl80211Interface::GetWiphy() const { - return Nl80211Wiphy::FromIndex(WiphyIndex); + return Nl80211Wiphy::FromIndex(WiphyIndex); } diff --git a/src/linux/libnl-helpers/include/microsoft/net/netlink/nl80211/Netlink80211Interface.hxx b/src/linux/libnl-helpers/include/microsoft/net/netlink/nl80211/Netlink80211Interface.hxx index 5c797047..4529d76b 100644 --- a/src/linux/libnl-helpers/include/microsoft/net/netlink/nl80211/Netlink80211Interface.hxx +++ b/src/linux/libnl-helpers/include/microsoft/net/netlink/nl80211/Netlink80211Interface.hxx @@ -26,6 +26,18 @@ struct Nl80211Interface uint32_t Index; uint32_t WiphyIndex; + Nl80211Interface() = default; + + /** + * @brief Construct a new Nl80211Interface object with the specified attributes. + * + * @param name The name of the interface. + * @param type The nl80211_iftype of the interface. + * @param index The interface index in the kernel. + * @param wiphyIndex The phy interface index in the kernel. + */ + Nl80211Interface(std::string_view name, nl80211_iftype type, uint32_t index, uint32_t wiphyIndex) noexcept; + /** * @brief Parse a netlink message into an Nl80211Interface. The netlink message must contain a response to the * NL80211_CMD_GET_INTERFACE command, which is encoded as a NL80211_CMD_NEW_INTERFACE. @@ -48,8 +60,8 @@ struct Nl80211Interface /** * @brief Get the Wiphy (PHY) object associated with this interface. - * - * @return std::optional + * + * @return std::optional */ std::optional GetWiphy() const; @@ -61,17 +73,6 @@ struct Nl80211Interface */ std::string ToString() const; - -private: - /** - * @brief Construct a new Nl80211Interface object with the specified attributes. - * - * @param name The name of the interface. - * @param type The nl80211_iftype of the interface. - * @param index The interface index in the kernel. - * @param wiphyIndex The phy interface index in the kernel. - */ - Nl80211Interface(std::string_view name, nl80211_iftype type, uint32_t index, uint32_t wiphyIndex) noexcept; }; } // namespace Microsoft::Net::Netlink::Nl80211 diff --git a/src/linux/wifi/apmanager/AccessPointDiscoveryAgentOperationsNetlink.cxx b/src/linux/wifi/apmanager/AccessPointDiscoveryAgentOperationsNetlink.cxx index 354cdbbf..01fdd384 100644 --- a/src/linux/wifi/apmanager/AccessPointDiscoveryAgentOperationsNetlink.cxx +++ b/src/linux/wifi/apmanager/AccessPointDiscoveryAgentOperationsNetlink.cxx @@ -30,7 +30,7 @@ using Microsoft::Net::Netlink::NetlinkMessage; using Microsoft::Net::Netlink::NetlinkSocket; using Microsoft::Net::Netlink::Nl80211::Nl80211ProtocolState; -AccessPointDiscoveryAgentOperationsNetlink::AccessPointDiscoveryAgentOperationsNetlink(std::shared_ptr accessPointFactory) : +AccessPointDiscoveryAgentOperationsNetlink::AccessPointDiscoveryAgentOperationsNetlink(std::shared_ptr accessPointFactory) : m_accessPointFactory(std::move(accessPointFactory)), m_cookie(CookieValid), m_netlink80211ProtocolState(Nl80211ProtocolState::Instance()) @@ -141,9 +141,10 @@ IsNl80211InterfaceTypeAp(const Nl80211Interface &nl80211Interface) * @return std::shared_ptr */ std::shared_ptr -MakeAccessPoint(std::shared_ptr accessPointFactory, const Nl80211Interface &nl80211Interface) +MakeAccessPoint(std::shared_ptr accessPointFactory, const Nl80211Interface &nl80211Interface) { - return accessPointFactory->Create(nl80211Interface.Name); + auto createArgs = std::make_unique(std::move(nl80211Interface)); + return accessPointFactory->Create(nl80211Interface.Name, std::move(createArgs)); } } // namespace detail diff --git a/src/linux/wifi/apmanager/CMakeLists.txt b/src/linux/wifi/apmanager/CMakeLists.txt index 80c95f0a..1382dfed 100644 --- a/src/linux/wifi/apmanager/CMakeLists.txt +++ b/src/linux/wifi/apmanager/CMakeLists.txt @@ -25,11 +25,5 @@ target_link_libraries(wifi-apmanager-linux libnl-helpers wifi-apmanager wifi-core -) - -install( - TARGETS wifi-apmanager-linux - EXPORT ${PROJECT_NAME} - FILE_SET HEADERS - PUBLIC_HEADER DESTINATION "${NETREMOTE_DIR_INSTALL_PUBLIC_HEADER_BASE}/${WIFI_APMANAGER_LINUX_PUBLIC_INCLUDE_SUFFIX}" + wifi-core-linux ) diff --git a/src/linux/wifi/apmanager/include/microsoft/net/wifi/AccessPointDiscoveryAgentOperationsNetlink.hxx b/src/linux/wifi/apmanager/include/microsoft/net/wifi/AccessPointDiscoveryAgentOperationsNetlink.hxx index bddfb87c..704354e6 100644 --- a/src/linux/wifi/apmanager/include/microsoft/net/wifi/AccessPointDiscoveryAgentOperationsNetlink.hxx +++ b/src/linux/wifi/apmanager/include/microsoft/net/wifi/AccessPointDiscoveryAgentOperationsNetlink.hxx @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -29,7 +30,12 @@ namespace Microsoft::Net::Wifi struct AccessPointDiscoveryAgentOperationsNetlink : public IAccessPointDiscoveryAgentOperations { - AccessPointDiscoveryAgentOperationsNetlink(std::shared_ptr accessPointFactory); + /** + * @brief Construct a new AccessPointDiscoveryAgentOperationsNetlink object with the specified access point factory. + * + * @param accessPointFactory The access point factory to use for creating access points. + */ + AccessPointDiscoveryAgentOperationsNetlink(std::shared_ptr accessPointFactory); virtual ~AccessPointDiscoveryAgentOperationsNetlink(); @@ -101,7 +107,7 @@ private: ProcessNetlinkMessage(struct nl_msg *netlinkMessage, AccessPointPresenceEventCallback &accessPointPresenceEventCallback); private: - std::shared_ptr m_accessPointFactory; + std::shared_ptr m_accessPointFactory; // Cookie used to validate that the callback context is valid. static constexpr uint32_t CookieValid{ 0x8BADF00Du }; diff --git a/src/linux/wifi/core/AccessPointLinux.cxx b/src/linux/wifi/core/AccessPointLinux.cxx index 4b1a5dad..d41bd1fe 100644 --- a/src/linux/wifi/core/AccessPointLinux.cxx +++ b/src/linux/wifi/core/AccessPointLinux.cxx @@ -1,9 +1,20 @@ +#include + #include #include +#include + +using Microsoft::Net::Netlink::Nl80211::Nl80211Interface; using namespace Microsoft::Net::Wifi; +AccessPointLinux::AccessPointLinux(std::string_view interfaceName, std::shared_ptr accessPointControllerFactory, Microsoft::Net::Netlink::Nl80211::Nl80211Interface nl80211Interface) : + AccessPoint(interfaceName, std::move(accessPointControllerFactory)), + m_nl80211Interface{ std::move(nl80211Interface) } +{ +} + std::unique_ptr AccessPointLinux::CreateController() { @@ -17,7 +28,17 @@ AccessPointFactoryLinux::Create(std::string_view interfaceName) } std::shared_ptr -AccessPointFactoryLinux::Create(std::string_view interfaceName, [[maybe_unused]] std::unique_ptr createArgs) +AccessPointFactoryLinux::Create(std::string_view interfaceName, std::unique_ptr createArgs) +{ + auto createArgsLinux = dynamic_cast(createArgs.get()); + if (createArgsLinux == nullptr) { + throw std::runtime_error("invalid arguments passed to AccessPointFactoryLinux::Create; this is a bug!"); + } + + return std::make_shared(interfaceName, GetControllerFactory(), std::move(createArgsLinux->Interface)); +} + +AccessPointCreateArgsLinux::AccessPointCreateArgsLinux(Nl80211Interface nl80211Interface) : + Interface{ std::move(nl80211Interface) } { - return std::make_shared(interfaceName, GetControllerFactory()); } diff --git a/src/linux/wifi/core/CMakeLists.txt b/src/linux/wifi/core/CMakeLists.txt index e18791ca..2b28088a 100644 --- a/src/linux/wifi/core/CMakeLists.txt +++ b/src/linux/wifi/core/CMakeLists.txt @@ -21,6 +21,7 @@ target_link_libraries(wifi-core-linux PRIVATE plog::plog PUBLIC + libnl-helpers wifi-core wpa-controller ) diff --git a/src/linux/wifi/core/include/microsoft/net/wifi/AccessPointLinux.hxx b/src/linux/wifi/core/include/microsoft/net/wifi/AccessPointLinux.hxx index b978ae93..856d36b5 100644 --- a/src/linux/wifi/core/include/microsoft/net/wifi/AccessPointLinux.hxx +++ b/src/linux/wifi/core/include/microsoft/net/wifi/AccessPointLinux.hxx @@ -6,6 +6,7 @@ #include #include +#include namespace Microsoft::Net::Wifi { @@ -16,12 +17,25 @@ struct AccessPointLinux : public AccessPoint { /** - * @brief Inherit the constructors from the base class. + * @brief Construct a new AccessPointLinux object with the specified interface name, access point controller + * factory, and nl80211 interface. + * + * @param interfaceName The name of the interface. + * @param accessPointControllerFactory The access point controller factory to use for creating access point. + * @param nl80211Interface The nl80211 interface object. */ - using AccessPoint::AccessPoint; + AccessPointLinux(std::string_view interfaceName, std::shared_ptr accessPointControllerFactory, Microsoft::Net::Netlink::Nl80211::Nl80211Interface nl80211Interface); + /** + * @brief Create a IAccessPointController object of type AccessPointControllerLinux. + * + * @return std::unique_ptr + */ virtual std::unique_ptr CreateController() override; + +private: + Microsoft::Net::Netlink::Nl80211::Nl80211Interface m_nl80211Interface; }; /** @@ -51,6 +65,22 @@ struct AccessPointFactoryLinux : virtual std::shared_ptr Create(std::string_view interfaceName, std::unique_ptr createArgs) override; }; + +/** + * @brief Arguments to be passed to the Linux access point during creation. + */ +struct AccessPointCreateArgsLinux : + public IAccessPointCreateArgs +{ + /** + * @brief Construct a new AccessPointCreateArgsLinux object with the specified nl80211 interface. + * + * @param nl80211Interface The nl80211 interface object. + */ + AccessPointCreateArgsLinux(Microsoft::Net::Netlink::Nl80211::Nl80211Interface nl80211Interface); + + Microsoft::Net::Netlink::Nl80211::Nl80211Interface Interface; +}; } // namespace Microsoft::Net::Wifi #endif // ACCESS_POINT_LINUX_HXX diff --git a/tests/unit/linux/wifi/CMakeLists.txt b/tests/unit/linux/wifi/CMakeLists.txt index 1e8a6c5d..d403f373 100644 --- a/tests/unit/linux/wifi/CMakeLists.txt +++ b/tests/unit/linux/wifi/CMakeLists.txt @@ -1,3 +1,4 @@ add_subdirectory(apmanager) add_subdirectory(core) +add_subdirectory(helpers) diff --git a/tests/unit/linux/wifi/apmanager/CMakeLists.txt b/tests/unit/linux/wifi/apmanager/CMakeLists.txt index e3adf6b8..3bfb70ea 100644 --- a/tests/unit/linux/wifi/apmanager/CMakeLists.txt +++ b/tests/unit/linux/wifi/apmanager/CMakeLists.txt @@ -19,7 +19,7 @@ target_link_libraries(wifi-apmanager-linux-test-unit plog::plog strings wifi-apmanager-linux - wifi-test-helpers + wifi-test-helpers-linux ) catch_discover_tests(wifi-apmanager-linux-test-unit) diff --git a/tests/unit/linux/wifi/apmanager/TestAccessPointDiscoveryAgentOperationsNetlink.cxx b/tests/unit/linux/wifi/apmanager/TestAccessPointDiscoveryAgentOperationsNetlink.cxx index 80031111..18eef096 100644 --- a/tests/unit/linux/wifi/apmanager/TestAccessPointDiscoveryAgentOperationsNetlink.cxx +++ b/tests/unit/linux/wifi/apmanager/TestAccessPointDiscoveryAgentOperationsNetlink.cxx @@ -6,6 +6,7 @@ #include #include +#include TEST_CASE("Create AccessPointDiscoveryAgentOperationsNetlink", "[wifi][core][apmanager]") { @@ -14,7 +15,7 @@ TEST_CASE("Create AccessPointDiscoveryAgentOperationsNetlink", "[wifi][core][apm SECTION("Create doesn't cause a crash") { - REQUIRE_NOTHROW(AccessPointDiscoveryAgentOperationsNetlink{ std::make_shared() }); + REQUIRE_NOTHROW(AccessPointDiscoveryAgentOperationsNetlink{ std::make_shared() }); } } @@ -25,7 +26,7 @@ TEST_CASE("Destroy AccessPointDiscoveryAgentOperationsNetlink", "[wifi][core][ap SECTION("Destroy doesn't cause a crash") { - std::optional accessPointDiscoveryAgent(std::make_shared()); + std::optional accessPointDiscoveryAgent(std::make_shared()); REQUIRE_NOTHROW(accessPointDiscoveryAgent.reset()); } } @@ -37,20 +38,20 @@ TEST_CASE("AccessPointDiscoveryAgentOperationsNetlink::Start", "[wifi][core][apm SECTION("Start doesn't cause a crash") { - AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; + AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; REQUIRE_NOTHROW(accessPointDiscoveryAgent.Start([](auto &&, auto &&) {})); } SECTION("Start doesn't cause a crash when called twice") { - AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; + AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; accessPointDiscoveryAgent.Start([](auto &&, auto &&) {}); REQUIRE_NOTHROW(accessPointDiscoveryAgent.Start([](auto &&, auto &&) {})); } SECTION("Start doesn't cause a crash when called with a null callback") { - AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; + AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; REQUIRE_NOTHROW(accessPointDiscoveryAgent.Start(nullptr)); } } @@ -62,20 +63,20 @@ TEST_CASE("AccessPointDiscoveryAgentOperationsNetlink::Stop", "[wifi][core][apma SECTION("Stop doesn't cause a crash when Start hasn't been called") { - AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; + AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; REQUIRE_NOTHROW(accessPointDiscoveryAgent.Stop()); } SECTION("Stop doesn't cause a crash when Start has been called") { - AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; + AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; accessPointDiscoveryAgent.Start([](auto &&, auto &&) {}); REQUIRE_NOTHROW(accessPointDiscoveryAgent.Stop()); } SECTION("Stop doesn't cause a crash when called twice") { - AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; + AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; accessPointDiscoveryAgent.Start([](auto &&, auto &&) {}); accessPointDiscoveryAgent.Stop(); REQUIRE_NOTHROW(accessPointDiscoveryAgent.Stop()); @@ -83,7 +84,7 @@ TEST_CASE("AccessPointDiscoveryAgentOperationsNetlink::Stop", "[wifi][core][apma SECTION("Stop doesn't cause a crash when called with a null callback") { - AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; + AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; accessPointDiscoveryAgent.Start(nullptr); REQUIRE_NOTHROW(accessPointDiscoveryAgent.Stop()); } @@ -96,27 +97,27 @@ TEST_CASE("AccessPointDiscoveryAgentOperationsNetlink::ProbeAsync", "[wifi][core SECTION("ProbeAsync doesn't cause a crash when Start hasn't been called") { - AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; + AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; REQUIRE_NOTHROW(accessPointDiscoveryAgent.ProbeAsync()); } SECTION("ProbeAsync doesn't cause a crash when Start has been called") { - AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; + AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; accessPointDiscoveryAgent.Start([](auto &&, auto &&) {}); REQUIRE_NOTHROW(accessPointDiscoveryAgent.ProbeAsync()); } SECTION("ProbeAsync doesn't cause a crash when Stop has been called") { - AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; + AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; accessPointDiscoveryAgent.Stop(); REQUIRE_NOTHROW(accessPointDiscoveryAgent.ProbeAsync()); } SECTION("ProbeAsync doesn't cause a crash when called twice") { - AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; + AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; accessPointDiscoveryAgent.Start([](auto &&, auto &&) {}); accessPointDiscoveryAgent.ProbeAsync(); REQUIRE_NOTHROW(accessPointDiscoveryAgent.ProbeAsync()); @@ -124,7 +125,7 @@ TEST_CASE("AccessPointDiscoveryAgentOperationsNetlink::ProbeAsync", "[wifi][core SECTION("ProbeAsync doesn't cause a crash when called after a Start/Stop sequence") { - AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; + AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; accessPointDiscoveryAgent.Start(nullptr); accessPointDiscoveryAgent.Stop(); REQUIRE_NOTHROW(accessPointDiscoveryAgent.ProbeAsync()); @@ -132,20 +133,20 @@ TEST_CASE("AccessPointDiscoveryAgentOperationsNetlink::ProbeAsync", "[wifi][core SECTION("ProbeAsync returns a valid future") { - AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; + AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; accessPointDiscoveryAgent.Start(nullptr); REQUIRE(accessPointDiscoveryAgent.ProbeAsync().valid()); } SECTION("ProbeAsync result can be obtained without causing a crash") { - AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; + AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; REQUIRE_NOTHROW(accessPointDiscoveryAgent.ProbeAsync().get()); } SECTION("ProbeAsync result is valid") { - AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; + AccessPointDiscoveryAgentOperationsNetlink accessPointDiscoveryAgent{ std::make_shared() }; REQUIRE_NOTHROW(accessPointDiscoveryAgent.ProbeAsync().get().clear()); } } diff --git a/tests/unit/linux/wifi/core/TestAccessPointFactoryLinux.cxx b/tests/unit/linux/wifi/core/TestAccessPointFactoryLinux.cxx index a8ae05c0..52a44dd4 100644 --- a/tests/unit/linux/wifi/core/TestAccessPointFactoryLinux.cxx +++ b/tests/unit/linux/wifi/core/TestAccessPointFactoryLinux.cxx @@ -33,7 +33,7 @@ TEST_CASE("Destroy an AccessPointFactoryLinux instance", "[wifi][core][ap][linux { using namespace Microsoft::Net::Wifi; - SECTION("Destroy doesn't cause a crashk with null controller factory") + SECTION("Destroy doesn't cause a crash with null controller factory") { AccessPointFactoryLinux accessPointFactory{ nullptr }; REQUIRE_NOTHROW(accessPointFactory.~AccessPointFactoryLinux()); @@ -50,28 +50,34 @@ TEST_CASE("Create() function", "[wifi][core][ap][linux]") { using namespace Microsoft::Net::Wifi; + using Microsoft::Net::Netlink::Nl80211::Nl80211Interface; + SECTION("Create() doesn't cause a crash") { + auto createArgs = std::make_unique(Nl80211Interface{}); AccessPointFactoryLinux accessPointFactory{ std::make_unique() }; - REQUIRE_NOTHROW(accessPointFactory.Create(Test::InterfaceNameDefault)); + REQUIRE_NOTHROW(accessPointFactory.Create(Test::InterfaceNameDefault, std::move(createArgs))); } SECTION("Create() with empty/null inteface doesn't cause a crash") { + auto createArgs = std::make_unique(Nl80211Interface{}); AccessPointFactoryLinux accessPointFactory{ std::make_unique() }; - REQUIRE_NOTHROW(accessPointFactory.Create({})); + REQUIRE_NOTHROW(accessPointFactory.Create({}, std::move(createArgs))); } SECTION("Create() with valid input arguments returns non-nullptr instance") { + auto createArgs = std::make_unique(Nl80211Interface{}); AccessPointFactoryLinux accessPointFactory{ std::make_unique() }; - REQUIRE(accessPointFactory.Create(Test::InterfaceNameDefault) != nullptr); + REQUIRE(accessPointFactory.Create(Test::InterfaceNameDefault, std::move(createArgs)) != nullptr); } SECTION("Create() instance reflects basic properties from base class") { + auto createArgs = std::make_unique(Nl80211Interface{}); AccessPointFactoryLinux accessPointFactory{ std::make_unique() }; - const auto accessPoint = accessPointFactory.Create(Test::InterfaceNameDefault); + const auto accessPoint = accessPointFactory.Create(Test::InterfaceNameDefault, std::move(createArgs)); REQUIRE(accessPoint->GetInterfaceName() == Test::InterfaceNameDefault); } } diff --git a/tests/unit/linux/wifi/core/TestAccessPointLinux.cxx b/tests/unit/linux/wifi/core/TestAccessPointLinux.cxx index 09680054..2f44f2dc 100644 --- a/tests/unit/linux/wifi/core/TestAccessPointLinux.cxx +++ b/tests/unit/linux/wifi/core/TestAccessPointLinux.cxx @@ -14,24 +14,26 @@ TEST_CASE("Create an AccessPointLinux instance", "[wifi][core][ap][linux]") { using namespace Microsoft::Net::Wifi; + using Microsoft::Net::Netlink::Nl80211::Nl80211Interface; + SECTION("Create doesn't cause a crash with null controller factory") { std::optional accessPoint; - REQUIRE_NOTHROW(accessPoint.emplace(Test::InterfaceNameDefault, nullptr)); + REQUIRE_NOTHROW(accessPoint.emplace(Test::InterfaceNameDefault, nullptr, Nl80211Interface{})); } SECTION("Create doesn't cause a crash") { std::optional accessPoint; - REQUIRE_NOTHROW(accessPoint.emplace(Test::InterfaceNameDefault, std::make_unique())); + REQUIRE_NOTHROW(accessPoint.emplace(Test::InterfaceNameDefault, std::make_unique(), Nl80211Interface{})); } SECTION("Create multiple for same interface doesn't cause a crash") { std::optional accessPoint1; - REQUIRE_NOTHROW(accessPoint1.emplace(Test::InterfaceNameDefault, std::make_unique())); + REQUIRE_NOTHROW(accessPoint1.emplace(Test::InterfaceNameDefault, std::make_unique(), Nl80211Interface{})); std::optional accessPoint2; - REQUIRE_NOTHROW(accessPoint2.emplace(Test::InterfaceNameDefault, std::make_unique())); + REQUIRE_NOTHROW(accessPoint2.emplace(Test::InterfaceNameDefault, std::make_unique(), Nl80211Interface{})); } } diff --git a/tests/unit/linux/wifi/helpers/AccessPointFactoryLinuxTest.cxx b/tests/unit/linux/wifi/helpers/AccessPointFactoryLinuxTest.cxx new file mode 100644 index 00000000..d8658bd9 --- /dev/null +++ b/tests/unit/linux/wifi/helpers/AccessPointFactoryLinuxTest.cxx @@ -0,0 +1,10 @@ + +#include +#include + +using namespace Microsoft::Net::Wifi::Test; + +AccessPointFactoryLinuxTest::AccessPointFactoryLinuxTest() : + AccessPointFactoryLinux{ std::make_shared() } +{ +} diff --git a/tests/unit/linux/wifi/helpers/CMakeLists.txt b/tests/unit/linux/wifi/helpers/CMakeLists.txt new file mode 100644 index 00000000..da8be958 --- /dev/null +++ b/tests/unit/linux/wifi/helpers/CMakeLists.txt @@ -0,0 +1,29 @@ + +add_library(wifi-test-helpers-linux STATIC "") + +set(WIFI_TEST_HELPERS_LINUX_PUBLIC_INCLUDE ${CMAKE_CURRENT_LIST_DIR}/include) +set(WIFI_TEST_HELPERS_LINUX_PUBLIC_INCLUDE_SUFFIX microsoft/net/wifi/test) +set(WIFI_TEST_HELPERS_LINUX_PUBLIC_INCLUDE_PREFIX ${WIFI_TEST_HELPERS_LINUX_PUBLIC_INCLUDE}/${WIFI_TEST_HELPERS_LINUX_PUBLIC_INCLUDE_SUFFIX}) + +target_sources(wifi-test-helpers-linux + PRIVATE + AccessPointFactoryLinuxTest.cxx + PUBLIC + FILE_SET HEADERS + BASE_DIRS ${WIFI_TEST_HELPERS_LINUX_PUBLIC_INCLUDE} + FILES + ${WIFI_TEST_HELPERS_LINUX_PUBLIC_INCLUDE_PREFIX}/AccessPointFactoryLinuxTest.hxx +) + +target_include_directories(wifi-test-helpers-linux + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + PUBLIC + ${WIFI_TEST_HELPERS_LINUX_PUBLIC_INCLUDE} +) + +target_link_libraries(wifi-test-helpers-linux + PUBLIC + wifi-core-linux + wifi-test-helpers +) diff --git a/tests/unit/linux/wifi/helpers/include/microsoft/net/wifi/test/AccessPointFactoryLinuxTest.hxx b/tests/unit/linux/wifi/helpers/include/microsoft/net/wifi/test/AccessPointFactoryLinuxTest.hxx new file mode 100644 index 00000000..b7c1f6b6 --- /dev/null +++ b/tests/unit/linux/wifi/helpers/include/microsoft/net/wifi/test/AccessPointFactoryLinuxTest.hxx @@ -0,0 +1,16 @@ + +#ifndef ACCESS_POINT_FACTORY_LINUX_TEST_HXX +#define ACCESS_POINT_FACTORY_LINUX_TEST_HXX + +#include + +namespace Microsoft::Net::Wifi::Test +{ +struct AccessPointFactoryLinuxTest : + public Microsoft::Net::Wifi::AccessPointFactoryLinux +{ + AccessPointFactoryLinuxTest(); +}; +} // namespace Microsoft::Net::Wifi::Test + +#endif // ACCESS_POINT_FACTORY_LINUX_TEST_HXX