Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 1 | # |
| 2 | # SPDX-License-Identifier: MIT |
| 3 | # |
| 4 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 5 | import os |
| 6 | from tempfile import mkstemp |
| 7 | |
| 8 | from oeqa.runtime.case import OERuntimeTestCase |
| 9 | from oeqa.core.decorator.depends import OETestDepends |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 10 | from oeqa.runtime.decorator.package import OEHasPackage |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 11 | |
| 12 | class ScpTest(OERuntimeTestCase): |
| 13 | |
| 14 | @classmethod |
| 15 | def setUpClass(cls): |
| 16 | cls.tmp_fd, cls.tmp_path = mkstemp() |
| 17 | with os.fdopen(cls.tmp_fd, 'w') as f: |
| 18 | f.seek(2 ** 22 -1) |
| 19 | f.write(os.linesep) |
| 20 | |
| 21 | @classmethod |
| 22 | def tearDownClass(cls): |
| 23 | os.remove(cls.tmp_path) |
| 24 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 25 | @OETestDepends(['ssh.SSHTest.test_ssh']) |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 26 | @OEHasPackage(['openssh-scp', 'dropbear']) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 27 | def test_scp_file(self): |
| 28 | dst = '/tmp/test_scp_file' |
| 29 | |
| 30 | (status, output) = self.target.copyTo(self.tmp_path, dst) |
| 31 | msg = 'File could not be copied. Output: %s' % output |
| 32 | self.assertEqual(status, 0, msg=msg) |
| 33 | |
| 34 | (status, output) = self.target.run('ls -la %s' % dst) |
| 35 | self.assertEqual(status, 0, msg = 'SCP test failed') |
| 36 | |
| 37 | self.target.run('rm %s' % dst) |