11from oeqa .selftest .systemupdate .systemupdatebase import SystemUpdateBase
22
3- from oeqa .utils .commands import runqemu , get_bb_var
3+ from oeqa .utils .commands import runqemu , get_bb_vars
44
55import errno
66import http .server
@@ -26,6 +26,15 @@ class RefkitOSTreeUpdateBase(SystemUpdateBase):
2626 # slirp network.
2727 OSTREE_SERVER = '10.0.2.100:8080'
2828
29+ # Global variables are the same for all recipes,
30+ # but RECIPE_SYSROOT_NATIVE is specific to socat-native.
31+ BB_VARS = get_bb_vars ([
32+ 'DEPLOY_DIR' ,
33+ 'MACHINE' ,
34+ 'RECIPE_SYSROOT_NATIVE' ,
35+ ],
36+ 'socat-native' )
37+
2938 def track_for_cleanup (self , name ):
3039 """
3140 Run a single test with NO_CLEANUP=<anything> oe-selftest to not clean up after the test.
@@ -47,7 +56,7 @@ def boot_image(self, overrides):
4756 self .track_for_cleanup (self .ostree_netcat .name )
4857
4958 qemuboot_conf = os .path .join (self .image_dir_test ,
50- '%s-%s.qemuboot.conf' % (self .IMAGE_PN , get_bb_var ( 'MACHINE' ) ))
59+ '%s-%s.qemuboot.conf' % (self .IMAGE_PN , self . BB_VARS [ 'MACHINE' ] ))
5160 with open (qemuboot_conf ) as f :
5261 conf = f .read ()
5362 with open (qemuboot_conf , 'w' ) as f :
@@ -66,7 +75,7 @@ def update_image(self, qemu):
6675 # image here, so we just assume that it is in the usual place.
6776 # For the sake of simplicity we change into that directory
6877 # because then we can use SimpleHTTPRequestHandler.
69- ostree_repo = os .path .join (get_bb_var ( 'DEPLOY_DIR' ) , 'ostree-repo' )
78+ ostree_repo = os .path .join (self . BB_VARS [ 'DEPLOY_DIR' ] , 'ostree-repo' )
7079 old_cwd = os .getcwd ()
7180 server = None
7281 try :
@@ -93,11 +102,16 @@ def create_httpd():
93102 self .logger .info ('serving OSTree repo %s on port %d' % (ostree_repo , port ))
94103 helper = threading .Thread (name = 'OSTree HTTPD' , target = server .serve_forever )
95104 helper .start ()
105+ # netcat can't be assumed to be present. Build and use socat instead.
106+ # It's a bit more complicated but has the advantage that it is in OE-core.
107+ socat = os .path .join (self .BB_VARS ['RECIPE_SYSROOT_NATIVE' ], 'usr' , 'bin' , 'socat' )
108+ if not os .path .exists (socat ):
109+ bitbake ('socat-native:do_addto_recipe_sysroot' , output_logger = self .logger )
110+ self .assertExists (socat , 'socat-native was not built as expected' )
96111 with open (self .ostree_netcat .name , 'w' ) as f :
97112 f .write ('''#!/bin/sh
98- exec netcat 2>>/tmp/ostree.log localhost 9999
99- #exec socat 2>>/tmp/ostree.log -D -v -d -d -d -d STDIO TCP:localhost:%d
100- ''' % port )
113+ exec %s 2>>/tmp/ostree.log -D -v -d -d -d -d STDIO TCP:localhost:%d
114+ ''' % (socat , port ))
101115
102116 cmd = '''ostree config set 'remote "updates".url' http://%s && refkit-ostree update''' % self .OSTREE_SERVER
103117 status , output = qemu .run_serial (cmd , timeout = 600 )
0 commit comments