Tarantool development patches archive
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: tml <tarantool-patches@dev.tarantool.org>
Subject: [Tarantool-patches] [PATCH 5/5] test: Add app/popen test
Date: Thu, 28 Nov 2019 23:45:12 +0300	[thread overview]
Message-ID: <20191128204512.19732-6-gorcunov@gmail.com> (raw)
In-Reply-To: <20191128204512.19732-1-gorcunov@gmail.com>

To test basic functionality of popen code.

Fixes #4031

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 test/app/popen.result   | 105 ++++++++++++++++++++++++++++++++++++++++
 test/app/popen.test.lua |  39 +++++++++++++++
 2 files changed, 144 insertions(+)
 create mode 100644 test/app/popen.result
 create mode 100644 test/app/popen.test.lua

diff --git a/test/app/popen.result b/test/app/popen.result
new file mode 100644
index 000000000..1a27b1b0c
--- /dev/null
+++ b/test/app/popen.result
@@ -0,0 +1,105 @@
+-- test-run result file version 2
+fio = require('fio')
+ | ---
+ | ...
+test_run = require('test_run').new()
+ | ---
+ | ...
+
+local err, reason, exit_code
+ | ---
+ | ...
+
+--
+-- Trivial echo output
+--
+script="echo -n 1 2 3 4 5"
+ | ---
+ | ...
+popen = fio.popen(script, "r")
+ | ---
+ | ...
+popen:wait()
+ | ---
+ | - null
+ | - 1
+ | - 0
+ | ...
+popen:read()
+ | ---
+ | - 1 2 3 4 5
+ | ...
+popen:close()
+ | ---
+ | - true
+ | - null
+ | ...
+
+--
+-- Test info and killing of a child process
+--
+script="while [ 1 ]; do sleep 10; done"
+ | ---
+ | ...
+popen = fio.popen(script, "r")
+ | ---
+ | ...
+popen:kill()
+ | ---
+ | - true
+ | ...
+--
+-- Killing child may be queued and depends on
+-- system load, so we may get ESRCH here.
+err, reason, exit_code = popen:wait()
+ | ---
+ | ...
+popen:status()
+ | ---
+ | - null
+ | - 2
+ | - 9
+ | ...
+info = popen:info()
+ | ---
+ | ...
+info["state"]
+ | ---
+ | - exited
+ | ...
+info["flags"]
+ | ---
+ | - 834
+ | ...
+info["exit_code"]
+ | ---
+ | - 9
+ | ...
+popen:close()
+ | ---
+ | - true
+ | - null
+ | ...
+
+--
+-- Test for stdin/out stream
+--
+script="prompt=''; read -n 5 prompt; echo -n $prompt"
+ | ---
+ | ...
+popen = fio.popen(script, "rw")
+ | ---
+ | ...
+popen:write("input")
+ | ---
+ | - 5
+ | ...
+popen:read()
+ | ---
+ | - input
+ | ...
+popen:close()
+ | ---
+ | - true
+ | - null
+ | ...
diff --git a/test/app/popen.test.lua b/test/app/popen.test.lua
new file mode 100644
index 000000000..46c49cb18
--- /dev/null
+++ b/test/app/popen.test.lua
@@ -0,0 +1,39 @@
+fio = require('fio')
+test_run = require('test_run').new()
+
+local err, reason, exit_code
+
+--
+-- Trivial echo output
+--
+script="echo -n 1 2 3 4 5"
+popen = fio.popen(script, "r")
+popen:wait()
+popen:read()
+popen:close()
+
+--
+-- Test info and killing of a child process
+--
+script="while [ 1 ]; do sleep 10; done"
+popen = fio.popen(script, "r")
+popen:kill()
+--
+-- Killing child may be queued and depends on
+-- system load, so we may get ESRCH here.
+err, reason, exit_code = popen:wait()
+popen:status()
+info = popen:info()
+info["state"]
+info["flags"]
+info["exit_code"]
+popen:close()
+
+--
+-- Test for stdin/out stream
+--
+script="prompt=''; read -n 5 prompt; echo -n $prompt"
+popen = fio.popen(script, "rw")
+popen:write("input")
+popen:read()
+popen:close()
-- 
2.20.1

      parent reply	other threads:[~2019-11-28 20:46 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-28 20:45 [Tarantool-patches] [PATCH 0/5] popen: Add ability to run external process Cyrill Gorcunov
2019-11-28 20:45 ` [Tarantool-patches] [PATCH 1/5] popen: Introduce a backend engine Cyrill Gorcunov
2019-11-29  5:52   ` Konstantin Osipov
2019-11-29  9:57     ` Cyrill Gorcunov
2019-11-29  5:59   ` Konstantin Osipov
2019-11-29  9:40     ` Cyrill Gorcunov
2019-11-29 11:19       ` Konstantin Osipov
2019-11-29 11:36         ` Cyrill Gorcunov
2019-11-29 14:50           ` Konstantin Osipov
2019-11-29 15:14             ` Cyrill Gorcunov
2019-11-29 15:17               ` Cyrill Gorcunov
2019-11-29 18:31               ` Konstantin Osipov
2019-11-29 19:17                 ` Cyrill Gorcunov
2019-11-29 22:36                   ` Cyrill Gorcunov
2019-11-30  4:21                     ` Konstantin Osipov
2019-11-30  7:48                       ` Cyrill Gorcunov
2019-11-30  4:14                   ` Konstantin Osipov
2019-11-30  7:36                     ` Cyrill Gorcunov
2019-11-30 10:04                       ` Konstantin Osipov
2019-11-30 10:47                         ` Cyrill Gorcunov
2019-11-30 10:54                           ` Cyrill Gorcunov
2019-11-30 12:16                             ` Cyrill Gorcunov
2019-11-30 20:30                             ` Konstantin Osipov
2019-11-30 20:36                               ` Cyrill Gorcunov
2019-12-13  2:50   ` Alexander Turenko
2019-11-28 20:45 ` [Tarantool-patches] [PATCH 2/5] lua/fio: Add lbox_fio_push_error as a separate helper Cyrill Gorcunov
2019-11-29  6:02   ` Konstantin Osipov
2019-11-29  9:47     ` Cyrill Gorcunov
2019-11-29 11:22       ` Konstantin Osipov
2019-11-29 11:42         ` Cyrill Gorcunov
2019-11-29 14:51           ` Konstantin Osipov
2019-11-28 20:45 ` [Tarantool-patches] [PATCH 3/5] popen/fio: Merge popen engine into fio internal module Cyrill Gorcunov
2019-11-28 20:45 ` [Tarantool-patches] [PATCH 4/5] popen/fio: Implement lua interface for a popen object Cyrill Gorcunov
2019-11-28 20:45 ` Cyrill Gorcunov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191128204512.19732-6-gorcunov@gmail.com \
    --to=gorcunov@gmail.com \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 5/5] test: Add app/popen test' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox