Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaozg committed Aug 13, 2023
1 parent a7aa1f5 commit 5e2bf67
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions tests/test-tty.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if not ffi then
return
end

if not (ffi.os == "linux" or ffi.os == "macos") then
if not (ffi.os == "Linux" or ffi.os == "OSX") then
print('skip, not on linux or macos')
return
end
Expand All @@ -31,24 +31,25 @@ return require('lib/tap')(function (test)
test("tty pty", function (print, p, expect, uv)
ffi.cdef[[
struct winsize {
unsigned short ws_row;
unsigned short ws_col;
unsigned short ws_xpixel; /* unused */
unsigned short ws_ypixel; /* unused */
unsigned short ws_row;
unsigned short ws_col;
unsigned short ws_xpixel; /* unused */
unsigned short ws_ypixel; /* unused */
};
int openpty(int *amaster, int *aslave, char *name,
const void* termp, const struct winsize* winp);
const void* termp, const struct winsize* winp);
]]

local master_fd = ffi.new('int[1]')
local slave_fd = ffi.new('int[1]')
local winp = ffi.new('struct winsize[1]')

local r = ffi.C.openpty(master_fd, slave_fd, nil, nil, winp);
local util = ffi.load('util')
local r = util.openpty(master_fd, slave_fd, nil, nil, winp);
assert(tonumber(r)==0)

local master_tty = uv.new_tty(tonumber(master_fd), false)
local slave_tty = uv.new_tty(tonumber(slave_fd), false)
local master_tty = uv.new_tty(tonumber(master_fd[0]), false)
local slave_tty = uv.new_tty(tonumber(slave_fd[0]), false)

assert(uv.is_readable(master_tty))
assert(uv.is_writable(master_tty))
Expand All @@ -61,13 +62,8 @@ return require('lib/tap')(function (test)

test("tty device", function (print, p, expect, uv)
ffi.cdef[[
typedef unsigned mode_t;
int open(const char *pathname, int flags, mode_t mode);
struct winsize {
unsigned short ws_row;
unsigned short ws_col;
unsigned short ws_xpixel; /* unused */
unsigned short ws_ypixel; /* unused */
};
]]

local ttyin_fd = ffi.C.open("/dev/tty", uv.constants.O_RDONLY, 0);
Expand Down

0 comments on commit 5e2bf67

Please sign in to comment.