//using Cosmos.Kernel.MM; //using Microsoft.VisualStudio.TestTools.UnitTesting; //using System; //using Cosmos.Kernel.Dispatch; //using System.Collections.Generic; //namespace Test.Cosmos.Kernel //{ // /// // ///This is a test class for MemoryPageTableTest and is intended // ///to contain all MemoryPageTableTest Unit Tests // /// // [TestClass()] // public class MemoryPageTableTest // { // private TestContext testContextInstance; // /// // ///Gets or sets the test context which provides // ///information about and functionality for the current test run. // /// // public TestContext TestContext // { // get // { // return testContextInstance; // } // set // { // testContextInstance = value; // } // } // #region Additional test attributes // // // //You can use the following additional attributes as you write your tests: // // // //Use ClassInitialize to run code before running the first test in the class // //[ClassInitialize()] // //public static void MyClassInitialize(TestContext testContext) // //{ // //} // // // //Use ClassCleanup to run code after all tests in a class have run // //[ClassCleanup()] // //public static void MyClassCleanup() // //{ // //} // // // //Use TestInitialize to run code before running each test // //[TestInitialize()] // //public void MyTestInitialize() // //{ // //} // // // //Use TestCleanup to run code after each test has run // //[TestCleanup()] // //public void MyTestCleanup() // //{ // //} // // // #endregion // /// // ///A test for UpdatePageTable // /// // [TestMethod()] // [DeploymentItem("Cosmos.Kernel.dll")] // public void UpdatePageTableTest() // { // PrivateObject param0 = null; // TODO: Initialize to an appropriate value // MemoryPageTable_Accessor target = new MemoryPageTable_Accessor(param0); // TODO: Initialize to an appropriate value // PageType type = new PageType(); // TODO: Initialize to an appropriate value // PageSharing sharing = new PageSharing(); // TODO: Initialize to an appropriate value // uint pid = 0; // TODO: Initialize to an appropriate value // uint numPages = 0; // TODO: Initialize to an appropriate value // UIntPtr baseMemoryAddress = new UIntPtr(); // TODO: Initialize to an appropriate value // target.UpdatePageTable(type, sharing, pid, numPages, baseMemoryAddress); // Assert.Inconclusive("A method that does not return a value cannot be verified."); // } // /// // ///A test for TryMerge // /// // [TestMethod()] // [DeploymentItem("Cosmos.Kernel.dll")] // public void TryMergeTest() // { // // Private Accessor for TryMerge is not found. Please rebuild the containing project or run the Publicize.exe manually. // Assert.Inconclusive("Private Accessor for TryMerge is not found. Please rebuild the containing project" + // " or run the Publicize.exe manually."); // } // /// // ///A test for QueryPage // /// // [TestMethod()] // public void QueryPageTest1() // { // UIntPtr baseAddress = new UIntPtr(); // TODO: Initialize to an appropriate value // uint pages = 0; // TODO: Initialize to an appropriate value // MemoryPageTable target = new MemoryPageTable(baseAddress, pages); // TODO: Initialize to an appropriate value // UIntPtr page = new UIntPtr(); // TODO: Initialize to an appropriate value // int pageOffset = 0; // TODO: Initialize to an appropriate value // PageEntry expected = new PageEntry(); // TODO: Initialize to an appropriate value // PageEntry actual; // actual = target.QueryPage(page, pageOffset); // Assert.AreEqual(expected, actual); // Assert.Inconclusive("Verify the correctness of this test method."); // } // /// // ///A test for QueryPage // /// // [TestMethod()] // public void QueryPageTest() // { // UIntPtr baseAddress = new UIntPtr(); // TODO: Initialize to an appropriate value // uint pages = 0; // TODO: Initialize to an appropriate value // MemoryPageTable target = new MemoryPageTable(baseAddress, pages); // TODO: Initialize to an appropriate value // UIntPtr page = new UIntPtr(); // TODO: Initialize to an appropriate value // PageEntry expected = new PageEntry(); // TODO: Initialize to an appropriate value // PageEntry actual; // actual = target.QueryPage(page); // Assert.AreEqual(expected, actual); // Assert.Inconclusive("Verify the correctness of this test method."); // } // /// // ///A test for ParseForAdjacent // /// // [TestMethod()] // [DeploymentItem("Cosmos.Kernel.dll")] // public void ParseForAdjacentTest() // { // // Private Accessor for ParseForAdjacent is not found. Please rebuild the containing project or run the Publicize.exe manually. // Assert.Inconclusive("Private Accessor for ParseForAdjacent is not found. Please rebuild the containing" + // " project or run the Publicize.exe manually."); // } // /// // ///A test for PageTableToMemoryAddress // /// // [TestMethod()] // [DeploymentItem("Cosmos.Kernel.dll")] // public void PageTableToMemoryAddressTest() // { // PrivateObject param0 = null; // TODO: Initialize to an appropriate value // MemoryPageTable_Accessor target = new MemoryPageTable_Accessor(param0); // TODO: Initialize to an appropriate value // int page = 0; // TODO: Initialize to an appropriate value // UIntPtr expected = new UIntPtr(); // TODO: Initialize to an appropriate value // UIntPtr actual; // actual = target.PageTableToMemoryAddress(page); // Assert.AreEqual(expected, actual); // Assert.Inconclusive("Verify the correctness of this test method."); // } // /// // ///A test for MemoryToPageTableAddress // /// // [TestMethod()] // [DeploymentItem("Cosmos.Kernel.dll")] // public void MemoryToPageTableAddressTest() // { // PrivateObject param0 = null; // TODO: Initialize to an appropriate value // MemoryPageTable_Accessor target = new MemoryPageTable_Accessor(param0); // TODO: Initialize to an appropriate value // UIntPtr physical = new UIntPtr(); // TODO: Initialize to an appropriate value // UIntPtr expected = new UIntPtr(); // TODO: Initialize to an appropriate value // UIntPtr actual; // actual = target.MemoryToPageTableAddress(physical); // Assert.AreEqual(expected, actual); // Assert.Inconclusive("Verify the correctness of this test method."); // } // /// // ///A test for LargestMemoryBlock // /// // [TestMethod()] // [DeploymentItem("Cosmos.Kernel.dll")] // public void LargestMemoryBlockTest() // { // PrivateObject param0 = null; // TODO: Initialize to an appropriate value // MemoryPageTable_Accessor target = new MemoryPageTable_Accessor(param0); // TODO: Initialize to an appropriate value // ulong expected = 0; // TODO: Initialize to an appropriate value // ulong actual; // actual = target.LargestMemoryBlock(); // Assert.AreEqual(expected, actual); // Assert.Inconclusive("Verify the correctness of this test method."); // } // /// // ///A test for IsAdjacent // /// // [TestMethod()] // public void IsAdjacentTest() // { // UIntPtr baseAddress = new UIntPtr(); // TODO: Initialize to an appropriate value // uint pages = 0; // TODO: Initialize to an appropriate value // MemoryPageTable target = new MemoryPageTable(baseAddress, pages); // TODO: Initialize to an appropriate value // PageRegion region1 = new PageRegion(); // TODO: Initialize to an appropriate value // PageRegion region2 = new PageRegion(); // TODO: Initialize to an appropriate value // bool expected = false; // TODO: Initialize to an appropriate value // bool actual; // actual = target.IsAdjacent(region1, region2); // Assert.AreEqual(expected, actual); // Assert.Inconclusive("Verify the correctness of this test method."); // } // /// // ///A test for InitPageTable // /// // [TestMethod()] // [DeploymentItem("Cosmos.Kernel.dll")] // public void InitPageTableTest() // { // PrivateObject param0 = null; // TODO: Initialize to an appropriate value // MemoryPageTable_Accessor target = new MemoryPageTable_Accessor(param0); // TODO: Initialize to an appropriate value // target.InitPageTable(); // Assert.Inconclusive("A method that does not return a value cannot be verified."); // } // /// // ///A test for Init // /// // [TestMethod()] // [DeploymentItem("Cosmos.Kernel.dll")] // public void InitTest() // { // PrivateObject param0 = null; // TODO: Initialize to an appropriate value // MemoryPageTable_Accessor target = new MemoryPageTable_Accessor(param0); // TODO: Initialize to an appropriate value // target.Init(); // Assert.Inconclusive("A method that does not return a value cannot be verified."); // } // /// // ///A test for GetFragmentation // /// // [TestMethod()] // [DeploymentItem("Cosmos.Kernel.dll")] // public void GetFragmentationTest() // { // PrivateObject param0 = null; // TODO: Initialize to an appropriate value // MemoryPageTable_Accessor target = new MemoryPageTable_Accessor(param0); // TODO: Initialize to an appropriate value // float expected = 0F; // TODO: Initialize to an appropriate value // float actual; // actual = target.GetFragmentation(); // Assert.AreEqual(expected, actual); // Assert.Inconclusive("Verify the correctness of this test method."); // } // /// // ///A test for GetAmountFree // /// // [TestMethod()] // [DeploymentItem("Cosmos.Kernel.dll")] // public void GetAmountFreeTest() // { // PrivateObject param0 = null; // TODO: Initialize to an appropriate value // MemoryPageTable_Accessor target = new MemoryPageTable_Accessor(param0); // TODO: Initialize to an appropriate value // float expected = 0F; // TODO: Initialize to an appropriate value // float actual; // actual = target.GetAmountFree(); // Assert.AreEqual(expected, actual); // Assert.Inconclusive("Verify the correctness of this test method."); // } // /// // ///A test for FindSmallestMatchingNode // /// // [TestMethod()] // [DeploymentItem("Cosmos.Kernel.dll")] // public void FindSmallestMatchingNodeTest() // { // PrivateObject param0 = null; // TODO: Initialize to an appropriate value // MemoryPageTable_Accessor target = new MemoryPageTable_Accessor(param0); // TODO: Initialize to an appropriate value // uint pages = 0; // TODO: Initialize to an appropriate value // PageRegion_Accessor expected = null; // TODO: Initialize to an appropriate value // PageRegion_Accessor actual; // actual = target.FindSmallestMatchingNode(pages); // Assert.AreEqual(expected, actual); // Assert.Inconclusive("Verify the correctness of this test method."); // } // /// // ///A test for DeAllocateMemory // /// // [TestMethod()] // public void DeAllocateMemoryTest() // { // UIntPtr baseAddress = new UIntPtr(); // TODO: Initialize to an appropriate value // uint pages = 0; // TODO: Initialize to an appropriate value // MemoryPageTable target = new MemoryPageTable(baseAddress, pages); // TODO: Initialize to an appropriate value // PageRegion region = new PageRegion(); // TODO: Initialize to an appropriate value // uint pid = 0; // TODO: Initialize to an appropriate value // target.DeAllocateMemory(region, pid); // Assert.Inconclusive("A method that does not return a value cannot be verified."); // } // /// // ///A test for MemoryPageTable Constructor // /// // [TestMethod()] // public void MemoryPageTableConstructorTest1() // { // UIntPtr baseAddress = new UIntPtr(); // TODO: Initialize to an appropriate value // uint pages = 0; // TODO: Initialize to an appropriate value // uint pageSize = 0; // TODO: Initialize to an appropriate value // MemoryPageTable target = new MemoryPageTable(baseAddress, pages, pageSize); // Assert.Inconclusive("TODO: Implement code to verify target"); // } // /// // ///A test for MemoryPageTable Constructor // /// // [TestMethod()] // public void MemoryPageTableConstructorTest() // { // uint pages = 12; // uint pageSize = 1 << 20; // //allocating actual memory not needed as its not used // //byte[] testBlock = new byte[pages * pageSize]; // //fixed (void* memPtr = testBlock) // //{ // // UIntPtr baseAddress = new UIntPtr(memPtr); // // MemoryPageTable target = new MemoryPageTable(baseAddress, pages, pageSize); // TODO: Initialize to an appropriate value // // var details = target.ComputeDetails(); // // Assert.AreEqual(pages, details.numPages); // //} // UIntPtr baseAddress = new UIntPtr(1000000); //random address // MemoryPageTable target = new MemoryPageTable(baseAddress, pages, pageSize); // TODO: Initialize to an appropriate value // var details = target.ComputeDetails(); // Assert.AreEqual(pages, details.numPages); // Assert.AreEqual(pageSize, details.pageSize); // Assert.AreEqual(pageSize* pages, details.memoryManaged); // Assert.AreEqual(pageSize * pages , details.largestSegment); // //details.largestSegment = LargestMemoryBlock(); // //details.memoryManaged = m_pages * PageEntry.PAGE_ENTRY_SIZE; // //details.fragmentation = GetFragmentation(); // //details.amountFree = GetAmountFree(); // //details.pageSize = m_pageSize; // } // /// // ///A test for AddAndMergeNode // /// // [TestMethod()] // [DeploymentItem("Cosmos.Kernel.dll")] // public void AddAndMergeNodeTest() // { // // Private Accessor for AddAndMergeNode is not found. Please rebuild the containing project or run the Publicize.exe manually. // Assert.Inconclusive("Private Accessor for AddAndMergeNode is not found. Please rebuild the containing " + // "project or run the Publicize.exe manually."); // } // /// // ///A test for AddNode // /// // [TestMethod()] // [DeploymentItem("Cosmos.Kernel.dll")] // public void AddNodeTest() // { // // Private Accessor for AddNode is not found. Please rebuild the containing project or run the Publicize.exe manually. // Assert.Inconclusive("Private Accessor for AddNode is not found. Please rebuild the containing project " + // "or run the Publicize.exe manually."); // } // /// // ///A test for AllocateMemory // /// // [TestMethod()] // [DeploymentItem("Cosmos.Kernel.dll")] // public void AllocateMemoryTest1() // { // PrivateObject param0 = null; // TODO: Initialize to an appropriate value // MemoryPageTable_Accessor target = new MemoryPageTable_Accessor(param0); // TODO: Initialize to an appropriate value // uint pages = 0; // TODO: Initialize to an appropriate value // PageType type = new PageType(); // TODO: Initialize to an appropriate value // PageSharing sharing = new PageSharing(); // TODO: Initialize to an appropriate value // uint pid = 0; // TODO: Initialize to an appropriate value // UIntPtr expected = new UIntPtr(); // TODO: Initialize to an appropriate value // UIntPtr actual; // actual = target.AllocateMemory(pages, type, sharing, pid); // Assert.AreEqual(expected, actual); // Assert.Inconclusive("Verify the correctness of this test method."); // } // /// // ///A test for MemoryPageTable Constructor // /// // [TestMethod()] // public void MemoryPageTableConstructorTest2() // { // UIntPtr baseAddress = new UIntPtr(); // TODO: Initialize to an appropriate value // uint pages = 0; // TODO: Initialize to an appropriate value // uint pageSize = 0; // TODO: Initialize to an appropriate value // LinkedList list = null; // TODO: Initialize to an appropriate value // MemoryPageTable target = new MemoryPageTable(baseAddress, pages, pageSize, list); // Assert.Inconclusive("TODO: Implement code to verify target"); // } // /// // ///A test for AllocateMemory // /// // [TestMethod()] // public void AllocateMemoryTest() // { // UIntPtr baseAddress = new UIntPtr(1<<20); // uint pages = 12; // MemoryPageTable target = new MemoryPageTable(baseAddress, pages , 1<<20); // TODO: Initialize to an appropriate value // ulong bytes = 0; // TODO: Initialize to an appropriate value // ulong alignment = 0; // TODO: Initialize to an appropriate value // PageType type = new PageType(); // TODO: Initialize to an appropriate value // PageSharing sharing = new PageSharing(); // TODO: Initialize to an appropriate value // uint pid = 0; // TODO: Initialize to an appropriate value // UIntPtr expected = new UIntPtr(); // TODO: Initialize to an appropriate value // UIntPtr actual; // actual = target.AllocateMemory(bytes, alignment, type, sharing, pid); // Assert.AreEqual(expected, actual); // Assert.Inconclusive("Verify the correctness of this test method."); // } // /// // ///A test for ComputeDetails // /// // [TestMethod()] // public void ComputeDetailsTest() // { // UIntPtr baseAddress = new UIntPtr(); // TODO: Initialize to an appropriate value // uint pages = 0; // TODO: Initialize to an appropriate value // MemoryPageTable target = new MemoryPageTable(baseAddress, pages); // TODO: Initialize to an appropriate value // MemoryDetails expected = new MemoryDetails(); // TODO: Initialize to an appropriate value // MemoryDetails actual; // actual = target.ComputeDetails(); // Assert.AreEqual(expected, actual); // Assert.Inconclusive("Verify the correctness of this test method."); // } // /// // ///A test for DeAllocateAllMemoryForProcess // /// // [TestMethod()] // public void DeAllocateAllMemoryForProcessTest() // { // UIntPtr baseAddress = new UIntPtr(); // TODO: Initialize to an appropriate value // uint pages = 0; // TODO: Initialize to an appropriate value // MemoryPageTable target = new MemoryPageTable(baseAddress, pages); // TODO: Initialize to an appropriate value // Process process = null; // TODO: Initialize to an appropriate value // target.DeAllocateAllMemoryForProcess(process); // Assert.Inconclusive("A method that does not return a value cannot be verified."); // } // } //}