persistentstorage/dbms/tdbms/t_dbbug.cpp
branchRCL_3
changeset 23 26645d81f48d
parent 0 08ec8eefde2f
child 24 cc28652e0254
--- a/persistentstorage/dbms/tdbms/t_dbbug.cpp	Thu Aug 19 11:36:21 2010 +0300
+++ b/persistentstorage/dbms/tdbms/t_dbbug.cpp	Tue Aug 31 16:57:14 2010 +0300
@@ -345,6 +345,7 @@
 	static const TDesC& Name();
 private:
 	static void WaitForServerExit();
+	static void KillDbmsServer();
 	static TInt Thread(TAny*);
 	};
 
@@ -354,6 +355,41 @@
 	return KName;
 	}
 
+void Defect_COMBBAR_463J5D::KillDbmsServer()
+    {
+    _LIT(KDbmsServer,"edbsrv.exe");
+     TFullName name;
+    //RDebug::Print(_L("Find and kill \"%S\" process.\n"), &aProcessName);
+    TBuf<64> pattern(KDbmsServer);
+    TInt length = pattern.Length();
+    pattern += _L("*");
+    TFindProcess procFinder(pattern);
+
+    while (procFinder.Next(name) == KErrNone)
+        {
+        if (name.Length() > length)
+            {//If found name is a string containing aProcessName string.
+            TChar c(name[length]);
+            if (c.IsAlphaDigit() ||
+                c == TChar('_') ||
+                c == TChar('-'))
+                {
+                // If the found name is other valid application name
+                // starting with aProcessName string.
+                //RDebug::Print(_L(":: Process name: \"%S\".\n"), &name);
+                continue;
+                }
+            }
+        RProcess proc;
+        if (proc.Open(name) == KErrNone)
+            {
+            proc.Kill(0);
+            //RDebug::Print(_L("\"%S\" process killed.\n"), &name);
+            }
+        proc.Close();
+        }
+    }
+
 void Defect_COMBBAR_463J5D::WaitForServerExit()
 	{
 	_LIT(KDbmsServer,"*!DBMS server");
@@ -392,8 +428,8 @@
 void Defect_COMBBAR_463J5D::TestL()
 	{
 	test.Next(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0584 "));
-	Print(_S("Wait for the server to exit"));
-	WaitForServerExit();
+	Print(_S("Kill the server if it has started"));
+	KillDbmsServer();
 //
 	Print(_S("Create the launching threads"));
 	RThread t1,t2;