[tbot] [Discussion] Calling tbot from within the source directory
Heiko Schocher
hs at denx.de
Thu Nov 29 10:09:05 UTC 2018
Hello Claudius,
Am 29.11.2018 um 10:41 schrieb Claudius Heine:
> Quoting Claudius Heine (2018-11-29 10:20:43)
>> Hi Harald,
>>
>> Quoting Harald Seiler (2018-11-29 10:01:34)
>>>>> then you could use the current working directory in your testcases, so
>>>>> you would not need an additional parameter or environment variable to
>>>>> point the the source-tree if you want to avoid having the path to it
>>>>> inside the testcases.
>>>>>
>>>>> I hope I made myself understandable, but I basically I would like to
>>>>> kill multiple birds with one stone:
>>>>>
>>>>> 1. Make calling tbot from outside the tbot configuration directory
>>>>> easier.
>>>>> 2. Make it possible to use cwd inside testcases to point to the
>>>>> source-tree -> make it easier to reuse/share testcases because they
>>>>> would not need to contain the path to the source tree anymore.
>>>>
>>>> I can just imagine that you need, but if you could draft a simple real
>>>> testcase here, it is easier to understand the reasons.
>>>
>>> I think I can see what Claudius is on about here. The thing is, you
>>> shouldn't use `cwd` in your testcases, because it doesn't honor the specified
>>> lab. Instead you should use `lh.workdir`, which is a proper tbot path
>>> and it's value should be defined in the lab-config.
>>
>> Ok, I think I get you here. You cannot do that, since the source/build
>> products might be somewhere else, not on the machine running tbot.
Yes, of course this is possible with tbot ... I build on hercules in
ubuntu 16.04 container, while my board is connected to a lab host (raspberry pi)
and starting tbot on my PC ...
>> But I would also argue that the path to a specific project is not a lab
>> or testcase configuration. It should be part of the user and project specific one.
>>
>> So I think I currently don't know enough about tbot to know where to
>> best put this kind of configuration. Maybe we have to implement some
>> sort of configuration file support in tbot then.
>
> Just a suggestion from me, calling tbot like this:
>
> tbot -c config.ini my-testcase
>
> Where the ini file would contain something like this:
>
> [tbot]
> verbose=2
> cwd=/home/user/work/tbot/tbot-myproduct
> lab=lab/my-lab.py
> board=board/my-board.py
> flags=flag1 flag2
> testcase=my-default-testcase
>
> [project]
> sources=work/source/my-project-source
> outdir=work/source/my-project-source/out
> nfsdir=/srv/nfs/my-project/user/
> tftpdir=/srv/tftp/my-project/user/
>
> What do you think?
I do not like this approach with ini files... trust me, I had such
config files in the old approach, and it was just a mess ...
You can define for example the workdir from your lab with:
class Tbot2goLab(lab.SSHLabHost, linux.BuildMachine):
name = "tbot2go"
hostname = "192.168.1.110"
username = "pi"
@property
def workdir(self) -> "linux.path.Path[Tbot2goLab]":
return linux.Workdir.static(self, f"/work/{self.username}/tbot-workdir")
I added here, a "yocto result dir", where I store build artifacts from
a yocto build (for example on hercules in ubuntu 16.04 container)
@property
def yocto_result_dir(self) -> "linux.path.Path[Tbot2goLab]":
return linux.Workdir.static(self, f"/srv/tftpboot/" + tbot.selectable.Board.name +
"/tbot/yocto_results")
Also I defined a build machine (hercules ubuntu 16.04 container)
I can access from my labhost.
class Hercules1604SSH(linux.SSHMachine, linux.BuildMachine):
name = "hercules-1604"
hostname = "hercules"
username = "hs"
port = 11604
@property
def ssh_config(self) -> typing.List[str]:
return [f"ProxyJump={self.username}@pollux.denx.org,hs at hercules"]
@property
def authenticator(self) -> linux.auth.Authenticator:
return linux.auth.PrivateKeyAuthenticator(
pathlib.PurePosixPath("/home") / "pi" / ".ssh" / "id_rsa"
)
@property
def workdir(self) -> "linux.Path[HerculesSSH]":
return linux.Workdir.static(self, f"/work/{self.username}/tbot")
So I have access to a workdir in the hercules ubuntu16.04 container and
workdir on the lab host ...
now you can use shell.copy() to transfer files between them in your testcase.py
y_result_files = [
"cuby-image-h03pl086-rootfs-h03pl086-sd.img",
"cuby-image-h03pl086.swu",
"u-boot-h03pl086.imx-qspi",
]
@tbot.testcase
def XXX_copy_to_lab(
lab: typing.Optional[linux.LabHost] = None,
build = None
) -> None:
with lab or tbot.acquire_lab() as lh:
with build or lh.build() as bh:
for f in y_result_files:
s = bh.workdir_dir / f
t = lh.workdir_dir / f
tbot.tc.shell.copy(s, t)
Also you can define in the respective class nfsdir, tftpdir ... and copy
files to them ...
All this is defined in your lab config py file.... no need for a ini file ...
I am sure Harald knows a better method than I describe :-P
bye,
Heiko
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
More information about the tbot
mailing list