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