kerneltest/e32test/hcr/d_hcrsim.cpp
changeset 90 947f0dc9f7a8
parent 39 5d2844f35677
child 257 3e88ff8f41d5
child 291 206a6eaaeb71
--- a/kerneltest/e32test/hcr/d_hcrsim.cpp	Tue Feb 02 01:24:03 2010 +0200
+++ b/kerneltest/e32test/hcr/d_hcrsim.cpp	Fri Apr 16 16:24:37 2010 +0300
@@ -742,38 +742,62 @@
 			}
 		case RHcrSimTestChannel::EHcrGetDataArray:
 			{
+			//args[0] - &aId
+			//args[1] - aMaxLen
+			//args[2] - aValue
+			//args[3] - &aLen
+			
 			// Get list of pointers
 			TAny* args[4];
 			TEST_MEMGET(a1, args, sizeof(args));
 			TUint maxlen = (TUint) args[1];
+			
 			// Retrieve structures from client
 			TSettingId id;
 			TEST_MEMGET(args[0], &id, sizeof(TSettingId));
 			// Allocate temporary memory
 			TUint16 len;
 			TUint8* value;
+			
 			TEST_ENTERCS();
-			value = (TUint8*) Kern::Alloc(maxlen * sizeof(TUint8));
-			TEST_LEAVECS();
-			if (value == NULL)
-				{
-				r = KErrNoMemory;
-				}
+			//Analyse user input. Some test cases can pass either aMaxLen == 0,
+			//aValue == NULL or both
+			if(args[2] != 0 && args[1] != 0)
+			    {
+			    value = (TUint8*) Kern::Alloc(maxlen);
+			    if(!value) return KErrNoMemory;
+			    }
+			//aValue == NULL, just pass NULL to HCR PIL
+			else if(args[2] == 0)
+			    value = NULL;
+			//aMaxLen = 0, allocate 4 bytes memory 
+			else if(args[1] == 0)
+			    {
+			    value = (TUint8*) Kern::Alloc(4);
+			    if(!value) return KErrNoMemory;
+			    }
+			//aVallue == NULL && aMaxLen == 0
 			else
-				{
-				// Actual API call
-				r = GetData(id, (TUint16) maxlen,
-							value, len);
-				// Send value back to client
-				if (!r)
-					{
-					TEST_MEMPUT(args[2], value, maxlen * sizeof(TUint8));
-					TEST_MEMPUT(args[3], &len, sizeof(TUint16));
-					}
-				TEST_ENTERCS();
-				Kern::Free(value);
-				TEST_LEAVECS();
-				}
+			    value = NULL;
+			TEST_LEAVECS();
+			
+			
+			// Actual API call
+			r = GetData(id, (TUint16) maxlen,
+			        value, len);
+			// Send value back to client
+			if(value && maxlen)
+			    {
+			    TEST_MEMPUT(args[2], value, maxlen * sizeof(TUint8));
+			    TEST_MEMPUT(args[3], &len, sizeof(TUint16));
+			    }
+			
+			if(value)
+			    {
+			    TEST_ENTERCS();
+			    Kern::Free(value);
+			    TEST_LEAVECS();
+			    }
 			break;
 			}
 		case RHcrSimTestChannel::EHcrGetDataDes:
@@ -837,43 +861,74 @@
 			break;
 			}
 		case RHcrSimTestChannel::EHcrGetArrayInt:
