Hi

I try to figure out a batter way to integrate test binaries with it's deps.
For example 'fio' depends on 'libaio' and it's code looks like follows:
setup():
        # Manually define 
        self.job.setup_dep(['libaio'])
        ldflags = '-L' + self.autodir + '/deps/libaio/lib'
        cflags = '-I' + self.autodir + '/deps/libaio/include'
        var_ldflags = 'LDFLAGS="' + ldflags + '"'
        var_cflags = 'CFLAGS="' + cflags + '"'
        utils.system('%s %s make' % (var_ldflags, var_cflags))

run_once():
        env_vars = 'LD_LIBRARY_PATH="' + self.autodir + '/deps/libaio/lib"'
        utils.system(env_vars + ' ./fio ')

This coding style is error prone for number of reasons:
1) Each test define compilation and execution environment which
   result in massive code duplication
2) There are not obvious way to manually run binary (during test debug phase)
   one can easily forget to pass valid LD_PRELOAD env.

First can be fixed by introducing conception of dependency object which
has various attributes such as:  src_path, lib_path, inc_path and etc,
test can easily use this variables by using generic helpers:
list)

def install_dep(test, dep_name):
    d = setup_dep(dep_name)
    test.dep.append(d)
    test.lib_path.append(d.lib_path)
    test.include_path.append(d.include_path)

In order to fix (2) one may think of two different ways 
A) Compile all libs and binaries as static
B) Create wrapper with valid environment variables, for example:
prep:
   echo "LD_LIBRARY_PATH=XXX; my_binary.bin $@" > my_binary
   chmod +x my_binary
run_once:
   ./my_binary $ARGS

   This approach encapsulate all environment information inside helper binary
   and provide convenient way to use this binary from autotest and
   during debugging phase.

(A) it very simple and reliable but not suitable for all cases, from
other view (B) is more flexible, but it means that we have to prepare
wrapper for each binary, is not very good for test which has a lot binaries
for example 'xfstests'

Please tell me what you do you think?

BTW: AFAIK Avocado has no dependency system yet. Are there any ideas
about future deps design?

Attachment: pgpbiyeZF5Jvf.pgp
Description: PGP signature

_______________________________________________
Autotest-kernel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/autotest-kernel

Reply via email to