diff options
Diffstat (limited to 'bitbake/lib/bb/tests/parse.py')
| -rw-r--r-- | bitbake/lib/bb/tests/parse.py | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/parse.py b/bitbake/lib/bb/tests/parse.py index 304bbbe222..72d1962e7e 100644 --- a/bitbake/lib/bb/tests/parse.py +++ b/bitbake/lib/bb/tests/parse.py | |||
| @@ -243,3 +243,101 @@ unset A[flag@.service] | |||
| 243 | with self.assertRaises(bb.parse.ParseError): | 243 | with self.assertRaises(bb.parse.ParseError): |
| 244 | d = bb.parse.handle(f.name, self.d)[''] | 244 | d = bb.parse.handle(f.name, self.d)[''] |
| 245 | 245 | ||
| 246 | export_function_recipe = """ | ||
| 247 | inherit someclass | ||
| 248 | """ | ||
| 249 | |||
| 250 | export_function_recipe2 = """ | ||
| 251 | inherit someclass | ||
| 252 | |||
| 253 | do_compile () { | ||
| 254 | false | ||
| 255 | } | ||
| 256 | |||
| 257 | python do_compilepython () { | ||
| 258 | bb.note("Something else") | ||
| 259 | } | ||
| 260 | |||
| 261 | """ | ||
| 262 | export_function_class = """ | ||
| 263 | someclass_do_compile() { | ||
| 264 | true | ||
| 265 | } | ||
| 266 | |||
| 267 | python someclass_do_compilepython () { | ||
| 268 | bb.note("Something") | ||
| 269 | } | ||
| 270 | |||
| 271 | EXPORT_FUNCTIONS do_compile do_compilepython | ||
| 272 | """ | ||
| 273 | |||
| 274 | export_function_class2 = """ | ||
| 275 | secondclass_do_compile() { | ||
| 276 | true | ||
| 277 | } | ||
| 278 | |||
| 279 | python secondclass_do_compilepython () { | ||
| 280 | bb.note("Something") | ||
| 281 | } | ||
| 282 | |||
| 283 | EXPORT_FUNCTIONS do_compile do_compilepython | ||
| 284 | """ | ||
| 285 | |||
| 286 | def test_parse_export_functions(self): | ||
| 287 | def check_function_flags(d): | ||
| 288 | self.assertEqual(d.getVarFlag("do_compile", "func"), 1) | ||
| 289 | self.assertEqual(d.getVarFlag("do_compilepython", "func"), 1) | ||
| 290 | self.assertEqual(d.getVarFlag("do_compile", "python"), None) | ||
| 291 | self.assertEqual(d.getVarFlag("do_compilepython", "python"), "1") | ||
| 292 | |||
| 293 | with tempfile.TemporaryDirectory() as tempdir: | ||
| 294 | self.d.setVar("__bbclasstype", "recipe") | ||
| 295 | recipename = tempdir + "/recipe.bb" | ||
| 296 | os.makedirs(tempdir + "/classes") | ||
| 297 | with open(tempdir + "/classes/someclass.bbclass", "w") as f: | ||
| 298 | f.write(self.export_function_class) | ||
| 299 | f.flush() | ||
| 300 | with open(tempdir + "/classes/secondclass.bbclass", "w") as f: | ||
| 301 | f.write(self.export_function_class2) | ||
| 302 | f.flush() | ||
| 303 | |||
| 304 | with open(recipename, "w") as f: | ||
| 305 | f.write(self.export_function_recipe) | ||
| 306 | f.flush() | ||
| 307 | os.chdir(tempdir) | ||
| 308 | d = bb.parse.handle(recipename, bb.data.createCopy(self.d))[''] | ||
| 309 | self.assertIn("someclass_do_compile", d.getVar("do_compile")) | ||
| 310 | self.assertIn("someclass_do_compilepython", d.getVar("do_compilepython")) | ||
| 311 | check_function_flags(d) | ||
| 312 | |||
| 313 | recipename2 = tempdir + "/recipe2.bb" | ||
| 314 | with open(recipename2, "w") as f: | ||
| 315 | f.write(self.export_function_recipe2) | ||
| 316 | f.flush() | ||
| 317 | |||
| 318 | d = bb.parse.handle(recipename2, bb.data.createCopy(self.d))[''] | ||
| 319 | self.assertNotIn("someclass_do_compile", d.getVar("do_compile")) | ||
| 320 | self.assertNotIn("someclass_do_compilepython", d.getVar("do_compilepython")) | ||
| 321 | self.assertIn("false", d.getVar("do_compile")) | ||
| 322 | self.assertIn("else", d.getVar("do_compilepython")) | ||
| 323 | check_function_flags(d) | ||
| 324 | |||
| 325 | with open(recipename, "a+") as f: | ||
| 326 | f.write("\ninherit secondclass\n") | ||
| 327 | f.flush() | ||
| 328 | with open(recipename2, "a+") as f: | ||
| 329 | f.write("\ninherit secondclass\n") | ||
| 330 | f.flush() | ||
| 331 | |||
| 332 | d = bb.parse.handle(recipename, bb.data.createCopy(self.d))[''] | ||
| 333 | self.assertIn("secondclass_do_compile", d.getVar("do_compile")) | ||
| 334 | self.assertIn("secondclass_do_compilepython", d.getVar("do_compilepython")) | ||
| 335 | check_function_flags(d) | ||
| 336 | |||
| 337 | d = bb.parse.handle(recipename2, bb.data.createCopy(self.d))[''] | ||
| 338 | self.assertNotIn("someclass_do_compile", d.getVar("do_compile")) | ||
| 339 | self.assertNotIn("someclass_do_compilepython", d.getVar("do_compilepython")) | ||
| 340 | self.assertIn("false", d.getVar("do_compile")) | ||
| 341 | self.assertIn("else", d.getVar("do_compilepython")) | ||
| 342 | check_function_flags(d) | ||
| 343 | |||
