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
7
8class ScpTest(OERuntimeTestCase):
9
10    @classmethod
11    def setUpClass(cls):
12        cls.tmp_fd, cls.tmp_path = mkstemp()
13        with os.fdopen(cls.tmp_fd, 'w') as f:
14            f.seek(2 ** 22 -1)
15            f.write(os.linesep)
16
17    @classmethod
18    def tearDownClass(cls):
19        os.remove(cls.tmp_path)
20
21    @OETestID(220)
22    @OETestDepends(['ssh.SSHTest.test_ssh'])
23    def test_scp_file(self):
24        dst = '/tmp/test_scp_file'
25
26        (status, output) = self.target.copyTo(self.tmp_path, dst)
27        msg = 'File could not be copied. Output: %s' % output
28        self.assertEqual(status, 0, msg=msg)
29
30        (status, output) = self.target.run('ls -la %s' % dst)
31        self.assertEqual(status, 0, msg = 'SCP test failed')
32
33        self.target.run('rm %s' % dst)
34