Add test cases for quotes appearing in the netcat and socket parameters, for the default behavior of proxy=auto where virt-ssh-helper is used if available, and for proxy=native. Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx> --- tests/virnetsockettest.c | 62 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c index 36f6993ba5..b0e26bc2b2 100644 --- a/tests/virnetsockettest.c +++ b/tests/virnetsockettest.c @@ -678,10 +678,70 @@ mymain(void) "'''\\''n c'\\'''' $ARG -U /tmp/sock et" "'\n", }; - VIR_WARNINGS_RESET if (virTestRun("SSH test 7", testSocketSSH, &sshData7) < 0) ret = -1; + struct testSSHData sshData8 = { + .nodename = "somehost", + .netcat = "n'c", + .path = "/tmp/sock'et", + .expectOut = "-T -e none -- somehost sh -c '" + "if '''\\''n'\\''\\'\\'''\\''c'\\'''' -q 2>&1 | grep \"requires an argument\" >/dev/null 2>&1; then " + "ARG=-q0; " + "else " + "ARG=; " + "fi; " + "'''\\''n'\\''\\'\\'''\\''c'\\'''' $ARG -U /tmp/sock'et" + "'\n", + }; + if (virTestRun("SSH test 8", testSocketSSH, &sshData8) < 0) + ret = -1; + + struct testSSHData sshData9 = { + .nodename = "somehost", + .netcat = "n\"c", + .path = "/tmp/sock\"et", + .expectOut = "-T -e none -- somehost sh -c '" + "if '''\\''n\"c'\\'''' -q 2>&1 | grep \"requires an argument\" >/dev/null 2>&1; then " + "ARG=-q0; " + "else " + "ARG=; " + "fi; " + "'''\\''n\"c'\\'''' $ARG -U /tmp/sock\"et" + "'\n", + }; + if (virTestRun("SSH test 9", testSocketSSH, &sshData9) < 0) + ret = -1; + + struct testSSHData sshData10 = { + .nodename = "somehost", + .path = "/tmp/socket", + .expectOut = "-T -e none -- somehost sh -c '" + "if which virt-ssh-helper >/dev/null 2>&1; then " + "virt-ssh-helper -r 'qemu:///session'; " + "else " + "if 'nc' -q 2>&1 | grep \"requires an argument\" >/dev/null 2>&1; then " + "ARG=-q0; " + "else " + "ARG=; " + "fi; " + "'nc' $ARG -U /tmp/socket; " + "fi" + "'\n" + }; + if (virTestRun("SSH test 10", testSocketSSH, &sshData10) < 0) + ret = -1; + + struct testSSHData sshData11 = { + .nodename = "somehost", + .proxy = VIR_NET_CLIENT_PROXY_NATIVE, + .expectOut = "-T -e none -- somehost sh -c '" + "virt-ssh-helper -r 'qemu:///session'" + "'\n" + }; + if (virTestRun("SSH test 11", testSocketSSH, &sshData11) < 0) + ret = -1; + VIR_WARNINGS_RESET #endif return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; -- 2.34.1