public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
Cc: ltp-list <ltp-list@lists.sourceforge.net>
Subject: Re: [LTP] [RFC PATCH] commands/du: Added new testcase to test du(1) command.
Date: Thu, 2 Apr 2015 13:59:22 +0200	[thread overview]
Message-ID: <20150402115922.GA30680@rei> (raw)
In-Reply-To: <1427970931.19106.8.camel@G08JYZSD130126.localdomain>

Hi!
> +#!/bin/sh
> +#
> +# Copyright (c) 2015 Fujitsu Ltd.
> +# Author: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
> +#
> +# This program is free software;  you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY;  without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
> +# the GNU General Public License for more details.
> +#
> +# Test du command with some basic options.
> +#
> +
> +TCID=du01
> +
> +TEST_FILE="du_test.file"
> +test_cases=(
> +	[1]=""
> +	[2]="$TEST_FILE"
> +	[3]="-0"
> +	[4]="--null"
> +	[5]="-a"
> +	[6]="--all"
> +	[7]="-B 20"
> +	[8]="--block-size=20"
> +	[9]="-b"
> +	[10]="--bytes"
> +	[11]="-c"
> +	[12]="--total"
> +	[13]="-D dir1/${TEST_FILE}"
> +	[14]="--dereference-args dir1/${TEST_FILE}"
> +	[15]="--max-depth=1"
> +	[16]="-H dir1/${TEST_FILE}"
> +	[17]="-h"
> +	[18]="--human-readable"
> +	[19]="-k"
> +	[20]="-L dir1/"
> +	[21]="--dereference dir1/"
> +	[22]="-m"
> +	[23]="-P"
> +	[24]="--no-dereference"
> +	[25]="--si"
> +	[26]="-s"
> +	[27]="--summarize"
> +	[28]="--exclude=${TEST_FILE}"
> +)

Have you tried with real sh (from bussybox) or dash? I doubt that this
array syntax works there.

> +TST_TOTAL=${#test_cases[@]}

This as well.

> +. test.sh
> +
> +export TEST_RETURN
> +TEST()
> +{
> +	$@ >${TCID}.temp 2>&1
> +	TEST_RETURN=$?
> +}

Hmm, why to save the output to a file if it's not used at all?

> +setup()
> +{
> +	tst_check_cmds du
> +
> +	tst_tmpdir
> +
> +	echo "test for du" > du_test.file
> +	if [ $? -ne 0 ]; then
> +		tst_brkm TBROK "create du_test.file failed."
> +	fi
> +
> +	mkdir -p dir1
> +	if [ $? -ne 0 ]; then
> +		tst_brkm TBROK "mkdir dir1 failed."
> +	fi

Hmm, maybe we should introduce safe_mkdir etc, similarily to the safe
macros we have for C.

> +	ln -s $(pwd)/du_test.file dir1/du_test.file

ln -s ./du_test.file dir1/du_test.file ?

> +	if [ $? -ne 0 ]; then
> +		tst_brkm TBROK "ln -s $(pwd)/du_test.file dir1/du_test.file"
> +	fi
> +}
> +
> +cleanup()
> +{
> +	tst_rmdir
> +}
> +
> +setup
> +TST_CLEANUP=cleanup
> +
> +for i in $(seq 1 ${#test_cases[@]})
> +do
> +	TEST du ${test_cases[$i]}
> +	if [ ${TEST_RETURN} -eq 0 ]; then
> +		tst_resm TPASS "du(option: ${test_cases[$i]}) succeeded."

Better test would also parse the test output and check if it's sane, but
for basic test this is okay.

> +	else
> +		tst_resm TFAIL "du(option: ${test_cases[$i]}) failed."
> +	fi
> +done
> +
> +tst_exit
> -- 
> 1.9.3
> 
> 
> 
> 
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming The Go Parallel Website, sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for all
> things parallel software development, from weekly thought leadership blogs to
> news, videos, case studies, tutorials and more. Take a look and join the 
> conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

  reply	other threads:[~2015-04-02 11:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-02 10:35 [LTP] [RFC PATCH] commands/du: Added new testcase to test du(1) command Zeng Linggang
2015-04-02 11:59 ` Cyril Hrubis [this message]
     [not found]   ` <1429010688.7190.24.camel@G08JYZSD130126.localdomain>
2015-04-22 12:47     ` [LTP] [RFC PATCH v2 1/2] testcases/lib/test.sh: added SAFE_CALL*() Cyril Hrubis
     [not found]       ` <1429755598.2416.14.camel@G08JYZSD130126.localdomain>
2015-04-23 10:27         ` Cyril Hrubis
     [not found]   ` <1429010747.7190.25.camel@G08JYZSD130126.localdomain>
2015-04-22 12:58     ` [LTP] [RFC PATCH v2 2/2] commands/du: Added new testcase to test du(1) command Cyril Hrubis
     [not found]       ` <1429784431-14017-1-git-send-email-zenglg.jy@cn.fujitsu.com>
2015-04-28 14:10         ` [LTP] [PATCH v3 1/2] testcases/lib/test.sh: Added ROD_SILENT() and ROD() Cyril Hrubis
     [not found]           ` <1430270054.7745.11.camel@G08JYZSD130126.localdomain>
     [not found]             ` <55417DFD.1040207@huawei.com>
2015-04-30  7:51               ` Cyril Hrubis
2015-04-30  7:52               ` 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=20150402115922.GA30680@rei \
    --to=chrubis@suse.cz \
    --cc=ltp-list@lists.sourceforge.net \
    --cc=zenglg.jy@cn.fujitsu.com \
    /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