Skip to content

Commit

Permalink
Added flexibility to two CAN_BCM tests where earlier kernel versions …
Browse files Browse the repository at this point in the history
…don't support the validation of bcm_timeval arguments while later releases will.
  • Loading branch information
derek-will committed Nov 11, 2022
1 parent 838499a commit 6fb4ca0
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions test/SocketCANSharpTest/BcmCanSocketTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,18 @@ public void BcmCanSocket_CreateCyclicTransmissionTask_InvalidTime_Failure_Test()
InitialIntervalConfiguration = new BcmInitialIntervalConfiguration(10, new BcmTimeval(0, -1)), // invalid time
PostInitialInterval = new BcmTimeval(-1, 0), // invalid time
};
SocketCanException ex = Assert.Throws<SocketCanException>(() => bcmCanSocket.CreateCyclicTransmissionTask(config, frames));
Assert.AreEqual(SocketError.InvalidArgument, ex.SocketErrorCode);
Assert.AreEqual(22, ex.NativeErrorCode);

try
{
// kernels prior to v5.0 won't throw - Updates to previous stable releases (i.e., v4.9.333) may throw
bcmCanSocket.CreateCyclicTransmissionTask(config, frames);
Assert.Inconclusive("Did not throw exception on invalid time configuration - This kernel does not support validation of that argument.");
}
catch (SocketCanException ex)
{
Assert.AreEqual(SocketError.InvalidArgument, ex.SocketErrorCode);
Assert.AreEqual(22, ex.NativeErrorCode);
}
}
}

Expand Down Expand Up @@ -1147,9 +1156,17 @@ public void BcmCanSocket_CreateReceiveFilterSubscription_InvalidTime_Failure_Tes
ReceiveMessageRateLimit = new BcmTimeval(-1, 0), // invalid time
};

SocketCanException ex = Assert.Throws<SocketCanException>(() => bcmCanSocket.CreateReceiveFilterSubscription(subscription, frames));
Assert.AreEqual(SocketError.InvalidArgument, ex.SocketErrorCode);
Assert.AreEqual(22, ex.NativeErrorCode);
try
{
// kernels prior to v5.0 won't throw - Updates to previous stable releases (i.e., v4.9.333) may throw
bcmCanSocket.CreateReceiveFilterSubscription(subscription, frames);
Assert.Inconclusive("Did not throw exception on invalid time configuration - This kernel does not support validation of that argument.");
}
catch (SocketCanException ex)
{
Assert.AreEqual(SocketError.InvalidArgument, ex.SocketErrorCode);
Assert.AreEqual(22, ex.NativeErrorCode);
}
}
}

Expand Down

0 comments on commit 6fb4ca0

Please sign in to comment.