Re: [hackers] [sbase][PATCH v2] Add tests for some utilities

From: Silvan Jegen <s.jegen_AT_gmail.com>
Date: Wed, 1 Aug 2018 16:36:35 +0200

Hi Mattias!

On Wed, Jul 11, 2018 at 09:39:23PM +0200, Mattias Andrée wrote:
> The following utilities are tested:
> - basename(1)
> - dirname(1)
> - echo(1)
> - false(1)
> - link(1)
> - printenv(1)
> - sleep(1)
> - test(1)
> - time(1)
> - true(1)
> - tty(1)
> - uname(1)
> - unexpand(1)
> - unlink(1)
> - whoami(1)
> - yes(1)
>
> Some tests contain "#ifdef TODO", these tests current
> fail, but there are patches submitted for most of them.
> There are not patches submitted for fixing the
> "#ifdef TODO"s in expand.test.c and unexpand.test.c.
>
> Signed-off-by: Mattias Andrée <maandree_AT_kth.se>

Sorry for not getting around to looking at this earlier.

I definitely think we should have unit tests for sbase (and other
projects?) as soon as possible. What concerns me with your approach is
that we have about 700 lines of C code in testing-common.{c,h} of which
I feel quite a bit could be dropped.

I have written some (crappy and probably non-portable) shell script
functions to check the stdout and stderr of a process. It's about 40
lines. I also converted your tests for dirname to use these functions
(both files attached. The test coverage is not exactly the same but
relatively similar).

I wonder if we couldn't use some cleaned-up version of the shell script
functions for the easy test cases that only check stdout and stderr
output and your custom C code for the more specialised test cases (like
'tty').

What do you think?


Cheers,

Silvan


> ---
> Makefile | 45 ++++-
> basename.test.c | 68 +++++++
> dirname.test.c | 55 ++++++
> echo.test.c | 51 ++++++
> expand.test.c | 92 ++++++++++
> false.test.c | 32 ++++
> link.test.c | 58 ++++++
> printenv.test.c | 79 ++++++++
> sleep.test.c | 53 ++++++
> test-common.c | 560 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> test-common.h | 219 ++++++++++++++++++++++
> test.test.c | 408 +++++++++++++++++++++++++++++++++++++++++
> time.test.c | 218 ++++++++++++++++++++++
> true.test.c | 31 ++++
> tty.test.c | 44 +++++
> uname.test.c | 283 ++++++++++++++++++++++++++++
> unexpand.test.c | 97 ++++++++++
> unlink.test.c | 56 ++++++
> whoami.test.c | 38 ++++
> yes.test.c | 131 +++++++++++++
> 20 files changed, 2614 insertions(+), 4 deletions(-)
>
> [snip]

Received on Wed Aug 01 2018 - 16:36:35 CEST

This archive was generated by hypermail 2.3.0 : Wed Aug 01 2018 - 16:48:23 CEST