public void ApplyCommandImpl_will_apply_command_for_all_cpu(SMUCmdConstant cmd, uint val, bool isDualSocket) { var subject = GetMockSubject(isDualSocket); Assert.Equal(isDualSocket, subject.Object.IsDualSocket); subject.Setup(mock => mock.ApplySMUCommand( It.IsAny <SMUCmdConstant>(), It.IsAny <uint>(), It.IsAny <uint>())) .Returns(SMU.Status.OK); Assert.True(subject.Object.ApplyCommandImpl(cmd, val, (uint value) => { Assert.Equal(val, value); return(""); })); subject.Verify(mock => mock.ApplySMUCommand(cmd, val, kPCI_ADDR_0), Times.Once()); if (isDualSocket) { subject.Verify(mock => mock.ApplySMUCommand(cmd, val, kPCI_ADDR_1), Times.Once()); mMockLogger.Verify(mock => mock.Invoke(It.IsAny <string>()), Times.Exactly(2)); } else { mMockLogger.Verify(mock => mock.Invoke(It.IsAny <string>()), Times.Exactly(1)); } }
internal virtual SMU.Status ApplySMUCommand(SMUCmdConstant command, uint value, uint pciAddr) { try { if (SmuWrite((uint)command, value, pciAddr)) { // Read response uint data = 0; if (SmuReadReg(mSmu.SMU_ADDR_RSP, ref data, pciAddr)) { return((SMU.Status)data); } mLogger.Invoke("Error reading response!"); } else { mLogger.Invoke("Error on writing SMU!"); } } catch (ApplicationException e) { mLogger.Invoke($"ERROR: {e.Message}"); } return(SMU.Status.FAILED); }
public void ApplySMUCommand_will_apply_command_and_wait_response(SMUCmdConstant cmd, uint val, uint pciAddr) { var subject = GetMockSubject(); subject.Setup(mock => mock.SmuWrite( It.IsAny <uint>(), It.IsAny <uint>(), It.IsAny <uint>())) .Returns(true); subject.Setup(mock => mock.SmuReadReg( kADDR_RSP, ref It.Ref <uint> .IsAny, pciAddr)) .Callback((SmuReadRegCallbackType)((uint _, ref uint data, uint __) => data = 1)) .Returns(true); Assert.Equal(SMU.Status.OK, subject.Object.ApplySMUCommand(cmd, val, pciAddr)); subject.Verify(mock => mock.SmuWrite((uint)cmd, val, pciAddr), Times.Once()); subject.Verify(mock => mock.SmuReadReg(kADDR_RSP, ref It.Ref <uint> .IsAny, pciAddr), Times.Once()); }
internal virtual bool ApplyCommandImpl(SMUCmdConstant cmd, uint val, Func <uint, string> msgFunc) { if (ApplySMUCommand(cmd, val, mSmu.SMU_PCI_ADDR) != SMU.Status.OK) { mLogger.Invoke($"Socket 1 apply cmd error: {cmd}"); return(false); } mLogger.Invoke($"Socket 1: {msgFunc.Invoke(val)}"); if (mIsDualSocket) { if (ApplySMUCommand(cmd, val, mSmu.SMU_PCI_ADDR_2) != SMU.Status.OK) { mLogger.Invoke($"Socket 2 apply cmd error: {cmd}"); return(false); } mLogger.Invoke($"Socket 2: {msgFunc.Invoke(val)}"); } return(true); }