defmodule Sersock.Test do use ExUnit.Case alias Sersock.TestHelper @reps 30 test "text mode test" do tty0 = TestHelper.tty0() tty1 = TestHelper.tty1() {:ok, pid0} = Sersock.start_link([portname: tty0, port: 4000]) {:ok, pid1} = Sersock.start_link([portname: tty1, port: 4001]) {:ok, sock0} = :gen_tcp.connect({127,0,0,1}, 4000, [:binary, packet: :raw, active: :false], 400) {:ok, sock1} = :gen_tcp.connect({127,0,0,1}, 4001, [:binary, packet: :raw, 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