#include "net/base/address_tracker_linux.h"
#include <linux/if.h>
#include <linux/rtnetlink.h>
#include <sched.h>
#include <memory>
#include <unordered_set>
#include <vector>
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/bind.h"
#include "base/test/multiprocess_test.h"
#include "base/test/spin_wait.h"
#include "base/test/task_environment.h"
#include "base/test/test_simple_task_runner.h"
#include "base/threading/simple_thread.h"
#include "build/build_config.h"
#include "net/base/address_map_cache_linux.h"
#include "net/base/address_map_linux.h"
#include "net/base/address_tracker_linux_test_util.h"
#include "net/base/ip_address.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/multiprocess_func_list.h"
#if BUILDFLAG(IS_ANDROID)
#include "base/android/build_info.h"
#endif
#ifndef IFA_F_HOMEADDRESS
#define IFA_F_HOMEADDRESS …
#endif
AddressTrackerLinux;
namespace net::test {
namespace {
const int kTestInterfaceEth = …;
const int kTestInterfaceWifi = …;
const int kTestInterfaceTun = …;
const int kTestInterfaceAp = …;
const char kIgnoredInterfaceName[] = …;
char* TestGetInterfaceName(int interface_index, char* buf) { … }
}
class AddressTrackerLinuxTest : public testing::Test { … };
namespace {
const unsigned char kAddress0[] = …;
const unsigned char kAddress1[] = …;
const unsigned char kAddress2[] = …;
const unsigned char kAddress3[] = …;
TEST_F(AddressTrackerLinuxTest, NewAddress) { … }
TEST_F(AddressTrackerLinuxTest, NewAddressChange) { … }
TEST_F(AddressTrackerLinuxTest, NewAddressDuplicate) { … }
TEST_F(AddressTrackerLinuxTest, DeleteAddress) { … }
TEST_F(AddressTrackerLinuxTest, DeprecatedLifetime) { … }
TEST_F(AddressTrackerLinuxTest, IgnoredMessage) { … }
TEST_F(AddressTrackerLinuxTest, AddInterface) { … }
TEST_F(AddressTrackerLinuxTest, RemoveInterface) { … }
TEST_F(AddressTrackerLinuxTest, IgnoreInterface) { … }
TEST_F(AddressTrackerLinuxTest, IgnoreInterface_NonIgnoredInterface) { … }
TEST_F(AddressTrackerLinuxTest, TunnelInterface) { … }
TEST_F(AddressTrackerLinuxTest, GetInterfaceName) { … }
TEST_F(AddressTrackerLinuxTest, NonTrackingMode) { … }
TEST_F(AddressTrackerLinuxTest, NonTrackingModeInit) { … }
class GetCurrentConnectionTypeRunner
: public base::DelegateSimpleThread::Delegate { … };
TEST_F(AddressTrackerLinuxTest, BroadcastInit) { … }
TEST_F(AddressTrackerLinuxTest, TunnelInterfaceName) { … }
}
}
namespace net::internal {
TEST(AddressTrackerLinuxNetlinkTest, TestInitializeTwoTrackers) { … }
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#if defined(CLONE_NEWUSER) && defined(CLONE_NEWPID)
namespace {
const char* const kSwitchParentWriteFd = …;
const char* const kSwitchReadFd = …;
enum IPCMessage { … };
base::File GetSwitchValueFile(const base::CommandLine* command_line,
std::string_view name) { … }
}
TEST(AddressTrackerLinuxNetlinkTest, TestInitializeTwoTrackersInPidNamespaces) { … }
MULTIPROCESS_TEST_MAIN(ChildProcessInitializeTrackerForTesting) { … }
#endif
#endif
}