Current section
Files
Jump to
Current section
Files
test/sersock_test.exs
defmodule Sersock.Test do
use ExUnit.Case
alias Sersock.TTY
@reps 30
test "text mode test" do
tty0 = TTY.tty0
tty1 = TTY.tty1
{:ok, pid0} = Sersock.start_link([device: tty0, port: 4000])
{:ok, pid1} = Sersock.start_link([device: tty1, port: 4001])
{:ok, sock0} = :gen_tcp.connect({127,0,0,1}, 4000, [:binary, packet: :line, active: :false], 400)
{:ok, sock1} = :gen_tcp.connect({127,0,0,1}, 4001, [:binary, packet: :line, active: :false], 400)
Enum.each 1..@reps, fn _x ->
:ok = :gen_tcp.send(sock0, "echo0\n");
{:ok, "echo0\n"} = :gen_tcp.recv(sock1, 0, 400)
end
Sersock.stop(pid0)
Sersock.stop(pid1)
end
end