Branch data Line data Source code
1 : : // Copyright (c) 2023-present The Bitcoin Core developers
2 : : // Distributed under the MIT software license, see the accompanying
3 : : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 : :
5 : : #include <ipc/process.h>
6 : : #include <ipc/test/ipc_test.h>
7 : :
8 : : #include <test/util/common.h>
9 : : #include <test/util/setup_common.h>
10 : : #include <boost/test/unit_test.hpp>
11 : :
12 : : BOOST_FIXTURE_TEST_SUITE(ipc_tests, BasicTestingSetup)
13 [ + - + - : 7 : BOOST_AUTO_TEST_CASE(ipc_tests)
+ - + - -
+ + - + -
+ - + - +
- + - - +
+ - + - +
- + - + -
+ - - + +
- + - + -
+ - + - +
- + - - +
+ - + - +
- + - + -
+ - - + +
- ]
14 : : {
15 : 1 : IpcPipeTest();
16 : 1 : IpcSocketPairTest();
17 [ + - ]: 1 : IpcSocketTest(m_args.GetDataDirNet());
18 : 1 : }
19 : :
20 : : // Test address parsing.
21 [ + - + - : 7 : BOOST_AUTO_TEST_CASE(parse_address_test)
+ - + - -
+ + - + -
+ - + - +
- + - - +
+ - + - +
- + - + -
+ - - + +
- + - + -
+ - + - +
- + - - +
+ - + - +
- + - + -
+ - - + +
- ]
22 : : {
23 : 1 : std::unique_ptr<ipc::Process> process{ipc::MakeProcess()};
24 [ + - ]: 1 : fs::path datadir{"/var/empty/notexist"};
25 : 4 : auto check_notexist{[](const std::system_error& e) { return e.code() == std::errc::no_such_file_or_directory; }};
26 : 6 : auto check_address{[&](std::string address, std::string expect_address, std::string expect_error) {
27 [ + + ]: 5 : if (expect_error.empty()) {
28 [ + - + - : 9 : BOOST_CHECK_EXCEPTION(process->connect(datadir, "test_bitcoin", address), std::system_error, check_notexist);
- + - - -
- - + + -
+ - ]
29 : : } else {
30 [ + - + - : 6 : BOOST_CHECK_EXCEPTION(process->connect(datadir, "test_bitcoin", address), std::invalid_argument, HasReason(expect_error));
- + - - -
- - + + -
- + + - +
- ]
31 : : }
32 [ + - ]: 5 : BOOST_CHECK_EQUAL(address, expect_address);
33 : 6 : }};
34 [ + - + - : 2 : check_address("unix", "unix:/var/empty/notexist/test_bitcoin.sock", "");
+ - + - ]
35 [ + - + - : 2 : check_address("unix:", "unix:/var/empty/notexist/test_bitcoin.sock", "");
+ - + - ]
36 [ + - + - : 2 : check_address("unix:path.sock", "unix:/var/empty/notexist/path.sock", "");
+ - + - ]
37 [ + - + - ]: 2 : check_address("unix:0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.sock",
38 [ + - ]: 2 : "unix:/var/empty/notexist/0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.sock",
39 [ + - ]: 1 : "Unix address path \"/var/empty/notexist/0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.sock\" exceeded maximum socket path length");
40 [ + - + - : 2 : check_address("invalid", "invalid", "Unrecognized address 'invalid'");
+ - + - ]
41 : 1 : }
42 : :
43 : : BOOST_AUTO_TEST_SUITE_END()
|