| 10 | | FILE *file = fopen("ucache_test/1.log","w"); |
| 11 | | /**/ |
| 12 | | if(LOG){out = file;} |
| 13 | | else{out = stdout;} |
| 14 | | |
| 15 | | /********** Begin Test **********/ |
| 16 | | ucache_initialize(); |
| 17 | | assert(ucache); |
| 18 | | /* Check Global Data */ |
| 19 | | if(DBG){ |
| 20 | | fprintf(out, "address of ucache ptr:\t0X%X\n", (unsigned int)&ucache); |
| 21 | | fprintf(out, "ucache ptr:\t\t0X%X\n", (unsigned int)ucache); |
| 22 | | fprintf(out, "ftbl ptr:\t\t0X%X\n", (unsigned int)&(ucache->ftbl)); |
| 23 | | fprintf(out, "cache initialized...\n\n"); |
| 24 | | } |
| 25 | | fprintf(stdout, "1:\tpass\n"); |
| 26 | | } |
| 27 | | |
| 28 | | /* Test Insertion, Lookup, Removal, then Lookup again on a single file */ |
| | 15 | FILE *file = fopen("ucache_test/1.log","w"); |
| | 16 | /**/ |
| | 17 | if(LOG){out = file;} |
| | 18 | else{out = stdout;} |
| | 19 | |
| | 20 | /********** Begin Test **********/ |
| | 21 | ucache_initialize(); |
| | 22 | assert(ucache); |
| | 23 | /* Check Global Data */ |
| | 24 | if(DBG){ |
| | 25 | fprintf(out, "address of ucache ptr:\t0X%X\n", (unsigned int)&ucache); |
| | 26 | fprintf(out, "ucache ptr:\t\t0X%X\n", (unsigned int)ucache); |
| | 27 | fprintf(out, "ftbl ptr:\t\t0X%X\n", (unsigned int)&(ucache->ftbl)); |
| | 28 | fprintf(out, "cache initialized...\n\n"); |
| | 29 | } |
| | 30 | fprintf(stdout, "1:\tpass\n"); |
| | 31 | } |
| | 32 | |
| | 33 | /* Test Insertion, Lookup, Removal, then Lookup again on a single file */ |
| 30 | | FILE *file = fopen("ucache_test/2.log","w"); |
| 31 | | /**/ |
| 32 | | if(LOG){out = file;} |
| 33 | | else{out = stdout;} |
| 34 | | |
| 35 | | /********** Begin Test **********/ |
| 36 | | ucache_initialize(); |
| 37 | | assert(ucache); |
| 38 | | /* Check Global Data */ |
| 39 | | if(DBG){ |
| 40 | | fprintf(out, "address of ucache ptr:\t0X%X\n", (unsigned int)&ucache); |
| 41 | | fprintf(out, "ucache ptr:\t\t0X%X\n", (unsigned int)ucache); |
| 42 | | fprintf(out, "ftbl ptr:\t\t0X%X\n", (unsigned int)&(ucache->ftbl)); |
| 43 | | fprintf(out, "cache initialized...\n\n"); |
| 44 | | } |
| 45 | | assert((int)insert_file(tValA, tValB)!=NIL); |
| 46 | | assert((int)lookup_file(tValA, tValB, NULL, NULL, NULL, NULL)!=NIL); |
| 47 | | assert(remove_file(tValA, tValB)==1); |
| 48 | | assert((int)lookup_file(tValA, tValB, NULL, NULL, NULL, NULL)==NIL); |
| 49 | | fprintf(stdout, "2:\tpass\n"); |
| 50 | | } |
| 51 | | |
| 52 | | /* Test Insertion, Lookup, Removal, then Lookup again on multiple files */ |
| | 35 | FILE *file = fopen("ucache_test/2.log","w"); |
| | 36 | /**/ |
| | 37 | if(LOG){out = file;} |
| | 38 | else{out = stdout;} |
| | 39 | |
| | 40 | /********** Begin Test **********/ |
| | 41 | ucache_initialize(); |
| | 42 | assert(ucache); |
| | 43 | /* Check Global Data */ |
| | 44 | if(DBG){ |
| | 45 | fprintf(out, "address of ucache ptr:\t0X%X\n", (unsigned int)&ucache); |
| | 46 | fprintf(out, "ucache ptr:\t\t0X%X\n", (unsigned int)ucache); |
| | 47 | fprintf(out, "ftbl ptr:\t\t0X%X\n", (unsigned int)&(ucache->ftbl)); |
| | 48 | fprintf(out, "cache initialized...\n\n"); |
| | 49 | } |
| | 50 | assert((int)insert_file(tValA, tValB)!=NIL); |
| | 51 | assert((int)lookup_file(tValA, tValB, NULL, NULL, NULL, NULL)!=NIL); |
| | 52 | assert(remove_file(tValA, tValB)==1); |
| | 53 | assert((int)lookup_file(tValA, tValB, NULL, NULL, NULL, NULL)==NIL); |
| | 54 | fprintf(stdout, "2:\tpass\n"); |
| | 55 | } |
| | 56 | |
| | 57 | /* Test Insertion, Lookup, Removal, then Lookup again on multiple files */ |
| 54 | | /* Setup Test */ |
| 55 | | FILE *file = fopen("ucache_test/3.log","w"); |
| 56 | | /**/ |
| 57 | | if(LOG){out = file;} |
| 58 | | else{out = stdout;} |
| 59 | | |
| 60 | | /********** Begin Test **********/ |
| 61 | | ucache_initialize(); |
| 62 | | assert(ucache); |
| 63 | | |
| 64 | | /* Check Global Data */ |
| 65 | | if(DBG){ |
| 66 | | fprintf(out, "address of ucache ptr:\t0X%X\n", (unsigned int)&ucache); |
| 67 | | fprintf(out, "ucache ptr:\t\t0X%X\n", (unsigned int)ucache); |
| 68 | | fprintf(out, "ftbl ptr:\t\t0X%X\n", (unsigned int)&(ucache->ftbl)); |
| 69 | | fprintf(out, "cache initialized...\n\n"); |
| 70 | | } |
| 71 | | assert((int)insert_file(tValA, tValB)!=NIL); |
| 72 | | assert((int)insert_file(tValA, tValB+31)!=NIL); |
| 73 | | assert((int)insert_file(tValA, tValB-31)!=NIL); |
| 74 | | assert((int)lookup_file(tValA, tValB, NULL, NULL, NULL, NULL)!=NIL); |
| 75 | | assert((int)lookup_file(tValA, tValB+31, NULL, NULL, NULL, NULL)!=NIL); |
| 76 | | assert((int)lookup_file(tValA, tValB-31, NULL, NULL, NULL, NULL)!=NIL); |
| 77 | | assert(remove_file(tValA, tValB)==1); |
| 78 | | assert(remove_file(tValA, tValB+31)==1); |
| 79 | | assert(remove_file(tValA, tValB-31)==1); |
| 80 | | assert((int)lookup_file(tValA, tValB, NULL, NULL, NULL, NULL)==NIL); |
| 81 | | assert((int)lookup_file(tValA, tValB+31, NULL, NULL, NULL, NULL)==NIL); |
| 82 | | assert((int)lookup_file(tValA, tValB-31, NULL, NULL, NULL, NULL)==NIL); |
| 83 | | fprintf(stdout, "3:\tpass\n"); |
| 84 | | } |
| 85 | | |
| 86 | | /* Testing file entry lookup after removal */ |
| | 59 | /* Setup Test */ |
| | 60 | FILE *file = fopen("ucache_test/3.log","w"); |
| | 61 | /**/ |
| | 62 | if(LOG){out = file;} |
| | 63 | else{out = stdout;} |
| | 64 | |
| | 65 | /********** Begin Test **********/ |
| | 66 | ucache_initialize(); |
| | 67 | assert(ucache); |
| | 68 | |
| | 69 | /* Check Global Data */ |
| | 70 | if(DBG){ |
| | 71 | fprintf(out, "address of ucache ptr:\t0X%X\n", (unsigned int)&ucache); |
| | 72 | fprintf(out, "ucache ptr:\t\t0X%X\n", (unsigned int)ucache); |
| | 73 | fprintf(out, "ftbl ptr:\t\t0X%X\n", (unsigned int)&(ucache->ftbl)); |
| | 74 | fprintf(out, "cache initialized...\n\n"); |
| | 75 | } |
| | 76 | assert((int)insert_file(tValA, tValB)!=NIL); |
| | 77 | assert((int)insert_file(tValA, tValB+31)!=NIL); |
| | 78 | assert((int)insert_file(tValA, tValB-31)!=NIL); |
| | 79 | assert((int)lookup_file(tValA, tValB, NULL, NULL, NULL, NULL)!=NIL); |
| | 80 | assert((int)lookup_file(tValA, tValB+31, NULL, NULL, NULL, NULL)!=NIL); |
| | 81 | assert((int)lookup_file(tValA, tValB-31, NULL, NULL, NULL, NULL)!=NIL); |
| | 82 | assert(remove_file(tValA, tValB)==1); |
| | 83 | assert(remove_file(tValA, tValB+31)==1); |
| | 84 | assert(remove_file(tValA, tValB-31)==1); |
| | 85 | assert((int)lookup_file(tValA, tValB, NULL, NULL, NULL, NULL)==NIL); |
| | 86 | assert((int)lookup_file(tValA, tValB+31, NULL, NULL, NULL, NULL)==NIL); |
| | 87 | assert((int)lookup_file(tValA, tValB-31, NULL, NULL, NULL, NULL)==NIL); |
| | 88 | fprintf(stdout, "3:\tpass\n"); |
| | 89 | } |
| | 90 | |
| | 91 | /* Testing file entry lookup after removal */ |
| 88 | | /* Setup Test */ |
| 89 | | FILE *file = fopen("ucache_test/4.log","w"); |
| 90 | | /**/ |
| 91 | | if(LOG){out = file;} |
| 92 | | else{out = stdout;} |
| 93 | | |
| 94 | | /********** Begin Test **********/ |
| 95 | | ucache_initialize(); |
| 96 | | assert((int)ucache!=NIL); |
| 97 | | |
| 98 | | /* Check Global Data */ |
| 99 | | if(DBG){ |
| 100 | | fprintf(out, "address of ucache ptr:\t0X%X\n", (unsigned int)&ucache); |
| 101 | | fprintf(out, "ucache ptr:\t\t0X%X\n", (unsigned int)ucache); |
| 102 | | fprintf(out, "ftbl ptr:\t\t0X%X\n", (unsigned int)&(ucache->ftbl)); |
| 103 | | fprintf(out, "cache initialized...\n\n"); |
| 104 | | } |
| 105 | | assert((int)insert_file(tValA, tValB)!=NIL); |
| 106 | | assert((int)insert_file(tValA, tValB+31)!=NIL); |
| 107 | | assert((int)insert_file(tValA, tValB-31)!=NIL); |
| 108 | | assert((int)lookup_file(tValA, tValB, NULL, NULL, NULL, NULL)!=NIL); |
| 109 | | assert((int)lookup_file(tValA, tValB+31, NULL, NULL, NULL, NULL)!=NIL); |
| 110 | | assert((int)lookup_file(tValA, tValB-31, NULL, NULL, NULL, NULL)!=NIL); |
| 111 | | assert(remove_file(tValA, tValB)==1); |
| 112 | | assert(remove_file(tValA, tValB+31)==1); |
| 113 | | assert((int)lookup_file(tValA, tValB+31, NULL, NULL, NULL, NULL)==NIL); |
| 114 | | assert(remove_file(tValA, tValB-31)==1); |
| 115 | | assert((int)lookup_file(tValA, tValB, NULL, NULL, NULL, NULL)==NIL); |
| 116 | | assert((int)lookup_file(tValA, tValB+31, NULL, NULL, NULL, NULL)==NIL); |
| 117 | | assert((int)lookup_file(tValA, tValB-31, NULL, NULL, NULL, NULL)==NIL); |
| 118 | | fprintf(stdout, "4:\tpass\n"); |
| 119 | | } |
| 120 | | |
| 121 | | /* Testing insertion, lookup, removal, and lookup of the max allowed file entries */ |
| | 93 | /* Setup Test */ |
| | 94 | FILE *file = fopen("ucache_test/4.log","w"); |
| | 95 | /**/ |
| | 96 | if(LOG){out = file;} |
| | 97 | else{out = stdout;} |
| | 98 | |
| | 99 | /********** Begin Test **********/ |
| | 100 | ucache_initialize(); |
| | 101 | assert((int)ucache!=NIL); |
| | 102 | |
| | 103 | /* Check Global Data */ |
| | 104 | if(DBG){ |
| | 105 | fprintf(out, "address of ucache ptr:\t0X%X\n", (unsigned int)&ucache); |
| | 106 | fprintf(out, "ucache ptr:\t\t0X%X\n", (unsigned int)ucache); |
| | 107 | fprintf(out, "ftbl ptr:\t\t0X%X\n", (unsigned int)&(ucache->ftbl)); |
| | 108 | fprintf(out, "cache initialized...\n\n"); |
| | 109 | } |
| | 110 | assert((int)insert_file(tValA, tValB)!=NIL); |
| | 111 | assert((int)insert_file(tValA, tValB+31)!=NIL); |
| | 112 | assert((int)insert_file(tValA, tValB-31)!=NIL); |
| | 113 | assert((int)lookup_file(tValA, tValB, NULL, NULL, NULL, NULL)!=NIL); |
| | 114 | assert((int)lookup_file(tValA, tValB+31, NULL, NULL, NULL, NULL)!=NIL); |
| | 115 | assert((int)lookup_file(tValA, tValB-31, NULL, NULL, NULL, NULL)!=NIL); |
| | 116 | assert(remove_file(tValA, tValB)==1); |
| | 117 | assert(remove_file(tValA, tValB+31)==1); |
| | 118 | assert((int)lookup_file(tValA, tValB+31, NULL, NULL, NULL, NULL)==NIL); |
| | 119 | assert(remove_file(tValA, tValB-31)==1); |
| | 120 | assert((int)lookup_file(tValA, tValB, NULL, NULL, NULL, NULL)==NIL); |
| | 121 | assert((int)lookup_file(tValA, tValB+31, NULL, NULL, NULL, NULL)==NIL); |
| | 122 | assert((int)lookup_file(tValA, tValB-31, NULL, NULL, NULL, NULL)==NIL); |
| | 123 | fprintf(stdout, "4:\tpass\n"); |
| | 124 | } |
| | 125 | |
| | 126 | /* Testing insertion, lookup, removal, and lookup of the max allowed file entries */ |
| 123 | | /* Setup Test */ |
| 124 | | FILE *file = fopen("ucache_test/5.log","w"); |
| 125 | | /**/ |
| 126 | | if(LOG){out = file;} |
| 127 | | else{out = stdout;} |
| 128 | | |
| 129 | | /********** Begin Test **********/ |
| 130 | | ucache_initialize(); |
| 131 | | assert(ucache); |
| 132 | | |
| 133 | | /* Check Global Data */ |
| 134 | | if(DBG){ |
| 135 | | fprintf(out, "address of ucache ptr:\t0X%X\n", (unsigned int)&ucache); |
| 136 | | fprintf(out, "ucache ptr:\t\t0X%X\n", (unsigned int)ucache); |
| 137 | | fprintf(out, "ftbl ptr:\t\t0X%X\n", (unsigned int)&(ucache->ftbl)); |
| 138 | | fprintf(out, "cache initialized...\n\n"); |
| 139 | | } |
| 140 | | |
| 141 | | int i; |
| 142 | | for(i=0; i<FILE_TABLE_ENTRY_COUNT; i++){ |
| 143 | | assert((int)insert_file(tValA, (tValB+i))!=NIL); |
| 144 | | } |
| 145 | | for(i=0; i<FILE_TABLE_ENTRY_COUNT; i++){ |
| 146 | | assert((int)lookup_file(tValA, (tValB+i), NULL, NULL, NULL, NULL)!=NIL); |
| 147 | | } |
| 148 | | for(i=0+10; i<FILE_TABLE_ENTRY_COUNT; i++){ |
| 149 | | assert(remove_file(tValA, (tValB+i))==1); |
| 150 | | } |
| 151 | | for(i=0+10; i<FILE_TABLE_ENTRY_COUNT; i++){ |
| 152 | | assert((int)lookup_file(tValA, (tValB+i), NULL, NULL, NULL, NULL)==NIL); |
| 153 | | } |
| 154 | | fprintf(stdout, "5:\tpass\n"); |
| 155 | | } |
| 156 | | |
| 157 | | /* Test Insertion, Lookup, Removal, then Lookup again on a single memory entry */ |
| | 128 | /* Setup Test */ |
| | 129 | FILE *file = fopen("ucache_test/5.log","w"); |
| | 130 | /**/ |
| | 131 | if(LOG){out = file;} |
| | 132 | else{out = stdout;} |
| | 133 | |
| | 134 | /********** Begin Test **********/ |
| | 135 | ucache_initialize(); |
| | 136 | assert(ucache); |
| | 137 | |
| | 138 | /* Check Global Data */ |
| | 139 | if(DBG){ |
| | 140 | fprintf(out, "address of ucache ptr:\t0X%X\n", (unsigned int)&ucache); |
| | 141 | fprintf(out, "ucache ptr:\t\t0X%X\n", (unsigned int)ucache); |
| | 142 | fprintf(out, "ftbl ptr:\t\t0X%X\n", (unsigned int)&(ucache->ftbl)); |
| | 143 | fprintf(out, "cache initialized...\n\n"); |
| | 144 | } |
| | 145 | |
| | 146 | int i; |
| | 147 | for(i=0; i<FILE_TABLE_ENTRY_COUNT; i++){ |
| | 148 | assert((int)insert_file(tValA, (tValB+i))!=NIL); |
| | 149 | } |
| | 150 | for(i=0; i<FILE_TABLE_ENTRY_COUNT; i++){ |
| | 151 | assert((int)lookup_file(tValA, (tValB+i), NULL, NULL, NULL, NULL)!=NIL); |
| | 152 | } |
| | 153 | for(i=0+10; i<FILE_TABLE_ENTRY_COUNT; i++){ |
| | 154 | assert(remove_file(tValA, (tValB+i))==1); |
| | 155 | } |
| | 156 | for(i=0+10; i<FILE_TABLE_ENTRY_COUNT; i++){ |
| | 157 | assert((int)lookup_file(tValA, (tValB+i), NULL, NULL, NULL, NULL)==NIL); |
| | 158 | } |
| | 159 | fprintf(stdout, "5:\tpass\n"); |
| | 160 | } |
| | 161 | |
| | 162 | /* Test Insertion, Lookup, Removal, then Lookup again on a single memory entry */ |
| 159 | | FILE *file = fopen("ucache_test/6.log","w"); |
| 160 | | /**/ |
| 161 | | if(LOG){out = file;} |
| 162 | | else{out = stdout;} |
| 163 | | |
| 164 | | /********** Begin Test **********/ |
| 165 | | ucache_initialize(); |
| 166 | | assert(ucache); |
| 167 | | /* Check Global Data */ |
| 168 | | if(DBG){ |
| 169 | | fprintf(out, "address of ucache ptr:\t0X%X\n", (unsigned int)&ucache); |
| 170 | | fprintf(out, "ucache ptr:\t\t0X%X\n", (unsigned int)ucache); |
| 171 | | fprintf(out, "ftbl ptr:\t\t0X%X\n", (unsigned int)&(ucache->ftbl)); |
| 172 | | fprintf(out, "cache initialized...\n\n"); |
| 173 | | } |
| 174 | | assert((int)insert_file(tValA, tValB)!=NIL); |
| 175 | | assert((int)lookup_file(tValA, tValB, NULL, NULL, NULL, |
| 176 | | NULL)!=NIL); |
| 177 | | assert((int)insert_mem(lookup_file(tValA, tValB, NULL, |
| 178 | | NULL, NULL, NULL), tValB)!=NIL); |
| 179 | | assert((int)lookup_mem(lookup_file(tValA, tValB, NULL, |
| 180 | | NULL, NULL, NULL), tValB, NULL, NULL, NULL)!=NIL); |
| 181 | | assert(remove_mem(lookup_file(tValA, tValB, NULL, NULL, |
| 182 | | NULL, NULL), tValB)==1); |
| 183 | | assert((int)lookup_mem(lookup_file(tValA, tValB, NULL, |
| 184 | | NULL, NULL, NULL), tValB, NULL, NULL, NULL)==NIL); |
| 185 | | assert(remove_file(tValA, tValB)==1); |
| 186 | | assert((int)lookup_file(tValA, tValB, NULL, NULL, NULL, |
| 187 | | NULL)==NIL); |
| 188 | | fprintf(stdout, "6:\tpass\n"); |
| 189 | | } |
| 190 | | |
| 191 | | /* Test max mem insertions, looking them up, removing them, and ensuring they're gone */ |
| | 164 | FILE *file = fopen("ucache_test/6.log","w"); |
| | 165 | /**/ |
| | 166 | if(LOG){out = file;} |
| | 167 | else{out = stdout;} |
| | 168 | |
| | 169 | /********** Begin Test **********/ |
| | 170 | ucache_initialize(); |
| | 171 | assert(ucache); |
| | 172 | /* Check Global Data */ |
| | 173 | if(DBG){ |
| | 174 | fprintf(out, "address of ucache ptr:\t0X%X\n", (unsigned int)&ucache); |
| | 175 | fprintf(out, "ucache ptr:\t\t0X%X\n", (unsigned int)ucache); |
| | 176 | fprintf(out, "ftbl ptr:\t\t0X%X\n", (unsigned int)&(ucache->ftbl)); |
| | 177 | fprintf(out, "cache initialized...\n\n"); |
| | 178 | } |
| | 179 | assert((int)insert_file(tValA, tValB)!=NIL); |
| | 180 | assert((int)lookup_file(tValA, tValB, NULL, NULL, NULL, |
| | 181 | NULL)!=NIL); |
| | 182 | assert((int)insert_mem(lookup_file(tValA, tValB, NULL, |
| | 183 | NULL, NULL, NULL), tValB)!=NIL); |
| | 184 | assert((int)lookup_mem(lookup_file(tValA, tValB, NULL, |
| | 185 | NULL, NULL, NULL), tValB, NULL, NULL, NULL)!=NIL); |
| | 186 | assert(remove_mem(lookup_file(tValA, tValB, NULL, NULL, |
| | 187 | NULL, NULL), tValB)==1); |
| | 188 | assert((int)lookup_mem(lookup_file(tValA, tValB, NULL, |
| | 189 | NULL, NULL, NULL), tValB, NULL, NULL, NULL)==NIL); |
| | 190 | assert(remove_file(tValA, tValB)==1); |
| | 191 | assert((int)lookup_file(tValA, tValB, NULL, NULL, NULL, |
| | 192 | NULL)==NIL); |
| | 193 | fprintf(stdout, "6:\tpass\n"); |
| | 194 | } |
| | 195 | |
| | 196 | /* Test max mem insertions, looking them up, removing them, and ensuring they're gone */ |
| 193 | | FILE *file = fopen("ucache_test/7.log","w"); |
| 194 | | /**/ |
| 195 | | if(LOG){out = file;} |
| 196 | | else{out = stdout;} |
| 197 | | |
| 198 | | /********** Begin Test **********/ |
| 199 | | ucache_initialize(); |
| 200 | | assert(ucache); |
| 201 | | /* Check Global Data */ |
| 202 | | if(DBG){ |
| 203 | | fprintf(out, "address of ucache ptr:\t0X%X\n", (unsigned int)&ucache); |
| 204 | | fprintf(out, "ucache ptr:\t\t0X%X\n", (unsigned int)ucache); |
| 205 | | fprintf(out, "ftbl ptr:\t\t0X%X\n", (unsigned int)&(ucache->ftbl)); |
| 206 | | fprintf(out, "cache initialized...\n\n"); |
| 207 | | } |
| 208 | | |
| 209 | | assert((int)insert_file(tValA, tValB)!=NIL); |
| 210 | | struct mem_table_s *mtbl= lookup_file(tValA, tValB, |
| 211 | | NULL, NULL, NULL, NULL); |
| 212 | | assert((int)mtbl!=NIL); |
| 213 | | |
| 214 | | int i; |
| 215 | | for(i=0; i<MEM_TABLE_ENTRY_COUNT; i++){ |
| 216 | | assert((int)insert_mem(mtbl, (tValB+i))!=NIL); |
| 217 | | } |
| 218 | | for(i=0; i<MEM_TABLE_ENTRY_COUNT; i++){ |
| 219 | | assert((int)lookup_mem(mtbl, (tValB+i), NULL, NULL, NULL)!=NIL); |
| 220 | | } |
| 221 | | for(i=0; i<MEM_TABLE_ENTRY_COUNT; i++){ |
| 222 | | assert(remove_mem(mtbl, (tValB+i))==1); |
| 223 | | } |
| 224 | | for(i=0; i<MEM_TABLE_ENTRY_COUNT; i++){ |
| 225 | | assert((int)lookup_mem(mtbl, (tValB+i), NULL, NULL, NULL)==NIL); |
| 226 | | } |
| 227 | | assert(remove_file(tValA, tValB)==1); |
| 228 | | assert((int)lookup_file(tValA, tValB, NULL, NULL, NULL, |
| 229 | | NULL)==NIL); |
| 230 | | fprintf(stdout, "7:\tpass\n"); |
| 231 | | } |
| 232 | | |
| 233 | | /* Test Eviction of Memory Entries - Requires #of blocks > MEM_TABLE_ENTRY_COUNT */ |
| | 198 | FILE *file = fopen("ucache_test/7.log","w"); |
| | 199 | /**/ |
| | 200 | if(LOG){out = file;} |
| | 201 | else{out = stdout;} |
| | 202 | |
| | 203 | /********** Begin Test **********/ |
| | 204 | ucache_initialize(); |
| | 205 | assert(ucache); |
| | 206 | /* Check Global Data */ |
| | 207 | if(DBG){ |
| | 208 | fprintf(out, "address of ucache ptr:\t0X%X\n", (unsigned int)&ucache); |
| | 209 | fprintf(out, "ucache ptr:\t\t0X%X\n", (unsigned int)ucache); |
| | 210 | fprintf(out, "ftbl ptr:\t\t0X%X\n", (unsigned int)&(ucache->ftbl)); |
| | 211 | fprintf(out, "cache initialized...\n\n"); |
| | 212 | } |
| | 213 | |
| | 214 | assert((int)insert_file(tValA, tValB)!=NIL); |
| | 215 | struct mem_table_s *mtbl= lookup_file(tValA, tValB, |
| | 216 | NULL, NULL, NULL, NULL); |
| | 217 | assert((int)mtbl!=NIL); |
| | 218 | |
| | 219 | int i; |
| | 220 | for(i=0; i<MEM_TABLE_ENTRY_COUNT; i++){ |
| | 221 | assert((int)insert_mem(mtbl, (tValB+i))!=NIL); |
| | 222 | } |
| | 223 | for(i=0; i<MEM_TABLE_ENTRY_COUNT; i++){ |
| | 224 | assert((int)lookup_mem(mtbl, (tValB+i), NULL, NULL, NULL)!=NIL); |
| | 225 | } |
| | 226 | for(i=0; i<MEM_TABLE_ENTRY_COUNT; i++){ |
| | 227 | assert(remove_mem(mtbl, (tValB+i))==1); |
| | 228 | } |
| | 229 | for(i=0; i<MEM_TABLE_ENTRY_COUNT; i++){ |
| | 230 | assert((int)lookup_mem(mtbl, (tValB+i), NULL, NULL, NULL)==NIL); |
| | 231 | } |
| | 232 | assert(remove_file(tValA, tValB)==1); |
| | 233 | assert((int)lookup_file(tValA, tValB, NULL, NULL, NULL, |
| | 234 | NULL)==NIL); |
| | 235 | fprintf(stdout, "7:\tpass\n"); |
| | 236 | } |
| | 237 | |
| | 238 | /* Test Eviction of Memory Entries - Requires #of blocks > MEM_TABLE_ENTRY_COUNT */ |
| 235 | | FILE *file = fopen("ucache_test/8.log","w"); |
| 236 | | /**/ |
| 237 | | if(LOG){out = file;} |
| 238 | | else{out = stdout;} |
| 239 | | |
| 240 | | /********** Begin Test **********/ |
| 241 | | ucache_initialize(); |
| 242 | | assert(ucache); |
| 243 | | /* Check Global Data */ |
| 244 | | if(DBG){ |
| 245 | | fprintf(out, "address of ucache ptr:\t0X%X\n", (unsigned int)&ucache); |
| 246 | | fprintf(out, "ucache ptr:\t\t0X%X\n", (unsigned int)ucache); |
| 247 | | fprintf(out, "ftbl ptr:\t\t0X%X\n", (unsigned int)&(ucache->ftbl)); |
| 248 | | fprintf(out, "cache initialized...\n\n"); |
| 249 | | } |
| 250 | | |
| 251 | | assert((int)insert_file(tValA, tValB)!=NIL); |
| 252 | | struct mem_table_s *mtbl= lookup_file(tValA, tValB, |
| 253 | | NULL, NULL, NULL, NULL); |
| 254 | | assert((int)mtbl!=NIL); |
| 255 | | |
| 256 | | int i; |
| 257 | | for(i=0; i<MEM_TABLE_ENTRY_COUNT+1000; i++){ |
| 258 | | if(DBG)printf("memory insertion # %d\n", i); |
| 259 | | assert((int)insert_mem(mtbl, (tValB+i))!=NIL); |
| 260 | | } |
| 261 | | assert(remove_file(tValA, tValB)==1); |
| 262 | | assert((int)lookup_file(tValA, tValB, NULL, NULL, NULL, |
| 263 | | NULL)==NIL); |
| 264 | | fprintf(stdout, "8:\tpass\n"); |
| 265 | | } |
| 266 | | |
| 267 | | /* Insert file, then overfill with ments, then overfill with fents */ |
| | 240 | FILE *file = fopen("ucache_test/8.log","w"); |
| | 241 | /**/ |
| | 242 | if(LOG){out = file;} |
| | 243 | else{out = stdout;} |
| | 244 | |
| | 245 | /********** Begin Test **********/ |
| | 246 | ucache_initialize(); |
| | 247 | assert(ucache); |
| | 248 | /* Check Global Data */ |
| | 249 | if(DBG){ |
| | 250 | fprintf(out, "address of ucache ptr:\t0X%X\n", (unsigned int)&ucache); |
| | 251 | fprintf(out, "ucache ptr:\t\t0X%X\n", (unsigned int)ucache); |
| | 252 | fprintf(out, "ftbl ptr:\t\t0X%X\n", (unsigned int)&(ucache->ftbl)); |
| | 253 | fprintf(out, "cache initialized...\n\n"); |
| | 254 | } |
| | 255 | |
| | 256 | assert((int)insert_file(tValA, tValB)!=NIL); |
| | 257 | struct mem_table_s *mtbl= lookup_file(tValA, tValB, |
| | 258 | NULL, NULL, NULL, NULL); |
| | 259 | assert((int)mtbl!=NIL); |
| | 260 | |
| | 261 | int i; |
| | 262 | for(i=0; i<MEM_TABLE_ENTRY_COUNT+1000; i++){ |
| | 263 | if(DBG)printf("memory insertion # %d\n", i); |
| | 264 | assert((int)insert_mem(mtbl, (tValB+i))!=NIL); |
| | 265 | } |
| | 266 | assert(remove_file(tValA, tValB)==1); |
| | 267 | assert((int)lookup_file(tValA, tValB, NULL, NULL, NULL, |
| | 268 | NULL)==NIL); |
| | 269 | fprintf(stdout, "8:\tpass\n"); |
| | 270 | } |
| | 271 | |
| | 272 | /* Insert file, then overfill with ments, then overfill with fents */ |
| 269 | | FILE *file = fopen("ucache_test/9.log","w"); |
| 270 | | /**/ |
| 271 | | if(LOG){out = file;} |
| 272 | | else{out = stdout;} |
| 273 | | |
| 274 | | /********** Begin Test **********/ |
| 275 | | ucache_initialize(); |
| 276 | | assert(ucache); |
| 277 | | /* Check Global Data */ |
| 278 | | if(DBG){ |
| 279 | | fprintf(out, "address of ucache ptr:\t0X%X\n", (unsigned int)&ucache); |
| 280 | | fprintf(out, "ucache ptr:\t\t0X%X\n", (unsigned int)ucache); |
| 281 | | fprintf(out, "ftbl ptr:\t\t0X%X\n", (unsigned int)&(ucache->ftbl)); |
| 282 | | fprintf(out, "cache initialized...\n\n"); |
| 283 | | } |
| 284 | | |
| 285 | | assert((int)insert_file(tValA, tValB)!=NIL); |
| 286 | | struct mem_table_s *mtbl= lookup_file(tValA, tValB, |
| 287 | | NULL, NULL, NULL, NULL); |
| 288 | | assert((int)mtbl!=NIL); |
| 289 | | |
| 290 | | int i; |
| 291 | | for(i=0; i<MEM_TABLE_ENTRY_COUNT+100; i++){ |
| 292 | | assert((int)insert_mem(mtbl, (tValB+i))!=NIL); |
| 293 | | } |
| 294 | | for(i=0; i<FILE_TABLE_ENTRY_COUNT+100; i++){ |
| 295 | | assert((int)insert_file(tValA, (tValB+i+1))!=NIL); |
| 296 | | } |
| 297 | | assert(remove_file(tValA, tValB)==1); |
| 298 | | assert((int)lookup_file(tValA, tValB, NULL, NULL, NULL, |
| 299 | | NULL)==NIL); |
| 300 | | fprintf(stdout, "9:\tpass\n"); |
| 301 | | } |
| 302 | | |
| 303 | | /* Test many mem entries, looking them, removing them up and ensuring they're gone */ |
| | 274 | FILE *file = fopen("ucache_test/9.log","w"); |
| | 275 | /**/ |
| | 276 | if(LOG){out = file;} |
| | 277 | else{out = stdout;} |
| | 278 | |
| | 279 | /********** Begin Test **********/ |
| | 280 | ucache_initialize(); |
| | 281 | assert(ucache); |
| | 282 | /* Check Global Data */ |
| | 283 | if(DBG){ |
| | 284 | fprintf(out, "address of ucache ptr:\t0X%X\n", (unsigned int)&ucache); |
| | 285 | fprintf(out, "ucache ptr:\t\t0X%X\n", (unsigned int)ucache); |
| | 286 | fprintf(out, "ftbl ptr:\t\t0X%X\n", (unsigned int)&(ucache->ftbl)); |
| | 287 | fprintf(out, "cache initialized...\n\n"); |
| | 288 | } |
| | 289 | |
| | 290 | assert((int)insert_file(tValA, tValB)!=NIL); |
| | 291 | struct mem_table_s *mtbl= lookup_file(tValA, tValB, |
| | 292 | NULL, NULL, NULL, NULL); |
| | 293 | assert((int)mtbl!=NIL); |
| | 294 | |
| | 295 | int i; |
| | 296 | for(i=0; i<MEM_TABLE_ENTRY_COUNT+100; i++){ |
| | 297 | assert((int)insert_mem(mtbl, (tValB+i))!=NIL); |
| | 298 | } |
| | 299 | for(i=0; i<FILE_TABLE_ENTRY_COUNT+100; i++){ |
| | 300 | assert((int)insert_file(tValA, (tValB+i+1))!=NIL); |
| | 301 | } |
| | 302 | assert(remove_file(tValA, tValB)==1); |
| | 303 | assert((int)lookup_file(tValA, tValB, NULL, NULL, NULL, |
| | 304 | NULL)==NIL); |
| | 305 | fprintf(stdout, "9:\tpass\n"); |
| | 306 | } |
| | 307 | |
| | 308 | /* Test many mem entries, looking them, removing them up and ensuring they're gone */ |
| 305 | | FILE *file = fopen("ucache_test/10.log","w"); |
| 306 | | /**/ |
| 307 | | if(LOG){out = file;} |
| 308 | | else{out = stdout;} |
| 309 | | |
| 310 | | /********** Begin Test **********/ |
| 311 | | ucache_initialize(); |
| 312 | | assert(ucache); |
| 313 | | /* Check Global Data */ |
| 314 | | if(DBG){ |
| 315 | | fprintf(out, "address of ucache ptr:\t0X%X\n", (unsigned int)&ucache); |
| 316 | | fprintf(out, "ucache ptr:\t\t0X%X\n", (unsigned int)ucache); |
| 317 | | fprintf(out, "ftbl ptr:\t\t0X%X\n", (unsigned int)&(ucache->ftbl)); |
| 318 | | fprintf(out, "cache initialized...\n\n"); |
| 319 | | } |
| 320 | | |
| 321 | | /* Insert three files */ |
| 322 | | assert((int)insert_file(tValA, tValB)!=NIL); |
| 323 | | assert((int)insert_file(tValA, tValB+1)!=NIL); |
| 324 | | assert((int)insert_file(tValA, tValB+2)!=NIL); |
| 325 | | |
| 326 | | struct mem_table_s *mtbl1= lookup_file(tValA, tValB, |
| 327 | | NULL, NULL, NULL, NULL); |
| 328 | | assert((int)mtbl1!=NIL); |
| 329 | | struct mem_table_s *mtbl2= lookup_file(tValA, tValB+1, |
| 330 | | NULL, NULL, NULL, NULL); |
| 331 | | assert((int)mtbl2!=NIL); |
| 332 | | struct mem_table_s *mtbl3= lookup_file(tValA, tValB+2, |
| 333 | | NULL, NULL, NULL, NULL); |
| 334 | | assert((int)mtbl3!=NIL); |
| 335 | | |
| 336 | | /* Insert (BLOCKS_IN_CACHE-1) memory entries */ |
| 337 | | int i; |
| 338 | | for(i=0; i<(BLOCKS_IN_CACHE-1); i++){ |
| 339 | | assert((int)insert_mem(mtbl2, (tValB+i))!=NIL); |
| 340 | | } |
| 341 | | assert((int)insert_mem(mtbl1, (tValB+i))!=NIL); |
| 342 | | assert((int)insert_mem(mtbl3, (tValB+i))!=NIL); |
| 343 | | fprintf(stdout, "10:\tpass\n"); |
| 344 | | } |
| 345 | | |
| 346 | | /* Test many file insertions evicting fents when necessary */ |
| | 310 | FILE *file = fopen("ucache_test/10.log","w"); |
| | 311 | /**/ |
| | 312 | if(LOG){out = file;} |
| | 313 | else{out = stdout;} |
| | 314 | |
| | 315 | /********** Begin Test **********/ |
| | 316 | ucache_initialize(); |
| | 317 | assert(ucache); |
| | 318 | /* Check Global Data */ |
| | 319 | if(DBG){ |
| | 320 | fprintf(out, "address of ucache ptr:\t0X%X\n", (unsigned int)&ucache); |
| | 321 | fprintf(out, "ucache ptr:\t\t0X%X\n", (unsigned int)ucache); |
| | 322 | fprintf(out, "ftbl ptr:\t\t0X%X\n", (unsigned int)&(ucache->ftbl)); |
| | 323 | fprintf(out, "cache initialized...\n\n"); |
| | 324 | } |
| | 325 | |
| | 326 | /* Insert three files */ |
| | 327 | assert((int)insert_file(tValA, tValB)!=NIL); |
| | 328 | assert((int)insert_file(tValA, tValB+1)!=NIL); |
| | 329 | assert((int)insert_file(tValA, tValB+2)!=NIL); |
| | 330 | |
| | 331 | struct mem_table_s *mtbl1= lookup_file(tValA, tValB, |
| | 332 | NULL, NULL, NULL, NULL); |
| | 333 | assert((int)mtbl1!=NIL); |
| | 334 | struct mem_table_s *mtbl2= lookup_file(tValA, tValB+1, |
| | 335 | NULL, NULL, NULL, NULL); |
| | 336 | assert((int)mtbl2!=NIL); |
| | 337 | struct mem_table_s *mtbl3= lookup_file(tValA, tValB+2, |
| | 338 | NULL, NULL, NULL, NULL); |
| | 339 | assert((int)mtbl3!=NIL); |
| | 340 | |
| | 341 | /* Insert (BLOCKS_IN_CACHE-1) memory entries */ |
| | 342 | int i; |
| | 343 | for(i=0; i<(BLOCKS_IN_CACHE-1); i++){ |
| | 344 | assert((int)insert_mem(mtbl2, (tValB+i))!=NIL); |
| | 345 | } |
| | 346 | assert((int)insert_mem(mtbl1, (tValB+i))!=NIL); |
| | 347 | assert((int)insert_mem(mtbl3, (tValB+i))!=NIL); |
| | 348 | fprintf(stdout, "10:\tpass\n"); |
| | 349 | } |
| | 350 | |
| | 351 | /* Test many file insertions evicting fents when necessary */ |
| 349 | | FILE *file = fopen("ucache_test/11.log","w"); |
| 350 | | /**/ |
| 351 | | if(LOG){out = file;} |
| 352 | | else{out = stdout;} |
| 353 | | /********** Begin Test **********/ |
| 354 | | ucache_initialize(); |
| 355 | | assert(ucache); |
| 356 | | /* Check Global Data */ |
| 357 | | if(DBG){ |
| 358 | | fprintf(out, "address of ucache ptr:\t0X%X\n", (unsigned int)&ucache); |
| 359 | | fprintf(out, "ucache ptr:\t\t0X%X\n", (unsigned int)ucache); |
| 360 | | fprintf(out, "ftbl ptr:\t\t0X%X\n", (unsigned int)&(ucache->ftbl)); |
| 361 | | fprintf(out, "cache initialized...\n\n"); |
| 362 | | } |
| 363 | | /* Insert three files */ |
| 364 | | int i; |
| 365 | | for(i = 0; i<FILE_TABLE_ENTRY_COUNT+100; i++) |
| 366 | | { |
| 367 | | assert((int)insert_file(tValA, tValB+i)!=NIL); |
| 368 | | } |
| 369 | | fprintf(stdout, "11:\tpass\n"); |
| | 354 | FILE *file = fopen("ucache_test/11.log","w"); |
| | 355 | /**/ |
| | 356 | if(LOG){out = file;} |
| | 357 | else{out = stdout;} |
| | 358 | /********** Begin Test **********/ |
| | 359 | ucache_initialize(); |
| | 360 | assert(ucache); |
| | 361 | /* Check Global Data */ |
| | 362 | if(DBG){ |
| | 363 | fprintf(out, "address of ucache ptr:\t0X%X\n", (unsigned int)&ucache); |
| | 364 | fprintf(out, "ucache ptr:\t\t0X%X\n", (unsigned int)ucache); |
| | 365 | fprintf(out, "ftbl ptr:\t\t0X%X\n", (unsigned int)&(ucache->ftbl)); |
| | 366 | fprintf(out, "cache initialized...\n\n"); |
| | 367 | } |
| | 368 | /* Insert three files */ |
| | 369 | int i; |
| | 370 | for(i = 0; i<FILE_TABLE_ENTRY_COUNT+1; i++) |
| | 371 | { |
| | 372 | assert((int)insert_file(tValA, tValB+i)!=NIL); |
| | 373 | } |
| | 374 | fprintf(stdout, "11:\tpass\n"); |
| 379 | | fprintf(stdout, "Testing...\n"); |
| 380 | | if(argc==2){ |
| 381 | | if(atoi(argv[1])==0) /* Run all tests */ |
| 382 | | { |
| 383 | | test_1(); |
| 384 | | test_2(); |
| 385 | | test_3(); |
| 386 | | test_4(); |
| 387 | | test_5(); |
| 388 | | test_6(); |
| 389 | | if(BLOCKS_IN_CACHE>MEM_TABLE_ENTRY_COUNT) |
| 390 | | { |
| 391 | | test_7(); |
| 392 | | } |
| 393 | | test_8(); |
| 394 | | if(BLOCKS_IN_CACHE>MEM_TABLE_ENTRY_COUNT) |
| 395 | | { |
| 396 | | test_9(); |
| 397 | | } |
| 398 | | test_10(); |
| 399 | | test_11(); |
| 400 | | } |
| 401 | | else if(atoi(argv[1])==1)test_1(); |
| 402 | | else if(atoi(argv[1])==2)test_2(); |
| 403 | | else if(atoi(argv[1])==3)test_3(); |
| 404 | | else if(atoi(argv[1])==4)test_4(); |
| 405 | | else if(atoi(argv[1])==5)test_5(); |
| 406 | | else if(atoi(argv[1])==6)test_6(); |
| 407 | | else if(atoi(argv[1])==7)test_7(); |
| 408 | | else if(atoi(argv[1])==8)test_8(); |
| 409 | | else if(atoi(argv[1])==9)test_9(); |
| 410 | | else if(atoi(argv[1])==10)test_10(); |
| 411 | | else if(atoi(argv[1])==11)test_11(); |
| 412 | | } |
| 413 | | else{printf("ERROR:\tenter an integer >=0\n");} |
| 414 | | return 0; |
| 415 | | } |
| | 384 | fprintf(stdout, "Testing...\n"); |
| | 385 | if(argc==2){ |
| | 386 | if(atoi(argv[1])==0) /* Run all tests */ |
| | 387 | { |
| | 388 | test_1(); |
| | 389 | test_2(); |
| | 390 | test_3(); |
| | 391 | test_4(); |
| | 392 | test_5(); |
| | 393 | test_6(); |
| | 394 | if(BLOCKS_IN_CACHE>MEM_TABLE_ENTRY_COUNT) |
| | 395 | { |
| | 396 | test_7(); |
| | 397 | } |
| | 398 | test_8(); |
| | 399 | if(BLOCKS_IN_CACHE>MEM_TABLE_ENTRY_COUNT) |
| | 400 | { |
| | 401 | test_9(); |
| | 402 | } |
| | 403 | test_10(); |
| | 404 | test_11(); |
| | 405 | } |
| | 406 | else if(atoi(argv[1])==1)test_1(); |
| | 407 | else if(atoi(argv[1])==2)test_2(); |
| | 408 | else if(atoi(argv[1])==3)test_3(); |
| | 409 | else if(atoi(argv[1])==4)test_4(); |
| | 410 | else if(atoi(argv[1])==5)test_5(); |
| | 411 | else if(atoi(argv[1])==6)test_6(); |
| | 412 | else if(atoi(argv[1])==7)test_7(); |
| | 413 | else if(atoi(argv[1])==8)test_8(); |
| | 414 | else if(atoi(argv[1])==9)test_9(); |
| | 415 | else if(atoi(argv[1])==10)test_10(); |
| | 416 | else if(atoi(argv[1])==11)test_11(); |
| | 417 | } |
| | 418 | else{printf("ERROR:\tenter an integer >=0\n");} |
| | 419 | return 0; |
| | 420 | } |
| | 421 | |
| | 422 | /* |
| | 423 | * Local variables: |
| | 424 | * c-indent-level: 4 |
| | 425 | * c-basic-offset: 4 |
| | 426 | * End: |
| | 427 | * |
| | 428 | * vim: ts=8 sts=4 sw=4 expandtab |
| | 429 | */ |
| | 430 | |