1 ##############################################################################
2 # Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
10 # Unittest for yardstick.benchmark.scenarios.compute.spec_cpu.SpecCPU
12 from __future__ import absolute_import
18 from yardstick.benchmark.scenarios.compute import spec_cpu
21 @mock.patch('yardstick.benchmark.scenarios.compute.spec_cpu.ssh')
22 class SpecCPUTestCase(unittest.TestCase):
29 'key_filename': "mykey.key"
35 def test_spec_cpu_successful_setup(self, mock_ssh):
38 "SPECint_benchmark": "perlbench",
39 "output_format": "all",
40 "runspec_iterations": "1",
41 "runspec_tune": "base",
42 "runspec_size": "test"
44 args = {"options": options}
45 s = spec_cpu.SpecCPU(args, self.ctx)
46 mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
49 self.assertIsNotNone(s.client)
50 self.assertTrue(s.setup_done, True)
52 def test_spec_cpu_successful__run_no_sla(self, mock_ssh):
55 "SPECint_benchmark": "perlbench",
56 "runspec_tune": "all",
57 "output_format": "all"
59 args = {"options": options}
60 s = spec_cpu.SpecCPU(args, self.ctx)
62 mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
65 self.assertEqual(self.result, expected_result)
67 def test_ramspeed_unsuccessful_script_error(self, mock_ssh):
69 "benchmark_subset": "int"
71 args = {"options": options}
72 s = spec_cpu.SpecCPU(args, self.ctx)
74 mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR')
75 self.assertRaises(RuntimeError, s.run, self.result)