Skip to content

Commit 9f17b6e

Browse files
fix: Arm64 test failures (#3619)
## Purpose of this PR Fixes some test failures when running against arm64: - Increased the timeout duration because the raspberry pi that tests were run on is quite slow and sometimes doesn't make the timeout - Removed booleans from structures that are created via random bytes because Arm64 doesn't handle booleans the same way as x86, and bool(1) doesn't compare as equal to bool(2) like it does on x86 - Removed booleans from the network variable HashSet test because it created an infinite loop, because bool(1) and bool(2) DO apparently HASH to the same key on arm64, where they create different keys on x86. (This was never a valid test to begin with, because creating a hash set with 32 boolean key values is, strictly speaking, not possible, and only worked by accident on x86) - ## Documentation [//]: # ( This section is REQUIRED and should mention what documentation changes were following the changes in this PR. We should always evaluate if the changes in this PR require any documentation changes. ) - No documentation changes or additions were necessary. ## Testing & QA [//]: # ( This section is REQUIRED and should describe how the changes were tested and how should they be tested when Playtesting for the release. It can range from "edge case covered by unit tests" to "manual testing required and new sample was added". Expectation is that PR creator does some manual testing and provides a summary of it here.) ### Functional Testing [//]: # (If checked, List manual tests that have been performed.) _Manual testing :_ - [ ] `Manual testing done` _Automated tests:_ - [x] `Covered by existing automated tests` - [ ] `Covered by new automated tests` _Does the change require QA team to:_ - [ ] `Review automated tests`? - [ ] `Execute manual tests`? If any boxes above are checked, please add QA as a PR reviewer. ## Backport [//]: # ( This section is REQUIRED and should link to the PR that targets other NGO version which is either develop or develop-2.0.0 branch Add the following to the PR title: "\[Backport\] ..." If this is not needed, for example feature specific to NGOv2.X, then just mention this fact. ) Not needed. Co-authored-by: Noel Stephens <[email protected]>
1 parent cdd0ddd commit 9f17b6e

File tree

2 files changed

+33
-19
lines changed

2 files changed

+33
-19
lines changed

com.unity.netcode.gameobjects/Tests/Runtime/NetworkVariable/NetworkVariableTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2901,7 +2901,7 @@ public void WhenSerializingAndDeserializingVeryLargeListNetworkVariables_ValuesA
29012901
public void WhenSerializingAndDeserializingVeryLargeHashSetNetworkVariables_ValuesAreSerializedCorrectly(
29022902

29032903
[Values(typeof(byte), typeof(sbyte), typeof(short), typeof(ushort), typeof(int), typeof(uint),
2904-
typeof(long), typeof(ulong), typeof(bool), typeof(char), typeof(float), typeof(double),
2904+
typeof(long), typeof(ulong), typeof(char), typeof(float), typeof(double),
29052905
typeof(Vector2), typeof(Vector3), typeof(Vector2Int), typeof(Vector3Int), typeof(Vector4),
29062906
typeof(Quaternion), typeof(Pose), typeof(HashableNetworkVariableTestClass), typeof(FixedString32Bytes))]
29072907
Type testType)

com.unity.netcode.gameobjects/Tests/Runtime/NetworkVariable/NetworkVariableTestsHelperTypes.cs

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,13 @@ internal struct HashableNetworkVariableTestStruct : INetworkSerializeByMemcpy, I
187187
public uint E;
188188
public long F;
189189
public ulong G;
190-
public bool H;
191-
public char I;
192-
public float J;
193-
public double K;
190+
public char H;
191+
public float I;
192+
public double J;
194193

195194
public bool Equals(HashableNetworkVariableTestStruct other)
196195
{
197-
return A == other.A && B == other.B && C == other.C && D == other.D && E == other.E && F == other.F && G == other.G && H == other.H && I == other.I && J.Equals(other.J) && K.Equals(other.K);
196+
return A == other.A && B == other.B && C == other.C && D == other.D && E == other.E && F == other.F && G == other.G && H == other.H && I.Equals(other.I) && J.Equals(other.J);
198197
}
199198

200199
public override bool Equals(object obj)
@@ -215,7 +214,6 @@ public override int GetHashCode()
215214
hashCode.Add(H);
216215
hashCode.Add(I);
217216
hashCode.Add(J);
218-
hashCode.Add(K);
219217
return hashCode.ToHashCode();
220218
}
221219
}
@@ -229,14 +227,18 @@ internal struct HashMapKeyStruct : INetworkSerializeByMemcpy, IEquatable<HashMap
229227
public uint E;
230228
public long F;
231229
public ulong G;
232-
public bool H;
233-
public char I;
234-
public float J;
235-
public double K;
230+
public char H;
231+
public float I;
232+
public double J;
236233

