basetest.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import unittest
  2. import os
  3. import datetime
  4. from infra.builder import Builder
  5. from infra.emulator import Emulator
  6. BASIC_TOOLCHAIN_CONFIG = \
  7. """
  8. BR2_arm=y
  9. BR2_TOOLCHAIN_EXTERNAL=y
  10. BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
  11. BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
  12. BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-arm-full-2015.05-1190-g4a48479.tar.bz2"
  13. BR2_TOOLCHAIN_EXTERNAL_GCC_4_7=y
  14. BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_10=y
  15. BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
  16. # BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
  17. BR2_TOOLCHAIN_EXTERNAL_INET_RPC=y
  18. BR2_TOOLCHAIN_EXTERNAL_CXX=y
  19. """
  20. MINIMAL_CONFIG = \
  21. """
  22. BR2_INIT_NONE=y
  23. BR2_SYSTEM_BIN_SH_NONE=y
  24. # BR2_PACKAGE_BUSYBOX is not set
  25. # BR2_TARGET_ROOTFS_TAR is not set
  26. """
  27. class BRTest(unittest.TestCase):
  28. config = None
  29. downloaddir = None
  30. outputdir = None
  31. logtofile = True
  32. keepbuilds = False
  33. def show_msg(self, msg):
  34. print "[%s/%s/%s] %s" % (os.path.basename(self.__class__.outputdir),
  35. self.testname,
  36. datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
  37. msg)
  38. def setUp(self):
  39. self.testname = self.__class__.__name__
  40. self.builddir = os.path.join(self.__class__.outputdir, self.testname)
  41. self.runlog = self.builddir + "-run.log"
  42. self.emulator = None
  43. self.show_msg("Starting")
  44. self.b = Builder(self.__class__.config, self.builddir, self.logtofile)
  45. if not self.keepbuilds:
  46. self.b.delete()
  47. if not self.b.is_finished():
  48. self.show_msg("Building")
  49. self.b.build()
  50. self.show_msg("Building done")
  51. self.emulator = Emulator(self.builddir, self.downloaddir, self.logtofile)
  52. def tearDown(self):
  53. self.show_msg("Cleaning up")
  54. if self.emulator:
  55. self.emulator.stop()
  56. if self.b and not self.keepbuilds:
  57. self.b.delete()