kerneltest/e32test/hcr/d_hcrsim.cpp
changeset 90 947f0dc9f7a8
parent 39 5d2844f35677
child 257 3e88ff8f41d5
child 291 206a6eaaeb71
equal deleted inserted replaced
52:2d65c2f76d7b 90:947f0dc9f7a8
   740 			TEST_MEMPUT(a2, &value, sizeof(value));
   740 			TEST_MEMPUT(a2, &value, sizeof(value));
   741 			break;
   741 			break;
   742 			}
   742 			}
   743 		case RHcrSimTestChannel::EHcrGetDataArray:
   743 		case RHcrSimTestChannel::EHcrGetDataArray:
   744 			{
   744 			{
       
   745 			//args[0] - &aId
       
   746 			//args[1] - aMaxLen
       
   747 			//args[2] - aValue
       
   748 			//args[3] - &aLen
       
   749 			
   745 			// Get list of pointers
   750 			// Get list of pointers
   746 			TAny* args[4];
   751 			TAny* args[4];
   747 			TEST_MEMGET(a1, args, sizeof(args));
   752 			TEST_MEMGET(a1, args, sizeof(args));
   748 			TUint maxlen = (TUint) args[1];
   753 			TUint maxlen = (TUint) args[1];
       
   754 			
   749 			// Retrieve structures from client
   755 			// Retrieve structures from client
   750 			TSettingId id;
   756 			TSettingId id;
   751 			TEST_MEMGET(args[0], &id, sizeof(TSettingId));
   757 			TEST_MEMGET(args[0], &id, sizeof(TSettingId));
   752 			// Allocate temporary memory
   758 			// Allocate temporary memory
   753 			TUint16 len;
   759 			TUint16 len;
   754 			TUint8* value;
   760 			TUint8* value;
       
   761 			
   755 			TEST_ENTERCS();
   762 			TEST_ENTERCS();
   756 			value = (TUint8*) Kern::Alloc(maxlen * sizeof(TUint8));
   763 			//Analyse user input. Some test cases can pass either aMaxLen == 0,
       
   764 			//aValue == NULL or both
       
   765 			if(args[2] != 0 && args[1] != 0)
       
   766 			    {
       
   767 			    value = (TUint8*) Kern::Alloc(maxlen);
       
   768 			    if(!value) return KErrNoMemory;
       
   769 			    }
       
   770 			//aValue == NULL, just pass NULL to HCR PIL
       
   771 			else if(args[2] == 0)
       
   772 			    value = NULL;
       
   773 			//aMaxLen = 0, allocate 4 bytes memory 
       
   774 			else if(args[1] == 0)
       
   775 			    {
       
   776 			    value = (TUint8*) Kern::Alloc(4);
       
   777 			    if(!value) return KErrNoMemory;
       
   778 			    }
       
   779 			//aVallue == NULL && aMaxLen == 0
       
   780 			else
       
   781 			    value = NULL;
   757 			TEST_LEAVECS();
   782 			TEST_LEAVECS();
   758 			if (value == NULL)
   783 			
   759 				{
   784 			
   760 				r = KErrNoMemory;
   785 			// Actual API call
   761 				}
   786 			r = GetData(id, (TUint16) maxlen,
   762 			else
   787 			        value, len);
   763 				{
   788 			// Send value back to client
   764 				// Actual API call
   789 			if(value && maxlen)
   765 				r = GetData(id, (TUint16) maxlen,
   790 			    {
   766 							value, len);
   791 			    TEST_MEMPUT(args[2], value, maxlen * sizeof(TUint8));
   767 				// Send value back to client
   792 			    TEST_MEMPUT(args[3], &len, sizeof(TUint16));
   768 				if (!r)
   793 			    }
   769 					{
   794 			
   770 					TEST_MEMPUT(args[2], value, maxlen * sizeof(TUint8));
   795 			if(value)
   771 					TEST_MEMPUT(args[3], &len, sizeof(TUint16));
   796 			    {
   772 					}
   797 			    TEST_ENTERCS();
   773 				TEST_ENTERCS();
   798 			    Kern::Free(value);
   774 				Kern::Free(value);
   799 			    TEST_LEAVECS();
   775 				TEST_LEAVECS();
   800 			    }
   776 				}
       
   777 			break;
   801 			break;
   778 			}
   802 			}
   779 		case RHcrSimTestChannel::EHcrGetDataDes:
   803 		case RHcrSimTestChannel::EHcrGetDataDes:
   780 			{
   804 			{
   781 			TSettingId setting;
   805 			TSettingId setting;
   835 			r = GetUInt(setting, value);
   859 			r = GetUInt(setting, value);
   836 			TEST_MEMPUT(a2, &value, sizeof(value));
   860 			TEST_MEMPUT(a2, &value, sizeof(value));
   837 			break;
   861 			break;
   838 			}
   862 			}
   839 		case RHcrSimTestChannel::EHcrGetArrayInt:
   863 		case RHcrSimTestChannel::EHcrGetArrayInt:
   840 			{
   864 		    {
   841 			// Get list of pointers
   865 		    //args[0] - &aId
   842 			TAny* args[4];
   866 		    //args[1] - aMaxLen
   843 			TEST_MEMGET(a1, args, sizeof(args));
   867 		    //args[2] - aValue
   844 			TUint maxlen = (TUint) args[1];
   868 		    //args[3] - &aLen
   845 			// Retrieve structures from client
   869 
   846 			TSettingId id;
   870 		    // Get list of pointers
   847 			TEST_MEMGET(args[0], &id, sizeof(TSettingId));
   871 		    TAny* args[4];
   848 			// Allocate temporary memory
   872 		    TEST_MEMGET(a1, args, sizeof(args));
   849 			TUint16 len;
   873 		    TUint maxlen = (TUint) args[1];
   850 			TInt32* value;
   874 		    // Retrieve structures from client
   851 			TEST_ENTERCS();
   875 		    TSettingId id;
   852 			value = (TInt32*) Kern::Alloc(maxlen);
   876 		    TEST_MEMGET(args[0], &id, sizeof(TSettingId));
   853 			TEST_LEAVECS();
   877 		    // Allocate temporary memory
   854 			if (value == NULL)
   878 		    TUint16 len;
   855 				{
   879 		    TInt32* value;
   856 				r = KErrNoMemory;
   880 
   857 				}
   881 		    TEST_ENTERCS();
   858 			else
   882 		    //Analyse user input. Some test cases can pass either aMaxLen == 0,
   859 				{
   883 		    //aValue == NULL or both
   860 				// Actual API call
   884 		    if(args[2] != 0 && args[1] != 0)
   861 				r = GetArray(id, (TUint16) maxlen,
   885 		        {
   862 							value, len);
   886                 value = (TInt32*) Kern::Alloc(maxlen*sizeof(TInt32));
   863 				// Send value back to client
   887                 if(!value) return KErrNoMemory;
   864 				if (!r)
   888 		        }
   865 					{
   889 		    //aValue == NULL, just pass NULL to HCR PIL
   866 					TEST_MEMPUT(args[2], value, maxlen);
   890 		    else if(args[2] == 0)
   867 					TEST_MEMPUT(args[3], &len, sizeof(TUint16));
   891 		        value = NULL;
   868 					}
   892 		    //aMaxLen = 0, allocate 4 bytes memory 
   869 				TEST_ENTERCS();
   893 		    else if(args[1] == 0)
   870 				Kern::Free(value);
   894 		        {
   871 				TEST_LEAVECS();
   895                 value = (TInt32*) Kern::Alloc(maxlen*sizeof(TInt32));
   872 				}
   896                 if(!value) return KErrNoMemory;
   873 			break;
   897 		        }
       
   898 		    //aVallue == NULL && aMaxLen == 0
       
   899 		    else
       
   900 		        value = NULL;
       
   901 		    TEST_LEAVECS();
       
   902 
       
   903 
       
   904 		    // Actual API call
       
   905 		    r = GetArray(id, (TUint16) maxlen,
       
   906 		            value, len);
       
   907 
       
   908 		    // Send value back to client
       
   909 		    //aMaxLen > 0 && aValue != NULL
       
   910 		    if (args[1] && args[2])
       
   911 		        {
       
   912 		    TEST_MEMPUT(args[2], value, maxlen);
       
   913 		    TEST_MEMPUT(args[3], &len, sizeof(TUint16));
       
   914 		        }
       
   915 
       
   916 		    if(value)
       
   917 		        {
       
   918 		    TEST_ENTERCS();
       
   919 		    Kern::Free(value);
       
   920 		    TEST_LEAVECS();
       
   921 		        }
       
   922 
       
   923 		        break;
   874 			}
   924 			}
   875 		case RHcrSimTestChannel::EHcrGetArrayUInt:
   925 		case RHcrSimTestChannel::EHcrGetArrayUInt:
   876 			{
   926 		    {
       
   927 		    //args[0] - &aId
       
   928 		    //args[1] - aMaxLen
       
   929 		    //args[2] - aValue
       
   930 		    //args[3] - &aLen
       
   931 		    
   877 			// Get list of pointers
   932 			// Get list of pointers
   878 			TAny* args[4];
   933 			TAny* args[4];
   879 			TEST_MEMGET(a1, args, sizeof(args));
   934 			TEST_MEMGET(a1, args, sizeof(args));
   880 			TUint maxlen = (TUint) args[1];
   935 			TUint maxlen = (TUint) args[1];
   881 			// Retrieve structures from client
   936 			// Retrieve structures from client
   882 			TSettingId id;
   937 			TSettingId id;
   883 			TEST_MEMGET(args[0], &id, sizeof(TSettingId));
   938 			TEST_MEMGET(args[0], &id, sizeof(TSettingId));
   884 			// Allocate temporary memory
   939 			// Allocate temporary memory
   885 			TUint16 len;
   940 			TUint16 len;
   886 			TUint32* value;
   941 			TUint32* value;
       
   942 			
   887 			TEST_ENTERCS();
   943 			TEST_ENTERCS();
   888 			value = (TUint32*) Kern::Alloc(maxlen);
   944 			//Analyse user input. Some test cases can pass either aMaxLen == 0,
       
   945 			//aValue == NULL or both
       
   946 			if(args[2] != 0 && args[1] != 0)
       
   947 			    {
       
   948 			    value = (TUint32*) Kern::Alloc(maxlen*sizeof(TUint32));
       
   949 			    if(!value) return KErrNoMemory;
       
   950 			    }
       
   951 			//aValue == NULL, just pass NULL to HCR PIL
       
   952 			else if(args[2] == 0)
       
   953 			    value = NULL;
       
   954 			//aMaxLen = 0, allocate 4 bytes memory 
       
   955 			else if(args[1] == 0)
       
   956 			    {
       
   957 			    value = (TUint32*) Kern::Alloc(maxlen*sizeof(TUint32));
       
   958 			    if(!value) return KErrNoMemory;
       
   959 			    }
       
   960 			//aVallue == NULL && aMaxLen == 0
       
   961 			else
       
   962 			    value = NULL;
   889 			TEST_LEAVECS();
   963 			TEST_LEAVECS();
   890 			if (value == NULL)
   964 			
   891 				{
   965 
   892 				r = KErrNoMemory;
   966 			// Actual API call
   893 				}
   967 			r = GetArray(id, (TUint16) maxlen,
   894 			else
   968 			        value, len);
   895 				{
   969 			// Send value back to client
   896 				// Actual API call
   970 			
   897 				r = GetArray(id, (TUint16) maxlen,
   971 			//aMaxLine != 0 && aValue != NULL
   898 							value, len);
   972 			if (args[1] && args[2])
   899 				// Send value back to client
   973 			    {
   900 				if (!r)
   974 			    TEST_MEMPUT(args[2], value, maxlen);
   901 					{
   975 			    TEST_MEMPUT(args[3], &len, sizeof(TUint16));
   902 					TEST_MEMPUT(args[2], value, maxlen);
   976 			    }
   903 					TEST_MEMPUT(args[3], &len, sizeof(TUint16));
   977 			
   904 					}
   978 			if(value)
   905 				TEST_ENTERCS();
   979 			    {
   906 				Kern::Free(value);
   980 			    TEST_ENTERCS();
   907 				TEST_LEAVECS();
   981 			    Kern::Free(value);
   908 				}
   982 			    TEST_LEAVECS();
   909 			break;
   983 			    }
   910 			}
   984 
       
   985 			break;
       
   986 			}
       
   987 		    
   911 		case RHcrSimTestChannel::EHcrGetStringArray:
   988 		case RHcrSimTestChannel::EHcrGetStringArray:
   912 			{
   989 			{
   913 			// Get list of pointers
   990 			// Get list of pointers
   914 			TAny* args[4];
   991 			TAny* args[4];
   915 			TEST_MEMGET(a1, args, sizeof(args));
   992 			TEST_MEMGET(a1, args, sizeof(args));
       
   993 			
       
   994 			//args[0] - &aId
       
   995 			//args[1] - aMaxLen
       
   996 			//args[2] - aValue
       
   997 			//args[3] - &aLen
       
   998 			
   916 			TUint maxlen = (TUint) args[1];
   999 			TUint maxlen = (TUint) args[1];
   917 			// Retrieve structures from client
  1000 			// Retrieve structures from client
   918 			TSettingId id;
  1001 			TSettingId id;
   919 			TEST_MEMGET(args[0], &id, sizeof(TSettingId));
  1002 			TEST_MEMGET(args[0], &id, sizeof(TSettingId));
   920 			// Allocate temporary memory
  1003 			// Allocate temporary memory
   921 			TUint16 len;
  1004 			TUint16 len;
   922 			TText8* value;
  1005 			TText8* value;
       
  1006 
   923 			TEST_ENTERCS();
  1007 			TEST_ENTERCS();
   924 			value = (TText8*) Kern::Alloc(maxlen * sizeof(TText8));
  1008 			
       
  1009 			//Analyse user input. Some test cases can pass either aMaxLen == 0,
       
  1010 			//aValue == NULL or both
       
  1011 			if(args[2] != 0 && args[1] != 0)
       
  1012 			    {
       
  1013 			    value = (TText8*) Kern::Alloc(maxlen*sizeof(TText8));
       
  1014 			    if(!value) return KErrNoMemory;
       
  1015 			    }
       
  1016 			//aValue == NULL, just pass NULL to HCR PIL
       
  1017 			else if(args[2] == 0)
       
  1018 			    value = NULL;
       
  1019 			//aMaxLen = 0, allocate 4 bytes memory 
       
  1020 			else if(args[1] == 0)
       
  1021 			    {
       
  1022 			    value = (TText8*) Kern::Alloc(maxlen*sizeof(TText8));
       
  1023 			    if(!value) return KErrNoMemory;
       
  1024 			    }
       
  1025 			//aVallue == NULL && aMaxLen == 0
       
  1026 			else
       
  1027 			    value = NULL;
   925 			TEST_LEAVECS();
  1028 			TEST_LEAVECS();
   926 			if (value == NULL)
  1029 
   927 				{
  1030 
   928 				r = KErrNoMemory;
  1031 			// Actual API call
   929 				}
  1032 			r = GetString(id, (TUint16) maxlen,
   930 			else
  1033 			        value, len);
   931 				{
  1034 			// Send value back to client
   932 				// Actual API call
  1035 			//aMaxLen != 0 && aValue != NULL
   933 				r = GetString(id, (TUint16) maxlen,
  1036 			if (args[1] && args[2])
   934 							value, len);
  1037 			    {
   935 				// Send value back to client
  1038 			    TEST_MEMPUT(args[2], value, maxlen * sizeof(TText8));
   936 				if (!r)
  1039 			    TEST_MEMPUT(args[3], &len, sizeof(TUint16));
   937 					{
  1040 			    }
   938 					TEST_MEMPUT(args[2], value, maxlen * sizeof(TText8));
  1041 
   939 					TEST_MEMPUT(args[3], &len, sizeof(TUint16));
  1042 			if(value)
   940 					}
  1043 			    {
   941 				TEST_ENTERCS();
  1044 			    TEST_ENTERCS();
   942 				Kern::Free(value);
  1045 			    Kern::Free(value);
   943 				TEST_LEAVECS();
  1046 			    TEST_LEAVECS();
   944 				}
  1047 			    }
       
  1048 			
   945 			break;
  1049 			break;
   946 			}
  1050 			}
   947 		case RHcrSimTestChannel::EHcrGetStringDes:
  1051 		case RHcrSimTestChannel::EHcrGetStringDes:
   948 			{
  1052 			{
   949 			TSettingId setting;
  1053 			TSettingId setting;