----- Original Message -----
From: "Amit Saha" <asaha(a)redhat.com>
To: "Beaker development" <beaker-devel(a)lists.fedorahosted.org>
Sent: Tuesday, July 30, 2013 5:03:26 PM
Subject: Re: [Beaker-devel] Test framework for lshw
----- Original Message -----
> From: "Nick Coghlan" <ncoghlan(a)redhat.com>
> To: beaker-devel(a)lists.fedorahosted.org
> Sent: Tuesday, July 30, 2013 4:58:53 PM
> Subject: Re: [Beaker-devel] Test framework for lshw
>
> On 07/30/2013 04:35 PM, Amit Saha wrote:
> > One approach that I can think of is:
> >
> > - Add an extra option to lshw -s specifying the location of the snapshot
> >
> > - When this is set, we can set an environment variable to point
> > to the location of the snapshot. In all the files where the information
> > is read from the file systems, before opening the file, we check
> > for this environment variable, and if it exists, we read the files from
> > there instead.
> >
> >
> > And of course, matching the expected output, etc follows after that.
> >
> > Would be interested in any feedback.
>
> It would be nice if this could be strictly a test harness thing rather
> than requiring changes to lshw. Can we play games by invoking lshw in an
> appropriately configured chroot instead?
heh, I did have that idea and thought it sounded crazy.
I spent some time to implement a basic chroot based testing script:
#!/bin/bash
cur_dir=`pwd`
temp_dir=`mktemp --directory`
cp -r src $temp_dir/src
pushd $temp_dir/src
# if we build a static executable, we don't need
# to take care of copying the shared libraries
yum -y install libstdc++-static
make static
mv lshw-static $cur_dir/testdata/`arch`/usr/sbin/lshw
popd
rm -rf $temp_dir
#invoke lshw in chroot testdata/arch
chroot ./testdata/`arch` /usr/sbin/lshw -xml
This script lives in the lshw/ git checkout with the testdata directory currently as:
$ tree -L 2
.
└── x86_64
├── proc
├── sys
└── usr
So, basically I have a x86_64 directory and have a files in proc/, sys/ and of course the
lshw executable built in usr/sbin. As a result when run with this directory as root
, lshw reads from these files instead of the real system. It works.
However, with this approach I think the difficulty is to run tests for all archs (that we
have in testdata)
on any arch. That is, I cannot run test the functionality of lshw with arm test data on a
x86_64
system and vice-versa. The reason being, lshw uses compiler macros heavily during the
compilation process
and hence the lshw executable has to be built on the arch on which it is to be tested.
[1]
[1]
http://sourceforge.net/p/predef/wiki/Architectures/
Thoughts and suggestions?
Best,
Amit.
--
Amit Saha <
http://echorand.me>
Infrastructure Engineering and Development
Red Hat, Inc.