Bug 1033466 - [rlImport] When run rlImport pkg/lib1 pkg/lib2, in lib2 can not find the function defined in lib1
Summary: [rlImport] When run rlImport pkg/lib1 pkg/lib2, in lib2 can not find the fu...
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Fedora
Classification: Fedora
Component: beakerlib
Version: 19
Hardware: All
OS: Linux
unspecified
urgent
Target Milestone: ---
Assignee: Petr Muller
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-11-22 07:28 UTC by JianHong Yin
Modified: 2016-09-20 02:10 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-02-18 15:07:52 UTC
Type: Bug


Attachments (Terms of Use)

Description JianHong Yin 2013-11-22 07:28:04 UTC
Description of problem:
When run "rlImport pkg/lib1 pkg/lib2", in lib2 can not find the function defined in lib1

But the follow usage works fine,
rlImport pkg/lib1
rlImport pkg/lib2

Version-Release number of selected component (if applicable):
beakerlib-1.8-1.fc19.noarch

How reproducible:
100%

Steps to Reproduce:
1. . /usr/share/beakerlib/beakerlib.sh
2. rlImport kernel/base  kernel/oldnfs
3.

Actual results:
[root@dhcp12-241 nfs-utils]# rlImport  kernel/base kernel/oldnfs
:: [ 15:19:43 ] :: [ INFO    ] :: rlImport: Found 'kernel/base' in /mnt/tests
:: [ 15:19:43 ] :: [ INFO    ] :: rlImport: Will try to import kernel/base from /mnt/tests/kernel/Library/base/lib.sh
:: [ 15:19:43 ] :: [ INFO    ] :: rlImport: Found 'kernel/oldnfs' in /mnt/tests
:: [ 15:19:43 ] :: [ INFO    ] :: rlImport: Will try to import kernel/oldnfs from /mnt/tests/kernel/Library/oldnfs/lib.sh
-bash: is_rhel5: command not found
-bash: is_rhel7: command not found
     these two is function defined in kernel/base

Expected results:
not error "command not found" happen.

Additional info:

Comment 1 JianHong Yin 2013-11-22 07:34:23 UTC
[root@dhcp12-241 oldnfs]# make run
test -x runtest.sh || chmod a+x runtest.sh
./runtest.sh

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: Setup
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [ 15:33:53 ] :: [ INFO    ] :: rlImport: Found 'kernel/base' in /mnt/tests
:: [ 15:33:53 ] :: [ INFO    ] :: rlImport: Will try to import kernel/base from /mnt/tests/kernel/Library/base/lib.sh
:: [ 15:33:53 ] :: [ INFO    ] :: rlImport: Found 'kernel/oldnfs' in /mnt/tests
:: [ 15:33:53 ] :: [ INFO    ] :: rlImport: Will try to import kernel/oldnfs from /mnt/tests/kernel/Library/oldnfs/lib.sh
/mnt/tests/kernel/Library/oldnfs/lib.sh: line 39: is_rhel5: command not found
/mnt/tests/kernel/Library/oldnfs/lib.sh: line 295: is_rhel7: command not found

Comment 2 Petr Muller 2013-12-02 15:57:58 UTC
Will look into it.

On a side note, you might be interested in the rlIsRHEL functions in BeakerLib which could help you with whatever you are doing in the is_rhelX functions.

Comment 5 Petr Muller 2014-02-18 15:07:52 UTC
I have looked into this, constructing the structure as follows:

==============================================
$ cat component/Library/basic/lib.sh:
# library-prefix = basic
basicLibraryLoaded() {}
basicLibraryFunction() {}

$ cat component/Library/use_basic/lib.sh
# library-prefix = use_basic
basicLibraryFunction # called when importing
use_basicLibraryLoaded() { basicLibraryFunction; } # called when import verified
use_basicLibraryFunction() { basicLibraryFunction; } # called when called from test

$ cat component/Sanity/dummy/runtest.sh
#!/usr/bin/bash

. /usr/share/beakerlib/beakerlib.sh

rlJournalStart
  rlPhaseStartSetup
    rlImport fakeroot/basic fakeroot/use_basic
    rlRun "use_basicLibraryFunction"
    rlRun "basicLibraryFunction"
  rlPhaseEnd
rlJournalEnd
==============================================

The important thing to note is that in this case, the component/Library/use_basic/Makefile file needs to declare 'RhtsRequires: library(component/basic)', or we do not know about the dependency. Then, simple 'rlImport component/use_basic' would work: and that is how it should work. We need to the dependency chain to be declared, so we can work with it.

If I do not have such Makefile in Library/use_basic, I observe results similar to yours. If I have it, the import works, and the functions too.

I have also looked at the kernel/Library/oldnfs lib, and I do not see the RhtsRequires there. Therefore, I'm closing this bug as the dependency resolving works for me. Please reopen if some part of my assessment is not correct.


Note You need to log in before you can comment on or make changes to this bug.