Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

tcmpmem.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1993 Digital Equipment Corporation 00004 00005 Module Name: 00006 00007 tcmpmem.c 00008 00009 Abstract: 00010 00011 This module implements a test of the operation of the RtlCompareMemory 00012 function by running an exhaustive test of every case of string offset, 00013 compare length, and return value up to and a little beyond one 32-byte 00014 cache line. This represents over one million test cases. It is assumed 00015 any bugs that exist will be found within this range. If only the error 00016 count summary is desired, type "tcmpmem > nul" instead. 00017 00018 Author: 00019 00020 Thomas Van Baak (tvb) 11-Jan-1993 00021 00022 Environment: 00023 00024 User mode. 00025 00026 Revision History: 00027 00028 --*/ 00029 00030 #include <nt.h> 00031 #include <ntrtl.h> 00032 #include <stdio.h> 00033 #include "localrtl.h" 00034 00035 #define BUFFER_SIZE (MAX_OFFSET + MAX_LENGTH) 00036 00037 UCHAR String1[BUFFER_SIZE]; 00038 UCHAR String2[BUFFER_SIZE]; 00039 00040 void 00041 __cdecl 00042 main() 00043 { 00044 ULONG ErrorCount; 00045 ULONG Expected; 00046 ULONG Length; 00047 ULONG Offset1; 00048 ULONG Offset2; 00049 ULONG Result; 00050 ULONG TestCases; 00051 00052 fprintf(stderr, "Testing RtlCompareMemory\n"); 00053 ErrorCount = 0; 00054 TestCases = 0; 00055 00056 for (Offset1 = 0; Offset1 <= MAX_OFFSET; Offset1 += 1) { 00057 00058 // 00059 // Copy the test pattern to Offset1 in String1 and then for each 00060 // possible offset of String1, for each possible offset of String2, 00061 // for each possible string compare length, and for each expected 00062 // return value, make a call RtlCompareMemory. 00063 // 00064 00065 FillPattern(&String1[Offset1], MAX_LENGTH); 00066 for (Offset2 = 0; Offset2 <= MAX_OFFSET; Offset2 += 1) { 00067 for (Length = 0; Length <= MAX_LENGTH; Length += 1) { 00068 for (Expected = 0; Expected <= Length; Expected += 1) { 00069 00070 // 00071 // Copy the test pattern starting at Offset2 in String2, 00072 // change one byte at location `Expected', call 00073 // RtlCompareMemory, and check that the function value 00074 // is in fact the expected value. 00075 // 00076 00077 FillPattern(&String2[Offset2], MAX_LENGTH); 00078 String2[Offset2 + Expected] = ' '; 00079 Result = RtlCompareMemory(&String1[Offset1], 00080 &String2[Offset2], 00081 Length); 00082 TestCases += 1; 00083 if (Result != Expected) { 00084 ErrorCount += 1; 00085 00086 // 00087 // The function failed to return the proper value. 00088 // 00089 00090 printf("ERROR: Offset1 = %d, Offset2 = %d, Length = %d, Expected = %d, Result = %d\n", 00091 Offset1, Offset2, Length, Expected, Result); 00092 printf(" String1[Offset1] = %lx: <%.*s>\n", 00093 &String1[Offset1], Length, &String1[Offset1]); 00094 printf(" String2[Offset2] = %lx: <%.*s>\n", 00095 &String2[Offset2], Length, &String2[Offset2]); 00096 printf("\n"); 00097 } 00098 } 00099 } 00100 } 00101 } 00102 00103 fprintf(stderr, "Test of RtlCompareMemory completed: "); 00104 fprintf(stderr, "%d test cases, %d errors found.\n", TestCases, ErrorCount); 00105 }

Generated on Sat May 15 19:41:57 2004 for test by doxygen 1.3.7