1c342db35SBrad Bishop#
2*92b42cb3SPatrick Williams# Copyright OpenEmbedded Contributors
3*92b42cb3SPatrick Williams#
4c342db35SBrad Bishop# SPDX-License-Identifier: MIT
5c342db35SBrad Bishop#
6c342db35SBrad Bishop
7eb8dc403SDave Cobbleyimport os
8eb8dc403SDave Cobbleyfrom tempfile import mkstemp
9eb8dc403SDave Cobbley
10eb8dc403SDave Cobbleyfrom oeqa.runtime.case import OERuntimeTestCase
11eb8dc403SDave Cobbleyfrom oeqa.core.decorator.depends import OETestDepends
12977dc1acSBrad Bishopfrom oeqa.runtime.decorator.package import OEHasPackage
13eb8dc403SDave Cobbley
14eb8dc403SDave Cobbleyclass ScpTest(OERuntimeTestCase):
15eb8dc403SDave Cobbley
16eb8dc403SDave Cobbley    @classmethod
17eb8dc403SDave Cobbley    def setUpClass(cls):
18eb8dc403SDave Cobbley        cls.tmp_fd, cls.tmp_path = mkstemp()
19eb8dc403SDave Cobbley        with os.fdopen(cls.tmp_fd, 'w') as f:
20eb8dc403SDave Cobbley            f.seek(2 ** 22 -1)
21eb8dc403SDave Cobbley            f.write(os.linesep)
22eb8dc403SDave Cobbley
23eb8dc403SDave Cobbley    @classmethod
24eb8dc403SDave Cobbley    def tearDownClass(cls):
25eb8dc403SDave Cobbley        os.remove(cls.tmp_path)
26eb8dc403SDave Cobbley
27eb8dc403SDave Cobbley    @OETestDepends(['ssh.SSHTest.test_ssh'])
28615f2f11SAndrew Geissler    @OEHasPackage(['openssh-scp'])
29eb8dc403SDave Cobbley    def test_scp_file(self):
30eb8dc403SDave Cobbley        dst = '/tmp/test_scp_file'
31eb8dc403SDave Cobbley
32eb8dc403SDave Cobbley        (status, output) = self.target.copyTo(self.tmp_path, dst)
33eb8dc403SDave Cobbley        msg = 'File could not be copied. Output: %s' % output
34eb8dc403SDave Cobbley        self.assertEqual(status, 0, msg=msg)
35eb8dc403SDave Cobbley
36eb8dc403SDave Cobbley        (status, output) = self.target.run('ls -la %s' % dst)
37eb8dc403SDave Cobbley        self.assertEqual(status, 0, msg = 'SCP test failed')
38eb8dc403SDave Cobbley
39eb8dc403SDave Cobbley        self.target.run('rm %s' % dst)
40