1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
%% Modify your ts.unix.config or ts.win32.config file before running these tests
-module(ct_telnet_basic_SUITE).
-compile(export_all).
-include_lib("common_test/include/ct.hrl").
%%--------------------------------------------------------------------
%% TEST SERVER CALLBACK FUNCTIONS
%%--------------------------------------------------------------------
init_per_suite(Config) ->
Config.
end_per_suite(_Config) ->
ok.
suite() -> [{require,telnet_temp,{unix,[telnet]}}].
all() ->
[start_stop, send_and_get, expect, already_closed,
cmd, sendf, close_wrong_type].
groups() ->
[].
init_per_group(_GroupName, Config) ->
Config.
end_per_group(_GroupName, Config) ->
Config.
start_stop(_Config) ->
{ok, Handle} = ct_telnet:open(telnet_temp),
ok = ct_telnet:close(Handle),
ok.
send_and_get(_) ->
{ok, Handle} = ct_telnet:open(telnet_temp),
ok = ct_telnet:send(Handle, "ayt"),
{ok, _Data} = ct_telnet:get_data(Handle),
ok = ct_telnet:close(Handle),
ok.
expect(_) ->
{ok, Handle} = ct_telnet:open(telnet_temp),
ok = ct_telnet:send(Handle, "echo ayt"),
ok = case ct_telnet:expect(Handle, ["ayt"]) of
{ok, _} ->
ok;
{error, {prompt, _}} ->
ok
end,
ok = ct_telnet:close(Handle),
ok.
already_closed(_) ->
{ok, Handle} = ct_telnet:open(telnet_temp),
ok = ct_telnet:close(Handle),
{error, already_closed} = ct_telnet:close(Handle),
ok.
cmd(_) ->
{ok, Handle} = ct_telnet:open(telnet_temp),
{ok, _} = ct_telnet:cmd(Handle, "display"),
{ok, _} = ct_telnet:cmdf(Handle, "~s ~s", ["set", "bsasdel"]),
ok = ct_telnet:close(Handle),
ok.
sendf(_) ->
{ok, Handle} = ct_telnet:open(telnet_temp),
ok = ct_telnet:sendf(Handle, "~s", ["ayt"]),
ok = ct_telnet:close(Handle),
ok.
close_wrong_type(_) ->
{error, _} = ct_telnet:close(whatever),
ok.
|