scp.py 1003 B

123456789101112131415161718192021222324252627282930313233
  1. import os
  2. from tempfile import mkstemp
  3. from oeqa.runtime.case import OERuntimeTestCase
  4. from oeqa.core.decorator.depends import OETestDepends
  5. from oeqa.runtime.decorator.package import OEHasPackage
  6. class ScpTest(OERuntimeTestCase):
  7. @classmethod
  8. def setUpClass(cls):
  9. cls.tmp_fd, cls.tmp_path = mkstemp()
  10. with os.fdopen(cls.tmp_fd, 'w') as f:
  11. f.seek(2 ** 22 -1)
  12. f.write(os.linesep)
  13. @classmethod
  14. def tearDownClass(cls):
  15. os.remove(cls.tmp_path)
  16. @OETestDepends(['ssh.SSHTest.test_ssh'])
  17. @OEHasPackage(['openssh-scp', 'dropbear'])
  18. def test_scp_file(self):
  19. dst = '/tmp/test_scp_file'
  20. (status, output) = self.target.copyTo(self.tmp_path, dst)
  21. msg = 'File could not be copied. Output: %s' % output
  22. self.assertEqual(status, 0, msg=msg)
  23. (status, output) = self.target.run('ls -la %s' % dst)
  24. self.assertEqual(status, 0, msg = 'SCP test failed')
  25. self.target.run('rm %s' % dst)