commit c-ares for openSUSE:Factory
Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package c-ares for openSUSE:Factory checked in at 2025-01-06 16:04:31 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/c-ares (Old) and /work/SRC/openSUSE:Factory/.c-ares.new.1881 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "c-ares" Mon Jan 6 16:04:31 2025 rev:26 rq:1234807 version:1.34.4 Changes: -------- --- /work/SRC/openSUSE:Factory/c-ares/c-ares.changes 2025-01-02 19:19:25.799534745 +0100 +++ /work/SRC/openSUSE:Factory/.c-ares.new.1881/c-ares.changes 2025-01-06 16:04:34.748181385 +0100 @@ -1,0 +2,6 @@ +Fri Jan 3 22:36:24 UTC 2025 - Adam Majer <adam.majer@suse.de> + +- skip-test.patch replaced with upstream unit test fix + a531524a3d085fcd9a5e25d5f6cbdb953082c2b9.patch + +------------------------------------------------------------------- Old: ---- skip-test.patch New: ---- a531524a3d085fcd9a5e25d5f6cbdb953082c2b9.patch BETA DEBUG BEGIN: Old: - skip-test.patch replaced with upstream unit test fix a531524a3d085fcd9a5e25d5f6cbdb953082c2b9.patch BETA DEBUG END: BETA DEBUG BEGIN: New:- skip-test.patch replaced with upstream unit test fix a531524a3d085fcd9a5e25d5f6cbdb953082c2b9.patch BETA DEBUG END: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ c-ares.spec ++++++ --- /var/tmp/diff_new_pack.L3nHRR/_old 2025-01-06 16:04:35.924229928 +0100 +++ /var/tmp/diff_new_pack.L3nHRR/_new 2025-01-06 16:04:35.924229928 +0100 @@ -36,8 +36,7 @@ Source3: c-ares.keyring Source4: baselibs.conf Source5: series -# forwarded: https://github.com/c-ares/c-ares/issues/953 -Patch1: skip-test.patch +Patch1: a531524a3d085fcd9a5e25d5f6cbdb953082c2b9.patch BuildRequires: c++_compiler BuildRequires: cmake # Needed for getservbyport_r function to work properly. ++++++ _scmsync.obsinfo ++++++ --- /var/tmp/diff_new_pack.L3nHRR/_old 2025-01-06 16:04:35.964231580 +0100 +++ /var/tmp/diff_new_pack.L3nHRR/_new 2025-01-06 16:04:35.968231745 +0100 @@ -1,5 +1,5 @@ -mtime: 1735561922 -commit: 966d0cfb8f0a94ec018ac57cd9bb2201406bb22f1427e9b358a023b44b451702 +mtime: 1735943824 +commit: 642897f8dd9ec9c30bf8b91bfd64940334473fc5dc81a41f82074bc1ea11d8db url: https://src.opensuse.org/adamm/c-ares.git -revision: 966d0cfb8f0a94ec018ac57cd9bb2201406bb22f1427e9b358a023b44b451702 +revision: 642897f8dd9ec9c30bf8b91bfd64940334473fc5dc81a41f82074bc1ea11d8db ++++++ a531524a3d085fcd9a5e25d5f6cbdb953082c2b9.patch ++++++ commit a531524a3d085fcd9a5e25d5f6cbdb953082c2b9 Author: Brad House <brad@brad-house.com> Date: Fri Jan 3 12:55:54 2025 -0500 tests: Convert some live tests to Mock tests (#954) In Issue #953 `GetTCPSock` and `VerifySocketFunctionCallback` tests might rely on the fact that `connect()` doesn't return an immediate failure. If `connect()` returned `EWOULDBLOCK`/`EAGAIN` the test would succeed, but on systems that check on the call for available routes or listening servers on localhost the `connect()` function would return an immediate failure. These functions were not actually tagged with a `Live` prefix so they would run even callers exclude Live tests. These are testing functions that shouldn't be limited to live scenarios so we need to move them to the Mock frameworks and test appropriately. Fixes #953 Signed-off-by: Brad House (@bradh352) diff --git a/test/ares-test-live.cc b/test/ares-test-live.cc index e23dadfe..557c485e 100644 --- a/test/ares-test-live.cc +++ b/test/ares-test-live.cc @@ -669,115 +669,7 @@ VIRT_NONVIRT_TEST_F(DefaultChannelTest, LiveGetNameInfoAllocFail) { EXPECT_EQ(ARES_ENOMEM, result.status_); } -VIRT_NONVIRT_TEST_F(DefaultChannelTest, GetSock) { - ares_socket_t socks[3] = {ARES_SOCKET_BAD, ARES_SOCKET_BAD, ARES_SOCKET_BAD}; - int bitmask = ares_getsock(channel_, socks, 3); - EXPECT_EQ(0, bitmask); - bitmask = ares_getsock(channel_, nullptr, 0); - EXPECT_EQ(0, bitmask); - - // Ask again with a pending query. - HostResult result; - ares_gethostbyname(channel_, "www.google.com.", AF_INET, HostCallback, &result); - bitmask = ares_getsock(channel_, socks, 3); - EXPECT_NE(0, bitmask); - - size_t sock_cnt = 0; - for (size_t i=0; i<3; i++) { - if (ARES_GETSOCK_READABLE(bitmask, i) || ARES_GETSOCK_WRITABLE(bitmask, i)) { - EXPECT_NE(ARES_SOCKET_BAD, socks[i]); - if (socks[i] != ARES_SOCKET_BAD) - sock_cnt++; - } - } - EXPECT_NE((size_t)0, sock_cnt); - - bitmask = ares_getsock(channel_, nullptr, 0); - EXPECT_EQ(0, bitmask); - - Process(); -} - -TEST_F(LibraryTest, GetTCPSock) { - ares_channel_t *channel; - struct ares_options opts; - memset(&opts, 0, sizeof(opts)); - opts.tcp_port = 53; - opts.flags = ARES_FLAG_USEVC; - int optmask = ARES_OPT_TCP_PORT | ARES_OPT_FLAGS; - EXPECT_EQ(ARES_SUCCESS, ares_init_options(&channel, &opts, optmask)); - EXPECT_NE(nullptr, channel); - - ares_socket_t socks[3] = {ARES_SOCKET_BAD, ARES_SOCKET_BAD, ARES_SOCKET_BAD}; - int bitmask = ares_getsock(channel, socks, 3); - EXPECT_EQ(0, bitmask); - bitmask = ares_getsock(channel, nullptr, 0); - EXPECT_EQ(0, bitmask); - - // Ask again with a pending query. - HostResult result; - ares_gethostbyname(channel, "www.google.com.", AF_INET, HostCallback, &result); - bitmask = ares_getsock(channel, socks, 3); - EXPECT_NE(0, bitmask); - - size_t sock_cnt = 0; - for (size_t i=0; i<3; i++) { - if (ARES_GETSOCK_READABLE(bitmask, i) || ARES_GETSOCK_WRITABLE(bitmask, i)) { - EXPECT_NE(ARES_SOCKET_BAD, socks[i]); - if (socks[i] != ARES_SOCKET_BAD) - sock_cnt++; - } - } - EXPECT_NE((size_t)0, sock_cnt); - - bitmask = ares_getsock(channel, nullptr, 0); - EXPECT_EQ(0, bitmask); - - ProcessWork(channel, NoExtraFDs, nullptr); - ares_destroy(channel); -} - -TEST_F(DefaultChannelTest, VerifySocketFunctionCallback) { - VirtualizeIO vio(channel_); - - auto my_functions = VirtualizeIO::default_functions; - size_t count = 0; - - my_functions.asocket = [](int af, int type, int protocol, void * p) -> ares_socket_t { - EXPECT_NE(nullptr, p); - (*reinterpret_cast<size_t *>(p))++; - return ::socket(af, type, protocol); - }; - - ares_set_socket_functions(channel_, &my_functions, &count); - - { - count = 0; - HostResult result; - ares_gethostbyname(channel_, "www.google.com.", AF_INET, HostCallback, &result); - Process(); - - EXPECT_TRUE(result.done_); - EXPECT_NE((size_t)0, count); - } - - { - count = 0; - ares_channel_t *copy; - EXPECT_EQ(ARES_SUCCESS, ares_dup(©, channel_)); - - HostResult result; - ares_gethostbyname(copy, "www.google.com.", AF_INET, HostCallback, &result); - - ProcessWork(copy, NoExtraFDs, nullptr); - - EXPECT_TRUE(result.done_); - ares_destroy(copy); - EXPECT_NE((size_t)0, count); - } - -} TEST_F(DefaultChannelTest, LiveSetServers) { struct ares_addr_node server1; diff --git a/test/ares-test-mock.cc b/test/ares-test-mock.cc index 8c74c05f..ebae7140 100644 --- a/test/ares-test-mock.cc +++ b/test/ares-test-mock.cc @@ -1662,6 +1662,135 @@ TEST_P(MockChannelTest, GetHostByAddrDestroy) { EXPECT_EQ(0, result.timeouts_); } +TEST_P(MockUDPChannelTest, GetSock) { + DNSPacket reply; + reply.set_response().set_aa() + .add_question(new DNSQuestion("www.google.com", T_A)) + .add_answer(new DNSARR("www.google.com", 0x0100, {0x01, 0x02, 0x03, 0x04})); + ON_CALL(server_, OnRequest("www.google.com", T_A)) + .WillByDefault(SetReply(&server_, &reply)); + + ares_socket_t socks[3] = {ARES_SOCKET_BAD, ARES_SOCKET_BAD, ARES_SOCKET_BAD}; + int bitmask; + + bitmask = ares_getsock(channel_, socks, 3); + EXPECT_EQ(0, bitmask); + bitmask = ares_getsock(channel_, nullptr, 0); + EXPECT_EQ(0, bitmask); + + // Ask again with a pending query. + HostResult result; + ares_gethostbyname(channel_, "www.google.com.", AF_INET, HostCallback, &result); + bitmask = ares_getsock(channel_, socks, 3); + EXPECT_NE(0, bitmask); + + size_t sock_cnt = 0; + for (size_t i=0; i<3; i++) { + if (ARES_GETSOCK_READABLE(bitmask, i) || ARES_GETSOCK_WRITABLE(bitmask, i)) { + EXPECT_NE(ARES_SOCKET_BAD, socks[i]); + if (socks[i] != ARES_SOCKET_BAD) + sock_cnt++; + } + } + EXPECT_NE((size_t)0, sock_cnt); + + Process(); + + bitmask = ares_getsock(channel_, nullptr, 0); + EXPECT_EQ(0, bitmask); +} + +TEST_P(MockTCPChannelTest, GetSock) { + DNSPacket reply; + reply.set_response().set_aa() + .add_question(new DNSQuestion("www.google.com", T_A)) + .add_answer(new DNSARR("www.google.com", 0x0100, {0x01, 0x02, 0x03, 0x04})); + ON_CALL(server_, OnRequest("www.google.com", T_A)) + .WillByDefault(SetReply(&server_, &reply)); + + ares_socket_t socks[3] = {ARES_SOCKET_BAD, ARES_SOCKET_BAD, ARES_SOCKET_BAD}; + int bitmask; + + bitmask = ares_getsock(channel_, socks, 3); + EXPECT_EQ(0, bitmask); + bitmask = ares_getsock(channel_, nullptr, 0); + EXPECT_EQ(0, bitmask); + + // Ask again with a pending query. + HostResult result; + ares_gethostbyname(channel_, "www.google.com.", AF_INET, HostCallback, &result); + bitmask = ares_getsock(channel_, socks, 3); + EXPECT_NE(0, bitmask); + + size_t sock_cnt = 0; + for (size_t i=0; i<3; i++) { + if (ARES_GETSOCK_READABLE(bitmask, i) || ARES_GETSOCK_WRITABLE(bitmask, i)) { + EXPECT_NE(ARES_SOCKET_BAD, socks[i]); + if (socks[i] != ARES_SOCKET_BAD) + sock_cnt++; + } + } + EXPECT_NE((size_t)0, sock_cnt); + + Process(); + + bitmask = ares_getsock(channel_, nullptr, 0); + EXPECT_EQ(0, bitmask); +} + + +TEST_P(MockChannelTest, VerifySocketFunctionCallback) { + ares_socket_functions sock_funcs; + memset(&sock_funcs, 0, sizeof(sock_funcs)); + + DNSPacket reply; + reply.set_response().set_aa() + .add_question(new DNSQuestion("www.google.com", T_A)) + .add_answer(new DNSARR("www.google.com", 0x0100, {0x01, 0x02, 0x03, 0x04})); + ON_CALL(server_, OnRequest("www.google.com", T_A)) + .WillByDefault(SetReply(&server_, &reply)); + + size_t count = 0; + + sock_funcs.asocket = [](int af, int type, int protocol, void * p) -> ares_socket_t { + EXPECT_NE(nullptr, p); + (*reinterpret_cast<size_t *>(p))++; + return ::socket(af, type, protocol); + }; + + ares_set_socket_functions(channel_, &sock_funcs, &count); + + { + count = 0; + HostResult result; + ares_gethostbyname(channel_, "www.google.com.", AF_INET, HostCallback, &result); + Process(); + + EXPECT_TRUE(result.done_); + EXPECT_EQ(ARES_SUCCESS, result.status_); + EXPECT_EQ(0, result.timeouts_); + EXPECT_NE((size_t)0, count); + } + + { + count = 0; + ares_channel_t *copy; + EXPECT_EQ(ARES_SUCCESS, ares_dup(©, channel_)); + + HostResult result; + ares_gethostbyname(copy, "www.google.com.", AF_INET, HostCallback, &result); + + ProcessAltChannel(copy); + + EXPECT_TRUE(result.done_); + ares_destroy(copy); + EXPECT_NE((size_t)0, count); + EXPECT_EQ(ARES_SUCCESS, result.status_); + EXPECT_EQ(0, result.timeouts_); + } + +} + static const unsigned char * fetch_server_cookie(const ares_dns_record_t *dnsrec, size_t *len) { diff --git a/test/ares-test.cc b/test/ares-test.cc index 99ab0a00..f383ecbe 100644 --- a/test/ares-test.cc +++ b/test/ares-test.cc @@ -888,14 +888,18 @@ void MockChannelOptsTest::ProcessFD(ares_socket_t fd) { } } -void MockChannelOptsTest::Process(unsigned int cancel_ms) { +void MockChannelOptsTest::ProcessAltChannel(ares_channel_t *chan, unsigned int cancel_ms) { using namespace std::placeholders; - ProcessWork(channel_, + ProcessWork(chan, std::bind(&MockChannelOptsTest::fds, this), std::bind(&MockChannelOptsTest::ProcessFD, this, _1), cancel_ms); } +void MockChannelOptsTest::Process(unsigned int cancel_ms) { + ProcessAltChannel(channel_, cancel_ms); +} + void MockEventThreadOptsTest::Process(unsigned int cancel_ms) { std::set<ares_socket_t> fds; diff --git a/test/ares-test.h b/test/ares-test.h index 61275921..77baa902 100644 --- a/test/ares-test.h +++ b/test/ares-test.h @@ -328,6 +328,7 @@ public: // Process all pending work on ares-owned and mock-server-owned file // descriptors. + void ProcessAltChannel(ares_channel_t *chan, unsigned int cancel_ms = 0); void Process(unsigned int cancel_ms = 0); protected: ++++++ build.specials.obscpio ++++++ diff: old/*: No such file or directory diff: new/*: No such file or directory
participants (1)
-
Source-Sync