Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
update bee
Browse files Browse the repository at this point in the history
  • Loading branch information
actboy168 committed Apr 22, 2024
1 parent 2b8a37a commit 7e09c1e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
11 changes: 3 additions & 8 deletions test/event.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,11 @@ local function assertEpollWait(epfd, values)
lt.assertEquals(actual, expected)
end

local function get_port(fd)
local _, port = fd:info "socket"
return port
end

local m = lt.test "event"

function m.test_connect()
local sfd <close> = helper.SimpleServer("tcp", "127.0.0.1", 0)
local cfd <close> = helper.SimpleClient("tcp", "127.0.0.1", get_port(sfd))
local cfd <close> = helper.SimpleClient("tcp", sfd:info "socket")
local sep <const> = epoll.create(16)
local cep <const> = epoll.create(16)
sep:event_add(sfd:handle(), epoll.EPOLLIN | epoll.EPOLLOUT, sfd)
Expand All @@ -105,7 +100,7 @@ end

function m.test_send_recv()
local sfd <close> = helper.SimpleServer("tcp", "127.0.0.1", 0)
local cfd <close> = helper.SimpleClient("tcp", "127.0.0.1", get_port(sfd))
local cfd <close> = helper.SimpleClient("tcp", sfd:info "socket")
local sep <const> = epoll.create(16)
local cep <const> = epoll.create(16)
sep:event_add(sfd:handle(), epoll.EPOLLIN | epoll.EPOLLOUT, sfd)
Expand All @@ -128,7 +123,7 @@ end

function m.test_shutdown()
local sfd <close> = helper.SimpleServer("tcp", "127.0.0.1", 0)
local cfd <close> = helper.SimpleClient("tcp", "127.0.0.1", get_port(sfd))
local cfd <close> = helper.SimpleClient("tcp", sfd:info "socket")
local sep <const> = epoll.create(16)
local cep <const> = epoll.create(16)
sep:event_add(sfd:handle(), epoll.EPOLLIN | epoll.EPOLLOUT | epoll.EPOLLRDHUP, sfd)
Expand Down
6 changes: 1 addition & 5 deletions test/pingpong.lua
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,6 @@ local function create_listen(fd)
end

function m.test()
local function get_port(fd)
local _, port = fd:info "socket"
return port
end
local quit = false
local s = helper.SimpleServer("tcp", "127.0.0.1", 0)
local server = create_listen(s)
Expand All @@ -200,7 +196,7 @@ function m.test()
end
end

local c = helper.SimpleClient("tcp", "127.0.0.1", get_port(s))
local c = helper.SimpleClient("tcp", s:info "socket")
local client = create_stream(c)
client:send "PING-1"
function client:on_recv()
Expand Down

0 comments on commit 7e09c1e

Please sign in to comment.