Exemplo n.º 1
0
def test_run_withresourcedir(mocker):
    """ docstring """

    mock_bms = mocker.patch(
        "ubench.benchmark_managers.benchmark_manager_set.BenchmarkManagerSet.run"
    )
    mock_isdir = mocker.patch("os.path.isdir")
    cmd = ubench_commands.UbenchCmd("platform", [])

    assert cmd.run({'w': [], 'file_params': [], 'custom_params': []}) is True
    mock_bms.assert_called_with("platform", {
        'w': [],
        'file_params': [],
        'custom_params': []
    })

    cmd.run({
        'w': ['6', 'cn184', 'cn[380,431-433]'],
        'file_params': [],
        'custom_params': []
    })
    mock_bms.assert_called_with(
        "platform", {
            'w': [(6, None), (1, 'cn184'), (4, 'cn[380,431-433]')],
            'file_params': [],
            'custom_params': []
        })
Exemplo n.º 2
0
def test_run_customp(monkeypatch, init_env):
    """ docstring """

    # pylint: disable=missing-docstring, unused-argument, unused-variable, redefined-outer-name, undefined-variable

    def mock_auto_bm_init(self, bench_dir, run_dir, benchmark_list):
        return True

    def mock_auto_bm_bench(self, name):
        return bm.BenchmarkManager("simple", "")

    def mock_bm_run_bench(self, opt_dict):
        return True

    monkeypatch.setattr(
        "ubench.benchmark_managers.standard_benchmark_manager.StandardBenchmarkManager.run",
        mock_bm_run_bench)

    ubench_cmd = ubench_commands.UbenchCmd("", ["simple"])
    ubench_cmd.run({
        'customp_list':
        ["param:new_value", "argexec:'PingPong -npmin 56 msglog 1:18'"],
        'w':
        "host1",
        'file_params':
        None,
        'custom_params':
        None
    })
Exemplo n.º 3
0
def test_run_noresourcedir(mocker):
    """ docstring """

    mock_bms = mocker.patch(
        "ubench.benchmark_managers.benchmark_manager_set.BenchmarkManagerSet.run"
    )

    cmd = ubench_commands.UbenchCmd("platform", [])

    assert cmd.run({'w': []}) is False
Exemplo n.º 4
0
def test_result(mocker):
    """ Test log command"""
    cmd = ubench_commands.UbenchCmd("platform", [])
    mock_bms = mocker.patch(
        "ubench.benchmark_managers.benchmark_manager_set.BenchmarkManagerSet.analyse"
    )
    cmd.result()
    mock_bms.assert_called_with('last')
    cmd.result([2], None)
    mock_bms.assert_called_with(2)
    cmd.result([2, 3], None)
    mock_bms.assert_called_with(3)
Exemplo n.º 5
0
def test_log(mocker):
    """ Test log command"""
    cmd = ubench_commands.UbenchCmd("platform", [])
    mock_bms = mocker.patch(
        "ubench.benchmark_managers.benchmark_manager_set.BenchmarkManagerSet.print_log"
    )
    cmd.log()
    mock_bms.assert_called_with(-1)
    cmd.log([2])
    mock_bms.assert_called_with(2)
    cmd.log([2, 3])
    mock_bms.assert_called_with(3)
Exemplo n.º 6
0
def test_wlist():
    """ docstring """

    cmd = ubench_commands.UbenchCmd("platform", [])
    assert cmd.translate_wlist_to_scheduler_wlist(['1', '2',
                                                   '3']) == [(1, None),
                                                             (2, None),
                                                             (3, None)]
    assert cmd.translate_wlist_to_scheduler_wlist(
        ['6', 'cn184', 'cn[380,431-433]']) == [(6, None), (1, 'cn184'),
                                               (4, 'cn[380,431-433]')]
    assert cmd.translate_wlist_to_scheduler_wlist(['6', 'cn184',
                                                   'host1']) == [(6, None),
                                                                 (1, 'cn184'),
                                                                 (1, 'host1')]
Exemplo n.º 7
0
def test_run_customp(monkeypatch,init_env):

  # Test complex paramaters with customp
  def mock_auto_bm_init(self,bench_dir,run_dir,benchmark_list):
    return True

  def mock_auto_bm_bench(self,name):
    return bm.BenchmarkManager("simple","")

  def mock_bm_set_param(self,params):
    # if params['param'] != 'new_value':
    if params['argexec'] != "'PingPong -npmin 56 msglog 1:18'":
      raise NameError('param error')
    return True

  def mock_bm_run_bench(self,platform,opt_dict):
    return True

  monkeypatch.setattr("ubench.benchmark_managers.standard_benchmark_manager.StandardBenchmarkManager.set_parameter",mock_bm_set_param)
  monkeypatch.setattr("ubench.benchmark_managers.standard_benchmark_manager.StandardBenchmarkManager.run",mock_bm_run_bench)
  ubench_cmd = ubench_commands.UbenchCmd("",["simple"])
  ubench_cmd.run({'customp_list': ["param:new_value","argexec:'PingPong -npmin 56 msglog 1:18'"],'w_list' : "host1"})