From: Jan Stancek <jstancek@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] new shell library
Date: Mon, 31 Oct 2016 06:03:42 -0400 (EDT) [thread overview]
Message-ID: <827120068.2432301.1477908222614.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20161027145806.GA25043@rei.lan>
----- Original Message -----
> From: "Cyril Hrubis" <chrubis@suse.cz>
> To: "Jan Stancek" <jstancek@redhat.com>
> Cc: ltp@lists.linux.it
> Sent: Thursday, 27 October, 2016 4:58:06 PM
> Subject: Re: [LTP] new shell library
>
> Hi!
> Up to date version is at usuall place[1]. I've managed to clean up most
> of the tests in commands (four more to go) and I think that I ate enough
> of my own dog food and, at this point, the tst_test.sh library should be
> reasonably stable.
>
> There is one change I'm not 100% sure of [2]. This is about ROD,
> EXPECT_PASS and EXPECT_FAIL. These are all implemented using one common
> funcntion and the $@ gets passed to it then gets parser in a loop in
> order to implement redirection and that is where the paramteres are
> expanded several times which breaks things horribly. As far as I can
> tell this is impossible to implement correctly in shell. For instance
> things like: ROD awk '{print $1}' wouldn't work with ROD_BASE as a shell
> fuction. As a result I've reimplemented the ROD_BASE as tst_rod in C,
> which works mostly fine. It's just stdin/stdout/stderr redirection +
> execvp() (and fallback to "/bin/sh -s" for shell buildins). The only
> thing that does not work are shell buildins that require to be executed
> in the context of current shell, such as 'wait' or 'jobs'. I'm pondering
> if it is worth of catching these two special cases in the tst_test.sh
> shell library to fix that issue. Any kind of feedback to this is warmly
> welcomed.
I don't recall original ROD email thread, but did we consider eval and
passing entire command as single argument? For most commands it would
seem to be as simple as adding quotes around, awk though needs some
escaping:
#!/bin/sh
ROD_BASE()
{
eval $@
}
ROD()
{
ROD_BASE "$@"
if [ $? -ne 0 ]; then
tst_brk TBROK "$@ failed"
fi
}
ROD_SILENT()
{
ROD_BASE "$@" > /dev/null 2>&1
if [ $? -ne 0 ]; then
tst_brk TBROK "$@ failed"
fi
}
sleep 1 &
ROD jobs
ROD "ps | awk '{print \$1}' > tempfile"
ROD_SILENT "whoami >> tempfile"
ROD_SILENT ls
ROD ls -la
>
> The rest of the changes should be more or less fine. The shell testcases
> now support looping parameter and have well defined way of adding test
> specific ones. What is not yet implemented is support for timeouts, that
> could be easily done later since that is more or less orthogonal to the
> current work.
>
> All in all I would love to have a second pair of eyes (or even more!) to
> check the code now.
>
> [1] https://github.com/metan-ucw/ltp/commits/master
> [2]
> https://github.com/metan-ucw/ltp/commit/61bebd11c6f956a7b9fcdf319ea6f4a47f5de35a
>
> --
> Cyril Hrubis
> chrubis@suse.cz
>
next prev parent reply other threads:[~2016-10-31 10:03 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-03 14:58 [LTP] new shell library Cyril Hrubis
2016-10-04 8:23 ` Jan Stancek
2016-10-04 8:45 ` Cyril Hrubis
2016-10-04 9:02 ` Jan Stancek
2016-10-04 9:35 ` Cyril Hrubis
2016-10-04 9:54 ` Jan Stancek
2016-10-04 11:50 ` Cyril Hrubis
2016-10-12 10:08 ` Cyril Hrubis
2016-10-12 10:32 ` Jan Stancek
2016-10-12 12:36 ` Cyril Hrubis
2016-10-12 13:17 ` Cyril Hrubis
2016-10-12 14:54 ` Jan Stancek
2016-10-12 15:06 ` Cyril Hrubis
2016-10-13 15:43 ` Cyril Hrubis
2016-10-27 14:58 ` Cyril Hrubis
2016-10-31 10:03 ` Jan Stancek [this message]
2016-10-31 10:39 ` Cyril Hrubis
2016-11-14 13:12 ` Cyril Hrubis
2016-11-22 6:50 ` Cyril Hrubis
2016-11-22 7:54 ` Jan Stancek
2016-11-22 8:02 ` Cyril Hrubis
2016-11-22 10:47 ` Jan Stancek
2016-11-22 11:21 ` Cyril Hrubis
-- strict thread matches above, loose matches on Subject: below --
2016-11-22 12:20 Jan Stancek
2016-11-22 13:27 ` Cyril Hrubis
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=827120068.2432301.1477908222614.JavaMail.zimbra@redhat.com \
--to=jstancek@redhat.com \
--cc=ltp@lists.linux.it \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox