summaryrefslogtreecommitdiff
path: root/db-4.8.30/test/scr037/LockingConfigTest.cs
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2016-12-17 21:28:53 -0800
committerJesse Morgan <jesse@jesterpm.net>2016-12-17 21:28:53 -0800
commit54df2afaa61c6a03cbb4a33c9b90fa572b6d07b8 (patch)
tree18147b92b969d25ffbe61935fb63035cac820dd0 /db-4.8.30/test/scr037/LockingConfigTest.cs
Berkeley DB 4.8 with rust build script for linux.
Diffstat (limited to 'db-4.8.30/test/scr037/LockingConfigTest.cs')
-rw-r--r--db-4.8.30/test/scr037/LockingConfigTest.cs162
1 files changed, 162 insertions, 0 deletions
diff --git a/db-4.8.30/test/scr037/LockingConfigTest.cs b/db-4.8.30/test/scr037/LockingConfigTest.cs
new file mode 100644
index 0000000..82cf630
--- /dev/null
+++ b/db-4.8.30/test/scr037/LockingConfigTest.cs
@@ -0,0 +1,162 @@
+/*-
+ * See the file LICENSE for redistribution information.
+ *
+ * Copyright (c) 2009 Oracle. All rights reserved.
+ *
+ */
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using System.Xml;
+using NUnit.Framework;
+using BerkeleyDB;
+
+namespace CsharpAPITest
+{
+ [TestFixture]
+ public class LockingConfigTest
+ {
+ private string testFixtureHome;
+ private string testFixtureName;
+ private string testName;
+ private string testHome;
+
+ [TestFixtureSetUp]
+ public void RunBeforeTests()
+ {
+ testFixtureName = "LockingConfigTest";
+ testFixtureHome = "./TestOut/" + testFixtureName;
+
+ Configuration.ClearDir(testFixtureHome);
+ }
+
+ [Test]
+ public void TestConfig()
+ {
+ testName = "TestConfig";
+
+ // Configure the fields/properties.
+ LockingConfig lockingConfig = new LockingConfig();
+ XmlElement xmlElem = Configuration.TestSetUp(
+ testFixtureName, testName);
+
+ // Configure LockingConfig
+ Config(xmlElem, ref lockingConfig, true);
+
+ // Confirm LockingConfig
+ Confirm(xmlElem, lockingConfig, true);
+ }
+
+ [Test]
+ public void TestMaxLock() {
+ testName = "TestMaxLock";
+ testHome = testFixtureHome + "/" + testName;
+ Configuration.ClearDir(testHome);
+
+ DatabaseEnvironment env;
+ uint maxLocks;
+ DatabaseEntry obj;
+
+ maxLocks = 1;
+ obj = new DatabaseEntry();
+
+ /*
+ * Initialize environment using locking subsystem. The max number
+ * of locks should be larger than environment's partitions. So in
+ * order to make the MaxLock work, the environment paritition is
+ * set to be the same value as MaxLock.
+ */
+ LockTest.LockingEnvSetUp(testHome, testName, out env,
+ maxLocks, 0, 0, maxLocks);
+ Assert.AreEqual(maxLocks, env.MaxLocks);
+
+ env.Close();
+ }
+
+ [Test]
+ public void TestMaxLocker() {
+ testName = "TestMaxLocker";
+ testHome = testFixtureHome + "/" + testName;
+ Configuration.ClearDir(testHome);
+
+ DatabaseEnvironment env;
+ uint maxLockers;
+
+ maxLockers = 1;
+ LockTest.LockingEnvSetUp(testHome, testName, out env,
+ 0, maxLockers, 0, 0);
+ Assert.AreEqual(maxLockers, env.MaxLockers);
+ env.Close();
+ }
+
+ [Test]
+ public void TestMaxObjects() {
+ testName = "TestMaxObjects";
+ testHome = testFixtureHome + "/" + testName;
+ Configuration.ClearDir(testHome);
+
+ DatabaseEnvironment env;
+ uint maxObjects;
+
+ maxObjects = 1;
+
+ /*
+ * Initialize environment using locking subsystem. The max number
+ * of objects should be larger than environment's partitions. So
+ * in order to make the MaxObject work, the environment paritition
+ * is set to be the same value as MaxObject.
+ */
+ LockTest.LockingEnvSetUp(testHome, testName, out env, 0, 0,
+ maxObjects, maxObjects);
+ Assert.AreEqual(maxObjects, env.MaxObjects);
+ env.Close();
+ }
+
+ public static void Confirm(XmlElement xmlElement,
+ LockingConfig lockingConfig, bool compulsory)
+ {
+ Configuration.ConfirmByteMatrix(xmlElement, "Conflicts",
+ lockingConfig.Conflicts, compulsory);
+ Configuration.ConfirmDeadlockPolicy(xmlElement,
+ "DeadlockResolution",
+ lockingConfig.DeadlockResolution, compulsory);
+ Configuration.ConfirmUint(xmlElement, "MaxLockers",
+ lockingConfig.MaxLockers, compulsory);
+ Configuration.ConfirmUint(xmlElement, "MaxLocks",
+ lockingConfig.MaxLocks, compulsory);
+ Configuration.ConfirmUint(xmlElement, "MaxObjects",
+ lockingConfig.MaxObjects, compulsory);
+ Configuration.ConfirmUint(xmlElement, "Partitions",
+ lockingConfig.Partitions, compulsory);
+ }
+
+ public static void Config(XmlElement xmlElement,
+ ref LockingConfig lockingConfig, bool compulsory)
+ {
+ byte[,] matrix = new byte[6, 6];
+ uint value = new uint();
+
+ if (Configuration.ConfigByteMatrix(xmlElement, "Conflicts",
+ ref matrix, compulsory) == true)
+ lockingConfig.Conflicts = matrix;
+
+ Configuration.ConfigDeadlockPolicy(xmlElement, "DeadlockResolution",
+ ref lockingConfig.DeadlockResolution, compulsory);
+ if (Configuration.ConfigUint(xmlElement, "MaxLockers",
+ ref value, compulsory))
+ lockingConfig.MaxLockers = value;
+ if (Configuration.ConfigUint(xmlElement, "MaxLocks",
+ ref value, compulsory))
+ lockingConfig.MaxLocks = value;
+ if (Configuration.ConfigUint(xmlElement, "MaxObjects",
+ ref value, compulsory))
+ lockingConfig.MaxObjects = value;
+ if (Configuration.ConfigUint(xmlElement, "Partitions",
+ ref value, compulsory))
+ lockingConfig.Partitions = value;
+ }
+
+ }
+}