diff --git a/.travis.yml b/.travis.yml
index 5a784ae..2332200 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,10 +14,15 @@ before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ulimit -n 2048; fi
install:
- dotnet tool install -g dotnet-format --version 4.0.40103 --add-source https://dotnet.myget.org/F/format/api/v3/index.json
+ - dotnet tool install -g coveralls.net --version 1.0.0
- export PATH="$PATH:$HOME/.dotnet/tools"
- dotnet-format --version
+ - csmacnz.Coveralls --version
before_script:
- - echo "Checking format ..."
+ - echo "Extracting author information ..."
+ - export COMMITTER_EMAIL="$(git log -1 $TRAVIS_COMMIT --pretty="%cE")"
+ - export AUTHOR_NAME="$(git log -1 $TRAVIS_COMMIT --pretty="%aN")"
+ - echo "Checking format ..."
- dotnet format --check --dry-run -w src/TuringMachine -v diagnostic
- dotnet format --check --dry-run -w src/TuringMachine.Core -v diagnostic
- dotnet format --check --dry-run -w tests/TuringMachine.Core.Tests -v diagnostic
@@ -28,7 +33,9 @@ script:
- cd tests/TuringMachine.Core.Tests
- dotnet restore
- find * -name *.csproj | xargs -I % dotnet add % package coverlet.msbuild
- - dotnet test -v m /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
+ - dotnet test -v m /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput='../../coverage.xml' /p:Exclude=\"[coverlet.*]*,[*]Coverlet.Core*\"
after_success:
- - echo "Test Success - Branch($TRAVIS_BRANCH) Pull Request($TRAVIS_PULL_REQUEST) Tag($TRAVIS_TAG)"
- - bash <(curl -s https://codecov.io/bash)
+ - echo "Test Success - Branch($TRAVIS_BRANCH) Pull Request($TRAVIS_PULL_REQUEST) Tag($TRAVIS_TAG) Author($AUTHOR_NAME) CommitterEmail($COMMITTER_EMAIL)"
+# - bash <(curl -s https://codecov.io/bash)
+ - cd ../../
+ - csmacnz.Coveralls --opencover -i coverage.xml --repoTokenVariable COVERALLS_REPO_TOKEN --useRelativePaths --commitId $TRAVIS_COMMIT --commitBranch $TRAVIS_BRANCH --jobId $TRAVIS_JOB_ID --commitMessage "$TRAVIS_COMMIT_MESSAGE" --commitAuthor "$AUTHOR_NAME" --commitEmail "$COMMITTER_EMAIL"
diff --git a/README.md b/README.md
index ae54880..be00700 100644
--- a/README.md
+++ b/README.md
@@ -7,8 +7,8 @@
-
-
+
+
diff --git a/src/TuringMachine.Core/Extensions/ObjectExtensions.cs b/src/TuringMachine.Core/Extensions/ObjectExtensions.cs
index 95bb63e..8096632 100644
--- a/src/TuringMachine.Core/Extensions/ObjectExtensions.cs
+++ b/src/TuringMachine.Core/Extensions/ObjectExtensions.cs
@@ -35,6 +35,11 @@ public static bool EqualWithNullCheck(this IEquatable a, IEquatable b)
/// True if are equals
public static bool SequenceEqualWithNullCheck(this IList a, IList b)
{
+ if (typeof(T) == typeof(byte[]))
+ {
+ return ChunkSequenceEqualWithNullCheck((IList)a, (IList)b);
+ }
+
if ((a == null) != (b == null))
{
return false;
@@ -50,7 +55,7 @@ public static bool SequenceEqualWithNullCheck(this IList a, IList b)
/// A
/// B
/// True if are equals
- public static bool ChunkSequenceEqualWithNullCheck(this IList chunks1, IList chunks2)
+ private static bool ChunkSequenceEqualWithNullCheck(this IList chunks1, IList chunks2)
{
if ((chunks1 == null) != (chunks2 == null)) return false;
if (chunks1 == null) return true;
diff --git a/src/TuringMachine.Core/Fuzzers/Mutational/MutationalChunk.cs b/src/TuringMachine.Core/Fuzzers/Mutational/MutationalChunk.cs
index 81ca19d..b71a73f 100644
--- a/src/TuringMachine.Core/Fuzzers/Mutational/MutationalChunk.cs
+++ b/src/TuringMachine.Core/Fuzzers/Mutational/MutationalChunk.cs
@@ -94,7 +94,7 @@ public bool Equals(MutationalChunk obj)
if (obj == null) return false;
return obj.Type == Type
- && obj.Allowed.ChunkSequenceEqualWithNullCheck(Allowed);
+ && obj.Allowed.SequenceEqualWithNullCheck(Allowed);
}
///
diff --git a/tests/TuringMachine.Core.Tests/Extensions/ObjectExtensionsTest.cs b/tests/TuringMachine.Core.Tests/Extensions/ObjectExtensionsTest.cs
new file mode 100644
index 0000000..3c8a361
--- /dev/null
+++ b/tests/TuringMachine.Core.Tests/Extensions/ObjectExtensionsTest.cs
@@ -0,0 +1,51 @@
+using NUnit.Framework;
+using System;
+using System.Collections.Generic;
+using System.Net;
+using TuringMachine.Core.Extensions;
+
+namespace TuringMachine.Core.Tests.Extensions
+{
+ [TestFixture]
+ public class ObjectExtensionsTest
+ {
+ [Test]
+ public void ClearTest()
+ {
+ // IPEndPoint
+
+ Assert.IsFalse(ObjectExtensions.EqualWithNullCheck(new IPEndPoint(0, 1), null));
+ Assert.IsFalse(ObjectExtensions.EqualWithNullCheck(null, new IPEndPoint(0, 1)));
+ Assert.IsTrue(ObjectExtensions.EqualWithNullCheck(new IPEndPoint(0, 1), new IPEndPoint(0, 1)));
+ Assert.IsFalse(ObjectExtensions.EqualWithNullCheck(new IPEndPoint(0, 1), new IPEndPoint(0, 2)));
+
+ // Byte[]
+
+ Assert.IsFalse(ObjectExtensions.SequenceEqualWithNullCheck(new byte[] { 0x00, 0x01 }, null));
+ Assert.IsFalse(ObjectExtensions.SequenceEqualWithNullCheck(null, new byte[] { 0x00, 0x01 }));
+ Assert.IsTrue(ObjectExtensions.SequenceEqualWithNullCheck(new byte[] { 0x00, 0x01 }, new byte[] { 0x00, 0x01 }));
+ Assert.IsFalse(ObjectExtensions.SequenceEqualWithNullCheck(new byte[] { 0x00, 0x01 }, new byte[] { 0x00, 0x02 }));
+
+ // IList
+
+ Assert.IsFalse(ObjectExtensions.SequenceEqualWithNullCheck(new List(new byte[] { 0x00, 0x01 }), null));
+ Assert.IsFalse(ObjectExtensions.SequenceEqualWithNullCheck(null, new List(new byte[] { 0x00, 0x01 })));
+ Assert.IsTrue(ObjectExtensions.SequenceEqualWithNullCheck(new List(new byte[] { 0x00, 0x01 }), new List(new byte[] { 0x00, 0x01 })));
+ Assert.IsFalse(ObjectExtensions.SequenceEqualWithNullCheck(new List(new byte[] { 0x00, 0x01 }), new List(new byte[] { 0x00, 0x02 })));
+
+ // IEquatable
+
+ Assert.IsFalse(ObjectExtensions.EqualWithNullCheck((IEquatable)new Decimal(1), null));
+ Assert.IsFalse(ObjectExtensions.EqualWithNullCheck(null, (IEquatable)new Decimal(1)));
+ Assert.IsTrue(ObjectExtensions.EqualWithNullCheck((IEquatable)new Decimal(1), (IEquatable)new Decimal(1)));
+ Assert.IsFalse(ObjectExtensions.EqualWithNullCheck((IEquatable)new Decimal(1), (IEquatable)new Decimal(2)));
+
+ // IList
+
+ Assert.IsFalse(ObjectExtensions.SequenceEqualWithNullCheck(new List(new byte[][] { new byte[] { 0x00, 0x01 } }), null));
+ Assert.IsFalse(ObjectExtensions.SequenceEqualWithNullCheck(null, new List(new byte[][] { new byte[] { 0x00, 0x01 } })));
+ Assert.IsTrue(ObjectExtensions.SequenceEqualWithNullCheck(new List(new byte[][] { new byte[] { 0x00, 0x01 } }), new List(new byte[][] { new byte[] { 0x00, 0x01 } })));
+ Assert.IsFalse(ObjectExtensions.SequenceEqualWithNullCheck(new List(new byte[][] { new byte[] { 0x00, 0x01 } }), new List(new byte[][] { new byte[] { 0x00, 0x02 } })));
+ }
+ }
+}
diff --git a/tests/TuringMachine.Core.Tests/FuzzerTest.cs b/tests/TuringMachine.Core.Tests/FuzzerTest.cs
index d8fc8c4..b8da7d4 100644
--- a/tests/TuringMachine.Core.Tests/FuzzerTest.cs
+++ b/tests/TuringMachine.Core.Tests/FuzzerTest.cs
@@ -67,6 +67,10 @@ private void Test(FuzzerConnectionBase serverConnection, FuzzerConnectionBase cl
using (var server = new FuzzerServer())
using (var client = new FuzzerClient())
{
+ // Change name
+
+ client.PublicName = "TestClient_" + Guid.NewGuid().ToString();
+
// Ensure no error
client.SendLog(null);
@@ -143,7 +147,7 @@ private void Test(FuzzerConnectionBase serverConnection, FuzzerConnectionBase cl
Assert.IsTrue(waitInput.WaitOne(TimeSpan.FromSeconds(10)), "Waiting for inputs");
Assert.AreEqual(1, server.Connections.Count);
- Assert.IsTrue(!string.IsNullOrEmpty(server.Connections.Values.FirstOrDefault()?.Source.Description));
+ Assert.IsTrue(server.Connections.Values.FirstOrDefault()?.Source.Description.Contains(client.PublicName));
Assert.AreNotEqual(Guid.Empty, server.Connections.Values.FirstOrDefault()?.Source.Id);
Assert.AreNotEqual(Guid.Empty, server.Connections.Values.FirstOrDefault()?.Id);
diff --git a/tests/TuringMachine.Core.Tests/Fuzzers/Mutational/MutationalTest.cs b/tests/TuringMachine.Core.Tests/Fuzzers/Mutational/MutationalTest.cs
index 0a7297a..059da7e 100644
--- a/tests/TuringMachine.Core.Tests/Fuzzers/Mutational/MutationalTest.cs
+++ b/tests/TuringMachine.Core.Tests/Fuzzers/Mutational/MutationalTest.cs
@@ -340,6 +340,7 @@ public void MutationalEntryPeerByteTest()
entry.Changes.Add(new MutationalChange()
{
Weight = 5,
+ Description = "Add A",
Append = new MutationalFromTo((byte)'A'),
RemoveLength = new FromToValue(1),
AppendIterations = new FromToValue(1)
@@ -348,6 +349,7 @@ public void MutationalEntryPeerByteTest()
{
// Remmove
Weight = 1,
+ Description = "Remove",
RemoveLength = new FromToValue(1),
AppendIterations = new FromToValue(1)
});
@@ -407,13 +409,14 @@ public void MutationalEntryPeerByteTest()
// Max changes 2
+ entry.Changes.RemoveAt(1);
entry.ValidOffset = new FromToValue(0, long.MaxValue);
entry.MaxChanges = new FromToValue(2);
-
input = new ManualFuzzingInput(new byte[100]);
+
using (var stream = new FuzzingStream(config, input.GetStream()))
{
- stream.CopyTo(new MemoryStream(), 100);
+ stream.CopyTo(new MemoryStream(), 16);
Assert.AreEqual(2, stream.Log.Length);
Assert.AreEqual(0, stream.Log[0].Offset);
diff --git a/tests/TuringMachine.Core.Tests/FuzzingStreamTest.cs b/tests/TuringMachine.Core.Tests/FuzzingStreamTest.cs
index 8a976a3..ab4399d 100644
--- a/tests/TuringMachine.Core.Tests/FuzzingStreamTest.cs
+++ b/tests/TuringMachine.Core.Tests/FuzzingStreamTest.cs
@@ -10,6 +10,32 @@ namespace TuringMachine.Core.Tests
[TestFixture]
public class FuzzingStreamTest
{
+ class Disposable : IDisposable
+ {
+ public int IsDisposed = 0;
+
+ public void Dispose()
+ {
+ IsDisposed++;
+ }
+ }
+
+ [Test]
+ public void DisposeTest()
+ {
+ var original = new byte[90];
+ var disposed = new Disposable();
+
+ using (var stream = new FuzzingStream(null, original))
+ {
+ stream.Variables.Add(0, disposed);
+
+ Assert.AreEqual(0, disposed.IsDisposed);
+ }
+
+ Assert.AreEqual(1, disposed.IsDisposed);
+ }
+
[Test]
public void CleanTest()
{