def test_tls_client_hello(self,
                              pytestconfig,
                              tcpdump,
                              curl_binary,
                              env_vars,
                              ld_preload,
                              browser_signatures,
                              expected_signature,
                              test_urls):
        """
        Check that curl's TLS signature is identical to that of a
        real browser.

        Launches curl while sniffing its TLS traffic with tcpdump. Then
        extracts the Client Hello packet from the capture and compares its
        signature with the expected one defined in the YAML database.
        """
        curl_binary = os.path.join(
            pytestconfig.getoption("install_dir"), "bin", curl_binary
        )
        if ld_preload:
            # Injecting libcurl-impersonate with LD_PRELOAD is supported on
            # Linux only. On Mac there is DYLD_INSERT_LIBRARIES but it
            # reuqires more work to be functional.
            if not sys.platform.startswith("linux"):
                pytest.skip()

            self._set_ld_preload(env_vars, os.path.join(
                pytestconfig.getoption("install_dir"), "lib", ld_preload
            ))

        test_urls = test_urls[0:2]
        ret = self._run_curl(curl_binary,
                             env_vars=env_vars,
                             extra_args=None,
                             urls=test_urls)
        assert ret == 0

        try:
            pcap, stderr = tcpdump.communicate(timeout=5)

            # If tcpdump finished running before timeout, it's likely it failed
            # with an error.
            assert tcpdump.returncode == 0, \
                (f"tcpdump failed with error code {tcpdump.returncode}, "
                 f"stderr: {stderr}")
        except subprocess.TimeoutExpired:
            tcpdump.kill()
            pcap, stderr = tcpdump.communicate(timeout=3)

        assert len(pcap) > 0
        logging.debug(f"Captured pcap of length {len(pcap)} bytes")

        client_hellos = self._extract_client_hello(pcap)
        # A client hello message for each URL
        assert len(client_hellos) == len(test_urls)

        logging.debug(f"Found {len(client_hellos)} Client Hello messages, "
                      f"comparing to signature '{expected_signature}'")

        for client_hello in client_hellos:
            sig = TLSClientHelloSignature.from_bytes(client_hello)
            expected_sig = TLSClientHelloSignature.from_dict(
                browser_signatures[expected_signature] \
                                  ["signature"] \
                                  ["tls_client_hello"]
            )

            allow_tls_permutation=browser_signatures[expected_signature]    \
                                                    ["signature"]           \
                                                    .get("options", {})     \
                                                    .get("tls_permute_extensions", False)
            equals, msg = sig.equals(
                expected_sig,
                allow_tls_permutation=allow_tls_permutation,
                reason=True
            )
            assert equals, msg

        Check that curl's TLS signature is identical to that of a
        real browser.

        Launches curl while sniffing its TLS traffic with tcpdump. Then
        extracts the Client Hello packet from the capture and compares its
        signature with the expected one defined in the YAML database.
        
tests/test_impersonate.py