diff --git a/skyscraper8.Tests/AstraBarkerTransponderTests.cs b/skyscraper8.Tests/AstraBarkerTransponderTests.cs deleted file mode 100644 index f0ed3fc..0000000 --- a/skyscraper8.Tests/AstraBarkerTransponderTests.cs +++ /dev/null @@ -1,100 +0,0 @@ -using skyscraper5.Mpeg2; -using skyscraper5.Skyscraper.IO; -using skyscraper5.Skyscraper.Scraper.StreamAutodetection.Contestants; -using skyscraper8.Ses; -using skyscraper8.Tests.ClassDependencies.AsraBarkerTransponderTests; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace skyscraper8.Tests -{ - public class AstraBarkerTransponderTests - { - private const string BARKER_TRANSPONDER_FILE_PATH = "C:\\Temp\\Astra1_12604_v_SGT-000000.ts"; - private Stream GetBarkerTransponder() - { - FileInfo fi = new FileInfo(BARKER_TRANSPONDER_FILE_PATH); - if (!fi.Exists) - { - Debug.WriteLine(String.Format("Could not find file: {0}", BARKER_TRANSPONDER_FILE_PATH)); - return null; - } - return fi.OpenRead(); - } - - [Fact] - public void TestAstraSdt() - { - Stream stream = GetBarkerTransponder(); - Skip.If(stream == null, "Barker Transponder stream not available."); - - SdtContestant contestant = new SdtContestant(0x002d); - - TsDescriptorUnpacker descriptorUnpacker = TsDescriptorUnpacker.GetInstance(); - for (byte i = 0x80; i < 0xfe; i++) - { - descriptorUnpacker.SetUserDefined(i, true); - } - descriptorUnpacker.SetUserDefined(0xfe, true); - - TsContext tsContext = new TsContext(); - tsContext.FilterChain = new List(); - tsContext.FilterChain.Add(new DummyFilter()); - tsContext.RegisterPacketProcessor(0x002d, contestant.PacketProcessor); - - byte[] buffer = new byte[188]; - while (stream.GetAvailableBytes() >= 188) - { - stream.Read(buffer, 0, 188); - tsContext.PushPacket(buffer); - if (contestant.Score >= 10) - break; - } - stream.Close(); - } - - [Fact] - public void TestAstraLcn() - { - Stream stream = GetBarkerTransponder(); - Skip.If(stream == null, "Barker Transponder stream not available."); - - SgtCandidate contestant = new SgtCandidate(0x0777); - SgtCandidate contestant2 = new SgtCandidate(0x0776); - - TsDescriptorUnpacker descriptorUnpacker = TsDescriptorUnpacker.GetInstance(); - for (byte i = 0x80; i < 0xfe; i++) - { - descriptorUnpacker.SetUserDefined(i, true); - } - descriptorUnpacker.SetUserDefined(0xfe, true); - - TsContext tsContext = new TsContext(); - tsContext.FilterChain = new List(); - tsContext.FilterChain.Add(new DummyFilter()); - tsContext.RegisterPacketProcessor(0x0777, contestant.PacketProcessor); - tsContext.RegisterPacketProcessor(0x0776, contestant2.PacketProcessor); - - byte[] buffer = new byte[188]; - while (stream.GetAvailableBytes() >= 188) - { - stream.Read(buffer, 0, 188); - tsContext.PushPacket(buffer); - bool winnerA = contestant.Score >= 10; - bool winnerB = contestant2.Score >= 10; - if (winnerA) - { - if (winnerB) - { - return; - } - } - } - stream.Close(); - } - } -} diff --git a/skyscraper8.Tests/DocsisTestsLong.cs b/skyscraper8.Tests/DocsisTestsLong.cs deleted file mode 100644 index 7048a4c..0000000 --- a/skyscraper8.Tests/DocsisTestsLong.cs +++ /dev/null @@ -1,69 +0,0 @@ -using skyscraper5.Mpeg2; -using skyscraper5.Skyscraper.Scraper.Storage.Filesystem; -using skyscraper5.Skyscraper.Scraper.Storage.InMemory; -using skyscraper5.Skyscraper.Scraper.Storage; -using skyscraper5.Skyscraper.Scraper; -using skyscraper5; -using skyscraper8.Skyscraper.IO; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using skyscraper8.Skyscraper.Scraper.Storage; - -namespace skyscraper8.Tests -{ - public class DocsisTestsLong - { - [Fact] - public void TestLongBoiSingleStreams() - { - DirectoryInfo di = new DirectoryInfo("D:\\DocsisDemo"); - if (!di.Exists) - { - Debug.WriteLine("Files not available!"); - return; - } - - FilesystemScraperStorageFactory storageFactory = new FilesystemScraperStorageFactory(); - storageFactory.Directory = "docsis_longboi"; - - Passing passing = new Passing(); - passing.DataStorage = storageFactory.CreateDataStorage(); - passing.MassImportDirectory(di); - } - - [Fact] - public void TestM3u8Stream() - { - FileInfo docsisM3u8 = new FileInfo("D:\\DocsisDemo\\docsis.m3u8"); - if (!docsisM3u8.Exists) - { - Debug.WriteLine("File not available!"); - return; - } - - FileInfo alreadyTested = new FileInfo("docsis_m3u8_test.complete"); - if (alreadyTested.Exists) - { - Debug.WriteLine("Hello!"); - return; - } - - - M3U8Stream m3u8 = new M3U8Stream(docsisM3u8.FullName); - - TsContext tsContext = new TsContext(); - InMemoryScraperStorageFactory storageFactory = new InMemoryScraperStorageFactory(); - DataStorage scraperStorage = storageFactory.CreateDataStorage(); - SkyscraperContext skyscraperContext = new SkyscraperContext(tsContext, scraperStorage, null); - skyscraperContext.InitalizeFilterChain(); - skyscraperContext.IngestFromStream(m3u8); - - File.WriteAllText("docsis_m3u8_test.complete", "1"); - } - - } -} diff --git a/skyscraper8.Tests/UselessCodeCoverageTests.cs b/skyscraper8.Tests/UselessCodeCoverageTests.cs index 406488b..30b5bc2 100644 --- a/skyscraper8.Tests/UselessCodeCoverageTests.cs +++ b/skyscraper8.Tests/UselessCodeCoverageTests.cs @@ -1,3 +1,5 @@ +using skyscraper5.Docsis; +using skyscraper5.Docsis.AnnexC; using skyscraper5.Mpeg2; namespace skyscraper8.Tests; @@ -10,4 +12,231 @@ public class UselessCodeCoverageTests PsiSection section = new PsiSection(); section.Append(new byte[] { 3 }); } + + [Fact] + void MacManagementMessageTypeAttributeTest() + { + MacManagementMessageTypeAttribute mmmta = new MacManagementMessageTypeAttribute(1, 2); + Console.WriteLine(mmmta.ToString()); + } + + [Fact] + void RcpIdEncodingTest() + { + RcpIdEncoding rie = new RcpIdEncoding(new byte[] { 7, 1, 0 }); + SimplifiedReceiveChannelAssignmentEncoding simplifiedReceiveChannelAssignmentEncoding = rie.SimplifiedReceiveChannelConfiguration; + Assert.NotNull(simplifiedReceiveChannelAssignmentEncoding); + Assert.Throws(() => new RcpIdEncoding(new byte[] { 255, 1, 0 })); + } + + [Fact] + void EthernetLlcPacketClassificationEncodingTest() + { + EthernetLlcPacketClassificationEncoding epce = new EthernetLlcPacketClassificationEncoding(new byte[] { 3, 3, 1, 0, 1 }); + ushort epceEProt = epce.EProt; + Assert.Equal(1, epce.EProt); + Assert.Equal(1, epce.Type); + Assert.Throws(() => new EthernetLlcPacketClassificationEncoding(new byte[] { 255, 1, 0 })); + } + + [Fact] + void SimplifiedReceiveChannelAssignmentEncodingTest() + { + SimplifiedReceiveChannelAssignmentEncoding srcae = + new SimplifiedReceiveChannelAssignmentEncoding(new byte[] { 1, 1, 0, 2, 1, 0, 3, 1, 0 }); + Assert.Equal(0,srcae.DownstreamChannelAssignment[0]); + Assert.Equal(0, srcae.DownstreamProfileAssignment[0]); + Assert.Equal(0, srcae.PrimaryDownstreamChannelAssignment[0]); + Assert.Throws(() => new SimplifiedReceiveChannelAssignmentEncoding(new byte[] { 254,0,1 })); + } + + [Fact] + void TransmitChannelConfigurationObjectTest() + { + CommonTlvEncodingObject.TransmitChannelConfigurationObject tcco = + new CommonTlvEncodingObject.TransmitChannelConfigurationObject( + new byte[] + { + 1, 1, 0, + 2, 1, 0, + 3, 1, 0, + 5, 4, 0, 0, 0, 0, + 6, 2, 0, 0, + 7, 1, 1, + 9, 1, 0, + 10, 1, 0, + 11, 1, 0 + }); + Assert.Equal(0, tcco.TccReferenceId.Value); + Assert.Equal(CommonTlvEncodingObject.TransmitChannelConfigurationObject.UpstreamChannelActionEnum.NoAction, tcco.UpstreamChannelAction.Value); + Assert.Equal(0, tcco.UpstreamChannelId.Value); + Assert.NotNull(tcco.UpstreamChannelDescriptor); + Assert.Equal(0, tcco.RangingSid.Value); + Assert.Equal(InitalizationTechniqueEnum.BroadcastInitialRanging, tcco.InitializationTechnique.Value); + Assert.Equal(0, tcco.DynamicRangeWindow); + Assert.Equal(0, tcco.P16Hi); + Assert.Equal(0, tcco.ListOfIucs[0]); + + Assert.Throws(() => + new CommonTlvEncodingObject.TransmitChannelConfigurationObject(new byte[] { 254, 1, 0 })); + } + + [Fact] + void CommonTlvEncodingObjectTest() + { + MemoryStream ms = new MemoryStream(new byte[] + { + 5, 1, 0, + 47, 1, 0, + 49, 1, 0, + 31, 1, 0, + 27, 1, 0, + 30, 1, 0, + 52, 2, 0, 1 + }); + CommonTlvEncodingObject commonTlv = new CommonTlvEncodingObject(ms); + Assert.NotNull(commonTlv.ModemCapabilitiesEncoding); + Assert.NotNull(commonTlv.ServiceFlowSidClusterAssignment); + Assert.NotNull(commonTlv.RcpId); + Assert.Equal(0, commonTlv.KeySequenceNumber); + Assert.Equal(0, commonTlv.HmacDigest[0]); + Assert.NotNull(commonTlv.AuthorizationHint); + Assert.Equal(new TimeSpan(0, 0, 1), commonTlv.InitializingChannelTimeout); + + ms = new MemoryStream(new byte[] { 254, 1, 0 }); + Assert.Throws(() => new CommonTlvEncodingObject(ms)); + } + + [Fact] + void GeneralPacketClassifierEncodingTest() + { + GeneralPacketClassifierEncoding gpce = new GeneralPacketClassifierEncoding(new byte[] + { + 6, 1, 1, + 5, 1, 0, + 9, 1, 0, + 3, 2, 0, 1, + 1, 1, 0, + 2, 2, 0, 1, + 4, 4, 0, 0, 0, 1, + 7, 1, 0, + 10, 1, 0, + 12, 16, + //IPv6 Packet Classification Encoding + 3, 2, 0, 1, + 4, 4, 127, 0, 0, 1, + 6, 4, 127, 0, 0, 1 + }); + Assert.True(gpce.ClassifierActivationState.Value); + Assert.Equal(0, gpce.RulePriority.Value); + Assert.NotNull(gpce.Ipv4PacketClassification); + Assert.Equal(1, gpce.ServiceFlowReference.Value); + Assert.Equal(0, gpce.ClassifierReference.Value); + Assert.Equal(1, gpce.ClassifierIdentifier.Value); + Assert.Equal((uint)1, gpce.ServiceFlowIdentifier.Value); + Assert.Equal(GeneralPacketClassifierEncoding.DynamicServiceChangeActionEnum.Add, gpce.DynamicServiceChangeAction.Value); + Assert.NotNull(gpce.EthernetLlcPacketClassificationEncodings); + + Assert.Throws(() => new GeneralPacketClassifierEncoding(new byte[] + { + 12, 4, + 255, 1, 0, 0 + })); + + Assert.Throws(() => new GeneralPacketClassifierEncoding(new byte[] + { + 254, 1, 0 + })); + } + + [Fact] + public void Ipv4PacketClassificationEncodingTest() + { + GeneralPacketClassifierEncoding.Ipv4PacketClassificationEncodings ipce = + new GeneralPacketClassifierEncoding.Ipv4PacketClassificationEncodings(new byte[] + { + 3, 4, 127, 0, 0, 1, + 5, 4, 127, 0, 0, 1, + 2, 2, 0, 1, + 4, 4, 255, 255, 255, 0, + 6, 4, 255, 255, 255, 0, + 9, 2, 0, 1, + 10, 2, 0, 1, + 7, 2, 0, 1, + 8, 2, 0, 1 + }); + Assert.NotNull(ipce.Ipv4SourceAddress); + Assert.NotNull(ipce.Ipv4DestinationAddress); + Assert.Equal(1, ipce.IpProtocol.Value); + Assert.NotNull(ipce.Ipv4SourceMask); + Assert.NotNull(ipce.Ipv4DestinationMask); + Assert.Equal(1, ipce.DestinationPortStart.Value); + Assert.Equal(1, ipce.DestinationPortEnd.Value); + Assert.Equal(1, ipce.SourcePortStart.Value); + Assert.Equal(1, ipce.SourcePortEnd.Value); + + Assert.Throws(() => + new GeneralPacketClassifierEncoding.Ipv4PacketClassificationEncodings(new byte[] + { + 255, 1, 0 + })); + } + + [Fact] + public void ServiceFlowSidClusterAssignmentObjectTest() + { + ServiceFlowSidClusterAssignmentObject sfscao = new ServiceFlowSidClusterAssignmentObject(new byte[] + { + 1, 4, 0, 0, 0, 1, + 2, 1, 0, + 3, 1, 0, + }); + Assert.Equal(1u, sfscao.SFID.Value); + Assert.NotNull(sfscao.SidClusterEncoding); + Assert.NotNull(sfscao.SidClusterSwitchoverCriteria); + + Assert.Throws(() => new ServiceFlowSidClusterAssignmentObject(new byte[] + { + 255, 1, 0 + })); + } + + [Fact] + public void SidClusterEncodingObjectTest() + { + ServiceFlowSidClusterAssignmentObject.SidClusterEncodingObject sceo = + new ServiceFlowSidClusterAssignmentObject.SidClusterEncodingObject(new byte[] + { + 1, 1, 1, + 2, 1, 0 + }); + Assert.Equal(1, sceo.SidClusterId.Value); + Assert.NotNull(sceo.SidToChannelMapping); + + Assert.Throws(() => new ServiceFlowSidClusterAssignmentObject.SidClusterEncodingObject(new byte[] + { + 255, 1, 0 + })); + } + + [Fact] + public void SidToChannelMappingObjectTest() + { + ServiceFlowSidClusterAssignmentObject.SidClusterEncodingObject.SidToChannelMappingObject stcmo = + new ServiceFlowSidClusterAssignmentObject.SidClusterEncodingObject.SidToChannelMappingObject(new byte[] + { + 1,1,1, + 2,2,0,1, + 3,1,1 + }); + Assert.Equal(1, stcmo.UpstreamChannelId.Value); + Assert.Equal(1, stcmo.SID.Value); + Assert.Equal(ServiceFlowSidClusterAssignmentObject.SidClusterEncodingObject.SidToChannelMappingObject.ActionEnum.Add,stcmo.Action.Value); + + Assert.Throws(() => + new ServiceFlowSidClusterAssignmentObject.SidClusterEncodingObject.SidToChannelMappingObject(new byte[] + { + 255, 1, 0 + })); + } } \ No newline at end of file diff --git a/skyscraper8.sln.DotSettings.user b/skyscraper8.sln.DotSettings.user index b6ef203..ef9d365 100644 --- a/skyscraper8.sln.DotSettings.user +++ b/skyscraper8.sln.DotSettings.user @@ -1,5 +1,6 @@  ForceIncluded + ForceIncluded ForceIncluded ForceIncluded ForceIncluded @@ -7,16 +8,14 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded ForceIncluded /home/schiemas/.cache/JetBrains/Rider2025.1/resharper-host/temp/Rider/vAny/CoverageData/_skyscraper8.1808907683/Snapshot/snapshot.utdcvr - <SessionState ContinuousTestingMode="0" IsActive="True" Name="CheckBfbsCrc #2" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> - <Solution /> -</SessionState> - <SessionState ContinuousTestingMode="0" Name="CheckBfbsCrc" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> - <TestAncestor> - <TestId>xUnit::84EE9FCD-2C7F-DF84-C1BA-99D018CE9412::net8.0::skyscraper8.Tests.GsType1SanityTest.CheckBfbsCrc</TestId> - </TestAncestor> + <SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from &lt;skyscraper8.Tests&gt;" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> + <Project Location="/home/schiemas/RiderProjects/skyscraper8/skyscraper8.Tests" Presentation="&lt;skyscraper8.Tests&gt;" /> </SessionState> + + <data><HostParameters type="LocalHostParameters" /><Argument type="StandaloneArgument"><Arguments IsNull="False"></Arguments><FileName IsNull="False"></FileName><WorkingDirectory IsNull="False"></WorkingDirectory><Scope><ProcessFilters /></Scope></Argument><Info type="TimelineInfo" /><CoreOptions type="CoreOptions"><CoreTempPath IsNull="False"></CoreTempPath><RemoteEndPoint IsNull="False"></RemoteEndPoint><AdditionalEnvironmentVariables /></CoreOptions><HostOptions type="HostOptions"><HostTempPath IsNull="False"></HostTempPath></HostOptions></data> \ No newline at end of file diff --git a/skyscraper8/Docsis/AnnexC/EthernetLlcPacketClassificationEncoding.cs b/skyscraper8/Docsis/AnnexC/EthernetLlcPacketClassificationEncoding.cs index 317cc33..63d2211 100644 --- a/skyscraper8/Docsis/AnnexC/EthernetLlcPacketClassificationEncoding.cs +++ b/skyscraper8/Docsis/AnnexC/EthernetLlcPacketClassificationEncoding.cs @@ -11,7 +11,7 @@ namespace skyscraper5.Docsis.AnnexC public EthernetLlcPacketClassificationEncoding(byte[] buffer) { MemoryStream ms = new MemoryStream(buffer, false); - while (ms.GetAvailableBytes() > 3) + while (ms.GetAvailableBytes() >= 3) { byte type = ms.ReadUInt8(); ushort length = ms.ReadUInt8(); diff --git a/skyscraper8/Docsis/AnnexC/RcpIdEncoding.cs b/skyscraper8/Docsis/AnnexC/RcpIdEncoding.cs index b398329..8332563 100644 --- a/skyscraper8/Docsis/AnnexC/RcpIdEncoding.cs +++ b/skyscraper8/Docsis/AnnexC/RcpIdEncoding.cs @@ -27,7 +27,7 @@ namespace skyscraper5.Docsis.AnnexC SimplifiedReceiveChannelConfiguration = new SimplifiedReceiveChannelAssignmentEncoding(v); break; default: - throw new NotFiniteNumberException(String.Format("{0} {1}", nameof(ModemCapabilitiesEncoding), type)); + throw new NotImplementedException(String.Format("{0} {1}", nameof(ModemCapabilitiesEncoding), type)); } } } @@ -59,7 +59,7 @@ namespace skyscraper5.Docsis.AnnexC break; default: //page 728, CM-SP-MULPIv4.0-I01-190815.pdf - throw new NotFiniteNumberException(String.Format("{0} {1}", nameof(SimplifiedReceiveChannelAssignmentEncoding), type)); + throw new NotImplementedException(String.Format("{0} {1}", nameof(SimplifiedReceiveChannelAssignmentEncoding), type)); } } }