diff options
Diffstat (limited to 'bitbake/lib/toaster/tests/builds')
-rw-r--r-- | bitbake/lib/toaster/tests/builds/buildtest.py | 110 |
1 files changed, 56 insertions, 54 deletions
diff --git a/bitbake/lib/toaster/tests/builds/buildtest.py b/bitbake/lib/toaster/tests/builds/buildtest.py index bf147f09e5..5a56a110a7 100644 --- a/bitbake/lib/toaster/tests/builds/buildtest.py +++ b/bitbake/lib/toaster/tests/builds/buildtest.py | |||
@@ -41,6 +41,61 @@ logger = logging.getLogger("toaster") | |||
41 | # want to wrap everything in a database transaction as an external process | 41 | # want to wrap everything in a database transaction as an external process |
42 | # (bitbake needs access to the database) | 42 | # (bitbake needs access to the database) |
43 | 43 | ||
44 | def load_build_environment(): | ||
45 | call_command('loaddata', 'settings.xml', app_label="orm") | ||
46 | call_command('loaddata', 'poky.xml', app_label="orm") | ||
47 | |||
48 | current_builddir = os.environ.get("BUILDDIR") | ||
49 | if current_builddir: | ||
50 | BuildTest.BUILDDIR = current_builddir | ||
51 | else: | ||
52 | # Setup a builddir based on default layout | ||
53 | # bitbake inside openebedded-core | ||
54 | oe_init_build_env_path = os.path.join( | ||
55 | os.path.dirname(os.path.abspath(__file__)), | ||
56 | os.pardir, | ||
57 | os.pardir, | ||
58 | os.pardir, | ||
59 | os.pardir, | ||
60 | os.pardir, | ||
61 | 'oe-init-build-env' | ||
62 | ) | ||
63 | if not os.path.exists(oe_init_build_env_path): | ||
64 | raise Exception("We had no BUILDDIR set and couldn't " | ||
65 | "find oe-init-build-env to set this up " | ||
66 | "ourselves please run oe-init-build-env " | ||
67 | "before running these tests") | ||
68 | |||
69 | oe_init_build_env_path = os.path.realpath(oe_init_build_env_path) | ||
70 | cmd = "bash -c 'source oe-init-build-env %s'" % BuildTest.BUILDDIR | ||
71 | p = subprocess.Popen( | ||
72 | cmd, | ||
73 | cwd=os.path.dirname(oe_init_build_env_path), | ||
74 | shell=True, | ||
75 | stdout=subprocess.PIPE, | ||
76 | stderr=subprocess.PIPE) | ||
77 | |||
78 | output, err = p.communicate() | ||
79 | p.wait() | ||
80 | |||
81 | logger.info("oe-init-build-env %s %s" % (output, err)) | ||
82 | |||
83 | os.environ['BUILDDIR'] = BuildTest.BUILDDIR | ||
84 | |||
85 | # Setup the path to bitbake we know where to find this | ||
86 | bitbake_path = os.path.join( | ||
87 | os.path.dirname(os.path.abspath(__file__)), | ||
88 | os.pardir, | ||
89 | os.pardir, | ||
90 | os.pardir, | ||
91 | os.pardir, | ||
92 | 'bin', | ||
93 | 'bitbake') | ||
94 | if not os.path.exists(bitbake_path): | ||
95 | raise Exception("Could not find bitbake at the expected path %s" | ||
96 | % bitbake_path) | ||
97 | |||
98 | os.environ['BBBASEDIR'] = bitbake_path | ||
44 | 99 | ||
45 | class BuildTest(unittest.TestCase): | 100 | class BuildTest(unittest.TestCase): |
46 | 101 | ||
@@ -59,60 +114,7 @@ class BuildTest(unittest.TestCase): | |||
59 | if built: | 114 | if built: |
60 | return built | 115 | return built |
61 | 116 | ||
62 | call_command('loaddata', 'settings.xml', app_label="orm") | 117 | load_build_environment() |
63 | call_command('loaddata', 'poky.xml', app_label="orm") | ||
64 | |||
65 | current_builddir = os.environ.get("BUILDDIR") | ||
66 | if current_builddir: | ||
67 | BuildTest.BUILDDIR = current_builddir | ||
68 | else: | ||
69 | # Setup a builddir based on default layout | ||
70 | # bitbake inside openebedded-core | ||
71 | oe_init_build_env_path = os.path.join( | ||
72 | os.path.dirname(os.path.abspath(__file__)), | ||
73 | os.pardir, | ||
74 | os.pardir, | ||
75 | os.pardir, | ||
76 | os.pardir, | ||
77 | os.pardir, | ||
78 | 'oe-init-build-env' | ||
79 | ) | ||
80 | if not os.path.exists(oe_init_build_env_path): | ||
81 | raise Exception("We had no BUILDDIR set and couldn't " | ||
82 | "find oe-init-build-env to set this up " | ||
83 | "ourselves please run oe-init-build-env " | ||
84 | "before running these tests") | ||
85 | |||
86 | oe_init_build_env_path = os.path.realpath(oe_init_build_env_path) | ||
87 | cmd = "bash -c 'source oe-init-build-env %s'" % BuildTest.BUILDDIR | ||
88 | p = subprocess.Popen( | ||
89 | cmd, | ||
90 | cwd=os.path.dirname(oe_init_build_env_path), | ||
91 | shell=True, | ||
92 | stdout=subprocess.PIPE, | ||
93 | stderr=subprocess.PIPE) | ||
94 | |||
95 | output, err = p.communicate() | ||
96 | p.wait() | ||
97 | |||
98 | logger.info("oe-init-build-env %s %s" % (output, err)) | ||
99 | |||
100 | os.environ['BUILDDIR'] = BuildTest.BUILDDIR | ||
101 | |||
102 | # Setup the path to bitbake we know where to find this | ||
103 | bitbake_path = os.path.join( | ||
104 | os.path.dirname(os.path.abspath(__file__)), | ||
105 | os.pardir, | ||
106 | os.pardir, | ||
107 | os.pardir, | ||
108 | os.pardir, | ||
109 | 'bin', | ||
110 | 'bitbake') | ||
111 | if not os.path.exists(bitbake_path): | ||
112 | raise Exception("Could not find bitbake at the expected path %s" | ||
113 | % bitbake_path) | ||
114 | |||
115 | os.environ['BBBASEDIR'] = bitbake_path | ||
116 | 118 | ||
117 | BuildEnvironment.objects.get_or_create( | 119 | BuildEnvironment.objects.get_or_create( |
118 | betype=BuildEnvironment.TYPE_LOCAL, | 120 | betype=BuildEnvironment.TYPE_LOCAL, |