> -----Original Message-----
> From: Alexander Kanavin <alex.kana...@gmail.com>
> Sent: Wednesday, January 24, 2024 5:42 PM
> To: Xu, Chi <chi...@windriver.com>
> Cc: openembedded-core@lists.openembedded.org
> Subject: Re: [OE-core] [PATCH] xz: Add ptest support
> 
> CAUTION: This email comes from a non Wind River email account!
> Do not click links or open attachments unless you recognize the sender and
> know the content is safe.
> 
> On Wed, 24 Jan 2024 at 10:04, Chi Xu <chi...@eng.windriver.com> wrote:
> > +Subject: [PATCH] Update test scripts: replace ../src/* with /usr/bin
> > +
> > +In order to run scripts on target, replace ../src/* with /usr/bin
> > +
> > +Upstream-Status: Inappropriate [embedded specific] -if test -x
> > +../src/xz/xz ; then
> > ++if test -x /usr/bin/xz ; then
> 
> It's better to bundle the xz* executables into the ptest package where the
> script expects them, and avoid making a non-upstreamable patch altogether.
> 
> > +ptestdir=$(dirname "$(readlink -f "$0")") cd "$ptestdir"/tests ||
> > +exit
> > +
> > +# executables test cases
> > +tests_exec=$(file $(ls test_*) | grep "ELF" | awk -F: '{print $1}')
> > +for i in ${tests_exec}; do
> > +    ./$i
> > +done
> > +
> > +# POSIX shell script test cases
> > +export srcdir=${ptestdir}/tests
> > +test_shell="test_files.sh test_scripts.sh test_compress.sh"
> > +for j in ${test_shell}; do
> > +    if [ $j == "test_compress.sh" ]; then
> > +        ./$j create_compress_files
> > +    else
> > +        ./$j
> > +    fi
> > +    if [ $? -eq 0 ]; then
> > +        echo "PASS: $j"
> > +    else
> > +        echo "FAIL: $j"
> > +    fi
> 
> I still don't understand this part. If these scripts are executed as a part of
> standard in-tree unit testing, what prints PASS/FAIL in that context? 
> Shouldn't
> we reuse that, to replicate the in-tree testing sequence as much as possible?
> 

According to the description on section 4.2 in 'INSTALL' file of xz, 
"The shell script tests can be copied from the source directory to the target 
machine to execute."
So I copy them to target and execute them in ptest.
They don't have out put like "PASS/FAIL", just return zero or non-zero, so in 
run-ptest, I print 
"PASS" or "FAIL" according to the return value.
  
==============
4.2. Cross compiling

    The tests can be built without running them:

        make check TESTS=

    The TESTS variable is the list of tests you wish to run. Leaving it
    empty will compile the tests without running any.

    If the tests are copied to a target machine to execute, the test data
    files in the directory tests/files must also be copied. The tests
    search for the data files using the environment variable $srcdir,
    expecting to find the data files under $srcdir/files/. If $srcdir
    isn't set then it defaults to the current directory.

    The shell script tests can be copied from the source directory to the
    target machine to execute. In addition to the test files, these tests
    will expect the following relative file paths to execute properly:
==============

Out put of shell script cases:
root@qemux86-64:/usr/lib/xz/ptest/tests# export srcdir=/usr/lib/xz/ptest/tests
root@qemux86-64:/usr/lib/xz/ptest/tests# ./test_files.sh
root@qemux86-64:/usr/lib/xz/ptest/tests# echo $?
0
root@qemux86-64:/usr/lib/xz/ptest/tests# ./test_scripts.sh
root@qemux86-64:/usr/lib/xz/ptest/tests# echo $?
0
root@qemux86-64:/usr/lib/xz/ptest/tests# ./test_compress.sh 
create_compress_files
root@qemux86-64:/usr/lib/xz/ptest/tests# echo $?
0

Thanks,
Chi

> Alex
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#194305): 
https://lists.openembedded.org/g/openembedded-core/message/194305
Mute This Topic: https://lists.openembedded.org/mt/103905858/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to