• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/router/db-4.8.30/test/scr037/
1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 2009 Oracle.  All rights reserved.
5 *
6 */
7using System;
8using System.Collections;
9using System.Collections.Generic;
10using System.IO;
11using System.Text;
12using System.Xml;
13using NUnit.Framework;
14using BerkeleyDB;
15
16namespace CsharpAPITest
17{
18	[TestFixture]
19	public class MutexConfigTest
20	{
21		private string testFixtureHome;
22		private string testFixtureName;
23		private string testName;
24
25		[TestFixtureSetUp]
26		public void RunBeforeTests()
27		{
28			testFixtureName = "MutexConfigTest";
29			testFixtureHome = "./TestOut/" + testFixtureName;
30			Configuration.ClearDir(testFixtureHome);
31		}
32
33		[Test]
34		public void TestConfig()
35		{
36			testName = "TestConfig";
37
38			/*
39			 * Configure the fields/properties and see if
40			 * they are updated successfully.
41			 */
42			MutexConfig lockingConfig = new MutexConfig();
43			XmlElement xmlElem = Configuration.TestSetUp(
44			    testFixtureName, testName);
45			Config(xmlElem, ref lockingConfig, true);
46			Confirm(xmlElem, lockingConfig, true);
47		}
48
49
50		public static void Confirm(XmlElement
51		    xmlElement, MutexConfig mutexConfig, bool compulsory)
52		{
53			Configuration.ConfirmUint(xmlElement, "Alignment",
54			    mutexConfig.Alignment, compulsory);
55			Configuration.ConfirmUint(xmlElement, "Increment",
56			    mutexConfig.Increment, compulsory);
57			Configuration.ConfirmUint(xmlElement, "MaxMutexes",
58			    mutexConfig.MaxMutexes, compulsory);
59			Configuration.ConfirmUint(xmlElement,
60			    "NumTestAndSetSpins",
61			    mutexConfig.NumTestAndSetSpins, compulsory);
62		}
63
64		public static void Config(XmlElement
65		    xmlElement, ref MutexConfig mutexConfig, bool compulsory)
66		{
67			uint value = new uint();
68			if (Configuration.ConfigUint(xmlElement, "Alignment",
69			    ref value, compulsory))
70				mutexConfig.Alignment = value;
71			if (Configuration.ConfigUint(xmlElement, "Increment",
72			    ref value, compulsory))
73				mutexConfig.Increment = value;
74			if (Configuration.ConfigUint(xmlElement, "MaxMutexes",
75			    ref value, compulsory))
76				mutexConfig.MaxMutexes = value;
77			if (Configuration.ConfigUint(xmlElement,
78			    "NumTestAndSetSpins", ref value, compulsory))
79				mutexConfig.NumTestAndSetSpins = value;
80		}
81	}
82}
83