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
|
#
# gensio - A library for abstracting stream I/O
# Copyright (C) 2018 Corey Minyard <minyard@acm.org>
#
# SPDX-License-Identifier: GPL-2.0-only
#
from utils import *
import gensio
import os
import gensios_enabled
gensios_enabled.check_iostr_gensios("pty")
if is_windows():
sys.exit(77)
print("Test pty basic echo")
io = alloc_io(o, "pty,cat", chunksize = 64)
check_raddr(io, "pty basic", '"cat"')
test_dataxfer(io, io, "This is a test string!")
io_close([io])
del io
print(" Success!")
def test_with_ptsname_r():
print("Test pty accepter")
TestAccept(o, "serialdev,", "conacc,pty", do_small_test)
print("Test pty symlinks")
try:
os.unlink("./ptylink1")
except:
pass
TestAccept(o, "serialdev,./ptylink1", "conacc,pty(link=./ptylink1)",
do_small_test, get_port = False)
print("Test pty symlink failure")
os.symlink("asdf", "./ptylink1")
try:
TestAccept(o, "serialdev,./ptylink1", "conacc,pty(link=./ptylink1)",
do_small_test, get_port = False, except_on_log = True)
except Exception as E:
if str(E) == "***err LOG: conacc,pty(link=./ptylink1): Error opening gensio: Value already exists":
None
elif str(E) == "gensio:startup: Value already exists":
None
else:
raise
print(" Success!")
print("Test pty symlink force")
TestAccept(o, "serialdev,./ptylink1", "conacc,pty(link=./ptylink1,forcelink)",
do_small_test, get_port = False)
if gensios_enabled.have_ptsname_r:
test_with_ptsname_r()
del o
test_shutdown()
|