From 3e0e65dd505bffaeff3d3aba6f2dbf1719b36c0d Mon Sep 17 00:00:00 2001 From: Andrew Vagin Date: Sat, 13 Feb 2016 20:55:25 +0300 Subject: [PATCH] test: check restoring external fifo-s Signed-off-by: Andrew Vagin Signed-off-by: Pavel Emelyanov --- test/inhfd/fifo.py | 35 +++++++++++++++++++++++++++++++++++ test/inhfd/fifo.py.desc | 1 + 2 files changed, 36 insertions(+) create mode 100755 test/inhfd/fifo.py create mode 100644 test/inhfd/fifo.py.desc diff --git a/test/inhfd/fifo.py b/test/inhfd/fifo.py new file mode 100755 index 000000000..a4b4fc84e --- /dev/null +++ b/test/inhfd/fifo.py @@ -0,0 +1,35 @@ +import os, tempfile + +id_str = "" + +def create_fds(): + tdir = tempfile.mkdtemp("zdtm.inhfd.XXXXXX") + if os.system("mount -t tmpfs zdtm.inhfd %s" % tdir) != 0: + raise Exception("Unable to mount tmpfs") + tfifo = os.path.join(tdir, "test_fifo") + os.mkfifo(tfifo) + fd2 = open(tfifo, "w+") + fd1 = open(tfifo, "r") + os.system("umount -l %s" % tdir) + os.rmdir(tdir) + + mnt_id = -1; + f = open("/proc/self/fdinfo/%d" % fd1.fileno()) + for l in f: + l = l.split() + if l[0] == "mnt_id:": + mnt_id = int(l[1]) + break + else: + raise Exception("Unable to find mnt_id") + + global id_str + id_str = "file[%x:%x]" % (mnt_id, os.fstat(fd1.fileno()).st_ino) + + return (fd2, fd1) + +def filename(pipef): + return id_str + +def dump_opts(sockf): + return [ "--external", id_str ] diff --git a/test/inhfd/fifo.py.desc b/test/inhfd/fifo.py.desc new file mode 100644 index 000000000..10666c823 --- /dev/null +++ b/test/inhfd/fifo.py.desc @@ -0,0 +1 @@ +{ 'flavor': 'h' }