basetest.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. jlevel = 0
  34. timeout_multiplier = 1
  35. def __init__(self, names):
  36. super(BRTest, self).__init__(names)
  37. self.testname = self.__class__.__name__
  38. self.builddir = self.outputdir and os.path.join(self.outputdir, self.testname)
  39. self.emulator = None
  40. self.config += "\nBR2_JLEVEL={}\n".format(self.jlevel)
  41. def show_msg(self, msg):
  42. print "{} {:40s} {}".format(datetime.datetime.now().strftime("%H:%M:%S"),
  43. self.testname, msg)
  44. def setUp(self):
  45. self.show_msg("Starting")
  46. self.b = Builder(self.config, self.builddir, self.logtofile)
  47. if not self.keepbuilds:
  48. self.b.delete()
  49. if not self.b.is_finished():
  50. self.show_msg("Building")
  51. self.b.build()
  52. self.show_msg("Building done")
  53. self.emulator = Emulator(self.builddir, self.downloaddir,
  54. self.logtofile, self.timeout_multiplier)
  55. def tearDown(self):
  56. self.show_msg("Cleaning up")
  57. if self.emulator:
  58. self.emulator.stop()
  59. if self.b and not self.keepbuilds:
  60. self.b.delete()