gcc.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #
  2. # SPDX-License-Identifier: MIT
  3. #
  4. import os
  5. from oeqa.runtime.case import OERuntimeTestCase
  6. from oeqa.core.decorator.depends import OETestDepends
  7. from oeqa.runtime.decorator.package import OEHasPackage
  8. class GccCompileTest(OERuntimeTestCase):
  9. @classmethod
  10. def setUp(cls):
  11. dst = '/tmp/'
  12. src = os.path.join(cls.tc.files_dir, 'test.c')
  13. cls.tc.target.copyTo(src, dst)
  14. src = os.path.join(cls.tc.runtime_files_dir, 'testmakefile')
  15. cls.tc.target.copyTo(src, dst)
  16. src = os.path.join(cls.tc.files_dir, 'test.cpp')
  17. cls.tc.target.copyTo(src, dst)
  18. @classmethod
  19. def tearDown(cls):
  20. files = '/tmp/test.c /tmp/test.o /tmp/test /tmp/testmakefile'
  21. cls.tc.target.run('rm %s' % files)
  22. @OETestDepends(['ssh.SSHTest.test_ssh'])
  23. @OEHasPackage(['gcc'])
  24. def test_gcc_compile(self):
  25. status, output = self.target.run('gcc /tmp/test.c -o /tmp/test -lm')
  26. msg = 'gcc compile failed, output: %s' % output
  27. self.assertEqual(status, 0, msg=msg)
  28. status, output = self.target.run('/tmp/test')
  29. msg = 'running compiled file failed, output: %s' % output
  30. self.assertEqual(status, 0, msg=msg)
  31. @OETestDepends(['ssh.SSHTest.test_ssh'])
  32. @OEHasPackage(['g++'])
  33. def test_gpp_compile(self):
  34. status, output = self.target.run('g++ /tmp/test.c -o /tmp/test -lm')
  35. msg = 'g++ compile failed, output: %s' % output
  36. self.assertEqual(status, 0, msg=msg)
  37. status, output = self.target.run('/tmp/test')
  38. msg = 'running compiled file failed, output: %s' % output
  39. self.assertEqual(status, 0, msg=msg)
  40. @OETestDepends(['ssh.SSHTest.test_ssh'])
  41. @OEHasPackage(['g++'])
  42. def test_gpp2_compile(self):
  43. status, output = self.target.run('g++ /tmp/test.cpp -o /tmp/test -lm')
  44. msg = 'g++ compile failed, output: %s' % output
  45. self.assertEqual(status, 0, msg=msg)
  46. status, output = self.target.run('/tmp/test')
  47. msg = 'running compiled file failed, output: %s' % output
  48. self.assertEqual(status, 0, msg=msg)
  49. @OETestDepends(['ssh.SSHTest.test_ssh'])
  50. @OEHasPackage(['gcc'])
  51. @OEHasPackage(['make'])
  52. def test_make(self):
  53. status, output = self.target.run('cd /tmp; make -f testmakefile')
  54. msg = 'running make failed, output %s' % output
  55. self.assertEqual(status, 0, msg=msg)