237234
public bool Equals(HashMapKeyStruct other)
238235
{
239-
return A == other.A && B == other.B && C == other.C && D == other.D && E == other.E && F == other.F && G == other.G && H == other.H && I == other.I && J.Equals(other.J) && K.Equals(other.K);
236+
return A == other.A && B == other.B && C == other.C && D == other.D && E == other.E && F == other.F && G == other.G && H == other.H && I.Equals(other.I) && J.Equals(other.J);
237+
}
238+
239+
public override string ToString()
240+
{
241+
return $"{{A: {A}, B: {B}, C:{C}, D:{D}, E:{E}, F:{F}, G:{G}, H:{H}, I:{I}, J:{J}}}";
240242
}
241243

242244
public override bool Equals(object obj)
@@ -257,7 +259,6 @@ public override int GetHashCode()
257259
hashCode.Add(H);
258260
hashCode.Add(I);
259261
hashCode.Add(J);
260-
hashCode.Add(K);
261262
return hashCode.ToHashCode();
262263
}
263264
}
@@ -271,14 +272,18 @@ internal struct HashMapValStruct : INetworkSerializeByMemcpy, IEquatable<HashMap
271272
public uint E;
272273
public long F;
273274
public ulong G;
274-
public bool H;
275-
public char I;
276-
public float J;
277-
public double K;
275+
public char H;
276+
public float I;
277+
public double J;
278278

279279
public bool Equals(HashMapValStruct other)
280280
{
281-
return A == other.A && B == other.B && C == other.C && D == other.D && E == other.E && F == other.F && G == other.G && H == other.H && I == other.I && J.Equals(other.J) && K.Equals(other.K);
281+
return A == other.A && B == other.B && C == other.C && D == other.D && E == other.E && F == other.F && G == other.G && H == other.H && I.Equals(other.I) && J.Equals(other.J);
282+
}
283+
284+
public override string ToString()
285+
{
286+
return $"{{A: {A}, B: {B}, C:{C}, D:{D}, E:{E}, F:{F}, G:{G}, H:{H}, I:{I}, J:{J}}}";
282287
}
283288

284289
public override bool Equals(object obj)
@@ -299,7 +304,6 @@ public override int GetHashCode()
299304
hashCode.Add(H);
300305
hashCode.Add(I);
301306
hashCode.Add(J);
302-
hashCode.Add(K);
303307
return hashCode.ToHashCode();
304308
}
305309
}
@@ -381,6 +385,11 @@ public override bool Equals(object obj)
381385
return obj is HashMapKeyClass other && Equals(other);
382386
}
383387

388+
public override string ToString()
389+
{
390+
return Data.ToString();
391+
}
392+
384393
public override int GetHashCode()
385394
{
386395
return Data.GetHashCode();
@@ -401,6 +410,11 @@ public bool Equals(HashMapValClass other)
401410
return Data.Equals(other.Data);
402411
}
403412

413+
public override string ToString()
414+
{
415+
return Data.ToString();
416+
}
417+
404418
public override bool Equals(object obj)
405419
{
406420
return obj is HashMapValClass other && Equals(other);

0 commit comments

Comments
 (0)