-			{
-			// Get list of pointers
-			TAny* args[4];
-			TEST_MEMGET(a1, args, sizeof(args));
-			TUint maxlen = (TUint) args[1];
-			// Retrieve structures from client
-			TSettingId id;
-			TEST_MEMGET(args[0], &id, sizeof(TSettingId));
-			// Allocate temporary memory
-			TUint16 len;
-			TInt32* value;
-			TEST_ENTERCS();
-			value = (TInt32*) Kern::Alloc(maxlen);
-			TEST_LEAVECS();
-			if (value == NULL)
-				{
-				r = KErrNoMemory;
-				}
-			else
-				{
-				// Actual API call
-				r = GetArray(id, (TUint16) maxlen,
-							value, len);
-				// Send value back to client
-				if (!r)
-					{
-					TEST_MEMPUT(args[2], value, maxlen);
-					TEST_MEMPUT(args[3], &len, sizeof(TUint16));
-					}
-				TEST_ENTERCS();
-				Kern::Free(value);
-				TEST_LEAVECS();
-				}
-			break;
+		    {
+		    //args[0] - &aId
+		    //args[1] - aMaxLen
+		    //args[2] - aValue
+		    //args[3] - &aLen
+
+		    // Get list of pointers
+		    TAny* args[4];
+		    TEST_MEMGET(a1, args, sizeof(args));
+		    TUint maxlen = (TUint) args[1];
+		    // Retrieve structures from client
+		    TSettingId id;
+		    TEST_MEMGET(args[0], &id, sizeof(TSettingId));
+		    // Allocate temporary memory
+		    TUint16 len;
+		    TInt32* value;
+
+		    TEST_ENTERCS();
+		    //Analyse user input. Some test cases can pass either aMaxLen == 0,
+		    //aValue == NULL or both
+		    if(args[2] != 0 && args[1] != 0)
+		        {
+                value = (TInt32*) Kern::Alloc(maxlen*sizeof(TInt32));
+                if(!value) return KErrNoMemory;
+		        }
+		    //aValue == NULL, just pass NULL to HCR PIL
+		    else if(args[2] == 0)
+		        value = NULL;
+		    //aMaxLen = 0, allocate 4 bytes memory 
+		    else if(args[1] == 0)
+		        {
+                value = (TInt32*) Kern::Alloc(maxlen*sizeof(TInt32));
+                if(!value) return KErrNoMemory;
+		        }
+		    //aVallue == NULL && aMaxLen == 0
+		    else
+		        value = NULL;
+		    TEST_LEAVECS();
+
+
+		    // Actual API call
+		    r = GetArray(id, (TUint16) maxlen,
+		            value, len);
+
+		    // Send value back to client
+		    //aMaxLen > 0 && aValue != NULL
+		    if (args[1] && args[2])
+		        {
+		    TEST_MEMPUT(args[2], value, maxlen);
+		    TEST_MEMPUT(args[3], &len, sizeof(TUint16));
+		        }
+
+		    if(value)
+		        {
+		    TEST_ENTERCS();
+		    Kern::Free(value);
+		    TEST_LEAVECS();
+		        }
+
+		        break;
 			}
 		case RHcrSimTestChannel::EHcrGetArrayUInt:
-			{
+		    {
+		    //args[0] - &aId
+		    //args[1] - aMaxLen
+		    //args[2] - aValue
+		    //args[3] - &aLen
+		    
 			// Get list of pointers
 			TAny* args[4];
 			TEST_MEMGET(a1, args, sizeof(args));
@@ -884,35 +939,63 @@
 			// Allocate temporary memory
 			TUint16 len;
 			TUint32* value;
+			
 			TEST_ENTERCS();
-			value = (TUint32*) Kern::Alloc(maxlen);
-			TEST_LEAVECS();
-			if (value == NULL)
-				{
-				r = KErrNoMemory;
-				}
+			//Analyse user input. Some test cases can pass either aMaxLen == 0,
+			//aValue == NULL or both
+			if(args[2] != 0 && args[1] != 0)
+			    {
+			    value = (TUint32*) Kern::Alloc(maxlen*sizeof(TUint32));
+			    if(!value) return KErrNoMemory;
+			    }
+			//aValue == NULL, just pass NULL to HCR PIL
+			else if(args[2] == 0)
+			    value = NULL;
+			//aMaxLen = 0, allocate 4 bytes memory 
+			else if(args[1] == 0)
+			    {
+			    value = (TUint32*) Kern::Alloc(maxlen*sizeof(TUint32));
+			    if(!value) return KErrNoMemory;
+			    }
+			//aVallue == NULL && aMaxLen == 0
 			else
-				{
-				// Actual API call
-				r = GetArray(id, (TUint16) maxlen,
-							value, len);
-				// Send value back to client
-				if (!r)
-					{
-					TEST_MEMPUT(args[2], value, maxlen);
-					TEST_MEMPUT(args[3], &len, sizeof(TUint16));
-					}
-				TEST_ENTERCS();
-				Kern::Free(value);
-				TEST_LEAVECS();
-				}
+			    value = NULL;
+			TEST_LEAVECS();
+			
+
+			// Actual API call
+			r = GetArray(id, (TUint16) maxlen,
+			        value, len);
+			// Send value back to client
+			
+			//aMaxLine != 0 && aValue != NULL
+			if (args[1] && args[2])
+			    {
+			    TEST_MEMPUT(args[2], value, maxlen);
+			    TEST_MEMPUT(args[3], &len, sizeof(TUint16));
+			    }
+			
+			if(value)
+			    {
+			    TEST_ENTERCS();
+			    Kern::Free(value);
+			    TEST_LEAVECS();
+			    }
+
 			break;
 			}
+		    
 		case RHcrSimTestChannel::EHcrGetStringArray:
 			{
 			// Get list of pointers
 			TAny* args[4];
 			TEST_MEMGET(a1, args, sizeof(args));
+			
+			//args[0] - &aId
+			//args[1] - aMaxLen
+			//args[2] - aValue
+			//args[3] - &aLen
+			
 			TUint maxlen = (TUint) args[1];
 			// Retrieve structures from client
 			TSettingId id;
@@ -920,28 +1003,49 @@
 			// Allocate temporary memory
 			TUint16 len;
 			TText8* value;
+
 			TEST_ENTERCS();
-			value = (TText8*) Kern::Alloc(maxlen * sizeof(TText8));
-			TEST_LEAVECS();
-			if (value == NULL)
-				{
-				r = KErrNoMemory;
-				}
+			
+			//Analyse user input. Some test cases can pass either aMaxLen == 0,
+			//aValue == NULL or both
+			if(args[2] != 0 && args[1] != 0)
+			    {
+			    value = (TText8*) Kern::Alloc(maxlen*sizeof(TText8));
+			    if(!value) return KErrNoMemory;
+			    }
+			//aValue == NULL, just pass NULL to HCR PIL
+			else if(args[2] == 0)
+			    value = NULL;
+			//aMaxLen = 0, allocate 4 bytes memory 
+			else if(args[1] == 0)
+			    {
+			    value = (TText8*) Kern::Alloc(maxlen*sizeof(TText8));
+			    if(!value) return KErrNoMemory;
+			    }
+			//aVallue == NULL && aMaxLen == 0
 			else
-				{
-				// Actual API call
-				r = GetString(id, (TUint16) maxlen,
-							value, len);
-				// Send value back to client
-				if (!r)
-					{
-					TEST_MEMPUT(args[2], value, maxlen * sizeof(TText8));
-					TEST_MEMPUT(args[3], &len, sizeof(TUint16));
-					}
-				TEST_ENTERCS();
-				Kern::Free(value);
-				TEST_LEAVECS();
-				}
+			    value = NULL;
+			TEST_LEAVECS();
+
+
+			// Actual API call
+			r = GetString(id, (TUint16) maxlen,
+			        value, len);
+			// Send value back to client
+			//aMaxLen != 0 && aValue != NULL
+			if (args[1] && args[2])
+			    {
+			    TEST_MEMPUT(args[2], value, maxlen * sizeof(TText8));
+			    TEST_MEMPUT(args[3], &len, sizeof(TUint16));
+			    }
+
+			if(value)
+			    {
+			    TEST_ENTERCS();
+			    Kern::Free(value);
+			    TEST_LEAVECS();
+			    }
+			
 			break;
 			}
 		case RHcrSimTestChannel::EHcrGetStringDes: