Hi Jan,
Thanks for taking the time out to bear my newbie-ness...
I am running this on an mx6q platform.
root@mx6q:~# ls -la /bin/sh
lrwxrwxrwx 1 root root 20 Jul 10 2014 /bin/sh -> /etc/alternatives/sh
Then PATH setting is as follows:
root@mx6q:~#
root@mx6q:~# cd /opt/ltp/
IDcheck.sh bin/ results/ runltplite.sh testcases/
Version runalltests.sh runtest/ testscripts/
abcd output/ runltp scenario_groups/ ver_linux
root@mx6q:~# cd /opt/ltp/
root@mx6q:/opt/ltp#
root@mx6q:/opt/ltp#
root@mx6q:/opt/ltp# echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
root@mx6q:/opt/ltp#
root@mx6q:/opt/ltp#
root@mx6q:/opt/ltp# export PATH=$PATH:/opt/ltp/testcases/bin/
root@mx6q:/opt/ltp#
root@mx6q:/opt/ltp# echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/ltp/testcases/bin/
/opt/ltp/testcases/bin/ is where I have test.sh present. Now the testcase:
root@mx6q:/opt/ltp/testcases/bin# cat foo.sh
#!/bin/sh
#
# This is a basic test for true shell buildin
#
TCID=true01
TST_TOTAL=1
. test.sh
false
ret=$?
if [ $ret -eq 0 ]; then
tst_resm TPASS "true returned 0"
else
tst_resm TFAIL "true rturned $ret"
fi
tst_exit
root@mx6q:/opt/ltp/testcases/bin#
root@mx6q:/opt/ltp/testcases/bin#
root@mx6q:/opt/ltp/testcases/bin#
root@mx6q:/opt/ltp/testcases/bin# ./foo.sh
## Start Test
Thu Jan 1 00:10:59 UTC 1970
659
## Create files
/opt/ltp/testcases/bin/test.sh: line 14: /home/root/fs-bench/cr: No such file
or directory
real 0m0.004s
user 0m0.000s
sys 0m0.000s
## tar all
tar: invalid option -- 'B'
BusyBox v1.21.1 (2014-07-10 15:06:02 PKT) multi-call binary.
Usage: tar -[cxtzJjhmvO] [-X FILE] [-T FILE] [-f TARFILE] [-C DIR] [FILE]...
## Change owner
chown: ./00: No such file or directory
real 0m0.010s
user 0m0.000s
sys 0m0.000s
## random access
/opt/ltp/testcases/bin/test.sh: line 26: /home/root/fs-bench/ra: No such file
or directory
real 0m0.002s
user 0m0.000s
sys 0m0.000s
## Change mode
chmod: ./00: No such file or directory
real 0m0.009s
user 0m0.000s
sys 0m0.000s
## Random delete and create
/opt/ltp/testcases/bin/test.sh: line 34: /home/root/fs-bench/radc: No such file
or directory
real 0m0.002s
user 0m0.000s
sys 0m0.000s
## Change mode again
chmod: ./00: No such file or directory
real 0m0.008s
user 0m0.000s
sys 0m0.000s
## Remove all files and directories
real 0m0.007s
user 0m0.000s
sys 0m0.000s
## Finish test
659
Thu Jan 1 00:10:59 UTC 1970
TOTAL(seconds): 0
Set variables TCID, TST_TOTAL, and TST_COUNT before each test:
export TCID=<test name>
export TST_TOTAL=<Total Number of Tests >
export TST_COUNT=<Test case number>
./foo.sh: line 17: 520 Aborted tst_resm TFAIL "true rturned $ret"
Set variables TCID, TST_TOTAL, and TST_COUNT before each test:
export TCID=<test name>
export TST_TOTAL=<Total Number of Tests >
export TST_COUNT=<Test case number>
./foo.sh: line 19: 521 Aborted tst_exit
root@mx6q:/opt/ltp/testcases/bin#
root@mx6q:/opt/ltp/testcases/bin#
root@mx6q:/opt/ltp/testcases/bin# echo $?
134
root@mx6q:/opt/ltp/testcases/bin#
LTP versioning:
LTP Version: 20140115
I'll be trying this out on a simple desktop now, just to confirm, in the
meantime please point out anything you see is out of place...
BR,
Awais
________________________________________
From: Jan Stancek [[email protected]]
Sent: Friday, July 11, 2014 7:51 PM
To: Belal, Awais
Cc: [email protected]
Subject: Re: [LTP] Shell Scripting - Basics
----- Original Message -----
> From: "Awais Belal" <[email protected]>
> To: [email protected]
> Sent: Friday, 11 July, 2014 2:00:36 PM
> Subject: [LTP] Shell Scripting - Basics
>
> Hi Guys,
>
> I have just started looking into LTP and how test automation can be achieved
> using the platform. While going through the very basics I am stuck on shell
> script writing for LTP. I was following
> https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines#231-basic-shell-test-structure
> and the very first thing that I got hit by was:
>
> Set variables TCID, TST_TOTAL, and TST_COUNT before each test:
> export TCID=<test name>
> export TST_TOTAL=<Total Number of Tests >
> export TST_COUNT=<Test case number>
Hi,
This output suggests that instead of tst_resm from test.sh,
it ran tst_resm from tools/apicmd.
and somehow this condition from ltpapicmd.c was true:
if (!strcmp(cmd_name, "tst_kvercmp") &&
!strcmp(cmd_name, "tst_kvercmp2") &&
!strcmp(cmd_name, "tst_get_unused_port")) {
That's the only place where I can see this message. I'm assuming you
are using latest git LTP.
Can you send your whole script and command how you run it?
What shell are you using? (ls -la /bin/sh)
If I try the example from 2.3.1 with 'false', it fails as expected:
$ cd /usr/src/ltp/testcases/lib
$ cat foo.sh
#!/bin/sh
#
# This is a basic test for true shell buildin
#
TCID=true01
TST_TOTAL=1
. test.sh
false
ret=$?
if [ $ret -eq 0 ]; then
tst_resm TPASS "true returned 0"
else
tst_resm TFAIL "true rturned $ret"
fi
tst_exit
$ PATH=.:$PATH sh ./foo.sh
true01 1 TFAIL : true rturned 1
$ echo $?
1
Regards,
Jan
>
> so I exported the variables in the above mentioned shell script (is the
> current wiki wrong???), the test passed as it should and I thought I was
> done and I understand, but then when I tried to make the test fail by doing
> the following:
>
> true ret = $?
> replaced with
> false ret = $?
>
> the test still reports success :(
>
> tst_exit says:
> "Exits the tests, note that this function has no parameters, the PASSES/FAILS
> reported by the tst_resm() interfaces were stored and are used for the exit
> value."
>
> If I explicitly write an 'exit 1' at the end of the testcase, it fails but I
> believe that shouldn't be the case (using an explicit return shouldn't be
> needed if tst_exit is being used)... What am I missing? (a brain perhaps...
> :S)
>
> BR,
> Awais
>
> ------------------------------------------------------------------------------
> Open source business process management suite built on Java and Eclipse
> Turn processes into business applications with Bonita BPM Community Edition
> Quickly connect people, data, and systems into organized workflows
> Winner of BOSSIE, CODIE, OW2 and Gartner awards
> http://p.sf.net/sfu/Bonitasoft
> _______________________________________________
> Ltp-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ltp-list
>
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck®
Code Sight™ - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list