From 71c78ba5a6d0f713268f831031153a69f49dd7f3 Mon Sep 17 00:00:00 2001 From: frazze-jobb Date: Tue, 1 Oct 2024 09:27:43 +0200 Subject: [PATCH] ssh: update ssh tests --- lib/kernel/test/interactive_shell_SUITE.erl | 19 ++------------ lib/ssh/src/ssh.app.src | 2 +- lib/ssh/src/ssh_cli.erl | 10 ++++--- lib/ssh/test/ssh_connection_SUITE.erl | 29 ++++++++++----------- 4 files changed, 23 insertions(+), 37 deletions(-) diff --git a/lib/kernel/test/interactive_shell_SUITE.erl b/lib/kernel/test/interactive_shell_SUITE.erl index ab6d9f779549..ff8135a9f791 100644 --- a/lib/kernel/test/interactive_shell_SUITE.erl +++ b/lib/kernel/test/interactive_shell_SUITE.erl @@ -116,36 +116,21 @@ groups() -> {ssh, [], [{group,ssh_unicode}, {group,ssh_latin1}, - %test_invalid_keymap, Cant see if the keymap is invalid from ssh_client - test_valid_keymap, - %shell_suspend, - %shell_full_queue, - %external_editor, - %external_editor_visual, shell_ignore_pager_commands ]}, {ssh_unicode,[], - [{group,ssh_tests} - %shell_invalid_unicode, % needs another method to send invalid unicode through ssh_client - %external_editor_unicode - %% unicode wrapping does not work right yet - %% shell_unicode_wrap, - %% shell_delete_unicode_wrap, - %% shell_delete_unicode_not_at_cursor_wrap, - %% shell_update_window_unicode_wrap - ]}, + [{group,ssh_tests}]}, {ssh_latin1,[],[{group,ssh_tests}]}, {ssh_tests, [], [shell_navigation, shell_multiline_navigation, shell_multiline_prompt_ssh, - shell_xnfix, shell_delete, %shell_format, + shell_xnfix, shell_delete, shell_transpose, shell_search, shell_insert, shell_update_window, shell_small_window_multiline_navigation, shell_huge_input, shell_support_ansi_input, shell_receive_standard_out, - %shell_standard_error_nlcr, shell_expand_location_above, shell_expand_location_below, shell_clear]}, diff --git a/lib/ssh/src/ssh.app.src b/lib/ssh/src/ssh.app.src index eb31e69db89e..4eb469771ef9 100644 --- a/lib/ssh/src/ssh.app.src +++ b/lib/ssh/src/ssh.app.src @@ -60,7 +60,7 @@ {runtime_dependencies, [ "crypto-5.0", "erts-14.0", - "kernel-9.0", + "kernel-@OTP-19226@", "public_key-1.6.1", "stdlib-6.0","stdlib-5.0", "runtime_tools-1.15.1" diff --git a/lib/ssh/src/ssh_cli.erl b/lib/ssh/src/ssh_cli.erl index 2216cb9ec8e3..3af18e287973 100644 --- a/lib/ssh/src/ssh_cli.erl +++ b/lib/ssh/src/ssh_cli.erl @@ -67,9 +67,11 @@ %% Description: Initiates the CLI %%-------------------------------------------------------------------- init([Shell, Exec]) -> - {ok, #state{shell = Shell, exec = Exec}}; + TTY = prim_tty:init_ssh(#{input => false}, {80, 24}, utf8), + {ok, #state{shell = Shell, exec = Exec, tty = TTY}}; init([Shell]) -> - {ok, #state{shell = Shell}}. + TTY = prim_tty:init_ssh(#{input => false}, {80, 24}, utf8), + {ok, #state{shell = Shell, tty = TTY}}. %%-------------------------------------------------------------------- %% Function: handle_ssh_msg(Args) -> {ok, State} | {stop, ChannelId, State} @@ -95,7 +97,7 @@ handle_ssh_msg({ssh_cm, ConnectionHandler, pixel_width = PixWidth, pixel_height = PixHeight, modes = Modes}}, - TTY = prim_tty:init_ssh(#{input => false, output => false}, {not_zero(Width, 80), not_zero(Height, 24)}, State#state.encoding), + TTY = prim_tty:init_ssh(#{input => false}, {not_zero(Width, 80), not_zero(Height, 24)}, utf8), set_echo(State), ssh_connection:reply_request(ConnectionHandler, WantReply, success, ChannelId), @@ -432,7 +434,7 @@ replace_escapes(Data) -> %%% We are *not* really unicode aware yet, we just filter away characters %%% beyond the latin1 range. We however handle the unicode binaries... %%% --spec io_request(term(), prim_tty:state(), term()) -> {list(), prim_tty:state()}. +%%-spec io_request(term(), prim_tty:state(), state()) -> {list(), prim_tty:state()}. io_request({requests,Rs}, TTY, State) -> io_requests(Rs, TTY, State, []); io_request(redraw_prompt, TTY, _State) -> diff --git a/lib/ssh/test/ssh_connection_SUITE.erl b/lib/ssh/test/ssh_connection_SUITE.erl index 11e6f95964c4..197b5cbc8517 100644 --- a/lib/ssh/test/ssh_connection_SUITE.erl +++ b/lib/ssh/test/ssh_connection_SUITE.erl @@ -814,12 +814,11 @@ new_shell_xterm_term(Config) when is_list(Config) -> exp_output => [<<"Enter command\r\n">>, <<"1> ">>, - <<"one_atom_please.\r\n\e[1022D\e[1B">>, + <<"one_atom_please.\r\n">>, <<"{simple_eval,one_atom_please}\r\n">>, <<"2> ">>, - <<"\e[3D\e[J">>, <<"\e[;1;4msearch:\e[0m ">>, - <<"\r\n one_atom_please.">>]}, + <<"\b\b\b\b\b\b\b\b\e[J\e[;1;4msearch:\e[0m \r\n one_atom_please.\e[A\b\b\b\b\b\b\b\b\b\b">>]}, Config). new_shell_helper(#{term := Term, cmds := Cmds, @@ -994,7 +993,7 @@ start_shell_exec_fun(Config) -> io:format("echo ~s\n", [Cmd]) end) end, - "testing", <<"echo testing\n">>, 0, + "testing", <<"echo testing\r\n">>, 0, Config). start_shell_exec_fun2(Config) -> @@ -1003,7 +1002,7 @@ start_shell_exec_fun2(Config) -> io:format("echo ~s ~s\n",[User,Cmd]) end) end, - "testing", <<"echo foo testing\n">>, 0, + "testing", <<"echo foo testing\r\n">>, 0, Config). start_shell_exec_fun3(Config) -> @@ -1012,7 +1011,7 @@ start_shell_exec_fun3(Config) -> io:format("echo ~s ~s\n",[User,Cmd]) end) end, - "testing", <<"echo foo testing\n">>, 0, + "testing", <<"echo foo testing\r\n">>, 0, Config). start_shell_exec_direct_fun(Config) -> @@ -1077,11 +1076,11 @@ start_exec_direct_fun1_read_write(Config) -> {ok, Ch} = ssh_connection:session_channel(C, infinity), success = ssh_connection:exec(C, Ch, "> ", infinity), - ssh_test_lib:receive_exec_result_or_fail({ssh_cm,C,{data,Ch,0,<<"Tiny read/write test\n">>}}), + ssh_test_lib:receive_exec_result_or_fail({ssh_cm,C,{data,Ch,0,<<"Tiny read/write test\r\n">>}}), ssh_test_lib:receive_exec_result_or_fail({ssh_cm,C,{data,Ch,0,<<"1> ">>}}), ok = ssh_connection:send(C, Ch, "hej.\n", 5000), - ssh_test_lib:receive_exec_result_or_fail({ssh_cm,C,{data,Ch,0,<<"{simple_eval,hej}\n">>}}), + ssh_test_lib:receive_exec_result_or_fail({ssh_cm,C,{data,Ch,0,<<"{simple_eval,hej}\r\n">>}}), ssh_test_lib:receive_exec_result_or_fail({ssh_cm,C,{data,Ch,0,<<"2> ">>}}), ok = ssh_connection:send(C, Ch, "quit.\n", 5000), @@ -1125,18 +1124,18 @@ start_exec_direct_fun1_read_write_advanced(Config) -> {ok, Ch} = ssh_connection:session_channel(C, infinity), success = ssh_connection:exec(C, Ch, "> ", infinity), - ssh_test_lib:receive_exec_result_or_fail({ssh_cm,C,{data,Ch,0,<<"Tiny read/write test\n">>}}), + ssh_test_lib:receive_exec_result_or_fail({ssh_cm,C,{data,Ch,0,<<"Tiny read/write test\r\n">>}}), ssh_test_lib:receive_exec_result_or_fail({ssh_cm,C,{data,Ch,0,<<"1> ">>}}), ok = ssh_connection:send(C, Ch, "hej.\n", 5000), - ssh_test_lib:receive_exec_result_or_fail({ssh_cm,C,{data,Ch,0,<<"{simple_eval,hej}\n">>}}), + ssh_test_lib:receive_exec_result_or_fail({ssh_cm,C,{data,Ch,0,<<"{simple_eval,hej}\r\n">>}}), ssh_test_lib:receive_exec_result_or_fail({ssh_cm,C,{data,Ch,0,<<"2> ">>}}), ok = ssh_connection:send(C, Ch, "'Hi ", 5000), ok = ssh_connection:send(C, Ch, "there", 5000), ok = ssh_connection:send(C, Ch, "'", 5000), ok = ssh_connection:send(C, Ch, ".\n", 5000), - ssh_test_lib:receive_exec_result_or_fail({ssh_cm,C,{data,Ch,0,<<"{simple_eval,'Hi there'}\n">>}}), + ssh_test_lib:receive_exec_result_or_fail({ssh_cm,C,{data,Ch,0,<<"{simple_eval,'Hi there'}\r\n">>}}), ssh_test_lib:receive_exec_result_or_fail({ssh_cm,C,{data,Ch,0,<<"3> ">>}}), ok = ssh_connection:send(C, Ch, "bad_input.\n", 5000), ssh_test_lib:receive_exec_result_or_fail({ssh_cm,C,{data,Ch,1,<<"**Error** {bad_input,3}">>}}), @@ -1251,7 +1250,7 @@ start_shell_sock_exec_fun(Config) when is_list(Config) -> "testing", infinity), receive - {ssh_cm, ConnectionRef, {data, _ChannelId, 0, <<"echo testing\n">>}} -> + {ssh_cm, ConnectionRef, {data, _ChannelId, 0, <<"echo testing\r\n">>}} -> ok after 5000 -> ct:fail("Exec Timeout") @@ -1296,7 +1295,7 @@ start_shell_sock_daemon_exec(Config) -> "testing", infinity), receive - {ssh_cm, ConnectionRef, {data, _ChannelId, 0, <<"echo testing\n">>}} -> + {ssh_cm, ConnectionRef, {data, _ChannelId, 0, <<"echo testing\r\n">>}} -> ok after 5000 -> ct:fail("Exec Timeout") @@ -1356,7 +1355,7 @@ start_shell_sock_daemon_exec_multi(Config) -> success = ssh_connection:exec(ConnectionRef, ChannelId0, "testing", infinity), ct:log("~p:~p: exec on connection ~p", [?MODULE,?LINE,ConnectionRef]), receive - {ssh_cm, ConnectionRef, {data, _ChannelId, 0, <<"echo testing\n">>}} -> + {ssh_cm, ConnectionRef, {data, _ChannelId, 0, <<"echo testing\r\n">>}} -> Parent ! {answer_received,self()}, ct:log("~p:~p: received result on connection ~p", [?MODULE,?LINE,ConnectionRef]) after 5000 -> @@ -1565,7 +1564,7 @@ stop_listener(Config) when is_list(Config) -> "testing", infinity), receive {ssh_cm, ConnectionRef0, - {data, ChannelId0, 0, <<"echo testing\n">>}} -> + {data, ChannelId0, 0, <<"echo testing\r\n">>}} -> ok after 5000 -> ct:fail("Exec Timeout")