Skip to content

Commit

Permalink
Use sudo to start mdnsd in discovery_zeroconf unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
xuzhenbao committed Jun 24, 2024
1 parent 2206733 commit ae2243a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ if (EI_TESTS)
target_compile_definitions(unit_test_discovery_zeroconf PRIVATE -DMDNSD="${DNSSD_INCLUDE_DIR}/../bin/mdnsd")


add_test(NAME run_unit_test_discovery_zeroconf COMMAND $<TARGET_FILE:unit_test_discovery_zeroconf>)
add_test(NAME run_unit_test_discovery_zeroconf COMMAND unit_test_discovery_zeroconf)
setup_target_for_coverage(unit_test_discovery_zeroconf SCAN_DIR ..)
endif ()
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ static int GetLoopBackIfIndex(void);
class DiscoveryZeroconfAnnouncerTestSuite : public ::testing::Test {
public:
static void SetUpTestCase() {
(void)system(MDNSD);
(void)system("sudo " MDNSD);
}

static void TearDownTestCase() {
(void)system("kill -s 9 `ps -aux | grep mdnsd | awk '{print $2}'`");
(void)system("sudo kill -s 9 `ps -aux | grep mdnsd | awk '{print $2}'`");
}
DiscoveryZeroconfAnnouncerTestSuite() {
auto* props = celix_properties_create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ static int GetTestNetInterfaceIndex() {
class DiscoveryZeroconfWatcherTestSuite : public ::testing::Test {
public:
static void SetUpTestCase() {
(void)system(MDNSD);
(void)system("sudo " MDNSD);
}

static void TearDownTestCase() {
(void)system("kill -s 9 `ps -aux | grep mdnsd | awk '{print $2}'`");
(void)system("sudo kill -s 9 `ps -aux | grep mdnsd | awk '{print $2}'`");
}

DiscoveryZeroconfWatcherTestSuite() {
Expand Down Expand Up @@ -341,15 +341,15 @@ class DiscoveryZeroconfWatcherTestSuite : public ::testing::Test {
class DiscoveryZeroconfWatcherWatchServiceTestSuite : public DiscoveryZeroconfWatcherTestSuite {
public:
static void SetUpTestCase() {
(void)system(MDNSD);
(void)system("sudo " MDNSD);
sleep(3);//wait for mdnsd start
testServiceRef = RegisterTestService(GetTestNetInterfaceIndex());
EXPECT_TRUE(testServiceRef != nullptr);
}

static void TearDownTestCase() {
DNSServiceRefDeallocate(testServiceRef);
(void)system("kill -s 9 `ps -aux | grep mdnsd | awk '{print $2}'`");
(void)system("sudo kill -s 9 `ps -aux | grep mdnsd | awk '{print $2}'`");
}

DiscoveryZeroconfWatcherWatchServiceTestSuite() {
Expand Down

0 comments on commit ae2243a

Please sign in to comment.