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.common import utils
21 from yardstick.benchmark.scenarios.compute import spec_cpu
24 @mock.patch('yardstick.benchmark.scenarios.compute.spec_cpu.ssh')
25 class SpecCPUTestCase(unittest.TestCase):
32 'key_filename': "mykey.key"
38 def test_spec_cpu_successful_setup(self, mock_ssh):
41 "SPECint_benchmark": "perlbench",
42 "runspec_tune": "all",
43 "output_format": "all",
44 "runspec_iterations": "1",
45 "runspec_tune": "base",
46 "runspec_size": "test"
48 args = {"options": options}
49 s = spec_cpu.SpecCPU(args, self.ctx)
50 mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
53 self.assertIsNotNone(s.client)
54 self.assertTrue(s.setup_done, True)
56 def test_spec_cpu_successful__run_no_sla(self, mock_ssh):
59 "SPECint_benchmark": "perlbench",
60 "runspec_tune": "all",
61 "output_format": "all"
63 args = {"options": options}
64 s = spec_cpu.SpecCPU(args, self.ctx)
67 mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
70 self.assertEqual(self.result, expected_result)
72 def test_ramspeed_unsuccessful_script_error(self, mock_ssh):
74 "benchmark_subset": "int"
76 args = {"options": options}
77 s = spec_cpu.SpecCPU(args, self.ctx)
79 mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
80 self.assertRaises(RuntimeError, s.run, self.result)
85 if __name__ == '__main__':