gcc.py 2.3 KB

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