3 ##############################################################################
4 # Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
12 # Unittest for yardstick.benchmark.scenarios.compute.spec_cpu.SpecCPU
14 from __future__ import absolute_import
20 from yardstick.benchmark.scenarios.compute import spec_cpu
23 @mock.patch('yardstick.benchmark.scenarios.compute.spec_cpu.ssh')
24 class SpecCPUTestCase(unittest.TestCase):
31 'key_filename': "mykey.key"
37 def test_spec_cpu_successful_setup(self, mock_ssh):
40 "SPECint_benchmark": "perlbench",
41 "output_format": "all",
42 "runspec_iterations": "1",
43 "runspec_tune": "base",
44 "runspec_size": "test"
46 args = {"options": options}
47 s = spec_cpu.SpecCPU(args, self.ctx)
48 mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
51 self.assertIsNotNone(s.client)
52 self.assertTrue(s.setup_done, True)
54 def test_spec_cpu_successful__run_no_sla(self, mock_ssh):
57 "SPECint_benchmark": "perlbench",
58 "runspec_tune": "all",
59 "output_format": "all"
61 args = {"options": options}
62 s = spec_cpu.SpecCPU(args, self.ctx)
64 mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
67 self.assertEqual(self.result, expected_result)
69 def test_ramspeed_unsuccessful_script_error(self, mock_ssh):
71 "benchmark_subset": "int"
73 args = {"options": options}
74 s = spec_cpu.SpecCPU(args, self.ctx)
76 mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
77 self.assertRaises(RuntimeError, s.run, self.result)
84 if __name__ == '__main__':