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