From efaeff339f1534429e30aba90712fa0445464ee6 Mon Sep 17 00:00:00 2001 From: leasunhy Date: Fri, 28 Apr 2017 10:36:23 +0800 Subject: [PATCH 01/38] Test: move to nunit - test --- tests/packages.config | 9 + tests/storage/storage4_nunit/TestResult.xml | 4 + tests/storage/storage4_nunit/packages.config | 11 + .../storage/storage4_nunit/storage4_nunit.cs | 633 ++++++++++++++++++ .../storage4_nunit/storage4_nunit.csproj | 78 +++ .../storage/storage4_nunit/storage4_nunit.tsl | 4 + .../storage4_nunit_coreclr.csproj | 20 + tests/tests.nunit | 6 + 8 files changed, 765 insertions(+) create mode 100644 tests/storage/storage4_nunit/TestResult.xml create mode 100644 tests/storage/storage4_nunit/packages.config create mode 100644 tests/storage/storage4_nunit/storage4_nunit.cs create mode 100644 tests/storage/storage4_nunit/storage4_nunit.csproj create mode 100644 tests/storage/storage4_nunit/storage4_nunit.tsl create mode 100644 tests/storage/storage4_nunit/storage4_nunit_coreclr.csproj create mode 100644 tests/tests.nunit diff --git a/tests/packages.config b/tests/packages.config index eaa7c9edb..3ee58d87a 100644 --- a/tests/packages.config +++ b/tests/packages.config @@ -2,4 +2,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/tests/storage/storage4_nunit/TestResult.xml b/tests/storage/storage4_nunit/TestResult.xml new file mode 100644 index 000000000..b4e183b9f --- /dev/null +++ b/tests/storage/storage4_nunit/TestResult.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/tests/storage/storage4_nunit/packages.config b/tests/storage/storage4_nunit/packages.config new file mode 100644 index 000000000..dc8fb90cb --- /dev/null +++ b/tests/storage/storage4_nunit/packages.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/tests/storage/storage4_nunit/storage4_nunit.cs b/tests/storage/storage4_nunit/storage4_nunit.cs new file mode 100644 index 000000000..e8a0026fc --- /dev/null +++ b/tests/storage/storage4_nunit/storage4_nunit.cs @@ -0,0 +1,633 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.IO; +using System.Diagnostics; +using System.Threading; +using System.Security; +using System.Runtime.ExceptionServices; +using Trinity; +using System.Globalization; +using NUnit.Framework; +using Trinity.Storage; + +namespace storage4 +{ + unsafe class Test + { + #region Parameters + /// + /// This seed is used to generate a random seed for each thread + /// + int RandomSeed; + /// + /// This Random is used by the main thread + /// + Random random; + /// + /// Value = true + /// This field aims to discern cell-lock-related and cell-lock-unrelated bugs, + /// if it's false, the threads will only operate on their own cells, otherwise, + /// they will all operate on all cells and there could be data-race + /// + bool ThreadCellRangeOverlap; + /// + /// Each thread has its own random seed, so if a bug occurs in NON_THREAD_WORK_OVERLAP mode, it can be reproduced + /// + Random[] Randoms; + + /// + /// At first we will save some initial cells to the trunks, this field specifies the length of the initial cell + /// + int CellSize; + + int MaxLargeObjectSize; + + /// + /// Pauses background defragmentation thread + /// + bool PauseDefragmentation; + + int IterationCount; + long OpsPerIteration; + + /// + /// We will create HALF this number of cells randomly in the beginning, + /// the other HALF may be added in the testing process.There is a hard limit of + /// the number of cells each memory trunk can hold, that is 128 M. This is + /// deliberately designed in this way. When you fed in more than 128 M cells, + /// it will behave in an unpredictable way. + /// + long MaxCellCount; + /// + /// If SingleTrunk is set to true, all the actions will be performed on the first + /// MemoryTrunk (and thus producing a very heavy load). Otherwise, Cell IDs will + /// be scattered to all the trunks. + /// + bool SingleTrunk; + /// + /// the number of operations, which is also the size of ENUM_JOBS + /// + const long OperationCategoryCount = 4; + enum CellOperationType { USE, ADD, DELETE, UPDATE, Load }; + long[] TimeoutOpCount = new long[OperationCategoryCount]; + Object TimeoutOpCountLock = new Object(); //threads will their counts to the array when they finish + #endregion + + public Test(int random_seed = 32771, bool thread_cell_range_overlap = true, int cell_size = 128, int max_lo_size = 1 << 16, bool pause_defrag = false, int iter_cnt = 20000, long ops_cnt = 20000, int max_cell_count = 1 << 20, bool single_trunk = false) + { + RandomSeed = random_seed; + random = new Random(random_seed); + ThreadCellRangeOverlap = thread_cell_range_overlap; + CellSize = cell_size; + MaxLargeObjectSize = max_lo_size; + PauseDefragmentation = pause_defrag; + IterationCount = iter_cnt; + OpsPerIteration = ops_cnt; + MaxCellCount = max_cell_count; + SingleTrunk = single_trunk; + } + + /// + /// The count of profiles + /// + int WorkerCount; + long[] DeltaCellCount; //the delta of cell number on each thread(newly-saved - deleted) + bool[] WorkerResizeException; // toggled by a worker thread when an exception is thrown on cell resize + List[] ThreadCellIds; + long InitialCellCount = 0; + + long StartCellId = 0x7FFFFFFF00000000; + + + /// + /// We want to trace the number of all the cells, so i add a lock when i'm calling saveCell + /// + Object[] cellLocks; + [HandleProcessCorruptedStateExceptions, SecurityCriticalAttribute] + public unsafe bool Run() + { + if (PauseDefragmentation) + { + LocalMemoryStorage.PauseMemoryDefragmentation(); + } + else + { + LocalMemoryStorage.RestartMemoryDefragmentation(); + } + + //Add In Profiles, the PID field must start from 0 and add 1 one by one + List WorkerProfile = new List(); + + WorkerProfile.Add(new WorkerProfile(0, OpsPerIteration, IterationCount, new List { 1, 1, 1, 3, 1 })); //use, add, delete, update, load + WorkerProfile.Add(new WorkerProfile(1, OpsPerIteration, IterationCount, new List { 1, 1, 3, 1, 1 })); //use, add, delete, update, load + WorkerProfile.Add(new WorkerProfile(2, OpsPerIteration, IterationCount, new List { 1, 3, 1, 1, 1 })); //use, add, delete, update, load + WorkerProfile.Add(new WorkerProfile(3, OpsPerIteration, IterationCount, new List { 1, 2, 1, 3, 1 })); //use, add, delete, update, load + WorkerProfile.Add(new WorkerProfile(4, OpsPerIteration, IterationCount, new List { 1, 1, 2, 2, 1 })); //use, add, delete, update, load + + for (int i = 5; i < Environment.ProcessorCount; i++) + { + WorkerProfile.Add(new WorkerProfile(i, OpsPerIteration, IterationCount, new List { 1, 1, 1, 1, 1 })); //use, add, delete, update, load + } + + WorkerCount = WorkerProfile.Count; + + Initialize(); + + List RunningThreads = new List(); + for (int i = 0; i < WorkerProfile.Count; i++) + { + Thread t = new Thread(new ParameterizedThreadStart(WorkerThread)); + RunningThreads.Add(t); + t.Start(WorkerProfile[i]); + } + + for (int i = 0; i < RunningThreads.Count; i++) + RunningThreads[i].Join(); + + bool testResult = VerifyData(); + return testResult; + } + /// + /// A Profile Class used to trace performance of each operation in a thread + /// + class OpPerformanceRecord + { + int threadId; + long sumTime; + int count; + long maxTime; + long minTime; + int warnings; + int warnLimit; + string OpName; + public OpPerformanceRecord(int thread, string s, int limit) + { + threadId = thread; + OpName = s; + warnLimit = limit; + sumTime = 0; + count = 0; + maxTime = 0; + warnings = 0; + minTime = 1000000; + } + public void Record(Stopwatch s) + { + long time = s.ElapsedTicks; + sumTime += time; + count++; + if (time > maxTime) + maxTime = time; + if (time < minTime) + minTime = time; + if (time > warnLimit) + { + //Log("THREAD" + threadId + " WARNING : A " + OpName + " elasped " + time + " milliseconds....Timeout!"); + warnings++; + } + } + public void Output() + { + Console.WriteLine("Thead: " + threadId + " Op: " + OpName); + Console.WriteLine("\tcount: " + count); + double average_ticks = ((double)sumTime) / count; + //resize, add, delete, update + int kk = 1; + if (OpName == "ADD") kk = 2; + if (OpName == "DELETE") kk = 3; + if (OpName == "UPDATE") kk = 4; + Console.WriteLine(threadId + " " + kk + " " + average_ticks + " " + average_ticks * 1000 / Stopwatch.Frequency); + Console.WriteLine("\taverage ticks: " + average_ticks + "\t=" + average_ticks * 1000 / Stopwatch.Frequency + "ms"); + Console.WriteLine("\tmax ticks: " + maxTime + "\t=" + maxTime * 1000 / Stopwatch.Frequency + "ms"); + Console.WriteLine("\tmin ticks: " + minTime + "\t=" + minTime * 1000 / Stopwatch.Frequency + "ms"); + Console.WriteLine("\twarnings: " + warnings); + Console.WriteLine(); + } + } + + [HandleProcessCorruptedStateExceptions, SecurityCriticalAttribute] + void WorkerThread(object obj) + { + Thread.Sleep(1000); + + WorkerProfile workerProfile = (WorkerProfile)obj; + List OpPercentages = workerProfile.OpRatio; + long IterationCount = workerProfile.TotalIteration; + int CurrentThreadId = workerProfile.WorkerId; + long OpCountPerIteration = workerProfile.OpCountPerIteration; + long UseAttempts = 0, DeleteAttempts = 0, AddAttempts = 0, UpdateAttempts = 0, LoadAttempts = 0; + + int ms2Tick = (int)(5 * Stopwatch.Frequency / 1000); + + OpPerformanceRecord useRec = new OpPerformanceRecord(workerProfile.WorkerId, "USE", ms2Tick); + OpPerformanceRecord deleteRec = new OpPerformanceRecord(workerProfile.WorkerId, "DELETE", ms2Tick); + OpPerformanceRecord updateRec = new OpPerformanceRecord(workerProfile.WorkerId, "UPDATE", ms2Tick); + OpPerformanceRecord addRec = new OpPerformanceRecord(workerProfile.WorkerId, "ADD", ms2Tick); + OpPerformanceRecord loadRec = new OpPerformanceRecord(workerProfile.WorkerId, "LOAD", ms2Tick); + + //byte[] cellBuffer = new byte[CellSize * 3]; + + + long[] _TimeoutOpCount = new long[OperationCategoryCount]; + long[] _TimeOpSum = new long[OperationCategoryCount]; + for (int i = 0; i < OperationCategoryCount; i++) + { + _TimeoutOpCount[i] = 0; + _TimeOpSum[i] = 0; + } + + #region initialization + int opCount = 0; + for (int i = 0; i < OpPercentages.Count; i++) + opCount += OpPercentages[i]; + + CellOperationType[] OpArray = new CellOperationType[opCount]; + opCount = 0; + for (int i = 0; i < OpPercentages.Count; i++) + { + for (int j = 0; j < OpPercentages[i]; j++) + { + OpArray[opCount] = (CellOperationType)i; + opCount++; + } + } + #endregion + + long garbage = 0; + for (int currentIteration = 0; currentIteration < IterationCount; currentIteration++) + { + Stopwatch _sw_ = new Stopwatch(); + int cellCountOfCurrentThread = ThreadCellIds[CurrentThreadId].Count; + Random tRandom = Randoms[CurrentThreadId]; + for (long opI = 0; opI < OpCountPerIteration; opI++) + { + CellOperationType CurrentOpType = OpArray[tRandom.Next(opCount)]; + int startI = tRandom.Next(cellCountOfCurrentThread); + + int finalI = startI + tRandom.Next(10); //! try a random number of attempts + for (int i = startI; i < finalI; i++) + { + long cellId = ThreadCellIds[CurrentThreadId][(int)(i % cellCountOfCurrentThread)]; + + if (CurrentOpType == CellOperationType.USE) + { + UseAttempts++; + #region USE + _sw_.Restart(); + int size, entryIndex; + byte* cellPtr; + ushort cellType; + TrinityErrorCode eResult = Global.LocalStorage.GetLockedCellInfo(cellId, out size, out cellType, out cellPtr, out entryIndex); + if (eResult == TrinityErrorCode.E_SUCCESS) + { + var junk = new byte[100]; + + if (size > 0) + { + int offset = Randoms[CurrentThreadId].Next(0, size); + + int delta = Randoms[CurrentThreadId].Next(0, size); + + if (Randoms[CurrentThreadId].NextDouble() < 0.8) + { + int remaining_bytes = (size - offset); + if (remaining_bytes > 0) + delta = -Randoms[CurrentThreadId].Next(0, remaining_bytes); + } + else if (size + delta > CellSize * 2) + { + delta = CellSize * 2 - size; + if (delta < 0 && offset - delta > size) + { + delta = size - offset; + } + } + + if (delta != 0) + { + try{ + cellPtr = Global.LocalStorage.ResizeCell(cellId, entryIndex, offset, delta); + }catch{ + Console.WriteLine($"{size}:{delta}"); + WorkerResizeException[CurrentThreadId] = true; + } + } + + size = size + delta; + for (int c = 0; c < size; c++) + cellPtr[c] = (byte)(cellId + c); + } + + Global.LocalStorage.ReleaseCellLock(cellId, entryIndex); + } + _sw_.Stop(); + + useRec.Record(_sw_); + #endregion + continue; + } + + if (CurrentOpType == CellOperationType.DELETE) + { + DeleteAttempts++; + #region DELETE + _sw_.Restart(); + if (Global.LocalStorage.RemoveCell(cellId) == TrinityErrorCode.E_SUCCESS) + { + Interlocked.Decrement(ref DeltaCellCount[CurrentThreadId]); + } + _sw_.Stop(); + /* + if (_sw_.ElapsedMilliseconds > 10) + { + _TimeoutOpCount[(int)CellOperationType.DELETE]++; + Log("Warning : A Remove elapsed : " + _sw_.ElapsedMilliseconds + " millis."); + }*/ + deleteRec.Record(_sw_); + #endregion + continue; + } + + if (CurrentOpType == CellOperationType.UPDATE) + { + UpdateAttempts++; + #region UPDATE + _sw_.Restart(); + + double prob_value = Randoms[CurrentThreadId].NextDouble(); + + int cell_size = 0; + if (prob_value < 0.0003) + cell_size = Randoms[CurrentThreadId].Next(2, MaxLargeObjectSize); + else + cell_size = Randoms[CurrentThreadId].Next(0, CellSize * 2); + + Global.LocalStorage.UpdateCell(cellId, GetCellContent(cellId, cell_size)); + _sw_.Stop(); + updateRec.Record(_sw_); + #endregion + continue; + } + + if (CurrentOpType == CellOperationType.ADD) + { + AddAttempts++; + #region ADD + _sw_.Restart(); + if (Global.LocalStorage.AddCell(cellId, GetCellContent(cellId, CellSize), 0, CellSize, ushort.MaxValue) == TrinityErrorCode.E_SUCCESS) + { + Interlocked.Increment(ref DeltaCellCount[CurrentThreadId]); + } + _sw_.Stop(); + addRec.Record(_sw_); + #endregion + continue; + } + + if (CurrentOpType == CellOperationType.Load) + { + LoadAttempts++; + #region Load + _sw_.Restart(); + + byte[] cellBuff; + Global.LocalStorage.LoadCell(cellId, out cellBuff); + garbage += cellBuff.Length; + _sw_.Stop(); + + loadRec.Record(_sw_); + #endregion + continue; + } + } + } + } + + Log("====WorkId : {0} all operations complete==== \n" + + "WorkId : {0} add attempts : {1}\n" + + "WorkId : {0} delete attempts : {2}\n" + + "WorkId : {0} update attempts : {3}\n" + + "WorkId : {0} cell count delta : {4}\n" + + "WorkId : {0} garbage : {5}\n" + , + CurrentThreadId, AddAttempts, DeleteAttempts, UpdateAttempts, DeltaCellCount[CurrentThreadId], garbage + ); + + + lock (TimeoutOpCountLock) + { + for (int i = 0; i < OperationCategoryCount; i++) + { + TimeoutOpCount[i] += _TimeoutOpCount[i]; + } + deleteRec.Output(); + updateRec.Output(); + addRec.Output(); + } + } + + void Initialize() + { + DeltaCellCount = new long[WorkerCount]; + WorkerResizeException = new bool[WorkerCount]; + for (int i = 0; i < WorkerCount; i++) + { + DeltaCellCount[i] = 0; + WorkerResizeException[i] = false; + } + cellLocks = new Object[MaxCellCount]; + for (int i = 0; i < MaxCellCount; i++) + cellLocks[i] = new Object(); + for (int i = 0; i < 4; i++) + TimeoutOpCount[i] = 0; + + Log("========== Parameters =========="); + Log("SEED : " + RandomSeed); + Log("THREAD_WORK_OVERLAP : " + ThreadCellRangeOverlap); + Log("THREAD_COUNT : " + WorkerCount); + Log("CELL_SIZE : " + CellSize); + Log("MAX_CELL_COUNT : " + MaxCellCount); + Log("SINGLE_TRUNK : " + SingleTrunk); + Log("ITERATION_COUNT : " + IterationCount); + Log("OPS_PER_ITERATION : " + OpsPerIteration); + + Console.WriteLine(); + + Randoms = new Random[WorkerCount]; + ThreadCellIds = new List[WorkerCount]; + for (int i = 0; i < WorkerCount; i++) + { + Randoms[i] = new Random(random.Next()); + ThreadCellIds[i] = new List(); + } + + Log("Start saving initial cells ..."); + long EndCellId = StartCellId + MaxCellCount; + for (long id = StartCellId; id < EndCellId; id++) + { + if (SingleTrunk && (byte)id != 0) + continue; + + if (random.NextDouble() > 0.5) //Firstly, only save about half of the cells + { + ++InitialCellCount; + Global.LocalStorage.SaveCell(id, GetCellContent(id, CellSize), ushort.MaxValue); + } + if (ThreadCellRangeOverlap) //assign the id to a thread + { + for (int i = 0; i < WorkerCount; i++) //assign it to all thread + ThreadCellIds[i].Add(id); + } + else + { + ThreadCellIds[random.Next(WorkerCount)].Add(id); //assign it to a random thread + } + } + for (int i = 0; i < WorkerCount; i++) + { + if (ThreadCellIds[i].Count == 0) + { + Log("Warning: worker #{0} does not have any cell to manipulate.", i); + throw new Exception(); + } + } + Log("Initial cell count: " + InitialCellCount); + } + + #region Utilities + Object loglock = new Object(); + void Log(string format, params object[] arg) + { + var message = string.Format(CultureInfo.InvariantCulture, format, arg); + lock (loglock) + { + Console.Error.WriteLine(message); + } + } + static byte[] GetCellContent(long id, int length) + { + byte[] content = new byte[length]; + for (int c = 0; c < length; c++) + content[c] = (byte)(id + c); + return content; + } + bool VerifyData() + { + Log("Saving storage, cell count: {0}", Global.LocalStorage.CellCount); + Global.LocalStorage.SaveStorage(); + Log("Storage saved."); + Log("Loading storage ..."); + Global.LocalStorage.LoadStorage(); + Log("Storage loaded"); + Console.WriteLine("Cell count: {0}", Global.LocalStorage.CellCount); + Log("====Data Verification===="); + bool right = true; + long finalActualCellCount = 0; + HashSet DistinctCells = new HashSet(); + + foreach (var cell in Global.LocalStorage) + { + finalActualCellCount++; + if (!DistinctCells.Add(cell.CellId)) + { + Console.WriteLine("Duplicated ID in the system: {0}", cell.CellId); + } + for (int i = 0; i < cell.CellSize; i++) + { + byte b = (byte)(cell.CellId + i); + byte c = *(cell.CellPtr + i); + if (c != b) + { + Log("final cell content test error : celId : " + cell.CellId); + right = false; + break; + } + } + } + + Console.Error.WriteLine("Cell Count: {0}", Global.LocalStorage.CellCount); + + for (int i = 0; i < OperationCategoryCount; i++) + { + Log((CellOperationType)i + " timeout : " + TimeoutOpCount[i]); + } + Log("initialCellNum : " + InitialCellCount); + long finalExpectedCellCount = InitialCellCount; + for (int i = 0; i < WorkerCount; i++) + { + Console.WriteLine("delta on PID " + i + " : " + DeltaCellCount[i]); + finalExpectedCellCount += DeltaCellCount[i]; + } + Console.WriteLine("Final Expected Cell Count : " + finalExpectedCellCount); + Console.WriteLine("Final Actual Cell Count : " + finalActualCellCount); + Console.WriteLine("Distinct Cell Count: " + DistinctCells.Count); + + if (finalExpectedCellCount != finalActualCellCount || DistinctCells.Count != finalActualCellCount) + { + Log("Error : finalCellNum inconsistent!!"); + right = false; + } + + if(WorkerResizeException.Any(_ => _)) + { + Log("Error : cell resize exception"); + } + + return right; + } + + class WorkerProfile + { + public readonly int WorkerId; + /// + /// At each iteration, the threads will randomly choose some cells to operate on, + /// we recommend the user to set the parameter to be close to CELL_EACH_TRUNK * size of TRUNKS_FOR_TEST + /// + public readonly long OpCountPerIteration; + public readonly int TotalIteration; + /// + /// ratio of workload of save, delete, update + /// + public readonly List OpRatio; + public WorkerProfile(int workerId, long op_per_iteration, int iterationCount, List op_ratio) + { + WorkerId = workerId; + OpCountPerIteration = op_per_iteration; + TotalIteration = iterationCount; + OpRatio = op_ratio; + } + } + #endregion + } + + public class storage4 + { + [TestCase(32771, true, 128, 1<<16, false, 20000, 20000, 2 << 20, false)] + [TestCase(25168, false, 511, 2<<16, false, 30000, 200, 1 << 20, false)] + [TestCase(496827356, true, 315, 1<<15, false, 20, 200000, 1 << 20, false)] + [TestCase(9486, false, 7, 3<<16, false, 50000, 1000, 1 << 20, false)] + [TestCase(67691, true, 916, 1<<13, false, 1000, 50000, 1 << 20, false)] + [TestCase(459, false, 617, 1<<20, false, 10000, 5000, 1 << 20, false)] + + [TestCase(32771, true, 128, 1<<16, true, 20000, 20000, 2 << 20, false)] + [TestCase(25168, false, 511, 2<<16, true, 30000, 200, 2 << 20, false)] + [TestCase(496827356, true, 315, 1<<15, true, 20, 2000000, 2 << 20, false)] + [TestCase(9486, false, 7, 3<<16, true, 50000, 10000, 2 << 20, false)] + [TestCase(67691, true, 916, 1<<13, true, 10000, 50000, 2 << 20, false)] + [TestCase(459, false, 617, 1<<20, true, 10000, 100000, 2 << 20, false)] + + [TestCase(32771, true, 128, 1<<16, false, 20000, 20000, 1 << 13, true)] + [TestCase(25168, false, 511, 2<<16, false, 30000, 200, 1 << 12, true)] + [TestCase(496827356, true, 315, 1<<15, false, 20, 2000000, 1 << 12, true)] + [TestCase(9486, false, 7, 1<<16, false, 50000, 10000, 1 << 12, true)] + [TestCase(67691, true, 916, 1<<13, false, 10000, 50000, 1 << 13, true)] + [TestCase(459, false, 617, 1<<20, false, 10000, 100000, 1 << 13, true)] + public void TestCMemTrunk(int random_seed, bool thread_cell_range_overlap, int cell_size, int max_lo_size, bool pause_defrag, int iter_cnt, long ops_cnt, int max_cell_count, bool single_trunk) + { + Global.LocalStorage.ResetStorage(); + Test t = new Test(random_seed, thread_cell_range_overlap, cell_size, max_lo_size, pause_defrag, iter_cnt, ops_cnt, max_cell_count, single_trunk); + Assert.True(t.Run()); + } + } +} diff --git a/tests/storage/storage4_nunit/storage4_nunit.csproj b/tests/storage/storage4_nunit/storage4_nunit.csproj new file mode 100644 index 000000000..77afbd107 --- /dev/null +++ b/tests/storage/storage4_nunit/storage4_nunit.csproj @@ -0,0 +1,78 @@ + + + + + + Debug + AnyCPU + {0AE97FA8-E63E-48EA-8336-529FE0A9DBC0} + Library + storage4_nunit + storage4_nunit + v4.6.1 + 512 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll + True + + + + + + + + + + + ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll + True + + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + diff --git a/tests/storage/storage4_nunit/storage4_nunit.tsl b/tests/storage/storage4_nunit/storage4_nunit.tsl new file mode 100644 index 000000000..f0560bad8 --- /dev/null +++ b/tests/storage/storage4_nunit/storage4_nunit.tsl @@ -0,0 +1,4 @@ +cell struct MyCell +{ + int A; +} \ No newline at end of file diff --git a/tests/storage/storage4_nunit/storage4_nunit_coreclr.csproj b/tests/storage/storage4_nunit/storage4_nunit_coreclr.csproj new file mode 100644 index 000000000..f6407a455 --- /dev/null +++ b/tests/storage/storage4_nunit/storage4_nunit_coreclr.csproj @@ -0,0 +1,20 @@ + + + + netcoreapp2.0 + 2.0.0-beta-001509-00 + storage4_nunit_coreclr + storage4_nunit + + + + + + + + + + + + + diff --git a/tests/tests.nunit b/tests/tests.nunit new file mode 100644 index 000000000..77bc9c555 --- /dev/null +++ b/tests/tests.nunit @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file From 20bf6282c6e354b9c4e392d6836d53fafa3ac3de Mon Sep 17 00:00:00 2001 From: leasunhy Date: Fri, 28 Apr 2017 11:24:57 +0800 Subject: [PATCH 02/38] Test: remove test project --- tests/storage/storage4_nunit/TestResult.xml | 4 - tests/storage/storage4_nunit/packages.config | 11 - .../storage/storage4_nunit/storage4_nunit.cs | 633 ------------------ .../storage4_nunit/storage4_nunit.csproj | 78 --- .../storage/storage4_nunit/storage4_nunit.tsl | 4 - .../storage4_nunit_coreclr.csproj | 20 - 6 files changed, 750 deletions(-) delete mode 100644 tests/storage/storage4_nunit/TestResult.xml delete mode 100644 tests/storage/storage4_nunit/packages.config delete mode 100644 tests/storage/storage4_nunit/storage4_nunit.cs delete mode 100644 tests/storage/storage4_nunit/storage4_nunit.csproj delete mode 100644 tests/storage/storage4_nunit/storage4_nunit.tsl delete mode 100644 tests/storage/storage4_nunit/storage4_nunit_coreclr.csproj diff --git a/tests/storage/storage4_nunit/TestResult.xml b/tests/storage/storage4_nunit/TestResult.xml deleted file mode 100644 index b4e183b9f..000000000 --- a/tests/storage/storage4_nunit/TestResult.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/tests/storage/storage4_nunit/packages.config b/tests/storage/storage4_nunit/packages.config deleted file mode 100644 index dc8fb90cb..000000000 --- a/tests/storage/storage4_nunit/packages.config +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/tests/storage/storage4_nunit/storage4_nunit.cs b/tests/storage/storage4_nunit/storage4_nunit.cs deleted file mode 100644 index e8a0026fc..000000000 --- a/tests/storage/storage4_nunit/storage4_nunit.cs +++ /dev/null @@ -1,633 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.IO; -using System.Diagnostics; -using System.Threading; -using System.Security; -using System.Runtime.ExceptionServices; -using Trinity; -using System.Globalization; -using NUnit.Framework; -using Trinity.Storage; - -namespace storage4 -{ - unsafe class Test - { - #region Parameters - /// - /// This seed is used to generate a random seed for each thread - /// - int RandomSeed; - /// - /// This Random is used by the main thread - /// - Random random; - /// - /// Value = true - /// This field aims to discern cell-lock-related and cell-lock-unrelated bugs, - /// if it's false, the threads will only operate on their own cells, otherwise, - /// they will all operate on all cells and there could be data-race - /// - bool ThreadCellRangeOverlap; - /// - /// Each thread has its own random seed, so if a bug occurs in NON_THREAD_WORK_OVERLAP mode, it can be reproduced - /// - Random[] Randoms; - - /// - /// At first we will save some initial cells to the trunks, this field specifies the length of the initial cell - /// - int CellSize; - - int MaxLargeObjectSize; - - /// - /// Pauses background defragmentation thread - /// - bool PauseDefragmentation; - - int IterationCount; - long OpsPerIteration; - - /// - /// We will create HALF this number of cells randomly in the beginning, - /// the other HALF may be added in the testing process.There is a hard limit of - /// the number of cells each memory trunk can hold, that is 128 M. This is - /// deliberately designed in this way. When you fed in more than 128 M cells, - /// it will behave in an unpredictable way. - /// - long MaxCellCount; - /// - /// If SingleTrunk is set to true, all the actions will be performed on the first - /// MemoryTrunk (and thus producing a very heavy load). Otherwise, Cell IDs will - /// be scattered to all the trunks. - /// - bool SingleTrunk; - /// - /// the number of operations, which is also the size of ENUM_JOBS - /// - const long OperationCategoryCount = 4; - enum CellOperationType { USE, ADD, DELETE, UPDATE, Load }; - long[] TimeoutOpCount = new long[OperationCategoryCount]; - Object TimeoutOpCountLock = new Object(); //threads will their counts to the array when they finish - #endregion - - public Test(int random_seed = 32771, bool thread_cell_range_overlap = true, int cell_size = 128, int max_lo_size = 1 << 16, bool pause_defrag = false, int iter_cnt = 20000, long ops_cnt = 20000, int max_cell_count = 1 << 20, bool single_trunk = false) - { - RandomSeed = random_seed; - random = new Random(random_seed); - ThreadCellRangeOverlap = thread_cell_range_overlap; - CellSize = cell_size; - MaxLargeObjectSize = max_lo_size; - PauseDefragmentation = pause_defrag; - IterationCount = iter_cnt; - OpsPerIteration = ops_cnt; - MaxCellCount = max_cell_count; - SingleTrunk = single_trunk; - } - - /// - /// The count of profiles - /// - int WorkerCount; - long[] DeltaCellCount; //the delta of cell number on each thread(newly-saved - deleted) - bool[] WorkerResizeException; // toggled by a worker thread when an exception is thrown on cell resize - List[] ThreadCellIds; - long InitialCellCount = 0; - - long StartCellId = 0x7FFFFFFF00000000; - - - /// - /// We want to trace the number of all the cells, so i add a lock when i'm calling saveCell - /// - Object[] cellLocks; - [HandleProcessCorruptedStateExceptions, SecurityCriticalAttribute] - public unsafe bool Run() - { - if (PauseDefragmentation) - { - LocalMemoryStorage.PauseMemoryDefragmentation(); - } - else - { - LocalMemoryStorage.RestartMemoryDefragmentation(); - } - - //Add In Profiles, the PID field must start from 0 and add 1 one by one - List WorkerProfile = new List(); - - WorkerProfile.Add(new WorkerProfile(0, OpsPerIteration, IterationCount, new List { 1, 1, 1, 3, 1 })); //use, add, delete, update, load - WorkerProfile.Add(new WorkerProfile(1, OpsPerIteration, IterationCount, new List { 1, 1, 3, 1, 1 })); //use, add, delete, update, load - WorkerProfile.Add(new WorkerProfile(2, OpsPerIteration, IterationCount, new List { 1, 3, 1, 1, 1 })); //use, add, delete, update, load - WorkerProfile.Add(new WorkerProfile(3, OpsPerIteration, IterationCount, new List { 1, 2, 1, 3, 1 })); //use, add, delete, update, load - WorkerProfile.Add(new WorkerProfile(4, OpsPerIteration, IterationCount, new List { 1, 1, 2, 2, 1 })); //use, add, delete, update, load - - for (int i = 5; i < Environment.ProcessorCount; i++) - { - WorkerProfile.Add(new WorkerProfile(i, OpsPerIteration, IterationCount, new List { 1, 1, 1, 1, 1 })); //use, add, delete, update, load - } - - WorkerCount = WorkerProfile.Count; - - Initialize(); - - List RunningThreads = new List(); - for (int i = 0; i < WorkerProfile.Count; i++) - { - Thread t = new Thread(new ParameterizedThreadStart(WorkerThread)); - RunningThreads.Add(t); - t.Start(WorkerProfile[i]); - } - - for (int i = 0; i < RunningThreads.Count; i++) - RunningThreads[i].Join(); - - bool testResult = VerifyData(); - return testResult; - } - /// - /// A Profile Class used to trace performance of each operation in a thread - /// - class OpPerformanceRecord - { - int threadId; - long sumTime; - int count; - long maxTime; - long minTime; - int warnings; - int warnLimit; - string OpName; - public OpPerformanceRecord(int thread, string s, int limit) - { - threadId = thread; - OpName = s; - warnLimit = limit; - sumTime = 0; - count = 0; - maxTime = 0; - warnings = 0; - minTime = 1000000; - } - public void Record(Stopwatch s) - { - long time = s.ElapsedTicks; - sumTime += time; - count++; - if (time > maxTime) - maxTime = time; - if (time < minTime) - minTime = time; - if (time > warnLimit) - { - //Log("THREAD" + threadId + " WARNING : A " + OpName + " elasped " + time + " milliseconds....Timeout!"); - warnings++; - } - } - public void Output() - { - Console.WriteLine("Thead: " + threadId + " Op: " + OpName); - Console.WriteLine("\tcount: " + count); - double average_ticks = ((double)sumTime) / count; - //resize, add, delete, update - int kk = 1; - if (OpName == "ADD") kk = 2; - if (OpName == "DELETE") kk = 3; - if (OpName == "UPDATE") kk = 4; - Console.WriteLine(threadId + " " + kk + " " + average_ticks + " " + average_ticks * 1000 / Stopwatch.Frequency); - Console.WriteLine("\taverage ticks: " + average_ticks + "\t=" + average_ticks * 1000 / Stopwatch.Frequency + "ms"); - Console.WriteLine("\tmax ticks: " + maxTime + "\t=" + maxTime * 1000 / Stopwatch.Frequency + "ms"); - Console.WriteLine("\tmin ticks: " + minTime + "\t=" + minTime * 1000 / Stopwatch.Frequency + "ms"); - Console.WriteLine("\twarnings: " + warnings); - Console.WriteLine(); - } - } - - [HandleProcessCorruptedStateExceptions, SecurityCriticalAttribute] - void WorkerThread(object obj) - { - Thread.Sleep(1000); - - WorkerProfile workerProfile = (WorkerProfile)obj; - List OpPercentages = workerProfile.OpRatio; - long IterationCount = workerProfile.TotalIteration; - int CurrentThreadId = workerProfile.WorkerId; - long OpCountPerIteration = workerProfile.OpCountPerIteration; - long UseAttempts = 0, DeleteAttempts = 0, AddAttempts = 0, UpdateAttempts = 0, LoadAttempts = 0; - - int ms2Tick = (int)(5 * Stopwatch.Frequency / 1000); - - OpPerformanceRecord useRec = new OpPerformanceRecord(workerProfile.WorkerId, "USE", ms2Tick); - OpPerformanceRecord deleteRec = new OpPerformanceRecord(workerProfile.WorkerId, "DELETE", ms2Tick); - OpPerformanceRecord updateRec = new OpPerformanceRecord(workerProfile.WorkerId, "UPDATE", ms2Tick); - OpPerformanceRecord addRec = new OpPerformanceRecord(workerProfile.WorkerId, "ADD", ms2Tick); - OpPerformanceRecord loadRec = new OpPerformanceRecord(workerProfile.WorkerId, "LOAD", ms2Tick); - - //byte[] cellBuffer = new byte[CellSize * 3]; - - - long[] _TimeoutOpCount = new long[OperationCategoryCount]; - long[] _TimeOpSum = new long[OperationCategoryCount]; - for (int i = 0; i < OperationCategoryCount; i++) - { - _TimeoutOpCount[i] = 0; - _TimeOpSum[i] = 0; - } - - #region initialization - int opCount = 0; - for (int i = 0; i < OpPercentages.Count; i++) - opCount += OpPercentages[i]; - - CellOperationType[] OpArray = new CellOperationType[opCount]; - opCount = 0; - for (int i = 0; i < OpPercentages.Count; i++) - { - for (int j = 0; j < OpPercentages[i]; j++) - { - OpArray[opCount] = (CellOperationType)i; - opCount++; - } - } - #endregion - - long garbage = 0; - for (int currentIteration = 0; currentIteration < IterationCount; currentIteration++) - { - Stopwatch _sw_ = new Stopwatch(); - int cellCountOfCurrentThread = ThreadCellIds[CurrentThreadId].Count; - Random tRandom = Randoms[CurrentThreadId]; - for (long opI = 0; opI < OpCountPerIteration; opI++) - { - CellOperationType CurrentOpType = OpArray[tRandom.Next(opCount)]; - int startI = tRandom.Next(cellCountOfCurrentThread); - - int finalI = startI + tRandom.Next(10); //! try a random number of attempts - for (int i = startI; i < finalI; i++) - { - long cellId = ThreadCellIds[CurrentThreadId][(int)(i % cellCountOfCurrentThread)]; - - if (CurrentOpType == CellOperationType.USE) - { - UseAttempts++; - #region USE - _sw_.Restart(); - int size, entryIndex; - byte* cellPtr; - ushort cellType; - TrinityErrorCode eResult = Global.LocalStorage.GetLockedCellInfo(cellId, out size, out cellType, out cellPtr, out entryIndex); - if (eResult == TrinityErrorCode.E_SUCCESS) - { - var junk = new byte[100]; - - if (size > 0) - { - int offset = Randoms[CurrentThreadId].Next(0, size); - - int delta = Randoms[CurrentThreadId].Next(0, size); - - if (Randoms[CurrentThreadId].NextDouble() < 0.8) - { - int remaining_bytes = (size - offset); - if (remaining_bytes > 0) - delta = -Randoms[CurrentThreadId].Next(0, remaining_bytes); - } - else if (size + delta > CellSize * 2) - { - delta = CellSize * 2 - size; - if (delta < 0 && offset - delta > size) - { - delta = size - offset; - } - } - - if (delta != 0) - { - try{ - cellPtr = Global.LocalStorage.ResizeCell(cellId, entryIndex, offset, delta); - }catch{ - Console.WriteLine($"{size}:{delta}"); - WorkerResizeException[CurrentThreadId] = true; - } - } - - size = size + delta; - for (int c = 0; c < size; c++) - cellPtr[c] = (byte)(cellId + c); - } - - Global.LocalStorage.ReleaseCellLock(cellId, entryIndex); - } - _sw_.Stop(); - - useRec.Record(_sw_); - #endregion - continue; - } - - if (CurrentOpType == CellOperationType.DELETE) - { - DeleteAttempts++; - #region DELETE - _sw_.Restart(); - if (Global.LocalStorage.RemoveCell(cellId) == TrinityErrorCode.E_SUCCESS) - { - Interlocked.Decrement(ref DeltaCellCount[CurrentThreadId]); - } - _sw_.Stop(); - /* - if (_sw_.ElapsedMilliseconds > 10) - { - _TimeoutOpCount[(int)CellOperationType.DELETE]++; - Log("Warning : A Remove elapsed : " + _sw_.ElapsedMilliseconds + " millis."); - }*/ - deleteRec.Record(_sw_); - #endregion - continue; - } - - if (CurrentOpType == CellOperationType.UPDATE) - { - UpdateAttempts++; - #region UPDATE - _sw_.Restart(); - - double prob_value = Randoms[CurrentThreadId].NextDouble(); - - int cell_size = 0; - if (prob_value < 0.0003) - cell_size = Randoms[CurrentThreadId].Next(2, MaxLargeObjectSize); - else - cell_size = Randoms[CurrentThreadId].Next(0, CellSize * 2); - - Global.LocalStorage.UpdateCell(cellId, GetCellContent(cellId, cell_size)); - _sw_.Stop(); - updateRec.Record(_sw_); - #endregion - continue; - } - - if (CurrentOpType == CellOperationType.ADD) - { - AddAttempts++; - #region ADD - _sw_.Restart(); - if (Global.LocalStorage.AddCell(cellId, GetCellContent(cellId, CellSize), 0, CellSize, ushort.MaxValue) == TrinityErrorCode.E_SUCCESS) - { - Interlocked.Increment(ref DeltaCellCount[CurrentThreadId]); - } - _sw_.Stop(); - addRec.Record(_sw_); - #endregion - continue; - } - - if (CurrentOpType == CellOperationType.Load) - { - LoadAttempts++; - #region Load - _sw_.Restart(); - - byte[] cellBuff; - Global.LocalStorage.LoadCell(cellId, out cellBuff); - garbage += cellBuff.Length; - _sw_.Stop(); - - loadRec.Record(_sw_); - #endregion - continue; - } - } - } - } - - Log("====WorkId : {0} all operations complete==== \n" + - "WorkId : {0} add attempts : {1}\n" + - "WorkId : {0} delete attempts : {2}\n" + - "WorkId : {0} update attempts : {3}\n" + - "WorkId : {0} cell count delta : {4}\n" + - "WorkId : {0} garbage : {5}\n" - , - CurrentThreadId, AddAttempts, DeleteAttempts, UpdateAttempts, DeltaCellCount[CurrentThreadId], garbage - ); - - - lock (TimeoutOpCountLock) - { - for (int i = 0; i < OperationCategoryCount; i++) - { - TimeoutOpCount[i] += _TimeoutOpCount[i]; - } - deleteRec.Output(); - updateRec.Output(); - addRec.Output(); - } - } - - void Initialize() - { - DeltaCellCount = new long[WorkerCount]; - WorkerResizeException = new bool[WorkerCount]; - for (int i = 0; i < WorkerCount; i++) - { - DeltaCellCount[i] = 0; - WorkerResizeException[i] = false; - } - cellLocks = new Object[MaxCellCount]; - for (int i = 0; i < MaxCellCount; i++) - cellLocks[i] = new Object(); - for (int i = 0; i < 4; i++) - TimeoutOpCount[i] = 0; - - Log("========== Parameters =========="); - Log("SEED : " + RandomSeed); - Log("THREAD_WORK_OVERLAP : " + ThreadCellRangeOverlap); - Log("THREAD_COUNT : " + WorkerCount); - Log("CELL_SIZE : " + CellSize); - Log("MAX_CELL_COUNT : " + MaxCellCount); - Log("SINGLE_TRUNK : " + SingleTrunk); - Log("ITERATION_COUNT : " + IterationCount); - Log("OPS_PER_ITERATION : " + OpsPerIteration); - - Console.WriteLine(); - - Randoms = new Random[WorkerCount]; - ThreadCellIds = new List[WorkerCount]; - for (int i = 0; i < WorkerCount; i++) - { - Randoms[i] = new Random(random.Next()); - ThreadCellIds[i] = new List(); - } - - Log("Start saving initial cells ..."); - long EndCellId = StartCellId + MaxCellCount; - for (long id = StartCellId; id < EndCellId; id++) - { - if (SingleTrunk && (byte)id != 0) - continue; - - if (random.NextDouble() > 0.5) //Firstly, only save about half of the cells - { - ++InitialCellCount; - Global.LocalStorage.SaveCell(id, GetCellContent(id, CellSize), ushort.MaxValue); - } - if (ThreadCellRangeOverlap) //assign the id to a thread - { - for (int i = 0; i < WorkerCount; i++) //assign it to all thread - ThreadCellIds[i].Add(id); - } - else - { - ThreadCellIds[random.Next(WorkerCount)].Add(id); //assign it to a random thread - } - } - for (int i = 0; i < WorkerCount; i++) - { - if (ThreadCellIds[i].Count == 0) - { - Log("Warning: worker #{0} does not have any cell to manipulate.", i); - throw new Exception(); - } - } - Log("Initial cell count: " + InitialCellCount); - } - - #region Utilities - Object loglock = new Object(); - void Log(string format, params object[] arg) - { - var message = string.Format(CultureInfo.InvariantCulture, format, arg); - lock (loglock) - { - Console.Error.WriteLine(message); - } - } - static byte[] GetCellContent(long id, int length) - { - byte[] content = new byte[length]; - for (int c = 0; c < length; c++) - content[c] = (byte)(id + c); - return content; - } - bool VerifyData() - { - Log("Saving storage, cell count: {0}", Global.LocalStorage.CellCount); - Global.LocalStorage.SaveStorage(); - Log("Storage saved."); - Log("Loading storage ..."); - Global.LocalStorage.LoadStorage(); - Log("Storage loaded"); - Console.WriteLine("Cell count: {0}", Global.LocalStorage.CellCount); - Log("====Data Verification===="); - bool right = true; - long finalActualCellCount = 0; - HashSet DistinctCells = new HashSet(); - - foreach (var cell in Global.LocalStorage) - { - finalActualCellCount++; - if (!DistinctCells.Add(cell.CellId)) - { - Console.WriteLine("Duplicated ID in the system: {0}", cell.CellId); - } - for (int i = 0; i < cell.CellSize; i++) - { - byte b = (byte)(cell.CellId + i); - byte c = *(cell.CellPtr + i); - if (c != b) - { - Log("final cell content test error : celId : " + cell.CellId); - right = false; - break; - } - } - } - - Console.Error.WriteLine("Cell Count: {0}", Global.LocalStorage.CellCount); - - for (int i = 0; i < OperationCategoryCount; i++) - { - Log((CellOperationType)i + " timeout : " + TimeoutOpCount[i]); - } - Log("initialCellNum : " + InitialCellCount); - long finalExpectedCellCount = InitialCellCount; - for (int i = 0; i < WorkerCount; i++) - { - Console.WriteLine("delta on PID " + i + " : " + DeltaCellCount[i]); - finalExpectedCellCount += DeltaCellCount[i]; - } - Console.WriteLine("Final Expected Cell Count : " + finalExpectedCellCount); - Console.WriteLine("Final Actual Cell Count : " + finalActualCellCount); - Console.WriteLine("Distinct Cell Count: " + DistinctCells.Count); - - if (finalExpectedCellCount != finalActualCellCount || DistinctCells.Count != finalActualCellCount) - { - Log("Error : finalCellNum inconsistent!!"); - right = false; - } - - if(WorkerResizeException.Any(_ => _)) - { - Log("Error : cell resize exception"); - } - - return right; - } - - class WorkerProfile - { - public readonly int WorkerId; - /// - /// At each iteration, the threads will randomly choose some cells to operate on, - /// we recommend the user to set the parameter to be close to CELL_EACH_TRUNK * size of TRUNKS_FOR_TEST - /// - public readonly long OpCountPerIteration; - public readonly int TotalIteration; - /// - /// ratio of workload of save, delete, update - /// - public readonly List OpRatio; - public WorkerProfile(int workerId, long op_per_iteration, int iterationCount, List op_ratio) - { - WorkerId = workerId; - OpCountPerIteration = op_per_iteration; - TotalIteration = iterationCount; - OpRatio = op_ratio; - } - } - #endregion - } - - public class storage4 - { - [TestCase(32771, true, 128, 1<<16, false, 20000, 20000, 2 << 20, false)] - [TestCase(25168, false, 511, 2<<16, false, 30000, 200, 1 << 20, false)] - [TestCase(496827356, true, 315, 1<<15, false, 20, 200000, 1 << 20, false)] - [TestCase(9486, false, 7, 3<<16, false, 50000, 1000, 1 << 20, false)] - [TestCase(67691, true, 916, 1<<13, false, 1000, 50000, 1 << 20, false)] - [TestCase(459, false, 617, 1<<20, false, 10000, 5000, 1 << 20, false)] - - [TestCase(32771, true, 128, 1<<16, true, 20000, 20000, 2 << 20, false)] - [TestCase(25168, false, 511, 2<<16, true, 30000, 200, 2 << 20, false)] - [TestCase(496827356, true, 315, 1<<15, true, 20, 2000000, 2 << 20, false)] - [TestCase(9486, false, 7, 3<<16, true, 50000, 10000, 2 << 20, false)] - [TestCase(67691, true, 916, 1<<13, true, 10000, 50000, 2 << 20, false)] - [TestCase(459, false, 617, 1<<20, true, 10000, 100000, 2 << 20, false)] - - [TestCase(32771, true, 128, 1<<16, false, 20000, 20000, 1 << 13, true)] - [TestCase(25168, false, 511, 2<<16, false, 30000, 200, 1 << 12, true)] - [TestCase(496827356, true, 315, 1<<15, false, 20, 2000000, 1 << 12, true)] - [TestCase(9486, false, 7, 1<<16, false, 50000, 10000, 1 << 12, true)] - [TestCase(67691, true, 916, 1<<13, false, 10000, 50000, 1 << 13, true)] - [TestCase(459, false, 617, 1<<20, false, 10000, 100000, 1 << 13, true)] - public void TestCMemTrunk(int random_seed, bool thread_cell_range_overlap, int cell_size, int max_lo_size, bool pause_defrag, int iter_cnt, long ops_cnt, int max_cell_count, bool single_trunk) - { - Global.LocalStorage.ResetStorage(); - Test t = new Test(random_seed, thread_cell_range_overlap, cell_size, max_lo_size, pause_defrag, iter_cnt, ops_cnt, max_cell_count, single_trunk); - Assert.True(t.Run()); - } - } -} diff --git a/tests/storage/storage4_nunit/storage4_nunit.csproj b/tests/storage/storage4_nunit/storage4_nunit.csproj deleted file mode 100644 index 77afbd107..000000000 --- a/tests/storage/storage4_nunit/storage4_nunit.csproj +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - Debug - AnyCPU - {0AE97FA8-E63E-48EA-8336-529FE0A9DBC0} - Library - storage4_nunit - storage4_nunit - v4.6.1 - 512 - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll - True - - - - - - - - - - - ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll - True - - - ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - diff --git a/tests/storage/storage4_nunit/storage4_nunit.tsl b/tests/storage/storage4_nunit/storage4_nunit.tsl deleted file mode 100644 index f0560bad8..000000000 --- a/tests/storage/storage4_nunit/storage4_nunit.tsl +++ /dev/null @@ -1,4 +0,0 @@ -cell struct MyCell -{ - int A; -} \ No newline at end of file diff --git a/tests/storage/storage4_nunit/storage4_nunit_coreclr.csproj b/tests/storage/storage4_nunit/storage4_nunit_coreclr.csproj deleted file mode 100644 index f6407a455..000000000 --- a/tests/storage/storage4_nunit/storage4_nunit_coreclr.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - netcoreapp2.0 - 2.0.0-beta-001509-00 - storage4_nunit_coreclr - storage4_nunit - - - - - - - - - - - - - From a916a55a49b3a998d97003b42decf8e8f19e3aa7 Mon Sep 17 00:00:00 2001 From: leasunhy Date: Fri, 28 Apr 2017 11:25:27 +0800 Subject: [PATCH 03/38] Test: add simple xunit-to-nunit converting scripts --- tests/convert_to_nunit.sh | 5 +++++ tests/xunit2nunit.sed | 4 ++++ 2 files changed, 9 insertions(+) create mode 100644 tests/convert_to_nunit.sh create mode 100644 tests/xunit2nunit.sed diff --git a/tests/convert_to_nunit.sh b/tests/convert_to_nunit.sh new file mode 100644 index 000000000..c12593e4a --- /dev/null +++ b/tests/convert_to_nunit.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +find . -name '*.cs' -not -path './**/*AssemblyInfo.cs' -not -path './**/obj/**/*.cs' -not -path './new_test.cs' \ + | xargs sed -i -f xunit2nunit.sed + diff --git a/tests/xunit2nunit.sed b/tests/xunit2nunit.sed new file mode 100644 index 000000000..e68a0a9f2 --- /dev/null +++ b/tests/xunit2nunit.sed @@ -0,0 +1,4 @@ +s@InlineData@TestCase@g +s@Fact@Test@g +s@using Xunit@using NUnit.Framework@g +/\[Theory\]/d From 10dcb983918988cc67c30d531065107127a9f6c1 Mon Sep 17 00:00:00 2001 From: leasunhy Date: Fri, 28 Apr 2017 11:27:36 +0800 Subject: [PATCH 04/38] Test: update root packages.config for nunit --- tests/packages.config | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/packages.config b/tests/packages.config index 3ee58d87a..148f451b8 100644 --- a/tests/packages.config +++ b/tests/packages.config @@ -1,8 +1,6 @@  - - @@ -11,4 +9,4 @@ - \ No newline at end of file + From 145872601fc38899ac7152573e5af46df2b9dfcf Mon Sep 17 00:00:00 2001 From: leasunhy Date: Fri, 28 Apr 2017 11:35:45 +0800 Subject: [PATCH 05/38] Test: updated template for nunit; project files for coreclr not updated --- tests/template/standalone/packages.config | 9 ++------- tests/template/standalone/test_name.cs | 4 ++-- tests/template/standalone/test_name.csproj | 17 ++--------------- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/tests/template/standalone/packages.config b/tests/template/standalone/packages.config index a86c34cbf..fb72b47d3 100644 --- a/tests/template/standalone/packages.config +++ b/tests/template/standalone/packages.config @@ -2,10 +2,5 @@ - - - - - - - \ No newline at end of file + + diff --git a/tests/template/standalone/test_name.cs b/tests/template/standalone/test_name.cs index fa2fd765c..173f7963e 100644 --- a/tests/template/standalone/test_name.cs +++ b/tests/template/standalone/test_name.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Xunit; +using NUnit.Framework; using Trinity; using Trinity.Storage; @@ -12,7 +12,7 @@ namespace test_name { public class test_name { - [Fact] + [Test] public void T1() { } diff --git a/tests/template/standalone/test_name.csproj b/tests/template/standalone/test_name.csproj index 1057c15a8..4271e4f94 100644 --- a/tests/template/standalone/test_name.csproj +++ b/tests/template/standalone/test_name.csproj @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll From 32fe9a5f843f359006c08ee3aec94be2c3400abf Mon Sep 17 00:00:00 2001 From: leasunhy Date: Fri, 28 Apr 2017 11:58:50 +0800 Subject: [PATCH 06/38] Test: update convert_to_unit script --- tests/convert_to_nunit.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/convert_to_nunit.sh b/tests/convert_to_nunit.sh index c12593e4a..7f8926a7b 100644 --- a/tests/convert_to_nunit.sh +++ b/tests/convert_to_nunit.sh @@ -1,5 +1,20 @@ #!/bin/bash -find . -name '*.cs' -not -path './**/*AssemblyInfo.cs' -not -path './**/obj/**/*.cs' -not -path './new_test.cs' \ - | xargs sed -i -f xunit2nunit.sed +set -e + +find . -name 'packages.config' \ + -not -path './packages.config' \ + -not -path './template/standalone/packages.config' \ + -not -path './minimal/*' \ + -not -path './minimal-tsl/*' \ + | while read line +do + project_dir=$(dirname "$line") + project_name=$(basename "$project_dir") + find "$project_dir" -name "*.cs" -not -path '*AssemblyInfo.cs' -not -path '*/obj/*.cs' | xargs sed -i -f xunit2nunit.sed + sed "s/test_name/$project_name/g" template/standalone/test_name.csproj > "${project_dir}/${project_name}.csproj" + sed "s/test_name/$project_name/g" template/standalone/test_name_coreclr.csproj > "${project_dir}/${project_name}_coreclr.csproj" + cp template/standalone/packages.config "$project_dir/" + echo $project_name +done From f4d7af524f62493e6af2079151e8238d7f0f7204 Mon Sep 17 00:00:00 2001 From: leasunhy Date: Fri, 28 Apr 2017 11:59:11 +0800 Subject: [PATCH 07/38] Test: convert existing test projects to nunit projects --- tests/cleanup/cleanup1/cleanup1.cs | 4 +- tests/cleanup/cleanup1/cleanup1.csproj | 19 +---- tests/cleanup/cleanup1/packages.config | 11 +-- tests/cleanup/cleanup2/cleanup2.cs | 4 +- tests/cleanup/cleanup2/cleanup2.csproj | 19 +---- tests/cleanup/cleanup2/packages.config | 11 +-- tests/cleanup/cleanup3/cleanup3.cs | 4 +- tests/cleanup/cleanup3/cleanup3.csproj | 19 +---- tests/cleanup/cleanup3/packages.config | 11 +-- tests/cleanup/cleanup4/cleanup4.cs | 4 +- tests/cleanup/cleanup4/cleanup4.csproj | 19 +---- tests/cleanup/cleanup4/packages.config | 11 +-- tests/cleanup/cleanup5/cleanup5.cs | 9 ++- tests/cleanup/cleanup5/cleanup5.csproj | 19 +---- tests/cleanup/cleanup5/packages.config | 11 +-- tests/config/config1/config1.cs | 14 ++-- tests/config/config1/config1.csproj | 19 +---- tests/config/config1/packages.config | 11 +-- tests/icall/icall1/icall1.cs | 4 +- tests/icall/icall1/icall1.csproj | 19 +---- tests/icall/icall1/packages.config | 11 +-- tests/icall/icall10/icall10.cs | 4 +- tests/icall/icall10/icall10.csproj | 19 +---- tests/icall/icall10/packages.config | 11 +-- tests/icall/icall11/icall11.cs | 4 +- tests/icall/icall11/icall11.csproj | 19 +---- tests/icall/icall11/packages.config | 11 +-- tests/icall/icall12/icall12.cs | 4 +- tests/icall/icall12/icall12.csproj | 19 +---- tests/icall/icall12/packages.config | 11 +-- tests/icall/icall2/icall2.cs | 4 +- tests/icall/icall2/icall2.csproj | 19 +---- tests/icall/icall2/packages.config | 11 +-- tests/icall/icall3/icall3.cs | 4 +- tests/icall/icall3/icall3.csproj | 19 +---- tests/icall/icall3/packages.config | 11 +-- tests/icall/icall4/icall4.cs | 4 +- tests/icall/icall4/icall4.csproj | 19 +---- tests/icall/icall4/packages.config | 11 +-- tests/icall/icall5/icall5.cs | 4 +- tests/icall/icall5/icall5.csproj | 19 +---- tests/icall/icall5/packages.config | 11 +-- tests/icall/icall6/icall6.cs | 4 +- tests/icall/icall6/icall6.csproj | 19 +---- tests/icall/icall6/packages.config | 11 +-- tests/icall/icall7/icall7.cs | 4 +- tests/icall/icall7/icall7.csproj | 19 +---- tests/icall/icall7/packages.config | 11 +-- tests/icall/icall8/icall8.cs | 4 +- tests/icall/icall8/icall8.csproj | 19 +---- tests/icall/icall8/packages.config | 11 +-- tests/icall/icall9/icall9.cs | 4 +- tests/icall/icall9/icall9.csproj | 19 +---- tests/icall/icall9/packages.config | 11 +-- tests/misc/misc1/misc1.cs | 4 +- tests/misc/misc1/misc1.csproj | 19 +---- tests/misc/misc1/packages.config | 11 +-- tests/storage/storage1/packages.config | 11 +-- tests/storage/storage1/storage1.cs | 11 ++- tests/storage/storage1/storage1.csproj | 19 +---- tests/storage/storage2/packages.config | 11 +-- tests/storage/storage2/storage2.cs | 13 ++-- tests/storage/storage2/storage2.csproj | 19 +---- tests/storage/storage3/packages.config | 11 +-- tests/storage/storage3/storage3.cs | 4 +- tests/storage/storage3/storage3.csproj | 19 +---- tests/storage/storage4/packages.config | 11 +-- tests/storage/storage4/storage4.cs | 43 ++++++------ tests/storage/storage4/storage4.csproj | 19 +---- tests/storage/storage5/packages.config | 11 +-- tests/storage/storage5/storage5.cs | 9 ++- tests/storage/storage5/storage5.csproj | 19 +---- tests/storage/storage6/packages.config | 11 +-- tests/storage/storage6/storage6.cs | 11 ++- tests/storage/storage6/storage6.csproj | 19 +---- tests/storage/storage7/packages.config | 11 +-- tests/storage/storage7/storage7.cs | 7 +- tests/storage/storage7/storage7.csproj | 19 +---- tests/tsl/tsl1/packages.config | 9 +-- tests/tsl/tsl1/test.cs | 96 ++++++++++++-------------- tests/tsl/tsl1/tsl1.csproj | 25 ++----- tests/tsl/tsl1/tsl1_coreclr.csproj | 4 +- 82 files changed, 300 insertions(+), 803 deletions(-) diff --git a/tests/cleanup/cleanup1/cleanup1.cs b/tests/cleanup/cleanup1/cleanup1.cs index 86c2ea985..7bffc224e 100644 --- a/tests/cleanup/cleanup1/cleanup1.cs +++ b/tests/cleanup/cleanup1/cleanup1.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Xunit; +using NUnit.Framework; using Trinity; using Trinity.Storage; @@ -12,7 +12,7 @@ namespace cleanup1 { public class cleanup1 { - [Fact] + [Test] public void T1() { TrinityServer server = new TrinityServer(); diff --git a/tests/cleanup/cleanup1/cleanup1.csproj b/tests/cleanup/cleanup1/cleanup1.csproj index 0cf971f50..facefefe0 100644 --- a/tests/cleanup/cleanup1/cleanup1.csproj +++ b/tests/cleanup/cleanup1/cleanup1.csproj @@ -1,4 +1,4 @@ - + @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll diff --git a/tests/cleanup/cleanup1/packages.config b/tests/cleanup/cleanup1/packages.config index dc8fb90cb..fb72b47d3 100644 --- a/tests/cleanup/cleanup1/packages.config +++ b/tests/cleanup/cleanup1/packages.config @@ -1,11 +1,6 @@ - + - - - - - - - \ No newline at end of file + + diff --git a/tests/cleanup/cleanup2/cleanup2.cs b/tests/cleanup/cleanup2/cleanup2.cs index 13384aaed..782f64fa4 100644 --- a/tests/cleanup/cleanup2/cleanup2.cs +++ b/tests/cleanup/cleanup2/cleanup2.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Xunit; +using NUnit.Framework; using Trinity; using Trinity.Storage; @@ -12,7 +12,7 @@ namespace cleanup2 { public class cleanup2 { - [Fact] + [Test] public void StartServerTwice() { TrinityServer server = new TrinityServer(); diff --git a/tests/cleanup/cleanup2/cleanup2.csproj b/tests/cleanup/cleanup2/cleanup2.csproj index da0edc37c..51dde5036 100644 --- a/tests/cleanup/cleanup2/cleanup2.csproj +++ b/tests/cleanup/cleanup2/cleanup2.csproj @@ -1,4 +1,4 @@ - + @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll diff --git a/tests/cleanup/cleanup2/packages.config b/tests/cleanup/cleanup2/packages.config index dc8fb90cb..fb72b47d3 100644 --- a/tests/cleanup/cleanup2/packages.config +++ b/tests/cleanup/cleanup2/packages.config @@ -1,11 +1,6 @@ - + - - - - - - - \ No newline at end of file + + diff --git a/tests/cleanup/cleanup3/cleanup3.cs b/tests/cleanup/cleanup3/cleanup3.cs index 1b9036450..cab328680 100644 --- a/tests/cleanup/cleanup3/cleanup3.cs +++ b/tests/cleanup/cleanup3/cleanup3.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Xunit; +using NUnit.Framework; using Trinity; using Trinity.Storage; @@ -12,7 +12,7 @@ namespace cleanup3 { public class cleanup3 { - [Fact] + [Test] public void T1() { Global.LocalStorage.ResetStorage(); diff --git a/tests/cleanup/cleanup3/cleanup3.csproj b/tests/cleanup/cleanup3/cleanup3.csproj index 8b9567c3e..90d86baa2 100644 --- a/tests/cleanup/cleanup3/cleanup3.csproj +++ b/tests/cleanup/cleanup3/cleanup3.csproj @@ -1,4 +1,4 @@ - + @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll diff --git a/tests/cleanup/cleanup3/packages.config b/tests/cleanup/cleanup3/packages.config index dc8fb90cb..fb72b47d3 100644 --- a/tests/cleanup/cleanup3/packages.config +++ b/tests/cleanup/cleanup3/packages.config @@ -1,11 +1,6 @@ - + - - - - - - - \ No newline at end of file + + diff --git a/tests/cleanup/cleanup4/cleanup4.cs b/tests/cleanup/cleanup4/cleanup4.cs index b9a2f0b07..07b8139d1 100644 --- a/tests/cleanup/cleanup4/cleanup4.cs +++ b/tests/cleanup/cleanup4/cleanup4.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Xunit; +using NUnit.Framework; using Trinity; using Trinity.Storage; @@ -12,7 +12,7 @@ namespace cleanup4 { public class cleanup4 { - [Fact] + [Test] public void AllocateLocalStorageTwice() { Global.LocalStorage.ResetStorage(); diff --git a/tests/cleanup/cleanup4/cleanup4.csproj b/tests/cleanup/cleanup4/cleanup4.csproj index 6063f53c7..a9b33faf0 100644 --- a/tests/cleanup/cleanup4/cleanup4.csproj +++ b/tests/cleanup/cleanup4/cleanup4.csproj @@ -1,4 +1,4 @@ - + @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll diff --git a/tests/cleanup/cleanup4/packages.config b/tests/cleanup/cleanup4/packages.config index dc8fb90cb..fb72b47d3 100644 --- a/tests/cleanup/cleanup4/packages.config +++ b/tests/cleanup/cleanup4/packages.config @@ -1,11 +1,6 @@ - + - - - - - - - \ No newline at end of file + + diff --git a/tests/cleanup/cleanup5/cleanup5.cs b/tests/cleanup/cleanup5/cleanup5.cs index b8b1a9742..b1e2867d4 100644 --- a/tests/cleanup/cleanup5/cleanup5.cs +++ b/tests/cleanup/cleanup5/cleanup5.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Xunit; +using NUnit.Framework; using Trinity; using Trinity.Storage; @@ -12,10 +12,9 @@ namespace cleanup5 { public class cleanup5 { - [Theory] - [InlineData(10)] - [InlineData(50)] - [InlineData(100)] + [TestCase(10)] + [TestCase(50)] + [TestCase(100)] public void InitUninitStressTest(int count) { for (int i=0; i + @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll diff --git a/tests/cleanup/cleanup5/packages.config b/tests/cleanup/cleanup5/packages.config index dc8fb90cb..fb72b47d3 100644 --- a/tests/cleanup/cleanup5/packages.config +++ b/tests/cleanup/cleanup5/packages.config @@ -1,11 +1,6 @@ - + - - - - - - - \ No newline at end of file + + diff --git a/tests/config/config1/config1.cs b/tests/config/config1/config1.cs index 3f57318a7..367bee39b 100644 --- a/tests/config/config1/config1.cs +++ b/tests/config/config1/config1.cs @@ -5,7 +5,7 @@ using System.Threading; using System.Threading.Tasks; using System.IO; -using Xunit; +using NUnit.Framework; using Trinity; using Trinity.Storage; @@ -13,33 +13,33 @@ namespace config1 { public class config1 { - [Fact] + [Test] public void save_config_no_exception() { TrinityConfig.SaveConfig(); } - [Fact] + [Test] public void save_config_no_exception_2() { TrinityConfig.SaveConfig("test2.xml"); } - [Fact] + [Test] public void load_config_no_exception() { TrinityConfig.LoadConfig(); } - [Fact] + [Test] public void load_config_no_exception_2() { TrinityConfig.LoadConfig("test2.xml"); } - [Fact] + [Test] // https://github.com/Microsoft/GraphEngine/issues/22 public void can_set_non_accessible_storage_root() { TrinityConfig.StorageRoot = "Y:"; } - [Fact] + [Test] public void saves_2_0_config_format() { TrinityConfig.SaveConfig("test.xml"); diff --git a/tests/config/config1/config1.csproj b/tests/config/config1/config1.csproj index 6fe029e0d..8beb50d17 100644 --- a/tests/config/config1/config1.csproj +++ b/tests/config/config1/config1.csproj @@ -1,4 +1,4 @@ - + @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll diff --git a/tests/config/config1/packages.config b/tests/config/config1/packages.config index dc8fb90cb..fb72b47d3 100644 --- a/tests/config/config1/packages.config +++ b/tests/config/config1/packages.config @@ -1,11 +1,6 @@ - + - - - - - - - \ No newline at end of file + + diff --git a/tests/icall/icall1/icall1.cs b/tests/icall/icall1/icall1.cs index 99eff22d9..e63d55585 100644 --- a/tests/icall/icall1/icall1.cs +++ b/tests/icall/icall1/icall1.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Xunit; +using NUnit.Framework; using Trinity; using Trinity.Storage; @@ -12,7 +12,7 @@ namespace icall1 { public class icall1 { - [Fact] + [Test] public void icall_committedindex() { var val = Global.LocalStorage.CommittedIndexMemory; diff --git a/tests/icall/icall1/icall1.csproj b/tests/icall/icall1/icall1.csproj index 92e4c3cf1..74bd56cd5 100644 --- a/tests/icall/icall1/icall1.csproj +++ b/tests/icall/icall1/icall1.csproj @@ -1,4 +1,4 @@ - + @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll diff --git a/tests/icall/icall1/packages.config b/tests/icall/icall1/packages.config index dc8fb90cb..fb72b47d3 100644 --- a/tests/icall/icall1/packages.config +++ b/tests/icall/icall1/packages.config @@ -1,11 +1,6 @@ - + - - - - - - - \ No newline at end of file + + diff --git a/tests/icall/icall10/icall10.cs b/tests/icall/icall10/icall10.cs index 0ffaa9c46..8ff8ffbd2 100644 --- a/tests/icall/icall10/icall10.cs +++ b/tests/icall/icall10/icall10.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Xunit; +using NUnit.Framework; using Trinity; using Trinity.Storage; @@ -12,7 +12,7 @@ namespace icall10 { public class icall10 { - [Fact] + [Test] public void icall_config_storagecapacity_get() { var val = TrinityConfig.StorageCapacity; diff --git a/tests/icall/icall10/icall10.csproj b/tests/icall/icall10/icall10.csproj index 38685b5ad..77585e805 100644 --- a/tests/icall/icall10/icall10.csproj +++ b/tests/icall/icall10/icall10.csproj @@ -1,4 +1,4 @@ - + @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll diff --git a/tests/icall/icall10/packages.config b/tests/icall/icall10/packages.config index dc8fb90cb..fb72b47d3 100644 --- a/tests/icall/icall10/packages.config +++ b/tests/icall/icall10/packages.config @@ -1,11 +1,6 @@ - + - - - - - - - \ No newline at end of file + + diff --git a/tests/icall/icall11/icall11.cs b/tests/icall/icall11/icall11.cs index dee936e87..e6a2e69ae 100644 --- a/tests/icall/icall11/icall11.cs +++ b/tests/icall/icall11/icall11.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Xunit; +using NUnit.Framework; using Trinity; using Trinity.Storage; @@ -12,7 +12,7 @@ namespace icall11 { public class icall11 { - [Fact] + [Test] public void icall_config_readonly_get() { var val = TrinityConfig.ReadOnly; diff --git a/tests/icall/icall11/icall11.csproj b/tests/icall/icall11/icall11.csproj index ac93eb262..6917fad4f 100644 --- a/tests/icall/icall11/icall11.csproj +++ b/tests/icall/icall11/icall11.csproj @@ -1,4 +1,4 @@ - + @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll diff --git a/tests/icall/icall11/packages.config b/tests/icall/icall11/packages.config index dc8fb90cb..fb72b47d3 100644 --- a/tests/icall/icall11/packages.config +++ b/tests/icall/icall11/packages.config @@ -1,11 +1,6 @@ - + - - - - - - - \ No newline at end of file + + diff --git a/tests/icall/icall12/icall12.cs b/tests/icall/icall12/icall12.cs index 28d798bc7..83bd17604 100644 --- a/tests/icall/icall12/icall12.cs +++ b/tests/icall/icall12/icall12.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Xunit; +using NUnit.Framework; using Trinity; using Trinity.Storage; @@ -12,7 +12,7 @@ namespace icall12 { public class icall12 { - [Fact] + [Test] public void icall_config_trunkcount_get() { var val = TrinityConfig.TrunkCount; diff --git a/tests/icall/icall12/icall12.csproj b/tests/icall/icall12/icall12.csproj index 302533df4..94ff9070a 100644 --- a/tests/icall/icall12/icall12.csproj +++ b/tests/icall/icall12/icall12.csproj @@ -1,4 +1,4 @@ - + @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll diff --git a/tests/icall/icall12/packages.config b/tests/icall/icall12/packages.config index dc8fb90cb..fb72b47d3 100644 --- a/tests/icall/icall12/packages.config +++ b/tests/icall/icall12/packages.config @@ -1,11 +1,6 @@ - + - - - - - - - \ No newline at end of file + + diff --git a/tests/icall/icall2/icall2.cs b/tests/icall/icall2/icall2.cs index 40aae31e5..ef958aa88 100644 --- a/tests/icall/icall2/icall2.cs +++ b/tests/icall/icall2/icall2.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Xunit; +using NUnit.Framework; using Trinity; using Trinity.Storage; @@ -12,7 +12,7 @@ namespace icall2 { public class icall2 { - [Fact] + [Test] public void icall_committedtrunk() { var val = Global.LocalStorage.CommittedTrunkMemory; diff --git a/tests/icall/icall2/icall2.csproj b/tests/icall/icall2/icall2.csproj index f2ade24ff..4900c0f6c 100644 --- a/tests/icall/icall2/icall2.csproj +++ b/tests/icall/icall2/icall2.csproj @@ -1,4 +1,4 @@ - + @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll diff --git a/tests/icall/icall2/packages.config b/tests/icall/icall2/packages.config index dc8fb90cb..fb72b47d3 100644 --- a/tests/icall/icall2/packages.config +++ b/tests/icall/icall2/packages.config @@ -1,11 +1,6 @@ - + - - - - - - - \ No newline at end of file + + diff --git a/tests/icall/icall3/icall3.cs b/tests/icall/icall3/icall3.cs index 90be9fcd4..01a80a668 100644 --- a/tests/icall/icall3/icall3.cs +++ b/tests/icall/icall3/icall3.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Xunit; +using NUnit.Framework; using Trinity; using Trinity.Storage; @@ -12,7 +12,7 @@ namespace icall3 { public class icall3 { - [Fact] + [Test] public void icall_cellcount() { var val = Global.LocalStorage.CellCount; diff --git a/tests/icall/icall3/icall3.csproj b/tests/icall/icall3/icall3.csproj index fd800380a..d59e7b1db 100644 --- a/tests/icall/icall3/icall3.csproj +++ b/tests/icall/icall3/icall3.csproj @@ -1,4 +1,4 @@ - + @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll diff --git a/tests/icall/icall3/packages.config b/tests/icall/icall3/packages.config index dc8fb90cb..fb72b47d3 100644 --- a/tests/icall/icall3/packages.config +++ b/tests/icall/icall3/packages.config @@ -1,11 +1,6 @@ - + - - - - - - - \ No newline at end of file + + diff --git a/tests/icall/icall4/icall4.cs b/tests/icall/icall4/icall4.cs index 98a48742b..9028a49ee 100644 --- a/tests/icall/icall4/icall4.cs +++ b/tests/icall/icall4/icall4.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Xunit; +using NUnit.Framework; using Trinity; using Trinity.Storage; @@ -12,7 +12,7 @@ namespace icall4 { public class icall4 { - [Fact] + [Test] public void icall_totalcommittedmemory() { var val = Global.LocalStorage.TotalCommittedMemory; diff --git a/tests/icall/icall4/icall4.csproj b/tests/icall/icall4/icall4.csproj index 243e4f680..ecba28ead 100644 --- a/tests/icall/icall4/icall4.csproj +++ b/tests/icall/icall4/icall4.csproj @@ -1,4 +1,4 @@ - + @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll diff --git a/tests/icall/icall4/packages.config b/tests/icall/icall4/packages.config index dc8fb90cb..fb72b47d3 100644 --- a/tests/icall/icall4/packages.config +++ b/tests/icall/icall4/packages.config @@ -1,11 +1,6 @@ - + - - - - - - - \ No newline at end of file + + diff --git a/tests/icall/icall5/icall5.cs b/tests/icall/icall5/icall5.cs index c67d6468c..ea3f626ee 100644 --- a/tests/icall/icall5/icall5.cs +++ b/tests/icall/icall5/icall5.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Xunit; +using NUnit.Framework; using Trinity; using Trinity.Storage; @@ -12,7 +12,7 @@ namespace icall5 { public class icall5 { - [Fact] + [Test] public void icall_addcell() { var val = Global.LocalStorage.AddCell(0, new byte[128], 0, 128, 0); diff --git a/tests/icall/icall5/icall5.csproj b/tests/icall/icall5/icall5.csproj index bef7552b5..7c0ba3a29 100644 --- a/tests/icall/icall5/icall5.csproj +++ b/tests/icall/icall5/icall5.csproj @@ -1,4 +1,4 @@ - + @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll diff --git a/tests/icall/icall5/packages.config b/tests/icall/icall5/packages.config index dc8fb90cb..fb72b47d3 100644 --- a/tests/icall/icall5/packages.config +++ b/tests/icall/icall5/packages.config @@ -1,11 +1,6 @@ - + - - - - - - - \ No newline at end of file + + diff --git a/tests/icall/icall6/icall6.cs b/tests/icall/icall6/icall6.cs index c04f4b179..e7ee3743f 100644 --- a/tests/icall/icall6/icall6.cs +++ b/tests/icall/icall6/icall6.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Xunit; +using NUnit.Framework; using Trinity; using Trinity.Storage; @@ -12,7 +12,7 @@ namespace icall6 { public class icall6 { - [Fact] + [Test] public void icall_loadcell() { byte[] content; diff --git a/tests/icall/icall6/icall6.csproj b/tests/icall/icall6/icall6.csproj index f26ba65cc..a481249c7 100644 --- a/tests/icall/icall6/icall6.csproj +++ b/tests/icall/icall6/icall6.csproj @@ -1,4 +1,4 @@ - + @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll diff --git a/tests/icall/icall6/packages.config b/tests/icall/icall6/packages.config index dc8fb90cb..fb72b47d3 100644 --- a/tests/icall/icall6/packages.config +++ b/tests/icall/icall6/packages.config @@ -1,11 +1,6 @@ - + - - - - - - - \ No newline at end of file + + diff --git a/tests/icall/icall7/icall7.cs b/tests/icall/icall7/icall7.cs index 7e8bbd867..bbd990df0 100644 --- a/tests/icall/icall7/icall7.cs +++ b/tests/icall/icall7/icall7.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Xunit; +using NUnit.Framework; using Trinity; using Trinity.Storage; @@ -12,7 +12,7 @@ namespace icall7 { public class icall7 { - [Fact] + [Test] public void icall_instantiate_local_storage() { var storage = Global.LocalStorage; diff --git a/tests/icall/icall7/icall7.csproj b/tests/icall/icall7/icall7.csproj index d0f27eff5..399da148c 100644 --- a/tests/icall/icall7/icall7.csproj +++ b/tests/icall/icall7/icall7.csproj @@ -1,4 +1,4 @@ - + @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll diff --git a/tests/icall/icall7/packages.config b/tests/icall/icall7/packages.config index dc8fb90cb..fb72b47d3 100644 --- a/tests/icall/icall7/packages.config +++ b/tests/icall/icall7/packages.config @@ -1,11 +1,6 @@ - + - - - - - - - \ No newline at end of file + + diff --git a/tests/icall/icall8/icall8.cs b/tests/icall/icall8/icall8.cs index 8dfdebaa0..b4b19b603 100644 --- a/tests/icall/icall8/icall8.cs +++ b/tests/icall/icall8/icall8.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Xunit; +using NUnit.Framework; using Trinity; using Trinity.Storage; @@ -12,7 +12,7 @@ namespace icall8 { public class icall8 { - [Fact] + [Test] public void icall_config_storageroot_get() { var val = TrinityConfig.StorageRoot; diff --git a/tests/icall/icall8/icall8.csproj b/tests/icall/icall8/icall8.csproj index 144ca9759..f67b4691d 100644 --- a/tests/icall/icall8/icall8.csproj +++ b/tests/icall/icall8/icall8.csproj @@ -1,4 +1,4 @@ - + @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll diff --git a/tests/icall/icall8/packages.config b/tests/icall/icall8/packages.config index dc8fb90cb..fb72b47d3 100644 --- a/tests/icall/icall8/packages.config +++ b/tests/icall/icall8/packages.config @@ -1,11 +1,6 @@ - + - - - - - - - \ No newline at end of file + + diff --git a/tests/icall/icall9/icall9.cs b/tests/icall/icall9/icall9.cs index 2316ea34f..1f1bab110 100644 --- a/tests/icall/icall9/icall9.cs +++ b/tests/icall/icall9/icall9.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Xunit; +using NUnit.Framework; using Trinity; using Trinity.Storage; @@ -12,7 +12,7 @@ namespace icall9 { public class icall9 { - [Fact] + [Test] public void icall_config_storageroot_set() { TrinityConfig.StorageRoot = "."; diff --git a/tests/icall/icall9/icall9.csproj b/tests/icall/icall9/icall9.csproj index 21a32b4a8..aa2723ca4 100644 --- a/tests/icall/icall9/icall9.csproj +++ b/tests/icall/icall9/icall9.csproj @@ -1,4 +1,4 @@ - + @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll diff --git a/tests/icall/icall9/packages.config b/tests/icall/icall9/packages.config index dc8fb90cb..fb72b47d3 100644 --- a/tests/icall/icall9/packages.config +++ b/tests/icall/icall9/packages.config @@ -1,11 +1,6 @@ - + - - - - - - - \ No newline at end of file + + diff --git a/tests/misc/misc1/misc1.cs b/tests/misc/misc1/misc1.cs index c20fb8a35..4b450d330 100644 --- a/tests/misc/misc1/misc1.cs +++ b/tests/misc/misc1/misc1.cs @@ -5,7 +5,7 @@ using System.Threading; using System.Threading.Tasks; using System.IO; -using Xunit; +using NUnit.Framework; using Trinity; using Trinity.Storage; @@ -13,7 +13,7 @@ namespace misc1 { public class misc1 { - [Fact] + [Test] public void global_myassemblypath_is_functional() { var path = Global.MyAssemblyPath; diff --git a/tests/misc/misc1/misc1.csproj b/tests/misc/misc1/misc1.csproj index fc204dd12..14fbda70f 100644 --- a/tests/misc/misc1/misc1.csproj +++ b/tests/misc/misc1/misc1.csproj @@ -1,4 +1,4 @@ - + @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll diff --git a/tests/misc/misc1/packages.config b/tests/misc/misc1/packages.config index dc8fb90cb..fb72b47d3 100644 --- a/tests/misc/misc1/packages.config +++ b/tests/misc/misc1/packages.config @@ -1,11 +1,6 @@ - + - - - - - - - \ No newline at end of file + + diff --git a/tests/storage/storage1/packages.config b/tests/storage/storage1/packages.config index dc8fb90cb..fb72b47d3 100644 --- a/tests/storage/storage1/packages.config +++ b/tests/storage/storage1/packages.config @@ -1,11 +1,6 @@ - + - - - - - - - \ No newline at end of file + + diff --git a/tests/storage/storage1/storage1.cs b/tests/storage/storage1/storage1.cs index 9e6f7f03d..5a11b686d 100644 --- a/tests/storage/storage1/storage1.cs +++ b/tests/storage/storage1/storage1.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading.Tasks; using System.Threading; -using Xunit; +using NUnit.Framework; using Trinity; using Trinity.Storage; @@ -12,11 +12,10 @@ namespace storage1 { public class cell_resize_1 { - [Theory] - [InlineData(1, 10)] - [InlineData(10, 100)] - [InlineData(100, 1000)] - [InlineData(1000, 10000)] + [TestCase(1, 10)] + [TestCase(10, 100)] + [TestCase(100, 1000)] + [TestCase(1000, 10000)] public void TestCellResize(int iterations, int count) { TrinityConfig.CurrentRunningMode = RunningMode.Embedded; diff --git a/tests/storage/storage1/storage1.csproj b/tests/storage/storage1/storage1.csproj index 8ae8ad5a8..ca2e914f0 100644 --- a/tests/storage/storage1/storage1.csproj +++ b/tests/storage/storage1/storage1.csproj @@ -1,4 +1,4 @@ - + @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll diff --git a/tests/storage/storage2/packages.config b/tests/storage/storage2/packages.config index dc8fb90cb..fb72b47d3 100644 --- a/tests/storage/storage2/packages.config +++ b/tests/storage/storage2/packages.config @@ -1,11 +1,6 @@ - + - - - - - - - \ No newline at end of file + + diff --git a/tests/storage/storage2/storage2.cs b/tests/storage/storage2/storage2.cs index e98f656d3..6da6a46da 100644 --- a/tests/storage/storage2/storage2.cs +++ b/tests/storage/storage2/storage2.cs @@ -3,7 +3,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -using Xunit; +using NUnit.Framework; using Trinity; using Trinity.Storage; @@ -13,12 +13,11 @@ namespace storage2 { public class storage2 { - [Theory] - [InlineData(10, 314, 333, 7)] - [InlineData(100, 2, 65, 34)] - [InlineData(1000, 8124, 16, 1)] - [InlineData(10000, 999, 0, 233)] - [InlineData(100000, 1, 1560, 12)] + [TestCase(10, 314, 333, 7)] + [TestCase(100, 2, 65, 34)] + [TestCase(1000, 8124, 16, 1)] + [TestCase(10000, 999, 0, 233)] + [TestCase(100000, 1, 1560, 12)] public void T1(int cellCount, int s1, int s2, byte v) { byte[] buff = new byte[s1]; diff --git a/tests/storage/storage2/storage2.csproj b/tests/storage/storage2/storage2.csproj index 36d0196d4..45104b96a 100644 --- a/tests/storage/storage2/storage2.csproj +++ b/tests/storage/storage2/storage2.csproj @@ -1,4 +1,4 @@ - + @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll diff --git a/tests/storage/storage3/packages.config b/tests/storage/storage3/packages.config index dc8fb90cb..fb72b47d3 100644 --- a/tests/storage/storage3/packages.config +++ b/tests/storage/storage3/packages.config @@ -1,11 +1,6 @@ - + - - - - - - - \ No newline at end of file + + diff --git a/tests/storage/storage3/storage3.cs b/tests/storage/storage3/storage3.cs index 759728780..29ea9ea4f 100644 --- a/tests/storage/storage3/storage3.cs +++ b/tests/storage/storage3/storage3.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Xunit; +using NUnit.Framework; using Trinity; using Trinity.Storage; @@ -12,7 +12,7 @@ namespace storage3 { public class storage3 { - [Fact] + [Test] public void T1() { for (int i = 0; i < 256; i++) diff --git a/tests/storage/storage3/storage3.csproj b/tests/storage/storage3/storage3.csproj index 3a97763ce..0b6971383 100644 --- a/tests/storage/storage3/storage3.csproj +++ b/tests/storage/storage3/storage3.csproj @@ -1,4 +1,4 @@ - + @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll diff --git a/tests/storage/storage4/packages.config b/tests/storage/storage4/packages.config index dc8fb90cb..fb72b47d3 100644 --- a/tests/storage/storage4/packages.config +++ b/tests/storage/storage4/packages.config @@ -1,11 +1,6 @@ - + - - - - - - - \ No newline at end of file + + diff --git a/tests/storage/storage4/storage4.cs b/tests/storage/storage4/storage4.cs index 39342d2c6..e8a0026fc 100644 --- a/tests/storage/storage4/storage4.cs +++ b/tests/storage/storage4/storage4.cs @@ -8,7 +8,7 @@ using System.Runtime.ExceptionServices; using Trinity; using System.Globalization; -using Xunit; +using NUnit.Framework; using Trinity.Storage; namespace storage4 @@ -603,27 +603,26 @@ public WorkerProfile(int workerId, long op_per_iteration, int iterationCount, Li public class storage4 { - [Theory] - [InlineData(32771, true, 128, 1<<16, false, 20000, 20000, 2 << 20, false)] - [InlineData(25168, false, 511, 2<<16, false, 30000, 200, 1 << 20, false)] - [InlineData(496827356, true, 315, 1<<15, false, 20, 200000, 1 << 20, false)] - [InlineData(9486, false, 7, 3<<16, false, 50000, 1000, 1 << 20, false)] - [InlineData(67691, true, 916, 1<<13, false, 1000, 50000, 1 << 20, false)] - [InlineData(459, false, 617, 1<<20, false, 10000, 5000, 1 << 20, false)] - - [InlineData(32771, true, 128, 1<<16, true, 20000, 20000, 2 << 20, false)] - [InlineData(25168, false, 511, 2<<16, true, 30000, 200, 2 << 20, false)] - [InlineData(496827356, true, 315, 1<<15, true, 20, 2000000, 2 << 20, false)] - [InlineData(9486, false, 7, 3<<16, true, 50000, 10000, 2 << 20, false)] - [InlineData(67691, true, 916, 1<<13, true, 10000, 50000, 2 << 20, false)] - [InlineData(459, false, 617, 1<<20, true, 10000, 100000, 2 << 20, false)] - - [InlineData(32771, true, 128, 1<<16, false, 20000, 20000, 1 << 13, true)] - [InlineData(25168, false, 511, 2<<16, false, 30000, 200, 1 << 12, true)] - [InlineData(496827356, true, 315, 1<<15, false, 20, 2000000, 1 << 12, true)] - [InlineData(9486, false, 7, 1<<16, false, 50000, 10000, 1 << 12, true)] - [InlineData(67691, true, 916, 1<<13, false, 10000, 50000, 1 << 13, true)] - [InlineData(459, false, 617, 1<<20, false, 10000, 100000, 1 << 13, true)] + [TestCase(32771, true, 128, 1<<16, false, 20000, 20000, 2 << 20, false)] + [TestCase(25168, false, 511, 2<<16, false, 30000, 200, 1 << 20, false)] + [TestCase(496827356, true, 315, 1<<15, false, 20, 200000, 1 << 20, false)] + [TestCase(9486, false, 7, 3<<16, false, 50000, 1000, 1 << 20, false)] + [TestCase(67691, true, 916, 1<<13, false, 1000, 50000, 1 << 20, false)] + [TestCase(459, false, 617, 1<<20, false, 10000, 5000, 1 << 20, false)] + + [TestCase(32771, true, 128, 1<<16, true, 20000, 20000, 2 << 20, false)] + [TestCase(25168, false, 511, 2<<16, true, 30000, 200, 2 << 20, false)] + [TestCase(496827356, true, 315, 1<<15, true, 20, 2000000, 2 << 20, false)] + [TestCase(9486, false, 7, 3<<16, true, 50000, 10000, 2 << 20, false)] + [TestCase(67691, true, 916, 1<<13, true, 10000, 50000, 2 << 20, false)] + [TestCase(459, false, 617, 1<<20, true, 10000, 100000, 2 << 20, false)] + + [TestCase(32771, true, 128, 1<<16, false, 20000, 20000, 1 << 13, true)] + [TestCase(25168, false, 511, 2<<16, false, 30000, 200, 1 << 12, true)] + [TestCase(496827356, true, 315, 1<<15, false, 20, 2000000, 1 << 12, true)] + [TestCase(9486, false, 7, 1<<16, false, 50000, 10000, 1 << 12, true)] + [TestCase(67691, true, 916, 1<<13, false, 10000, 50000, 1 << 13, true)] + [TestCase(459, false, 617, 1<<20, false, 10000, 100000, 1 << 13, true)] public void TestCMemTrunk(int random_seed, bool thread_cell_range_overlap, int cell_size, int max_lo_size, bool pause_defrag, int iter_cnt, long ops_cnt, int max_cell_count, bool single_trunk) { Global.LocalStorage.ResetStorage(); diff --git a/tests/storage/storage4/storage4.csproj b/tests/storage/storage4/storage4.csproj index 0c36a166c..07be93cbe 100644 --- a/tests/storage/storage4/storage4.csproj +++ b/tests/storage/storage4/storage4.csproj @@ -1,4 +1,4 @@ - + @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll diff --git a/tests/storage/storage5/packages.config b/tests/storage/storage5/packages.config index dc8fb90cb..fb72b47d3 100644 --- a/tests/storage/storage5/packages.config +++ b/tests/storage/storage5/packages.config @@ -1,11 +1,6 @@ - + - - - - - - - \ No newline at end of file + + diff --git a/tests/storage/storage5/storage5.cs b/tests/storage/storage5/storage5.cs index 39db5736f..a60a12b0d 100644 --- a/tests/storage/storage5/storage5.cs +++ b/tests/storage/storage5/storage5.cs @@ -5,7 +5,7 @@ using System.Threading; using System.Threading.Tasks; using System.Diagnostics; -using Xunit; +using NUnit.Framework; using Trinity; using Trinity.Storage; @@ -13,10 +13,9 @@ namespace storage5 { public class storage5 { - [Theory] - [InlineData(100, 314, 7)] - [InlineData(1000, 6736, 65)] - [InlineData(100000, 23, 255)] + [TestCase(100, 314, 7)] + [TestCase(1000, 6736, 65)] + [TestCase(100000, 23, 255)] public unsafe void T1(int cellCount, int cellSize, byte content) { Global.LocalStorage.ResetStorage(); diff --git a/tests/storage/storage5/storage5.csproj b/tests/storage/storage5/storage5.csproj index d4aedf747..9af09e874 100644 --- a/tests/storage/storage5/storage5.csproj +++ b/tests/storage/storage5/storage5.csproj @@ -1,4 +1,4 @@ - + @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll diff --git a/tests/storage/storage6/packages.config b/tests/storage/storage6/packages.config index dc8fb90cb..fb72b47d3 100644 --- a/tests/storage/storage6/packages.config +++ b/tests/storage/storage6/packages.config @@ -1,11 +1,6 @@ - + - - - - - - - \ No newline at end of file + + diff --git a/tests/storage/storage6/storage6.cs b/tests/storage/storage6/storage6.cs index 54abab480..74348c8a5 100644 --- a/tests/storage/storage6/storage6.cs +++ b/tests/storage/storage6/storage6.cs @@ -5,7 +5,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Xunit; +using NUnit.Framework; using Trinity; using Trinity.Storage; @@ -13,11 +13,10 @@ namespace storage6 { public class storage6 { - [Theory] - [InlineData(1<<10, 8<<20, 4)] - [InlineData(1<<20, 8<<10, 4)] - [InlineData(1<<11, 8<<16, 24)] - [InlineData(1<<21, 8<<8, 24)] + [TestCase(1<<10, 8<<20, 4)] + [TestCase(1<<20, 8<<10, 4)] + [TestCase(1<<11, 8<<16, 24)] + [TestCase(1<<21, 8<<8, 24)] public void T1(int cellSize, int count, int tCount) { byte[] content = new byte[cellSize]; diff --git a/tests/storage/storage6/storage6.csproj b/tests/storage/storage6/storage6.csproj index d2219bf86..8487b3f47 100644 --- a/tests/storage/storage6/storage6.csproj +++ b/tests/storage/storage6/storage6.csproj @@ -1,4 +1,4 @@ - + @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll diff --git a/tests/storage/storage7/packages.config b/tests/storage/storage7/packages.config index dc8fb90cb..fb72b47d3 100644 --- a/tests/storage/storage7/packages.config +++ b/tests/storage/storage7/packages.config @@ -1,11 +1,6 @@ - + - - - - - - - \ No newline at end of file + + diff --git a/tests/storage/storage7/storage7.cs b/tests/storage/storage7/storage7.cs index f809b518e..7b85639f6 100644 --- a/tests/storage/storage7/storage7.cs +++ b/tests/storage/storage7/storage7.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using Xunit; +using NUnit.Framework; using Trinity; using Trinity.Storage; @@ -12,9 +12,8 @@ namespace storage7 { public class storage7 { - [Theory] - [InlineData(1027, 1<<20)] - [InlineData(2049, 1575984)] + [TestCase(1027, 1<<20)] + [TestCase(2049, 1575984)] public unsafe void T1(int buff_len, int count) { Global.LocalStorage.ResetStorage(); diff --git a/tests/storage/storage7/storage7.csproj b/tests/storage/storage7/storage7.csproj index b9f41f5d8..f82b2323c 100644 --- a/tests/storage/storage7/storage7.csproj +++ b/tests/storage/storage7/storage7.csproj @@ -1,4 +1,4 @@ - + @@ -48,21 +48,8 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll diff --git a/tests/tsl/tsl1/packages.config b/tests/tsl/tsl1/packages.config index a86c34cbf..fb72b47d3 100644 --- a/tests/tsl/tsl1/packages.config +++ b/tests/tsl/tsl1/packages.config @@ -2,10 +2,5 @@ - - - - - - - \ No newline at end of file + + diff --git a/tests/tsl/tsl1/test.cs b/tests/tsl/tsl1/test.cs index 4c0e19f07..8d25f6e0d 100644 --- a/tests/tsl/tsl1/test.cs +++ b/tests/tsl/tsl1/test.cs @@ -5,46 +5,43 @@ using System.Threading.Tasks; using Trinity; using Trinity.Storage; -using Xunit; +using NUnit.Framework; namespace tsl1 { public class simple_tsl_tests { - [Fact] + [Test] public void T1() { MyCell cell = new MyCell(); Assert.NotNull(cell); } - [Theory] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] + [TestCase(1)] + [TestCase(2)] + [TestCase(3)] public void T2(int i) { MyCell cell = new MyCell(i); Assert.Equal(i, cell.A); } - [Theory] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] + [TestCase(1)] + [TestCase(2)] + [TestCase(3)] public void T3(long cell_id) { MyCell cell = new MyCell(cell_id); Assert.Equal(cell_id, cell.CellID); } - [Theory] - [InlineData(1, 2)] - [InlineData(2, 3)] - [InlineData(3, 4)] - [InlineData(1, 5)] - [InlineData(3, 2)] - [InlineData(6, 1)] + [TestCase(1, 2)] + [TestCase(2, 3)] + [TestCase(3, 4)] + [TestCase(1, 5)] + [TestCase(3, 2)] + [TestCase(6, 1)] public void T4(long cell_id, int x) { MyCell cell = new MyCell(cell_id, x); @@ -55,13 +52,12 @@ public void T4(long cell_id, int x) Assert.Equal(x, load_cell.A); } - [Theory] - [InlineData(1, 2)] - [InlineData(2, 3)] - [InlineData(3, 4)] - [InlineData(1, 5)] - [InlineData(3, 2)] - [InlineData(6, 1)] + [TestCase(1, 2)] + [TestCase(2, 3)] + [TestCase(3, 4)] + [TestCase(1, 5)] + [TestCase(3, 2)] + [TestCase(6, 1)] public void T5(long cell_id, int x) { MyCell cell = new MyCell(cell_id, x); @@ -74,13 +70,12 @@ public void T5(long cell_id, int x) } } - [Theory] - [InlineData(1, 2)] - [InlineData(2, 3)] - [InlineData(3, 4)] - [InlineData(1, 5)] - [InlineData(3, 2)] - [InlineData(6, 1)] + [TestCase(1, 2)] + [TestCase(2, 3)] + [TestCase(3, 4)] + [TestCase(1, 5)] + [TestCase(3, 2)] + [TestCase(6, 1)] public void T6(long cell_id, int x) { Global.LocalStorage.RemoveCell(cell_id); @@ -96,13 +91,12 @@ public void T6(long cell_id, int x) } } - [Theory] - [InlineData(1, 2)] - [InlineData(2, 3)] - [InlineData(3, 4)] - [InlineData(1, 5)] - [InlineData(3, 2)] - [InlineData(6, 1)] + [TestCase(1, 2)] + [TestCase(2, 3)] + [TestCase(3, 4)] + [TestCase(1, 5)] + [TestCase(3, 2)] + [TestCase(6, 1)] public void T7(long cell_id, int x) { Global.LocalStorage.RemoveCell(cell_id); @@ -111,13 +105,12 @@ public void T7(long cell_id, int x) Global.LocalStorage.UseMyCell(cell_id, Trinity.TSL.Lib.CellAccessOptions.ThrowExceptionOnCellNotFound)); } - [Theory] - [InlineData(1, 2)] - [InlineData(2, 3)] - [InlineData(3, 4)] - [InlineData(1, 5)] - [InlineData(3, 2)] - [InlineData(6, 1)] + [TestCase(1, 2)] + [TestCase(2, 3)] + [TestCase(3, 4)] + [TestCase(1, 5)] + [TestCase(3, 2)] + [TestCase(6, 1)] public void T8(long cell_id, int x) { var cell = Global.LocalStorage.NewGenericCell("MyCell"); @@ -128,13 +121,12 @@ public void T8(long cell_id, int x) Assert.Equal(x, Global.LocalStorage.LoadMyCell(cell_id).A); } - [Theory] - [InlineData(1, 2)] - [InlineData(2, 3)] - [InlineData(3, 4)] - [InlineData(1, 5)] - [InlineData(3, 2)] - [InlineData(6, 1)] + [TestCase(1, 2)] + [TestCase(2, 3)] + [TestCase(3, 4)] + [TestCase(1, 5)] + [TestCase(3, 2)] + [TestCase(6, 1)] public void T9(long cell_id, int x) { Global.LocalStorage.SaveMyCell(cell_id, x); diff --git a/tests/tsl/tsl1/tsl1.csproj b/tests/tsl/tsl1/tsl1.csproj index cc428c4b1..44c06c6b3 100644 --- a/tests/tsl/tsl1/tsl1.csproj +++ b/tests/tsl/tsl1/tsl1.csproj @@ -7,10 +7,9 @@ AnyCPU {0AE97FA8-E63E-48EA-8336-529FE0A9DBC0} Library - Properties tsl1 tsl1 - v4.5.2 + v4.6.1 512 @@ -49,30 +48,16 @@ ..\..\packages\GraphEngine.Core.1.0.8850\lib\Trinity.Core.dll True - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll - True + + ..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll - - + - + diff --git a/tests/tsl/tsl1/tsl1_coreclr.csproj b/tests/tsl/tsl1/tsl1_coreclr.csproj index 91163fa6f..46ea99fa3 100644 --- a/tests/tsl/tsl1/tsl1_coreclr.csproj +++ b/tests/tsl/tsl1/tsl1_coreclr.csproj @@ -1,4 +1,4 @@ - + netcoreapp2.0 @@ -10,7 +10,7 @@ - + From d4a44251219470e7700ef78a0d7ff14a3b57f38c Mon Sep 17 00:00:00 2001 From: leasunhy Date: Fri, 28 Apr 2017 13:13:12 +0800 Subject: [PATCH 08/38] Test: update convert script to handle Assert.Equal --- tests/xunit2nunit.sed | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/xunit2nunit.sed b/tests/xunit2nunit.sed index e68a0a9f2..f5ae3a8e8 100644 --- a/tests/xunit2nunit.sed +++ b/tests/xunit2nunit.sed @@ -1,4 +1,5 @@ s@InlineData@TestCase@g s@Fact@Test@g s@using Xunit@using NUnit.Framework@g +s@Assert.Equal@Assert.AreEqual@g /\[Theory\]/d From 1c2213a155e849fc3654bba10dd012c4424801d7 Mon Sep 17 00:00:00 2001 From: leasunhy Date: Fri, 28 Apr 2017 13:14:04 +0800 Subject: [PATCH 09/38] Test: update test.csproj to run nunit tests; test_coreclr.csproj not updated --- tests/test.csproj | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/test.csproj b/tests/test.csproj index 4b6a280dc..5df765763 100644 --- a/tests/test.csproj +++ b/tests/test.csproj @@ -16,7 +16,7 @@ bin\Release\$(ProjectName).dll bin\Release\$(ProjectName).exe--> $(MSBuildProjectDirectory)\packages\NuGet.CommandLine.3.5.0\tools\NuGet - $(MSBuildProjectDirectory)\packages\xunit.runner.console.2.2.0\tools\xunit.console + $(MSBuildProjectDirectory)\packages\NUnit.ConsoleRunner.3.6.1\tools\nunit3-console @@ -34,10 +34,10 @@ ContinueOnError="false" Condition="Exists('$([System.IO.Path]::GetDirectoryName(%(Exe.Identity)))\bin\Release\$([System.IO.Path]::GetFileNameWithoutExtension(%(Exe.Identity))).exe')"/> - + - - + + From 12cd1efe625e1b01efc34ab3a66e0a67b0745b61 Mon Sep 17 00:00:00 2001 From: leasunhy Date: Fri, 28 Apr 2017 13:14:38 +0800 Subject: [PATCH 10/38] Test: fix Assert.Equal and Assert.InRange --- tests/storage/storage1/storage1.cs | 6 +++--- tests/storage/storage2/storage2.cs | 10 +++++----- tests/storage/storage3/storage3.cs | 2 +- tests/storage/storage5/storage5.cs | 14 +++++++------- tests/storage/storage6/storage6.cs | 4 ++-- tests/storage/storage7/storage7.cs | 8 ++++---- tests/tsl/tsl1/test.cs | 20 ++++++++++---------- 7 files changed, 32 insertions(+), 32 deletions(-) diff --git a/tests/storage/storage1/storage1.cs b/tests/storage/storage1/storage1.cs index 5a11b686d..075d66a17 100644 --- a/tests/storage/storage1/storage1.cs +++ b/tests/storage/storage1/storage1.cs @@ -41,9 +41,9 @@ public void TestCellResize(int iterations, int count) { using (var cell = Global.LocalStorage.UseGraphNode(i)) { - Assert.Equal(iterations, cell.outLinks.Count); - Assert.Equal(0, cell.inLinks.Count); - Assert.Equal("MyCell", cell.value); + Assert.AreEqual(iterations, cell.outLinks.Count); + Assert.AreEqual(0, cell.inLinks.Count); + Assert.AreEqual("MyCell", cell.value); } } } diff --git a/tests/storage/storage2/storage2.cs b/tests/storage/storage2/storage2.cs index 6da6a46da..8d1abd197 100644 --- a/tests/storage/storage2/storage2.cs +++ b/tests/storage/storage2/storage2.cs @@ -32,9 +32,9 @@ public void T1(int cellCount, int s1, int s2, byte v) byte[] out_buf = null; Global.LocalStorage.LoadCell(i, out out_buf); Assert.NotNull(out_buf); - Assert.Equal(s1, out_buf.Length); + Assert.AreEqual(s1, out_buf.Length); foreach(var b in out_buf) - Assert.Equal(v, b); + Assert.AreEqual(v, b); } Random rand = new Random(); @@ -52,10 +52,10 @@ public void T1(int cellCount, int s1, int s2, byte v) byte[] out_buf = null; Global.LocalStorage.LoadCell(i, out out_buf); Assert.NotNull(out_buf); - Assert.InRange(out_buf.Length, Math.Min(1, s2), Math.Max(1, s2)); + Assert.That(out_buf.Length, Is.InRange(Math.Min(1, s2), Math.Max(1, s2))); for(int j=0;j= 0; --i) { long id = (long)i + (pid * count / tCount); - Assert.Equal(TrinityErrorCode.E_SUCCESS, Global.LocalStorage.SaveCell(id, content)); + Assert.AreEqual(TrinityErrorCode.E_SUCCESS, Global.LocalStorage.SaveCell(id, content)); } }); diff --git a/tests/storage/storage7/storage7.cs b/tests/storage/storage7/storage7.cs index 7b85639f6..7a891e088 100644 --- a/tests/storage/storage7/storage7.cs +++ b/tests/storage/storage7/storage7.cs @@ -44,21 +44,21 @@ public unsafe void T1(int buff_len, int count) var after = Global.LocalStorage.CellCount; - Assert.Equal(before, after); + Assert.AreEqual(before, after); Console.WriteLine("Begin testing ..."); for (int i = 0; i < count; ++i) { - Assert.Equal(TrinityErrorCode.E_SUCCESS, Global.LocalStorage.LoadCell(i, out buf)); + Assert.AreEqual(TrinityErrorCode.E_SUCCESS, Global.LocalStorage.LoadCell(i, out buf)); fixed (byte* b = buf) { long* p = (long*)b; - Assert.Equal(buff_len, buf.Length); + Assert.AreEqual(buff_len, buf.Length); for (int j = 0; j < buf.Length / sizeof(long); ++j) { - Assert.Equal(p[j], (long)(i + j)); + Assert.AreEqual(p[j], (long)(i + j)); } } } diff --git a/tests/tsl/tsl1/test.cs b/tests/tsl/tsl1/test.cs index 8d25f6e0d..d0aa82cb2 100644 --- a/tests/tsl/tsl1/test.cs +++ b/tests/tsl/tsl1/test.cs @@ -24,7 +24,7 @@ public void T1() public void T2(int i) { MyCell cell = new MyCell(i); - Assert.Equal(i, cell.A); + Assert.AreEqual(i, cell.A); } [TestCase(1)] @@ -33,7 +33,7 @@ public void T2(int i) public void T3(long cell_id) { MyCell cell = new MyCell(cell_id); - Assert.Equal(cell_id, cell.CellID); + Assert.AreEqual(cell_id, cell.CellID); } [TestCase(1, 2)] @@ -48,8 +48,8 @@ public void T4(long cell_id, int x) Global.LocalStorage.SaveMyCell(cell); var load_cell = Global.LocalStorage.LoadMyCell(cell_id); - Assert.Equal(cell_id, load_cell.CellID); - Assert.Equal(x, load_cell.A); + Assert.AreEqual(cell_id, load_cell.CellID); + Assert.AreEqual(x, load_cell.A); } [TestCase(1, 2)] @@ -65,8 +65,8 @@ public void T5(long cell_id, int x) using (var accessor = Global.LocalStorage.UseMyCell(cell_id)) { - Assert.Equal(cell_id, accessor.CellID); - Assert.Equal(x, accessor.A); + Assert.AreEqual(cell_id, accessor.CellID); + Assert.AreEqual(x, accessor.A); } } @@ -86,8 +86,8 @@ public void T6(long cell_id, int x) using (var accessor = Global.LocalStorage.UseMyCell(cell_id, Trinity.TSL.Lib.CellAccessOptions.CreateNewOnCellNotFound)) { - Assert.Equal(cell_id, accessor.CellID); - Assert.Equal(x, accessor.A); + Assert.AreEqual(cell_id, accessor.CellID); + Assert.AreEqual(x, accessor.A); } } @@ -118,7 +118,7 @@ public void T8(long cell_id, int x) cell.SetField("A", x); Global.LocalStorage.SaveGenericCell(cell); - Assert.Equal(x, Global.LocalStorage.LoadMyCell(cell_id).A); + Assert.AreEqual(x, Global.LocalStorage.LoadMyCell(cell_id).A); } [TestCase(1, 2)] @@ -131,7 +131,7 @@ public void T9(long cell_id, int x) { Global.LocalStorage.SaveMyCell(cell_id, x); - Assert.Equal(x, Global.LocalStorage.LoadGenericCell(cell_id).GetField("A")); + Assert.AreEqual(x, Global.LocalStorage.LoadGenericCell(cell_id).GetField("A")); } } } From f0f7574e20fd6786022fe29c39eb6a680fa2386d Mon Sep 17 00:00:00 2001 From: leasunhy Date: Fri, 28 Apr 2017 13:15:17 +0800 Subject: [PATCH 11/38] Test: update .gitignore to ignore nunit reports --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 4fbf33a65..cae796cd6 100644 --- a/.gitignore +++ b/.gitignore @@ -88,4 +88,6 @@ tools/dotnet/* tools/dotnet-dev-win-x64.latest.exe tests/xunit_reports tests/xunit_coreclr_reports +tests/nunit_reports +tests/nunit_coreclr_reports tests/new_test.exe From ceb3e51e60994d2aa1f6ad6cd27b44edc019bd07 Mon Sep 17 00:00:00 2001 From: leasunhy Date: Fri, 28 Apr 2017 13:17:27 +0800 Subject: [PATCH 12/38] Test: fix tsl1 --- tests/tsl/tsl1/{test.cs => tsl1.cs} | 0 tests/tsl/tsl1/{test.tsl => tsl1.tsl} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/tsl/tsl1/{test.cs => tsl1.cs} (100%) rename tests/tsl/tsl1/{test.tsl => tsl1.tsl} (100%) diff --git a/tests/tsl/tsl1/test.cs b/tests/tsl/tsl1/tsl1.cs similarity index 100% rename from tests/tsl/tsl1/test.cs rename to tests/tsl/tsl1/tsl1.cs diff --git a/tests/tsl/tsl1/test.tsl b/tests/tsl/tsl1/tsl1.tsl similarity index 100% rename from tests/tsl/tsl1/test.tsl rename to tests/tsl/tsl1/tsl1.tsl From 7eec74cc73ed9961e7a031b26bd405c199c18b27 Mon Sep 17 00:00:00 2001 From: leasunhy Date: Fri, 28 Apr 2017 19:36:21 +0800 Subject: [PATCH 13/38] Test: replace Assert.True with Assert.That --- tests/config/config1/config1.cs | 2 +- tests/misc/misc1/misc1.cs | 2 +- tests/storage/storage4/storage4.cs | 2 +- tests/storage/storage5/storage5.cs | 2 +- tests/xunit2nunit.sed | 3 ++- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/config/config1/config1.cs b/tests/config/config1/config1.cs index 367bee39b..ced00d2ff 100644 --- a/tests/config/config1/config1.cs +++ b/tests/config/config1/config1.cs @@ -43,7 +43,7 @@ public void can_set_non_accessible_storage_root() public void saves_2_0_config_format() { TrinityConfig.SaveConfig("test.xml"); - Assert.True(File.ReadAllText("test.xml").Contains("ConfigVersion=\"2.0\"")); + Assert.That(File.ReadAllText("test.xml").Contains("ConfigVersion=\"2.0\"")); } } } diff --git a/tests/misc/misc1/misc1.cs b/tests/misc/misc1/misc1.cs index 4b450d330..d5dddbeed 100644 --- a/tests/misc/misc1/misc1.cs +++ b/tests/misc/misc1/misc1.cs @@ -17,7 +17,7 @@ public class misc1 public void global_myassemblypath_is_functional() { var path = Global.MyAssemblyPath; - Assert.True(Directory.GetFileSystemEntries(path).Any(_ => _.Contains("misc1"))); + Assert.That(Directory.GetFileSystemEntries(path).Any(_ => _.Contains("misc1"))); } } } diff --git a/tests/storage/storage4/storage4.cs b/tests/storage/storage4/storage4.cs index e8a0026fc..9ec46700d 100644 --- a/tests/storage/storage4/storage4.cs +++ b/tests/storage/storage4/storage4.cs @@ -627,7 +627,7 @@ public void TestCMemTrunk(int random_seed, bool thread_cell_range_overlap, int c { Global.LocalStorage.ResetStorage(); Test t = new Test(random_seed, thread_cell_range_overlap, cell_size, max_lo_size, pause_defrag, iter_cnt, ops_cnt, max_cell_count, single_trunk); - Assert.True(t.Run()); + Assert.That(t.Run()); } } } diff --git a/tests/storage/storage5/storage5.cs b/tests/storage/storage5/storage5.cs index 4877ff93c..ff72f9ed6 100644 --- a/tests/storage/storage5/storage5.cs +++ b/tests/storage/storage5/storage5.cs @@ -84,7 +84,7 @@ public unsafe void T1(int cellCount, int cellSize, byte content) foreach (var c in cells) { - Assert.True(c.CellId < cellCount / 2); + Assert.That(c.CellId < cellCount / 2); } long __count = 0; diff --git a/tests/xunit2nunit.sed b/tests/xunit2nunit.sed index f5ae3a8e8..86710e9ae 100644 --- a/tests/xunit2nunit.sed +++ b/tests/xunit2nunit.sed @@ -1,5 +1,6 @@ s@InlineData@TestCase@g s@Fact@Test@g s@using Xunit@using NUnit.Framework@g -s@Assert.Equal@Assert.AreEqual@g +s@Assert\.Equal@Assert.AreEqual@g +s@Assert\.True@Assert.That@g /\[Theory\]/d From 303d7964c591bc3afeec517c624f307823f0ae50 Mon Sep 17 00:00:00 2001 From: leasunhy Date: Fri, 28 Apr 2017 19:36:50 +0800 Subject: [PATCH 14/38] Test: update msbuild script to make nunit spawn only one worker --- tests/test.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test.csproj b/tests/test.csproj index 5df765763..492bdc10b 100644 --- a/tests/test.csproj +++ b/tests/test.csproj @@ -48,7 +48,7 @@ ContinueOnError="true" Properties="Configuration=Release;Platform=AnyCPU" UnloadProjectsOnCompletion="true"/> From eecb1cd1908327a9154a92bb07d35828244cbdf0 Mon Sep 17 00:00:00 2001 From: leasunhy Date: Mon, 1 May 2017 14:02:26 +0800 Subject: [PATCH 15/38] Test: coreclr support for NUnit wip --- tests/template/standalone/test_name_coreclr.csproj | 5 +++-- tests/test_coreclr.csproj | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/template/standalone/test_name_coreclr.csproj b/tests/template/standalone/test_name_coreclr.csproj index 5a7228005..6394c2cb3 100644 --- a/tests/template/standalone/test_name_coreclr.csproj +++ b/tests/template/standalone/test_name_coreclr.csproj @@ -8,9 +8,10 @@ - - + + + diff --git a/tests/test_coreclr.csproj b/tests/test_coreclr.csproj index 82dfaf286..a9c6cf8e3 100644 --- a/tests/test_coreclr.csproj +++ b/tests/test_coreclr.csproj @@ -31,10 +31,10 @@ WorkingDirectory="$([System.IO.Path]::GetDirectoryName(%(Exe.Identity)))" ContinueOnError="false" /> - + - - + + Date: Mon, 1 May 2017 15:03:28 +0800 Subject: [PATCH 16/38] Test: fix the permission mode for tests/convert_to_nunit.sh --- tests/convert_to_nunit.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 tests/convert_to_nunit.sh diff --git a/tests/convert_to_nunit.sh b/tests/convert_to_nunit.sh old mode 100644 new mode 100755 From ccc2f72a14f27094d41d78db6fecf3d7ca20365c Mon Sep 17 00:00:00 2001 From: leasunhy Date: Mon, 1 May 2017 20:49:30 +0800 Subject: [PATCH 17/38] Test: NUnit test runner init --- tests/nunit_test_runner/NuGet.config | 6 +++++ tests/nunit_test_runner/Program.cs | 24 +++++++++++++++++++ .../nunit_test_runner/nunitlite-runner.csproj | 11 +++++++++ 3 files changed, 41 insertions(+) create mode 100755 tests/nunit_test_runner/NuGet.config create mode 100755 tests/nunit_test_runner/Program.cs create mode 100755 tests/nunit_test_runner/nunitlite-runner.csproj diff --git a/tests/nunit_test_runner/NuGet.config b/tests/nunit_test_runner/NuGet.config new file mode 100755 index 000000000..0b3837670 --- /dev/null +++ b/tests/nunit_test_runner/NuGet.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/nunit_test_runner/Program.cs b/tests/nunit_test_runner/Program.cs new file mode 100755 index 000000000..98393eb08 --- /dev/null +++ b/tests/nunit_test_runner/Program.cs @@ -0,0 +1,24 @@ +using System; +using System.Linq; +using System.Reflection; +using System.Runtime.Loader; +using NUnitLite; +using Trinity.Core; +using NUnit.Framework; + +namespace nunitlite_runner +{ + class Program + { + static int Main(string[] args) + { + if (args.Length < 1) + { + Console.Error.WriteLine("Usage: runner [nunit-arg ...]"); + return 1; + } + var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(args[0]); + return new AutoRun(assembly).Execute(args.Skip(1).ToArray()); + } + } +} diff --git a/tests/nunit_test_runner/nunitlite-runner.csproj b/tests/nunit_test_runner/nunitlite-runner.csproj new file mode 100755 index 000000000..1d6e4d430 --- /dev/null +++ b/tests/nunit_test_runner/nunitlite-runner.csproj @@ -0,0 +1,11 @@ + + + Exe + netcoreapp2.0 + + + + + + + \ No newline at end of file From 7ba657137412bd7f9fca8507a85be58e6beb9411 Mon Sep 17 00:00:00 2001 From: leasunhy Date: Mon, 1 May 2017 20:51:31 +0800 Subject: [PATCH 18/38] Test: update coreclr csproj template and accordingly update existing test projects --- tests/cleanup/cleanup1/cleanup1_coreclr.csproj | 3 +-- tests/cleanup/cleanup2/cleanup2_coreclr.csproj | 3 +-- tests/cleanup/cleanup3/cleanup3_coreclr.csproj | 3 +-- tests/cleanup/cleanup4/cleanup4_coreclr.csproj | 3 +-- tests/cleanup/cleanup5/cleanup5_coreclr.csproj | 3 +-- tests/config/config1/config1_coreclr.csproj | 3 +-- tests/icall/icall1/icall1_coreclr.csproj | 3 +-- tests/icall/icall10/icall10_coreclr.csproj | 3 +-- tests/icall/icall11/icall11_coreclr.csproj | 3 +-- tests/icall/icall12/icall12_coreclr.csproj | 3 +-- tests/icall/icall2/icall2_coreclr.csproj | 3 +-- tests/icall/icall3/icall3_coreclr.csproj | 3 +-- tests/icall/icall4/icall4_coreclr.csproj | 3 +-- tests/icall/icall5/icall5_coreclr.csproj | 3 +-- tests/icall/icall6/icall6_coreclr.csproj | 3 +-- tests/icall/icall7/icall7_coreclr.csproj | 3 +-- tests/icall/icall8/icall8_coreclr.csproj | 3 +-- tests/icall/icall9/icall9_coreclr.csproj | 3 +-- tests/misc/misc1/misc1_coreclr.csproj | 3 +-- tests/storage/storage1/storage1_coreclr.csproj | 3 +-- tests/storage/storage2/storage2_coreclr.csproj | 3 +-- tests/storage/storage3/storage3_coreclr.csproj | 3 +-- tests/storage/storage4/storage4_coreclr.csproj | 3 +-- tests/storage/storage5/storage5_coreclr.csproj | 3 +-- tests/storage/storage6/storage6_coreclr.csproj | 3 +-- tests/storage/storage7/storage7_coreclr.csproj | 3 +-- tests/template/standalone/test_name_coreclr.csproj | 2 -- tests/tsl/tsl1/tsl1_coreclr.csproj | 3 +-- 28 files changed, 27 insertions(+), 56 deletions(-) diff --git a/tests/cleanup/cleanup1/cleanup1_coreclr.csproj b/tests/cleanup/cleanup1/cleanup1_coreclr.csproj index 12cce8d44..83666080b 100644 --- a/tests/cleanup/cleanup1/cleanup1_coreclr.csproj +++ b/tests/cleanup/cleanup1/cleanup1_coreclr.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tests/cleanup/cleanup2/cleanup2_coreclr.csproj b/tests/cleanup/cleanup2/cleanup2_coreclr.csproj index fee4f91fa..2d47ff96e 100644 --- a/tests/cleanup/cleanup2/cleanup2_coreclr.csproj +++ b/tests/cleanup/cleanup2/cleanup2_coreclr.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tests/cleanup/cleanup3/cleanup3_coreclr.csproj b/tests/cleanup/cleanup3/cleanup3_coreclr.csproj index 3b398b529..b8a5955e2 100644 --- a/tests/cleanup/cleanup3/cleanup3_coreclr.csproj +++ b/tests/cleanup/cleanup3/cleanup3_coreclr.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tests/cleanup/cleanup4/cleanup4_coreclr.csproj b/tests/cleanup/cleanup4/cleanup4_coreclr.csproj index e5f97d1a9..952c0add1 100644 --- a/tests/cleanup/cleanup4/cleanup4_coreclr.csproj +++ b/tests/cleanup/cleanup4/cleanup4_coreclr.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tests/cleanup/cleanup5/cleanup5_coreclr.csproj b/tests/cleanup/cleanup5/cleanup5_coreclr.csproj index 4a2e94624..51419daaf 100644 --- a/tests/cleanup/cleanup5/cleanup5_coreclr.csproj +++ b/tests/cleanup/cleanup5/cleanup5_coreclr.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tests/config/config1/config1_coreclr.csproj b/tests/config/config1/config1_coreclr.csproj index 9f87e833a..f39090bd9 100644 --- a/tests/config/config1/config1_coreclr.csproj +++ b/tests/config/config1/config1_coreclr.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tests/icall/icall1/icall1_coreclr.csproj b/tests/icall/icall1/icall1_coreclr.csproj index 41586353e..74ebdee7b 100644 --- a/tests/icall/icall1/icall1_coreclr.csproj +++ b/tests/icall/icall1/icall1_coreclr.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tests/icall/icall10/icall10_coreclr.csproj b/tests/icall/icall10/icall10_coreclr.csproj index 4bfe620dd..babec31c0 100644 --- a/tests/icall/icall10/icall10_coreclr.csproj +++ b/tests/icall/icall10/icall10_coreclr.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tests/icall/icall11/icall11_coreclr.csproj b/tests/icall/icall11/icall11_coreclr.csproj index a4ee00d07..d253edd4f 100644 --- a/tests/icall/icall11/icall11_coreclr.csproj +++ b/tests/icall/icall11/icall11_coreclr.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tests/icall/icall12/icall12_coreclr.csproj b/tests/icall/icall12/icall12_coreclr.csproj index 8c879744e..30fe04a40 100644 --- a/tests/icall/icall12/icall12_coreclr.csproj +++ b/tests/icall/icall12/icall12_coreclr.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tests/icall/icall2/icall2_coreclr.csproj b/tests/icall/icall2/icall2_coreclr.csproj index 6a921a974..e63af4465 100644 --- a/tests/icall/icall2/icall2_coreclr.csproj +++ b/tests/icall/icall2/icall2_coreclr.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tests/icall/icall3/icall3_coreclr.csproj b/tests/icall/icall3/icall3_coreclr.csproj index 57019df87..536d16052 100644 --- a/tests/icall/icall3/icall3_coreclr.csproj +++ b/tests/icall/icall3/icall3_coreclr.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tests/icall/icall4/icall4_coreclr.csproj b/tests/icall/icall4/icall4_coreclr.csproj index a951126fb..02ef919d6 100644 --- a/tests/icall/icall4/icall4_coreclr.csproj +++ b/tests/icall/icall4/icall4_coreclr.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tests/icall/icall5/icall5_coreclr.csproj b/tests/icall/icall5/icall5_coreclr.csproj index 0fd79f3d6..13579c8bc 100644 --- a/tests/icall/icall5/icall5_coreclr.csproj +++ b/tests/icall/icall5/icall5_coreclr.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tests/icall/icall6/icall6_coreclr.csproj b/tests/icall/icall6/icall6_coreclr.csproj index 2459bcd8e..91274a8dd 100644 --- a/tests/icall/icall6/icall6_coreclr.csproj +++ b/tests/icall/icall6/icall6_coreclr.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tests/icall/icall7/icall7_coreclr.csproj b/tests/icall/icall7/icall7_coreclr.csproj index 4a79c0be0..50c9e6ff0 100644 --- a/tests/icall/icall7/icall7_coreclr.csproj +++ b/tests/icall/icall7/icall7_coreclr.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tests/icall/icall8/icall8_coreclr.csproj b/tests/icall/icall8/icall8_coreclr.csproj index 252697365..b13ef3f11 100644 --- a/tests/icall/icall8/icall8_coreclr.csproj +++ b/tests/icall/icall8/icall8_coreclr.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tests/icall/icall9/icall9_coreclr.csproj b/tests/icall/icall9/icall9_coreclr.csproj index 81a58128a..828cd4582 100644 --- a/tests/icall/icall9/icall9_coreclr.csproj +++ b/tests/icall/icall9/icall9_coreclr.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tests/misc/misc1/misc1_coreclr.csproj b/tests/misc/misc1/misc1_coreclr.csproj index 2777e1c35..5c2808594 100644 --- a/tests/misc/misc1/misc1_coreclr.csproj +++ b/tests/misc/misc1/misc1_coreclr.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tests/storage/storage1/storage1_coreclr.csproj b/tests/storage/storage1/storage1_coreclr.csproj index e4a1c0ff3..a7e5c6164 100644 --- a/tests/storage/storage1/storage1_coreclr.csproj +++ b/tests/storage/storage1/storage1_coreclr.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tests/storage/storage2/storage2_coreclr.csproj b/tests/storage/storage2/storage2_coreclr.csproj index 055fb50c3..16cc5dbf2 100644 --- a/tests/storage/storage2/storage2_coreclr.csproj +++ b/tests/storage/storage2/storage2_coreclr.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tests/storage/storage3/storage3_coreclr.csproj b/tests/storage/storage3/storage3_coreclr.csproj index 12e0e4d48..9345fb065 100644 --- a/tests/storage/storage3/storage3_coreclr.csproj +++ b/tests/storage/storage3/storage3_coreclr.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tests/storage/storage4/storage4_coreclr.csproj b/tests/storage/storage4/storage4_coreclr.csproj index e71cf2d4a..a380e55cb 100644 --- a/tests/storage/storage4/storage4_coreclr.csproj +++ b/tests/storage/storage4/storage4_coreclr.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tests/storage/storage5/storage5_coreclr.csproj b/tests/storage/storage5/storage5_coreclr.csproj index 304e4c927..920b67554 100644 --- a/tests/storage/storage5/storage5_coreclr.csproj +++ b/tests/storage/storage5/storage5_coreclr.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tests/storage/storage6/storage6_coreclr.csproj b/tests/storage/storage6/storage6_coreclr.csproj index 685b560f7..6174dfe0f 100644 --- a/tests/storage/storage6/storage6_coreclr.csproj +++ b/tests/storage/storage6/storage6_coreclr.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tests/storage/storage7/storage7_coreclr.csproj b/tests/storage/storage7/storage7_coreclr.csproj index 5cf7da632..3b0e6f027 100644 --- a/tests/storage/storage7/storage7_coreclr.csproj +++ b/tests/storage/storage7/storage7_coreclr.csproj @@ -8,8 +8,7 @@ - - + diff --git a/tests/template/standalone/test_name_coreclr.csproj b/tests/template/standalone/test_name_coreclr.csproj index 6394c2cb3..7b3d5c86c 100644 --- a/tests/template/standalone/test_name_coreclr.csproj +++ b/tests/template/standalone/test_name_coreclr.csproj @@ -8,10 +8,8 @@ - - diff --git a/tests/tsl/tsl1/tsl1_coreclr.csproj b/tests/tsl/tsl1/tsl1_coreclr.csproj index 46ea99fa3..7e909d5af 100644 --- a/tests/tsl/tsl1/tsl1_coreclr.csproj +++ b/tests/tsl/tsl1/tsl1_coreclr.csproj @@ -8,8 +8,7 @@ - - + From 56d9255ac95e1ac1aba874093fd1698d1bd7cb8c Mon Sep 17 00:00:00 2001 From: leasunhy Date: Mon, 1 May 2017 22:00:36 +0800 Subject: [PATCH 19/38] Test: fix nunit test runner --- tests/nunit_test_runner/Program.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/nunit_test_runner/Program.cs b/tests/nunit_test_runner/Program.cs index 98393eb08..b2f3cec1a 100755 --- a/tests/nunit_test_runner/Program.cs +++ b/tests/nunit_test_runner/Program.cs @@ -2,6 +2,7 @@ using System.Linq; using System.Reflection; using System.Runtime.Loader; +using System.IO; using NUnitLite; using Trinity.Core; using NUnit.Framework; @@ -17,7 +18,8 @@ static int Main(string[] args) Console.Error.WriteLine("Usage: runner [nunit-arg ...]"); return 1; } - var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(args[0]); + var path = Path.GetFullPath(args[0]); + var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(path); return new AutoRun(assembly).Execute(args.Skip(1).ToArray()); } } From bdaf8019fc6488a22f1c377a853937fdf0679922 Mon Sep 17 00:00:00 2001 From: leasunhy Date: Mon, 1 May 2017 22:27:17 +0800 Subject: [PATCH 20/38] Test: update test_coreclr.csproj to make use of nunit_test_runner --- tests/test_coreclr.csproj | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/tests/test_coreclr.csproj b/tests/test_coreclr.csproj index a9c6cf8e3..98e8e4357 100644 --- a/tests/test_coreclr.csproj +++ b/tests/test_coreclr.csproj @@ -14,6 +14,7 @@ + + + + + + + + + - - - + ContinueOnError="true" /> - From 69f815f58c2db5a773260b6f7a84dc7e9f35ce5d Mon Sep 17 00:00:00 2001 From: leasunhy Date: Tue, 2 May 2017 10:10:26 +0800 Subject: [PATCH 21/38] Test: meta runner wip --- .../nunit_meta_runner}/NuGet.config | 12 +-- .../nunit_tools/nunit_meta_runner/Program.cs | 83 +++++++++++++++++++ .../nunit_meta_runner.csproj | 10 +++ .../nunit_test_runner/NuGet.config | 6 ++ .../nunit_test_runner/Program.cs | 52 ++++++------ .../nunit_test_runner/nunitlite-runner.csproj | 0 tests/test_coreclr.csproj | 23 ++++- 7 files changed, 150 insertions(+), 36 deletions(-) rename tests/{nunit_test_runner => nunit_tools/nunit_meta_runner}/NuGet.config (97%) mode change 100755 => 100644 create mode 100755 tests/nunit_tools/nunit_meta_runner/Program.cs create mode 100644 tests/nunit_tools/nunit_meta_runner/nunit_meta_runner.csproj create mode 100755 tests/nunit_tools/nunit_test_runner/NuGet.config rename tests/{ => nunit_tools}/nunit_test_runner/Program.cs (96%) rename tests/{ => nunit_tools}/nunit_test_runner/nunitlite-runner.csproj (100%) diff --git a/tests/nunit_test_runner/NuGet.config b/tests/nunit_tools/nunit_meta_runner/NuGet.config old mode 100755 new mode 100644 similarity index 97% rename from tests/nunit_test_runner/NuGet.config rename to tests/nunit_tools/nunit_meta_runner/NuGet.config index 0b3837670..7be9c71ec --- a/tests/nunit_test_runner/NuGet.config +++ b/tests/nunit_tools/nunit_meta_runner/NuGet.config @@ -1,6 +1,6 @@ - - - - - - + + + + + + diff --git a/tests/nunit_tools/nunit_meta_runner/Program.cs b/tests/nunit_tools/nunit_meta_runner/Program.cs new file mode 100755 index 000000000..18767feb5 --- /dev/null +++ b/tests/nunit_tools/nunit_meta_runner/Program.cs @@ -0,0 +1,83 @@ +using System; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Runtime.Loader; +using System.Collections.Generic; +using System.Diagnostics; +using NUnitLite; +using NUnit.Framework.Api; +using NUnit.Framework.Interfaces; + +namespace NUnitLiteNetCoreTest +{ + class Program + { + public static int Main(string[] args) + { + if (args.Length < 2) + { + Console.Error.WriteLine("Usage: runner [nunitlite-arg ..]"); + return 1; + } + + var runnerPath = Path.GetFullPath(args[0]); + var assemblyPath = Path.GetFullPath(args[1]); + var remainingOptions = args.Skip(2).ToArray(); + + var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(assemblyPath); + + var rootTestSuite = GetITest(assembly, remainingOptions); + var allTestNames = GetDecendentTests(rootTestSuite) + .Select(_ => _.FullName) + .ToList(); + + Console.WriteLine("Discovered tests:"); + foreach (var testName in allTestNames) + { + Console.WriteLine(testName); + } + + foreach (var testName in allTestNames) + { + var process = CreateProcessForTest(runnerPath, assemblyPath, testName); + process.WaitForExit(); + } + return 0; + } + + private static Process CreateProcessForTest(string runnerPath, string assemblyPath, string testName) + { + var commandLineOptions = new List(); + commandLineOptions.Add($"\"{runnerPath}\""); + commandLineOptions.Add($"\"{assemblyPath}\""); + commandLineOptions.Add("--workers=1"); + commandLineOptions.Add($"--test={testName}"); + + var startInfo = new ProcessStartInfo(); + startInfo.FileName = "dotnet"; + startInfo.Arguments = string.Join(" ", commandLineOptions); + startInfo.UseShellExecute = false; + startInfo.RedirectStandardOutput = true; + + return Process.Start(startInfo); + } + + private static ITest GetITest(Assembly assembly, string[] commandLineOptions) + { + // we should control what `options` holds + commandLineOptions = new [] {"--explore"}; + var options = new NUnitLiteOptions(commandLineOptions); + var builder = new DefaultTestAssemblyBuilder(); + var runSettings = TextRunner.MakeRunSettings(options); + return builder.Build(assembly, runSettings); + } + + private static IEnumerable GetDecendentTests(ITest root) + { + if (root.IsSuite) + return root.Tests.SelectMany(GetDecendentTests); + return new []{root}; + } + } +} diff --git a/tests/nunit_tools/nunit_meta_runner/nunit_meta_runner.csproj b/tests/nunit_tools/nunit_meta_runner/nunit_meta_runner.csproj new file mode 100644 index 000000000..331bb0b66 --- /dev/null +++ b/tests/nunit_tools/nunit_meta_runner/nunit_meta_runner.csproj @@ -0,0 +1,10 @@ + + + Exe + netcoreapp2.0 + + + + + + \ No newline at end of file diff --git a/tests/nunit_tools/nunit_test_runner/NuGet.config b/tests/nunit_tools/nunit_test_runner/NuGet.config new file mode 100755 index 000000000..7be9c71ec --- /dev/null +++ b/tests/nunit_tools/nunit_test_runner/NuGet.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/nunit_test_runner/Program.cs b/tests/nunit_tools/nunit_test_runner/Program.cs similarity index 96% rename from tests/nunit_test_runner/Program.cs rename to tests/nunit_tools/nunit_test_runner/Program.cs index b2f3cec1a..accd7846e 100755 --- a/tests/nunit_test_runner/Program.cs +++ b/tests/nunit_tools/nunit_test_runner/Program.cs @@ -1,26 +1,26 @@ -using System; -using System.Linq; -using System.Reflection; -using System.Runtime.Loader; -using System.IO; -using NUnitLite; -using Trinity.Core; -using NUnit.Framework; - -namespace nunitlite_runner -{ - class Program - { - static int Main(string[] args) - { - if (args.Length < 1) - { - Console.Error.WriteLine("Usage: runner [nunit-arg ...]"); - return 1; - } - var path = Path.GetFullPath(args[0]); - var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(path); - return new AutoRun(assembly).Execute(args.Skip(1).ToArray()); - } - } -} +using System; +using System.Linq; +using System.Reflection; +using System.Runtime.Loader; +using System.IO; +using NUnitLite; +using Trinity.Core; +using NUnit.Framework; + +namespace nunitlite_runner +{ + class Program + { + static int Main(string[] args) + { + if (args.Length < 1) + { + Console.Error.WriteLine("Usage: runner [nunit-arg ...]"); + return 1; + } + var path = Path.GetFullPath(args[0]); + var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(path); + return new AutoRun(assembly).Execute(args.Skip(1).ToArray()); + } + } +} diff --git a/tests/nunit_test_runner/nunitlite-runner.csproj b/tests/nunit_tools/nunit_test_runner/nunitlite-runner.csproj similarity index 100% rename from tests/nunit_test_runner/nunitlite-runner.csproj rename to tests/nunit_tools/nunit_test_runner/nunitlite-runner.csproj diff --git a/tests/test_coreclr.csproj b/tests/test_coreclr.csproj index 98e8e4357..82763aa33 100644 --- a/tests/test_coreclr.csproj +++ b/tests/test_coreclr.csproj @@ -8,6 +8,12 @@ + + $(MSBuildProjectDirectory)\nunit_tools\bin\nunit_meta_runner.dll + $(MSBuildProjectDirectory)\nunit_tools\bin\nunitlite-runner.dll + + + @@ -36,11 +42,20 @@ + + + @@ -56,7 +71,7 @@ WorkingDirectory="$([System.IO.Path]::GetDirectoryName(%(Test.Identity)))" ContinueOnError="true" /> From 052a24c7d608ec2d1afc6e223f9726655b00179d Mon Sep 17 00:00:00 2001 From: leasunhy Date: Tue, 2 May 2017 11:02:19 +0800 Subject: [PATCH 22/38] Test: meta runner milestone - process isolation done --- tests/nunit_tools/nunit_meta_runner/Program.cs | 17 +++++++++++++---- .../nunit_meta_runner/nunit_meta_runner.csproj | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/nunit_tools/nunit_meta_runner/Program.cs b/tests/nunit_tools/nunit_meta_runner/Program.cs index 18767feb5..6f2838be2 100755 --- a/tests/nunit_tools/nunit_meta_runner/Program.cs +++ b/tests/nunit_tools/nunit_meta_runner/Program.cs @@ -9,6 +9,10 @@ using NUnit.Framework.Api; using NUnit.Framework.Interfaces; +// preloading dependencies +using Trinity; +using NUnit.Framework; + namespace NUnitLiteNetCoreTest { class Program @@ -25,6 +29,8 @@ public static int Main(string[] args) var assemblyPath = Path.GetFullPath(args[1]); var remainingOptions = args.Skip(2).ToArray(); + // NOTE(leasunhy): this may fail silently if some of the dependencies are not preloaded! + // In that case, no tests can be discovered in `assembly`. var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(assemblyPath); var rootTestSuite = GetITest(assembly, remainingOptions); @@ -40,19 +46,23 @@ public static int Main(string[] args) foreach (var testName in allTestNames) { - var process = CreateProcessForTest(runnerPath, assemblyPath, testName); + var process = CreateProcessForTest(runnerPath, assemblyPath, remainingOptions, testName); process.WaitForExit(); + Console.WriteLine(process.StandardOutput.ReadToEnd()); } return 0; } - private static Process CreateProcessForTest(string runnerPath, string assemblyPath, string testName) + private static Process CreateProcessForTest(string runnerPath, string assemblyPath, + string[] runnerOptions, string testName) { var commandLineOptions = new List(); commandLineOptions.Add($"\"{runnerPath}\""); commandLineOptions.Add($"\"{assemblyPath}\""); + commandLineOptions.AddRange(runnerOptions); commandLineOptions.Add("--workers=1"); - commandLineOptions.Add($"--test={testName}"); + if (testName != null && testName != "") + commandLineOptions.Add($"--test={testName}"); var startInfo = new ProcessStartInfo(); startInfo.FileName = "dotnet"; @@ -66,7 +76,6 @@ private static Process CreateProcessForTest(string runnerPath, string assemblyPa private static ITest GetITest(Assembly assembly, string[] commandLineOptions) { // we should control what `options` holds - commandLineOptions = new [] {"--explore"}; var options = new NUnitLiteOptions(commandLineOptions); var builder = new DefaultTestAssemblyBuilder(); var runSettings = TextRunner.MakeRunSettings(options); diff --git a/tests/nunit_tools/nunit_meta_runner/nunit_meta_runner.csproj b/tests/nunit_tools/nunit_meta_runner/nunit_meta_runner.csproj index 331bb0b66..70fadf27b 100644 --- a/tests/nunit_tools/nunit_meta_runner/nunit_meta_runner.csproj +++ b/tests/nunit_tools/nunit_meta_runner/nunit_meta_runner.csproj @@ -4,6 +4,7 @@ netcoreapp2.0 + From a5f417a2809fcba73aceb6ef2bd6e966fabefd12 Mon Sep 17 00:00:00 2001 From: leasunhy Date: Tue, 2 May 2017 11:19:43 +0800 Subject: [PATCH 23/38] Test: meta runner - add argument `result-dir` --- .../nunit_tools/nunit_meta_runner/Program.cs | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/nunit_tools/nunit_meta_runner/Program.cs b/tests/nunit_tools/nunit_meta_runner/Program.cs index 6f2838be2..a755be967 100755 --- a/tests/nunit_tools/nunit_meta_runner/Program.cs +++ b/tests/nunit_tools/nunit_meta_runner/Program.cs @@ -13,7 +13,7 @@ using Trinity; using NUnit.Framework; -namespace NUnitLiteNetCoreTest +namespace NUnitMetaRunner { class Program { @@ -21,13 +21,14 @@ public static int Main(string[] args) { if (args.Length < 2) { - Console.Error.WriteLine("Usage: runner [nunitlite-arg ..]"); + Console.Error.WriteLine("Usage: runner [nunitlite-arg ..]"); return 1; } var runnerPath = Path.GetFullPath(args[0]); - var assemblyPath = Path.GetFullPath(args[1]); - var remainingOptions = args.Skip(2).ToArray(); + var resultDirPath = Path.GetFullPath(args[1]); + var assemblyPath = Path.GetFullPath(args[2]); + var remainingOptions = args.Skip(3).ToArray(); // NOTE(leasunhy): this may fail silently if some of the dependencies are not preloaded! // In that case, no tests can be discovered in `assembly`. @@ -46,23 +47,25 @@ public static int Main(string[] args) foreach (var testName in allTestNames) { - var process = CreateProcessForTest(runnerPath, assemblyPath, remainingOptions, testName); + var process = CreateProcessForTest(runnerPath, assemblyPath, resultDirPath, remainingOptions, testName); process.WaitForExit(); Console.WriteLine(process.StandardOutput.ReadToEnd()); + // TODO(leasunhy): check the exit status of the process and regard the test as a failure + // if the process did not exit normally. } return 0; } - private static Process CreateProcessForTest(string runnerPath, string assemblyPath, + private static Process CreateProcessForTest(string runnerPath, string assemblyPath, string resultDir, string[] runnerOptions, string testName) { var commandLineOptions = new List(); commandLineOptions.Add($"\"{runnerPath}\""); commandLineOptions.Add($"\"{assemblyPath}\""); commandLineOptions.AddRange(runnerOptions); - commandLineOptions.Add("--workers=1"); - if (testName != null && testName != "") - commandLineOptions.Add($"--test={testName}"); + commandLineOptions.Add($"--test={testName}"); + var testResultPath = Path.Combine(resultDir, $"{testName}.xml"); + commandLineOptions.Add($"--result=\"{testResultPath}\""); var startInfo = new ProcessStartInfo(); startInfo.FileName = "dotnet"; From 4e28745cecf5365addb80b22df2bf055b0a54c30 Mon Sep 17 00:00:00 2001 From: leasunhy Date: Tue, 2 May 2017 11:56:04 +0800 Subject: [PATCH 24/38] Test: update test_coreclr.csproj --- tests/test_coreclr.csproj | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tests/test_coreclr.csproj b/tests/test_coreclr.csproj index 82763aa33..5df19c74d 100644 --- a/tests/test_coreclr.csproj +++ b/tests/test_coreclr.csproj @@ -9,11 +9,11 @@ - $(MSBuildProjectDirectory)\nunit_tools\bin\nunit_meta_runner.dll - $(MSBuildProjectDirectory)\nunit_tools\bin\nunitlite-runner.dll + $(MSBuildProjectDirectory)/nunit_tools/bin/nunit_meta_runner.dll + $(MSBuildProjectDirectory)/nunit_tools/bin/nunitlite-runner.dll + $(MSBuildProjectDirectory)/nunit_coreclr_reports - @@ -58,20 +58,21 @@ WorkingDirectory="nunit_tools/nunit_meta_runner" ContinueOnError="false" /> - - - - - - - + + + + From 96687874d8081bbb70be6b506615755a274ce4e4 Mon Sep 17 00:00:00 2001 From: leasunhy Date: Tue, 2 May 2017 14:24:00 +0800 Subject: [PATCH 25/38] Test: refine test_coreclr.csproj - tests failing to build will not be run now --- tests/test_coreclr.csproj | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tests/test_coreclr.csproj b/tests/test_coreclr.csproj index 5df19c74d..358e35ec7 100644 --- a/tests/test_coreclr.csproj +++ b/tests/test_coreclr.csproj @@ -28,11 +28,6 @@ WorkingDirectory="$([System.IO.Path]::GetDirectoryName(%(Exe.Identity)))" ContinueOnError="false"/> - - + ContinueOnError="true" Condition="Exists('$([System.IO.Path]::GetDirectoryName(%(Test.Identity)))/bin/Release/netcoreapp2.0/$([System.IO.Path]::GetFileNameWithoutExtension(%(Test.Identity))).dll')"/> From 7887feed3d32cc65c5b5486574ce52efe668673a Mon Sep 17 00:00:00 2001 From: leasunhy Date: Tue, 2 May 2017 14:25:19 +0800 Subject: [PATCH 26/38] Test: coreclr tests are run with a time limit of 30mins --- tests/test_coreclr.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_coreclr.csproj b/tests/test_coreclr.csproj index 358e35ec7..5538b5e25 100644 --- a/tests/test_coreclr.csproj +++ b/tests/test_coreclr.csproj @@ -67,7 +67,7 @@ WorkingDirectory="$([System.IO.Path]::GetDirectoryName(%(Test.Identity)))" ContinueOnError="true" /> From 30c14fbe0c45b09a62eff645ba88407fef66f83d Mon Sep 17 00:00:00 2001 From: leasunhy Date: Mon, 8 May 2017 15:56:43 +0800 Subject: [PATCH 27/38] Test: omit timeout for now --- tests/test_coreclr.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_coreclr.csproj b/tests/test_coreclr.csproj index 5538b5e25..358e35ec7 100644 --- a/tests/test_coreclr.csproj +++ b/tests/test_coreclr.csproj @@ -67,7 +67,7 @@ WorkingDirectory="$([System.IO.Path]::GetDirectoryName(%(Test.Identity)))" ContinueOnError="true" /> From 10a7080c9c9a3e6eeeefb637d9fa868b4dfd1d35 Mon Sep 17 00:00:00 2001 From: leasunhy Date: Mon, 8 May 2017 16:30:19 +0800 Subject: [PATCH 28/38] Test: use new syntax for command line args for the meta runner --- .../nunit_tools/nunit_meta_runner/Program.cs | 58 +++++++++++++++---- .../nunit_meta_runner.csproj | 1 + 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/tests/nunit_tools/nunit_meta_runner/Program.cs b/tests/nunit_tools/nunit_meta_runner/Program.cs index a755be967..931b8d7b5 100755 --- a/tests/nunit_tools/nunit_meta_runner/Program.cs +++ b/tests/nunit_tools/nunit_meta_runner/Program.cs @@ -5,6 +5,10 @@ using System.Runtime.Loader; using System.Collections.Generic; using System.Diagnostics; + +using CommandLine; +using CommandLine.Text; + using NUnitLite; using NUnit.Framework.Api; using NUnit.Framework.Interfaces; @@ -19,22 +23,22 @@ class Program { public static int Main(string[] args) { - if (args.Length < 2) + var options = new CommandLineOptions(); + if (!CommandLine.Parser.Default.ParseArguments(args, options)) { - Console.Error.WriteLine("Usage: runner [nunitlite-arg ..]"); return 1; } - var runnerPath = Path.GetFullPath(args[0]); - var resultDirPath = Path.GetFullPath(args[1]); - var assemblyPath = Path.GetFullPath(args[2]); - var remainingOptions = args.Skip(3).ToArray(); + var runnerPath = Path.GetFullPath(options.RunnerPath); + var resultDirPath = Path.GetFullPath(options.ResultDirPath); + var assemblyPath = Path.GetFullPath(options.AssemblyPath); + var runnerOptions = options.RunnerOptions; // NOTE(leasunhy): this may fail silently if some of the dependencies are not preloaded! // In that case, no tests can be discovered in `assembly`. var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(assemblyPath); - var rootTestSuite = GetITest(assembly, remainingOptions); + var rootTestSuite = GetITest(assembly, runnerOptions); var allTestNames = GetDecendentTests(rootTestSuite) .Select(_ => _.FullName) .ToList(); @@ -47,7 +51,7 @@ public static int Main(string[] args) foreach (var testName in allTestNames) { - var process = CreateProcessForTest(runnerPath, assemblyPath, resultDirPath, remainingOptions, testName); + var process = CreateProcessForTest(runnerPath, assemblyPath, resultDirPath, runnerOptions, testName); process.WaitForExit(); Console.WriteLine(process.StandardOutput.ReadToEnd()); // TODO(leasunhy): check the exit status of the process and regard the test as a failure @@ -57,12 +61,12 @@ public static int Main(string[] args) } private static Process CreateProcessForTest(string runnerPath, string assemblyPath, string resultDir, - string[] runnerOptions, string testName) + string runnerOptions, string testName) { var commandLineOptions = new List(); commandLineOptions.Add($"\"{runnerPath}\""); commandLineOptions.Add($"\"{assemblyPath}\""); - commandLineOptions.AddRange(runnerOptions); + commandLineOptions.Add(runnerOptions); commandLineOptions.Add($"--test={testName}"); var testResultPath = Path.Combine(resultDir, $"{testName}.xml"); commandLineOptions.Add($"--result=\"{testResultPath}\""); @@ -76,10 +80,10 @@ private static Process CreateProcessForTest(string runnerPath, string assemblyPa return Process.Start(startInfo); } - private static ITest GetITest(Assembly assembly, string[] commandLineOptions) + private static ITest GetITest(Assembly assembly, string commandLineOptions) { // we should control what `options` holds - var options = new NUnitLiteOptions(commandLineOptions); + var options = new NUnitLiteOptions(commandLineOptions.Split(' ')); var builder = new DefaultTestAssemblyBuilder(); var runSettings = TextRunner.MakeRunSettings(options); return builder.Build(assembly, runSettings); @@ -92,4 +96,34 @@ private static IEnumerable GetDecendentTests(ITest root) return new []{root}; } } + + class CommandLineOptions + { + [Option('r', "runner", Required = true, + HelpText = "The path to the runner for the test assembly.")] + public string RunnerPath { get; set; } + + [Option('t', "timeout", Required = false, DefaultValue = -1, + HelpText = "Set timeout for each test case in milliseconds.")] + public int Timeout { get; set; } + + [Option('d', "resultDirectory", Required = true, + HelpText = "Set the directory to put the results.")] + public string ResultDirPath { get; set; } + + [Option('a', "assembly", Required = true, + HelpText = "The path to the test assembly.")] + public string AssemblyPath { get; set; } + + [Option('o', "options", Required = false, DefaultValue = "", + HelpText = "The command line arguments to be passed to the runner.")] + public string RunnerOptions { get; set; } + + [HelpOption] + public string GetUsage() + { + return HelpText.AutoBuild(this, + (HelpText current) => HelpText.DefaultParsingErrorsHandler(this, current)); + } + } } diff --git a/tests/nunit_tools/nunit_meta_runner/nunit_meta_runner.csproj b/tests/nunit_tools/nunit_meta_runner/nunit_meta_runner.csproj index 70fadf27b..aef588154 100644 --- a/tests/nunit_tools/nunit_meta_runner/nunit_meta_runner.csproj +++ b/tests/nunit_tools/nunit_meta_runner/nunit_meta_runner.csproj @@ -4,6 +4,7 @@ netcoreapp2.0 + From d6f094d6efa89c6ec87b83ad8b9f36081a10465e Mon Sep 17 00:00:00 2001 From: leasunhy Date: Mon, 8 May 2017 16:47:46 +0800 Subject: [PATCH 29/38] Test: add timeout support in meta runner --- .../nunit_tools/nunit_meta_runner/Program.cs | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/tests/nunit_tools/nunit_meta_runner/Program.cs b/tests/nunit_tools/nunit_meta_runner/Program.cs index 931b8d7b5..cb14496b0 100755 --- a/tests/nunit_tools/nunit_meta_runner/Program.cs +++ b/tests/nunit_tools/nunit_meta_runner/Program.cs @@ -33,6 +33,7 @@ public static int Main(string[] args) var resultDirPath = Path.GetFullPath(options.ResultDirPath); var assemblyPath = Path.GetFullPath(options.AssemblyPath); var runnerOptions = options.RunnerOptions; + var timeout = options.Timeout; // NOTE(leasunhy): this may fail silently if some of the dependencies are not preloaded! // In that case, no tests can be discovered in `assembly`. @@ -51,11 +52,23 @@ public static int Main(string[] args) foreach (var testName in allTestNames) { - var process = CreateProcessForTest(runnerPath, assemblyPath, resultDirPath, runnerOptions, testName); - process.WaitForExit(); - Console.WriteLine(process.StandardOutput.ReadToEnd()); - // TODO(leasunhy): check the exit status of the process and regard the test as a failure - // if the process did not exit normally. + try + { + var process = CreateProcessForTest(runnerPath, assemblyPath, resultDirPath, runnerOptions, testName); + process.WaitForExit(timeout < 0 ? Int32.MaxValue : timeout); + if (!process.HasExited) + { + Console.WriteLine($"Test {testName} has timed out."); + process.Kill(); + } + Console.WriteLine(process.StandardOutput.ReadToEnd()); + // TODO(leasunhy): check the exit status of the process and regard the test as a failure + // if the process did not exit normally. + } + catch (Exception e) + { + Console.Error.WriteLine(e.Message); + } } return 0; } From c3cbffe221f491f8219076323d313ad0ec00d01b Mon Sep 17 00:00:00 2001 From: leasunhy Date: Mon, 8 May 2017 16:48:31 +0800 Subject: [PATCH 30/38] Test: add timeout support in test_coreclr.csproj --- tests/test_coreclr.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_coreclr.csproj b/tests/test_coreclr.csproj index 358e35ec7..9fd1dc37c 100644 --- a/tests/test_coreclr.csproj +++ b/tests/test_coreclr.csproj @@ -67,7 +67,7 @@ WorkingDirectory="$([System.IO.Path]::GetDirectoryName(%(Test.Identity)))" ContinueOnError="true" /> From 4253a305ba905e01d9d47eedc668d393bcdf8bf8 Mon Sep 17 00:00:00 2001 From: leasunhy Date: Mon, 8 May 2017 17:00:55 +0800 Subject: [PATCH 31/38] Test: the meta runner now use the same random seed for all tests --- tests/nunit_tools/nunit_meta_runner/Program.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/nunit_tools/nunit_meta_runner/Program.cs b/tests/nunit_tools/nunit_meta_runner/Program.cs index cb14496b0..2c2cbaffa 100755 --- a/tests/nunit_tools/nunit_meta_runner/Program.cs +++ b/tests/nunit_tools/nunit_meta_runner/Program.cs @@ -34,6 +34,7 @@ public static int Main(string[] args) var assemblyPath = Path.GetFullPath(options.AssemblyPath); var runnerOptions = options.RunnerOptions; var timeout = options.Timeout; + var randomSeed = options.RandomSeed ?? new Random().Next(); // NOTE(leasunhy): this may fail silently if some of the dependencies are not preloaded! // In that case, no tests can be discovered in `assembly`. @@ -54,7 +55,8 @@ public static int Main(string[] args) { try { - var process = CreateProcessForTest(runnerPath, assemblyPath, resultDirPath, runnerOptions, testName); + var process = CreateProcessForTest(runnerPath, assemblyPath, resultDirPath, + randomSeed, runnerOptions, testName); process.WaitForExit(timeout < 0 ? Int32.MaxValue : timeout); if (!process.HasExited) { @@ -74,7 +76,7 @@ public static int Main(string[] args) } private static Process CreateProcessForTest(string runnerPath, string assemblyPath, string resultDir, - string runnerOptions, string testName) + int randomSeed, string runnerOptions, string testName) { var commandLineOptions = new List(); commandLineOptions.Add($"\"{runnerPath}\""); @@ -83,6 +85,7 @@ private static Process CreateProcessForTest(string runnerPath, string assemblyPa commandLineOptions.Add($"--test={testName}"); var testResultPath = Path.Combine(resultDir, $"{testName}.xml"); commandLineOptions.Add($"--result=\"{testResultPath}\""); + commandLineOptions.Add($"--seed=\"{randomSeed}\""); var startInfo = new ProcessStartInfo(); startInfo.FileName = "dotnet"; @@ -132,6 +135,10 @@ class CommandLineOptions HelpText = "The command line arguments to be passed to the runner.")] public string RunnerOptions { get; set; } + [Option('s', "seed", Required = false, + HelpText = "The random seed to use for the tests.")] + public int? RandomSeed { get; set; } + [HelpOption] public string GetUsage() { From 336aaadd95dacafac60c0f95e0e2386aab25742a Mon Sep 17 00:00:00 2001 From: leasunhy Date: Wed, 10 May 2017 20:11:31 +0800 Subject: [PATCH 32/38] Test: add naive result aggregator --- .../nunit_tools/nunit_meta_runner/Program.cs | 29 ++++- .../ResultAggregator/NodeInfos.cs | 105 +++++++++++++++ .../ResultAggregator/ResultAggregator.cs | 122 ++++++++++++++++++ 3 files changed, 253 insertions(+), 3 deletions(-) create mode 100755 tests/nunit_tools/nunit_meta_runner/ResultAggregator/NodeInfos.cs create mode 100755 tests/nunit_tools/nunit_meta_runner/ResultAggregator/ResultAggregator.cs diff --git a/tests/nunit_tools/nunit_meta_runner/Program.cs b/tests/nunit_tools/nunit_meta_runner/Program.cs index 2c2cbaffa..ffc64c756 100755 --- a/tests/nunit_tools/nunit_meta_runner/Program.cs +++ b/tests/nunit_tools/nunit_meta_runner/Program.cs @@ -5,7 +5,7 @@ using System.Runtime.Loader; using System.Collections.Generic; using System.Diagnostics; - +using System.Xml.Linq; using CommandLine; using CommandLine.Text; @@ -13,6 +13,8 @@ using NUnit.Framework.Api; using NUnit.Framework.Interfaces; +using NUnitLiteNetCoreTest.ResultAggregator; + // preloading dependencies using Trinity; using NUnit.Framework; @@ -30,7 +32,7 @@ public static int Main(string[] args) } var runnerPath = Path.GetFullPath(options.RunnerPath); - var resultDirPath = Path.GetFullPath(options.ResultDirPath); + var resultDirRoot = Path.GetFullPath(options.ResultDirPath); var assemblyPath = Path.GetFullPath(options.AssemblyPath); var runnerOptions = options.RunnerOptions; var timeout = options.Timeout; @@ -51,6 +53,10 @@ public static int Main(string[] args) Console.WriteLine(testName); } + var resultDirPath = Path.Combine(resultDirRoot, rootTestSuite.Name); + if (!Directory.Exists(resultDirPath)) + Directory.CreateDirectory(resultDirPath); + foreach (var testName in allTestNames) { try @@ -72,6 +78,23 @@ public static int Main(string[] args) Console.Error.WriteLine(e.Message); } } + + var xmlDocs = Directory.EnumerateFiles(resultDirPath) + .Where(f => Path.GetExtension(f) == ".xml") + .Select(XDocument.Load) + .ToList(); + if (xmlDocs.Count != allTestNames.Count) + { + Console.Error.WriteLine($"Warning: {allTestNames.Count} tests should be run in {rootTestSuite.Name}, " + + $"but only {xmlDocs.Count} result files are found."); + } + + var aggregated = ResultAggregator.Aggregate(xmlDocs); + var resultFile = Path.Combine(resultDirRoot, rootTestSuite.Name + ".xml"); + using (var output = new StreamWriter(new FileStream(resultFile, FileMode.Create))) + { + aggregated.Save(output); + } return 0; } @@ -85,7 +108,7 @@ private static Process CreateProcessForTest(string runnerPath, string assemblyPa commandLineOptions.Add($"--test={testName}"); var testResultPath = Path.Combine(resultDir, $"{testName}.xml"); commandLineOptions.Add($"--result=\"{testResultPath}\""); - commandLineOptions.Add($"--seed=\"{randomSeed}\""); + commandLineOptions.Add($"--seed={randomSeed}"); var startInfo = new ProcessStartInfo(); startInfo.FileName = "dotnet"; diff --git a/tests/nunit_tools/nunit_meta_runner/ResultAggregator/NodeInfos.cs b/tests/nunit_tools/nunit_meta_runner/ResultAggregator/NodeInfos.cs new file mode 100755 index 000000000..b61c4cd02 --- /dev/null +++ b/tests/nunit_tools/nunit_meta_runner/ResultAggregator/NodeInfos.cs @@ -0,0 +1,105 @@ +using System; +using System.Xml.Linq; + +namespace NUnitLiteNetCoreTest.ResultAggregator +{ + internal interface INodeInfo + { + DateTime StartTime { get; } + DateTime EndTime { get; } + double Duration { get; } + int WarningCount { get; } + int AssertCount { get; } + int TotalTestCount { get; } + int PassedTestCount { get; } + int InconclusiveTestCount { get; } + int FailedTestCount { get; } + int SkippedTestCount { get; } + } + + internal class TestCaseInfo : INodeInfo + { + public DateTime StartTime { get; } + public DateTime EndTime { get; } + public double Duration { get; } + public int WarningCount { get; } + public int AssertCount { get; } + public int TotalTestCount { get; } + + public int PassedTestCount { get; } = 0; + public int InconclusiveTestCount { get; } = 0; + public int FailedTestCount { get; } = 0; + public int SkippedTestCount { get; } = 0; + + public TestCaseInfo(XElement element) + { + StartTime = DateTime.Parse(element.Attribute("start-time").Value); + EndTime = DateTime.Parse(element.Attribute("end-time").Value); + Duration = double.Parse(element.Attribute("duration").Value); + //WarningCount = int.Parse(element.Attribute("warnings").Value); + // TODO: how are warnings related to test-case? + WarningCount = 0; + AssertCount = int.Parse(element.Attribute("asserts").Value); + TotalTestCount = 1; + + var result = element.Attribute("result").Value; + switch (result) + { + case "Passed": + PassedTestCount = 1; + break; + case "Inconclusive": + InconclusiveTestCount = 1; + break; + case "Failed": + FailedTestCount = 1; + break; + case "Skipped": + SkippedTestCount = 1; + break; + default: + throw new NotSupportedException($"result = {result}"); + } + } + } + + internal class TestSuiteInfo : INodeInfo + { + public DateTime StartTime { get; } + public DateTime EndTime { get; } + public double Duration { get; } + public int WarningCount { get; } + public int AssertCount { get; } + public int TotalTestCount { get; } + public int PassedTestCount { get; } + public int InconclusiveTestCount { get; } + public int FailedTestCount { get; } + public int SkippedTestCount { get; } + + public TestSuiteInfo(XElement element) + { + StartTime = DateTime.Parse(element.Attribute("start-time").Value); + EndTime = DateTime.Parse(element.Attribute("end-time").Value); + Duration = double.Parse(element.Attribute("duration").Value); + WarningCount = int.Parse(element.Attribute("warnings").Value); + AssertCount = int.Parse(element.Attribute("asserts").Value); + TotalTestCount = int.Parse(element.Attribute("total").Value); + PassedTestCount = int.Parse(element.Attribute("total").Value); + InconclusiveTestCount = int.Parse(element.Attribute("inconclusive").Value); + FailedTestCount = int.Parse(element.Attribute("failed").Value); + SkippedTestCount = int.Parse(element.Attribute("skipped").Value); + } + } + + internal class NodeInfoFactory + { + public static INodeInfo GetInfoFor(XElement element) + { + if (element.Name.LocalName == "test-case") + return new TestCaseInfo(element); + if (element.Name.LocalName == "test-suite") + return new TestSuiteInfo(element); + throw new NotSupportedException($"Can't get info for an element of unknown type: {element.Name.LocalName}"); + } + } +} diff --git a/tests/nunit_tools/nunit_meta_runner/ResultAggregator/ResultAggregator.cs b/tests/nunit_tools/nunit_meta_runner/ResultAggregator/ResultAggregator.cs new file mode 100755 index 000000000..2127a07f3 --- /dev/null +++ b/tests/nunit_tools/nunit_meta_runner/ResultAggregator/ResultAggregator.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Xml.Linq; + +namespace NUnitLiteNetCoreTest.ResultAggregator +{ + public static class ResultAggregator + { + public static XDocument Aggregate(IEnumerable resDocs) + { + if (resDocs == null) throw new ArgumentNullException(nameof(resDocs)); + var documentList = resDocs.ToList(); + if (!documentList.Any()) throw new ArgumentException("Argument is empty", nameof(resDocs)); + + var pivot = new XDocument(documentList.First()); + var suites = documentList.SelectMany(a => a.Elements("test-run")) + .GroupBy(e => e.Attribute("fullname").Value) + .Select(g => AggregateElements(g, "TestRun")) + .ToList(); + pivot.Elements("test-run").Remove(); + foreach (var e in suites) + pivot.Add(e); + return pivot; + } + + class NodeType + { + public string TypeName { get; set; } + public string[] ChildNodeTypes { get; set; } + public bool HasChildTestCases { get; set; } + public Action Hook { get; set; } = null; + } + + private static readonly Dictionary NodeTypes = new[] { + new NodeType { TypeName = "TestRun", HasChildTestCases = false, ChildNodeTypes = new [] { "Assembly" }, + Hook = e => e.Elements("filter").Elements().Remove()}, + new NodeType { TypeName = "Assembly", HasChildTestCases = false, ChildNodeTypes = new [] { "TestSuite" }}, + new NodeType { TypeName = "TestSuite", HasChildTestCases = false, ChildNodeTypes = new [] { "TestFixture" }}, + new NodeType { TypeName = "TestFixture", HasChildTestCases = true, ChildNodeTypes = new [] { "ParameterizedMethod", "Theory" }}, + new NodeType { TypeName = "ParameterizedMethod", HasChildTestCases = true, ChildNodeTypes = new string[] {}}, + new NodeType { TypeName = "Theory", HasChildTestCases = true, ChildNodeTypes = new string[] {}}, + }.ToDictionary(nt => nt.TypeName); + + private static XElement AggregateElements(IEnumerable elements, string elementType) + { + var elementList = elements.ToList(); + var pivot = new XElement(elementList.First()); + Debug.Assert(elementList.All(a => a.Name == pivot.Name)); + + var nodeType = NodeTypes[elementType]; + + if (nodeType.ChildNodeTypes.Length > 0) + { + var newChildSuites = nodeType.ChildNodeTypes + .SelectMany(tn => GetChildSuites(tn, elementList)) + .ToList(); + pivot.Elements("test-suite").Remove(); + foreach (var suite in newChildSuites) + pivot.Add(suite); + } + + if (nodeType.HasChildTestCases) + { + var testcases = elementList.SelectMany(f => f.Elements("test-case")).ToList(); + pivot.Elements("test-case").Remove(); + foreach (var e in testcases) + pivot.Add(e); + } + + AggregateAttributes(pivot); + nodeType.Hook?.Invoke(pivot); + return pivot; + } + + private static void AggregateAttributes(XElement parent) + { + var children = parent.Elements("test-suite").Concat(parent.Elements("test-case")); + var infos = children.Select(NodeInfoFactory.GetInfoFor).ToList(); + int total, failed, passed, skipped; + parent.SetAttributeValue("total", total = infos.Sum(i => i.TotalTestCount)); + parent.SetAttributeValue("passed", passed = infos.Sum(i => i.PassedTestCount)); + parent.SetAttributeValue("warnings", infos.Sum(i => i.WarningCount)); + parent.SetAttributeValue("inconclusive", infos.Sum(i => i.InconclusiveTestCount)); + parent.SetAttributeValue("skipped", skipped = infos.Sum(i => i.SkippedTestCount)); + parent.SetAttributeValue("failed", failed = infos.Sum(i => i.FailedTestCount)); + parent.SetAttributeValue("asserts", infos.Sum(i => i.AssertCount)); + parent.SetAttributeValue("duration", infos.Sum(i => i.Duration)); + parent.SetAttributeValue("start-time", infos.Min(i => i.StartTime).ToString("u")); + parent.SetAttributeValue("end-time", infos.Max(i => i.EndTime).ToString("u")); + + // TODO(leasunhy): aggregate