Ejemplo n.º 1
0
        private StringBuilder AddScenePartItemsReport(StringBuilder sb, IEntityInventory inv)
        {
            ConsoleDisplayTable cdt = new ConsoleDisplayTable();

            cdt.Indent = 2;

            cdt.AddColumn("Name", 50);
            cdt.AddColumn("Type", 12);
            cdt.AddColumn("Running", 7);
            cdt.AddColumn("Item UUID", 36);
            cdt.AddColumn("Asset UUID", 36);

            foreach (TaskInventoryItem item in inv.GetInventoryItems())
            {
                bool foundScriptInstance, scriptRunning;
                foundScriptInstance
                    = SceneObjectPartInventory.TryGetScriptInstanceRunning(m_scene, item, out scriptRunning);

                cdt.AddRow(
                    item.Name,
                    ((InventoryType)item.InvType).ToString(),
                    foundScriptInstance ? scriptRunning.ToString() : "n/a",
                    item.ItemID.ToString(),
                    item.AssetID.ToString());
            }

            return(sb.Append(cdt.ToString()));
        }
Ejemplo n.º 2
0
        private void TestSingleStatementNoStop(string script)
        {
            // In these tests we expect to see at least 2 chat messages to confirm that the loop is working properly.
            m_chatMessagesThreshold = 2;

            UUID userId = TestHelpers.ParseTail(0x1);
            //            UUID objectId = TestHelpers.ParseTail(0x100);
            //            UUID itemId = TestHelpers.ParseTail(0x3);
            string itemName = "TestNoStop";

            SceneObjectPart partWhereRezzed = CreateScript(script, itemName, userId);

            // Wait for the script to start the event before we try stopping it.
            m_chatEvent.WaitOne(60000);

            if (m_osChatMessageReceived == null)
            {
                Assert.Fail("Script did not start");
            }
            else
            {
                Assert.That(m_chatMessagesReceived, Is.EqualTo(2));
            }

            bool running;
            TaskInventoryItem scriptItem = partWhereRezzed.Inventory.GetInventoryItem(itemName);

            Assert.That(
                SceneObjectPartInventory.TryGetScriptInstanceRunning(m_scene, scriptItem, out running), Is.True);
            Assert.That(running, Is.True);
        }
Ejemplo n.º 3
0
        private void TestStop(string script)
        {
            // In these tests we're only interested in the first message to confirm that the script has started.
            m_chatMessagesThreshold = 1;

            UUID userId = TestHelpers.ParseTail(0x1);
            //            UUID objectId = TestHelpers.ParseTail(0x100);
            //            UUID itemId = TestHelpers.ParseTail(0x3);
            string itemName = "TestStop";

            SceneObjectPart   partWhereRezzed = CreateScript(script, itemName, userId);
            TaskInventoryItem rezzedItem      = partWhereRezzed.Inventory.GetInventoryItem(itemName);

            // Wait for the script to start the event before we try stopping it.
            m_chatEvent.WaitOne(60000);

            if (m_osChatMessageReceived != null)
            {
                Console.WriteLine("Script started with message [{0}]", m_osChatMessageReceived.Message);
            }
            else
            {
                Assert.Fail("Script did not start");
            }

            // FIXME: This is a very poor way of trying to avoid a low-probability race condition where the script
            // executes llSay() but has not started the next statement before we try to stop it.
            Thread.Sleep(1000);

            // We need a way of carrying on if StopScript() fail, since it won't return if the script isn't actually
            // stopped.  This kind of multi-threading is far from ideal in a regression test.
            new Thread(() => { m_xEngine.StopScript(rezzedItem.ItemID); m_stoppedEvent.Set(); }).Start();

            if (!m_stoppedEvent.WaitOne(30000))
            {
                Assert.Fail("Script did not co-operatively stop.");
            }

            bool running;
            TaskInventoryItem scriptItem = partWhereRezzed.Inventory.GetInventoryItem(itemName);

            Assert.That(
                SceneObjectPartInventory.TryGetScriptInstanceRunning(m_scene, scriptItem, out running), Is.True);
            Assert.That(running, Is.False);
        }
Ejemplo n.º 4
0
        public void TestCompileAndStartScript()
        {
            TestHelpers.InMethod();
            TestHelpers.EnableLogging();

            UUID userId = TestHelpers.ParseTail(0x1);
//            UUID objectId = TestHelpers.ParseTail(0x100);
//            UUID itemId = TestHelpers.ParseTail(0x3);
            string itemName = "TestStartScript() Item";

            SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, "TestStartScriptPart_", 0x100);

            m_scene.AddNewSceneObject(so, true);

            InventoryItemBase itemTemplate = new InventoryItemBase();

//            itemTemplate.ID = itemId;
            itemTemplate.Name    = itemName;
            itemTemplate.Folder  = so.UUID;
            itemTemplate.InvType = (int)InventoryType.LSL;

            m_scene.EventManager.OnChatFromWorld += OnChatFromWorld;

            SceneObjectPart partWhereRezzed = m_scene.RezNewScript(userId, itemTemplate);

            m_chatEvent.WaitOne(60000);

            Assert.That(m_osChatMessageReceived, Is.Not.Null, "No chat message received in TestStartScript()");
            Assert.That(m_osChatMessageReceived.Message, Is.EqualTo("Script running"));

            bool running;
            TaskInventoryItem scriptItem = partWhereRezzed.Inventory.GetInventoryItem(itemName);

            Assert.That(
                SceneObjectPartInventory.TryGetScriptInstanceRunning(m_scene, scriptItem, out running), Is.True);
            Assert.That(running, Is.True);
        }