diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d5d3e8b32..ac0c6a0c3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,6 +15,8 @@ jobs: run: make - name: check run: make check + - name: tests + run: make tests - name: diverse configurations run: | make distclean ENABLE_COMPUTED_GOTO=0 diff --git a/Makefile b/Makefile index 159be32ba..bafc5379e 100644 --- a/Makefile +++ b/Makefile @@ -109,6 +109,7 @@ $(BIN): $(OBJS) # RISC-V Architecture Tests include mk/riscv-arch-test.mk +include mk/tests.mk CHECK_ELF_FILES := \ hello \ @@ -143,7 +144,7 @@ endif endif clean: - $(RM) $(BIN) $(OBJS) $(deps) + $(RM) $(BIN) $(OBJS) $(deps) $(CACHE_OUT) distclean: clean -$(RM) $(DOOM_DATA) $(QUAKE_DATA) $(RM) -r $(OUT)/id1 diff --git a/mk/tests.mk b/mk/tests.mk new file mode 100644 index 000000000..42991e2d3 --- /dev/null +++ b/mk/tests.mk @@ -0,0 +1,46 @@ +CACHE_TEST_DIR := tests/cache +CACHE_BUILD_DIR := build/cache +TARGET := test_cache + +CACHE_OBJS := \ + test_cache.o + +CACHE_OBJS := $(addprefix $(CACHE_BUILD_DIR)/, $(CACHE_OBJS)) +OBJS += $(CACHE_OBJS) +deps += $(CACHE_OBJS:%.o=%.o.d) + + +CACHE_CHECK_ELF_FILES := \ + cache_new \ + cache_put \ + cache_get \ + cache_lru_replace \ + cache_lfu_replace \ + cache_lfu_ghost_replace \ + +CACHE_OUT = $(addprefix $(CACHE_BUILD_DIR)/, $(CACHE_CHECK_ELF_FILES:%=%.out)) + +tests : $(CACHE_OUT) + $(Q)$(foreach e,$(CACHE_CHECK_ELF_FILES),\ + $(PRINTF) "Running $(e) ... "; \ + if cmp $(CACHE_TEST_DIR)/$(e).expect $(CACHE_BUILD_DIR)/$(e).out; then \ + $(call notice, [OK]); \ + else \ + $(PRINTF) "Failed.\n"; \ + exit 1; \ + fi; \ + ) + +$(CACHE_OUT): $(TARGET) + $(Q)$(foreach e,$(CACHE_CHECK_ELF_FILES),\ + $(CACHE_BUILD_DIR)/$(TARGET) $(CACHE_TEST_DIR)/$(e).in > $(CACHE_BUILD_DIR)/$(e).out; \ + ) + +$(TARGET): $(CACHE_OBJS) + $(VECHO) " CC\t$@\n" + $(Q)$(CC) $^ build/cache.o -o $(CACHE_BUILD_DIR)/$(TARGET) + +$(CACHE_BUILD_DIR)/%.o: $(CACHE_TEST_DIR)/%.c + $(VECHO) " CC\t$@\n" + $(Q)mkdir -p $(dir $@) + $(Q)$(CC) -o $@ $(CFLAGS) -I./src -c -MMD -MF $@.d $< \ No newline at end of file diff --git a/tests/cache/cache_get.expect b/tests/cache/cache_get.expect new file mode 100644 index 000000000..3c48e0620 --- /dev/null +++ b/tests/cache/cache_get.expect @@ -0,0 +1,5 @@ +NEW CACHE +NULL +NULL +3 +FREE CACHE diff --git a/tests/cache/cache_get.in b/tests/cache/cache_get.in new file mode 100644 index 000000000..e4cac51b0 --- /dev/null +++ b/tests/cache/cache_get.in @@ -0,0 +1,6 @@ +NEW +GET 1 +GET 2 +PUT 3 3 +GET 3 +FREE \ No newline at end of file diff --git a/tests/cache/cache_lfu_ghost_replace.expect b/tests/cache/cache_lfu_ghost_replace.expect new file mode 100644 index 000000000..b62769b6f --- /dev/null +++ b/tests/cache/cache_lfu_ghost_replace.expect @@ -0,0 +1,259 @@ +NEW CACHE +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +REPLACE 1 +FREE CACHE diff --git a/tests/cache/cache_lfu_ghost_replace.in b/tests/cache/cache_lfu_ghost_replace.in new file mode 100644 index 000000000..733b4d65c --- /dev/null +++ b/tests/cache/cache_lfu_ghost_replace.in @@ -0,0 +1,771 @@ +NEW +PUT 1 1 +PUT 2 2 +PUT 3 3 +PUT 4 4 +PUT 5 5 +PUT 6 6 +PUT 7 7 +PUT 8 8 +PUT 9 9 +PUT 10 10 +PUT 11 11 +PUT 12 12 +PUT 13 13 +PUT 14 14 +PUT 15 15 +PUT 16 16 +PUT 17 17 +PUT 18 18 +PUT 19 19 +PUT 20 20 +PUT 21 21 +PUT 22 22 +PUT 23 23 +PUT 24 24 +PUT 25 25 +PUT 26 26 +PUT 27 27 +PUT 28 28 +PUT 29 29 +PUT 30 30 +PUT 31 31 +PUT 32 32 +PUT 33 33 +PUT 34 34 +PUT 35 35 +PUT 36 36 +PUT 37 37 +PUT 38 38 +PUT 39 39 +PUT 40 40 +PUT 41 41 +PUT 42 42 +PUT 43 43 +PUT 44 44 +PUT 45 45 +PUT 46 46 +PUT 47 47 +PUT 48 48 +PUT 49 49 +PUT 50 50 +PUT 51 51 +PUT 52 52 +PUT 53 53 +PUT 54 54 +PUT 55 55 +PUT 56 56 +PUT 57 57 +PUT 58 58 +PUT 59 59 +PUT 60 60 +PUT 61 61 +PUT 62 62 +PUT 63 63 +PUT 64 64 +PUT 65 65 +PUT 66 66 +PUT 67 67 +PUT 68 68 +PUT 69 69 +PUT 70 70 +PUT 71 71 +PUT 72 72 +PUT 73 73 +PUT 74 74 +PUT 75 75 +PUT 76 76 +PUT 77 77 +PUT 78 78 +PUT 79 79 +PUT 80 80 +PUT 81 81 +PUT 82 82 +PUT 83 83 +PUT 84 84 +PUT 85 85 +PUT 86 86 +PUT 87 87 +PUT 88 88 +PUT 89 89 +PUT 90 90 +PUT 91 91 +PUT 92 92 +PUT 93 93 +PUT 94 94 +PUT 95 95 +PUT 96 96 +PUT 97 97 +PUT 98 98 +PUT 99 99 +PUT 100 100 +PUT 101 101 +PUT 102 102 +PUT 103 103 +PUT 104 104 +PUT 105 105 +PUT 106 106 +PUT 107 107 +PUT 108 108 +PUT 109 109 +PUT 110 110 +PUT 111 111 +PUT 112 112 +PUT 113 113 +PUT 114 114 +PUT 115 115 +PUT 116 116 +PUT 117 117 +PUT 118 118 +PUT 119 119 +PUT 120 120 +PUT 121 121 +PUT 122 122 +PUT 123 123 +PUT 124 124 +PUT 125 125 +PUT 126 126 +PUT 127 127 +PUT 128 128 +PUT 129 129 +PUT 130 130 +PUT 131 131 +PUT 132 132 +PUT 133 133 +PUT 134 134 +PUT 135 135 +PUT 136 136 +PUT 137 137 +PUT 138 138 +PUT 139 139 +PUT 140 140 +PUT 141 141 +PUT 142 142 +PUT 143 143 +PUT 144 144 +PUT 145 145 +PUT 146 146 +PUT 147 147 +PUT 148 148 +PUT 149 149 +PUT 150 150 +PUT 151 151 +PUT 152 152 +PUT 153 153 +PUT 154 154 +PUT 155 155 +PUT 156 156 +PUT 157 157 +PUT 158 158 +PUT 159 159 +PUT 160 160 +PUT 161 161 +PUT 162 162 +PUT 163 163 +PUT 164 164 +PUT 165 165 +PUT 166 166 +PUT 167 167 +PUT 168 168 +PUT 169 169 +PUT 170 170 +PUT 171 171 +PUT 172 172 +PUT 173 173 +PUT 174 174 +PUT 175 175 +PUT 176 176 +PUT 177 177 +PUT 178 178 +PUT 179 179 +PUT 180 180 +PUT 181 181 +PUT 182 182 +PUT 183 183 +PUT 184 184 +PUT 185 185 +PUT 186 186 +PUT 187 187 +PUT 188 188 +PUT 189 189 +PUT 190 190 +PUT 191 191 +PUT 192 192 +PUT 193 193 +PUT 194 194 +PUT 195 195 +PUT 196 196 +PUT 197 197 +PUT 198 198 +PUT 199 199 +PUT 200 200 +PUT 201 201 +PUT 202 202 +PUT 203 203 +PUT 204 204 +PUT 205 205 +PUT 206 206 +PUT 207 207 +PUT 208 208 +PUT 209 209 +PUT 210 210 +PUT 211 211 +PUT 212 212 +PUT 213 213 +PUT 214 214 +PUT 215 215 +PUT 216 216 +PUT 217 217 +PUT 218 218 +PUT 219 219 +PUT 220 220 +PUT 221 221 +PUT 222 222 +PUT 223 223 +PUT 224 224 +PUT 225 225 +PUT 226 226 +PUT 227 227 +PUT 228 228 +PUT 229 229 +PUT 230 230 +PUT 231 231 +PUT 232 232 +PUT 233 233 +PUT 234 234 +PUT 235 235 +PUT 236 236 +PUT 237 237 +PUT 238 238 +PUT 239 239 +PUT 240 240 +PUT 241 241 +PUT 242 242 +PUT 243 243 +PUT 244 244 +PUT 245 245 +PUT 246 246 +PUT 247 247 +PUT 248 248 +PUT 249 249 +PUT 250 250 +PUT 251 251 +PUT 252 252 +PUT 253 253 +PUT 254 254 +PUT 255 255 +PUT 256 256 +GET 1 +GET 2 +GET 3 +GET 4 +GET 5 +GET 6 +GET 7 +GET 8 +GET 9 +GET 10 +GET 11 +GET 12 +GET 13 +GET 14 +GET 15 +GET 16 +GET 17 +GET 18 +GET 19 +GET 20 +GET 21 +GET 22 +GET 23 +GET 24 +GET 25 +GET 26 +GET 27 +GET 28 +GET 29 +GET 30 +GET 31 +GET 32 +GET 33 +GET 34 +GET 35 +GET 36 +GET 37 +GET 38 +GET 39 +GET 40 +GET 41 +GET 42 +GET 43 +GET 44 +GET 45 +GET 46 +GET 47 +GET 48 +GET 49 +GET 50 +GET 51 +GET 52 +GET 53 +GET 54 +GET 55 +GET 56 +GET 57 +GET 58 +GET 59 +GET 60 +GET 61 +GET 62 +GET 63 +GET 64 +GET 65 +GET 66 +GET 67 +GET 68 +GET 69 +GET 70 +GET 71 +GET 72 +GET 73 +GET 74 +GET 75 +GET 76 +GET 77 +GET 78 +GET 79 +GET 80 +GET 81 +GET 82 +GET 83 +GET 84 +GET 85 +GET 86 +GET 87 +GET 88 +GET 89 +GET 90 +GET 91 +GET 92 +GET 93 +GET 94 +GET 95 +GET 96 +GET 97 +GET 98 +GET 99 +GET 100 +GET 101 +GET 102 +GET 103 +GET 104 +GET 105 +GET 106 +GET 107 +GET 108 +GET 109 +GET 110 +GET 111 +GET 112 +GET 113 +GET 114 +GET 115 +GET 116 +GET 117 +GET 118 +GET 119 +GET 120 +GET 121 +GET 122 +GET 123 +GET 124 +GET 125 +GET 126 +GET 127 +GET 128 +GET 129 +GET 130 +GET 131 +GET 132 +GET 133 +GET 134 +GET 135 +GET 136 +GET 137 +GET 138 +GET 139 +GET 140 +GET 141 +GET 142 +GET 143 +GET 144 +GET 145 +GET 146 +GET 147 +GET 148 +GET 149 +GET 150 +GET 151 +GET 152 +GET 153 +GET 154 +GET 155 +GET 156 +GET 157 +GET 158 +GET 159 +GET 160 +GET 161 +GET 162 +GET 163 +GET 164 +GET 165 +GET 166 +GET 167 +GET 168 +GET 169 +GET 170 +GET 171 +GET 172 +GET 173 +GET 174 +GET 175 +GET 176 +GET 177 +GET 178 +GET 179 +GET 180 +GET 181 +GET 182 +GET 183 +GET 184 +GET 185 +GET 186 +GET 187 +GET 188 +GET 189 +GET 190 +GET 191 +GET 192 +GET 193 +GET 194 +GET 195 +GET 196 +GET 197 +GET 198 +GET 199 +GET 200 +GET 201 +GET 202 +GET 203 +GET 204 +GET 205 +GET 206 +GET 207 +GET 208 +GET 209 +GET 210 +GET 211 +GET 212 +GET 213 +GET 214 +GET 215 +GET 216 +GET 217 +GET 218 +GET 219 +GET 220 +GET 221 +GET 222 +GET 223 +GET 224 +GET 225 +GET 226 +GET 227 +GET 228 +GET 229 +GET 230 +GET 231 +GET 232 +GET 233 +GET 234 +GET 235 +GET 236 +GET 237 +GET 238 +GET 239 +GET 240 +GET 241 +GET 242 +GET 243 +GET 244 +GET 245 +GET 246 +GET 247 +GET 248 +GET 249 +GET 250 +GET 251 +GET 252 +GET 253 +GET 254 +GET 255 +GET 256 +PUT 257 257 +PUT 258 258 +PUT 259 259 +PUT 260 260 +PUT 261 261 +PUT 262 262 +PUT 263 263 +PUT 264 264 +PUT 265 265 +PUT 266 266 +PUT 267 267 +PUT 268 268 +PUT 269 269 +PUT 270 270 +PUT 271 271 +PUT 272 272 +PUT 273 273 +PUT 274 274 +PUT 275 275 +PUT 276 276 +PUT 277 277 +PUT 278 278 +PUT 279 279 +PUT 280 280 +PUT 281 281 +PUT 282 282 +PUT 283 283 +PUT 284 284 +PUT 285 285 +PUT 286 286 +PUT 287 287 +PUT 288 288 +PUT 289 289 +PUT 290 290 +PUT 291 291 +PUT 292 292 +PUT 293 293 +PUT 294 294 +PUT 295 295 +PUT 296 296 +PUT 297 297 +PUT 298 298 +PUT 299 299 +PUT 300 300 +PUT 301 301 +PUT 302 302 +PUT 303 303 +PUT 304 304 +PUT 305 305 +PUT 306 306 +PUT 307 307 +PUT 308 308 +PUT 309 309 +PUT 310 310 +PUT 311 311 +PUT 312 312 +PUT 313 313 +PUT 314 314 +PUT 315 315 +PUT 316 316 +PUT 317 317 +PUT 318 318 +PUT 319 319 +PUT 320 320 +PUT 321 321 +PUT 322 322 +PUT 323 323 +PUT 324 324 +PUT 325 325 +PUT 326 326 +PUT 327 327 +PUT 328 328 +PUT 329 329 +PUT 330 330 +PUT 331 331 +PUT 332 332 +PUT 333 333 +PUT 334 334 +PUT 335 335 +PUT 336 336 +PUT 337 337 +PUT 338 338 +PUT 339 339 +PUT 340 340 +PUT 341 341 +PUT 342 342 +PUT 343 343 +PUT 344 344 +PUT 345 345 +PUT 346 346 +PUT 347 347 +PUT 348 348 +PUT 349 349 +PUT 350 350 +PUT 351 351 +PUT 352 352 +PUT 353 353 +PUT 354 354 +PUT 355 355 +PUT 356 356 +PUT 357 357 +PUT 358 358 +PUT 359 359 +PUT 360 360 +PUT 361 361 +PUT 362 362 +PUT 363 363 +PUT 364 364 +PUT 365 365 +PUT 366 366 +PUT 367 367 +PUT 368 368 +PUT 369 369 +PUT 370 370 +PUT 371 371 +PUT 372 372 +PUT 373 373 +PUT 374 374 +PUT 375 375 +PUT 376 376 +PUT 377 377 +PUT 378 378 +PUT 379 379 +PUT 380 380 +PUT 381 381 +PUT 382 382 +PUT 383 383 +PUT 384 384 +PUT 385 358 +PUT 386 386 +PUT 387 387 +PUT 388 388 +PUT 389 389 +PUT 390 390 +PUT 391 391 +PUT 392 392 +PUT 393 393 +PUT 394 394 +PUT 395 395 +PUT 396 396 +PUT 397 397 +PUT 398 398 +PUT 399 399 +PUT 400 400 +PUT 401 401 +PUT 402 402 +PUT 403 403 +PUT 404 404 +PUT 405 405 +PUT 406 406 +PUT 407 407 +PUT 408 408 +PUT 409 409 +PUT 410 410 +PUT 411 411 +PUT 412 412 +PUT 413 413 +PUT 414 414 +PUT 415 415 +PUT 416 416 +PUT 417 417 +PUT 418 418 +PUT 419 419 +PUT 420 420 +PUT 421 421 +PUT 422 422 +PUT 423 423 +PUT 424 424 +PUT 425 425 +PUT 426 426 +PUT 427 427 +PUT 428 428 +PUT 429 429 +PUT 430 430 +PUT 431 431 +PUT 432 432 +PUT 433 433 +PUT 434 434 +PUT 435 435 +PUT 436 436 +PUT 437 437 +PUT 438 438 +PUT 439 439 +PUT 440 440 +PUT 441 441 +PUT 442 442 +PUT 443 443 +PUT 444 444 +PUT 445 445 +PUT 446 446 +PUT 447 447 +PUT 448 448 +PUT 449 449 +PUT 450 450 +PUT 451 451 +PUT 452 452 +PUT 453 453 +PUT 454 454 +PUT 455 455 +PUT 456 456 +PUT 457 457 +PUT 458 458 +PUT 459 459 +PUT 460 460 +PUT 461 461 +PUT 462 462 +PUT 463 463 +PUT 464 464 +PUT 465 465 +PUT 466 466 +PUT 467 467 +PUT 468 468 +PUT 469 469 +PUT 470 470 +PUT 471 471 +PUT 472 472 +PUT 473 473 +PUT 474 474 +PUT 475 475 +PUT 476 476 +PUT 477 477 +PUT 478 478 +PUT 479 479 +PUT 480 480 +PUT 481 481 +PUT 482 482 +PUT 483 483 +PUT 484 484 +PUT 485 485 +PUT 486 486 +PUT 487 487 +PUT 488 488 +PUT 489 489 +PUT 490 490 +PUT 491 491 +PUT 492 492 +PUT 493 493 +PUT 494 494 +PUT 495 495 +PUT 496 496 +PUT 497 497 +PUT 498 498 +PUT 499 499 +PUT 500 500 +PUT 501 501 +PUT 502 502 +PUT 503 503 +PUT 504 504 +PUT 505 505 +PUT 506 506 +PUT 507 507 +PUT 508 508 +PUT 509 509 +PUT 510 510 +PUT 511 511 +PUT 512 512 +PUT 513 513 +FREE \ No newline at end of file diff --git a/tests/cache/cache_lfu_replace.expect b/tests/cache/cache_lfu_replace.expect new file mode 100644 index 000000000..00f32a3fa --- /dev/null +++ b/tests/cache/cache_lfu_replace.expect @@ -0,0 +1,515 @@ +NEW CACHE +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +REPLACE 1 +FREE CACHE diff --git a/tests/cache/cache_lfu_replace.in b/tests/cache/cache_lfu_replace.in new file mode 100644 index 000000000..2fc4c3a82 --- /dev/null +++ b/tests/cache/cache_lfu_replace.in @@ -0,0 +1,1027 @@ +NEW +PUT 1 1 +PUT 2 2 +PUT 3 3 +PUT 4 4 +PUT 5 5 +PUT 6 6 +PUT 7 7 +PUT 8 8 +PUT 9 9 +PUT 10 10 +PUT 11 11 +PUT 12 12 +PUT 13 13 +PUT 14 14 +PUT 15 15 +PUT 16 16 +PUT 17 17 +PUT 18 18 +PUT 19 19 +PUT 20 20 +PUT 21 21 +PUT 22 22 +PUT 23 23 +PUT 24 24 +PUT 25 25 +PUT 26 26 +PUT 27 27 +PUT 28 28 +PUT 29 29 +PUT 30 30 +PUT 31 31 +PUT 32 32 +PUT 33 33 +PUT 34 34 +PUT 35 35 +PUT 36 36 +PUT 37 37 +PUT 38 38 +PUT 39 39 +PUT 40 40 +PUT 41 41 +PUT 42 42 +PUT 43 43 +PUT 44 44 +PUT 45 45 +PUT 46 46 +PUT 47 47 +PUT 48 48 +PUT 49 49 +PUT 50 50 +PUT 51 51 +PUT 52 52 +PUT 53 53 +PUT 54 54 +PUT 55 55 +PUT 56 56 +PUT 57 57 +PUT 58 58 +PUT 59 59 +PUT 60 60 +PUT 61 61 +PUT 62 62 +PUT 63 63 +PUT 64 64 +PUT 65 65 +PUT 66 66 +PUT 67 67 +PUT 68 68 +PUT 69 69 +PUT 70 70 +PUT 71 71 +PUT 72 72 +PUT 73 73 +PUT 74 74 +PUT 75 75 +PUT 76 76 +PUT 77 77 +PUT 78 78 +PUT 79 79 +PUT 80 80 +PUT 81 81 +PUT 82 82 +PUT 83 83 +PUT 84 84 +PUT 85 85 +PUT 86 86 +PUT 87 87 +PUT 88 88 +PUT 89 89 +PUT 90 90 +PUT 91 91 +PUT 92 92 +PUT 93 93 +PUT 94 94 +PUT 95 95 +PUT 96 96 +PUT 97 97 +PUT 98 98 +PUT 99 99 +PUT 100 100 +PUT 101 101 +PUT 102 102 +PUT 103 103 +PUT 104 104 +PUT 105 105 +PUT 106 106 +PUT 107 107 +PUT 108 108 +PUT 109 109 +PUT 110 110 +PUT 111 111 +PUT 112 112 +PUT 113 113 +PUT 114 114 +PUT 115 115 +PUT 116 116 +PUT 117 117 +PUT 118 118 +PUT 119 119 +PUT 120 120 +PUT 121 121 +PUT 122 122 +PUT 123 123 +PUT 124 124 +PUT 125 125 +PUT 126 126 +PUT 127 127 +PUT 128 128 +GET 1 +GET 2 +GET 3 +GET 4 +GET 5 +GET 6 +GET 7 +GET 8 +GET 9 +GET 10 +GET 11 +GET 12 +GET 13 +GET 14 +GET 15 +GET 16 +GET 17 +GET 18 +GET 19 +GET 20 +GET 21 +GET 22 +GET 23 +GET 24 +GET 25 +GET 26 +GET 27 +GET 28 +GET 29 +GET 30 +GET 31 +GET 32 +GET 33 +GET 34 +GET 35 +GET 36 +GET 37 +GET 38 +GET 39 +GET 40 +GET 41 +GET 42 +GET 43 +GET 44 +GET 45 +GET 46 +GET 47 +GET 48 +GET 49 +GET 50 +GET 51 +GET 52 +GET 53 +GET 54 +GET 55 +GET 56 +GET 57 +GET 58 +GET 59 +GET 60 +GET 61 +GET 62 +GET 63 +GET 64 +GET 65 +GET 66 +GET 67 +GET 68 +GET 69 +GET 70 +GET 71 +GET 72 +GET 73 +GET 74 +GET 75 +GET 76 +GET 77 +GET 78 +GET 79 +GET 80 +GET 81 +GET 82 +GET 83 +GET 84 +GET 85 +GET 86 +GET 87 +GET 88 +GET 89 +GET 90 +GET 91 +GET 92 +GET 93 +GET 94 +GET 95 +GET 96 +GET 97 +GET 98 +GET 99 +GET 100 +GET 101 +GET 102 +GET 103 +GET 104 +GET 105 +GET 106 +GET 107 +GET 108 +GET 109 +GET 110 +GET 111 +GET 112 +GET 113 +GET 114 +GET 115 +GET 116 +GET 117 +GET 118 +GET 119 +GET 120 +GET 121 +GET 122 +GET 123 +GET 124 +GET 125 +GET 126 +GET 127 +GET 128 +PUT 129 129 +PUT 130 130 +PUT 131 131 +PUT 132 132 +PUT 133 133 +PUT 134 134 +PUT 135 135 +PUT 136 136 +PUT 137 137 +PUT 138 138 +PUT 139 139 +PUT 140 140 +PUT 141 141 +PUT 142 142 +PUT 143 143 +PUT 144 144 +PUT 145 145 +PUT 146 146 +PUT 147 147 +PUT 148 148 +PUT 149 149 +PUT 150 150 +PUT 151 151 +PUT 152 152 +PUT 153 153 +PUT 154 154 +PUT 155 155 +PUT 156 156 +PUT 157 157 +PUT 158 158 +PUT 159 159 +PUT 160 160 +PUT 161 161 +PUT 162 162 +PUT 163 163 +PUT 164 164 +PUT 165 165 +PUT 166 166 +PUT 167 167 +PUT 168 168 +PUT 169 169 +PUT 170 170 +PUT 171 171 +PUT 172 172 +PUT 173 173 +PUT 174 174 +PUT 175 175 +PUT 176 176 +PUT 177 177 +PUT 178 178 +PUT 179 179 +PUT 180 180 +PUT 181 181 +PUT 182 182 +PUT 183 183 +PUT 184 184 +PUT 185 185 +PUT 186 186 +PUT 187 187 +PUT 188 188 +PUT 189 189 +PUT 190 190 +PUT 191 191 +PUT 192 192 +PUT 193 193 +PUT 194 194 +PUT 195 195 +PUT 196 196 +PUT 197 197 +PUT 198 198 +PUT 199 199 +PUT 200 200 +PUT 201 201 +PUT 202 202 +PUT 203 203 +PUT 204 204 +PUT 205 205 +PUT 206 206 +PUT 207 207 +PUT 208 208 +PUT 209 209 +PUT 210 210 +PUT 211 211 +PUT 212 212 +PUT 213 213 +PUT 214 214 +PUT 215 215 +PUT 216 216 +PUT 217 217 +PUT 218 218 +PUT 219 219 +PUT 220 220 +PUT 221 221 +PUT 222 222 +PUT 223 223 +PUT 224 224 +PUT 225 225 +PUT 226 226 +PUT 227 227 +PUT 228 228 +PUT 229 229 +PUT 230 230 +PUT 231 231 +PUT 232 232 +PUT 233 233 +PUT 234 234 +PUT 235 235 +PUT 236 236 +PUT 237 237 +PUT 238 238 +PUT 239 239 +PUT 240 240 +PUT 241 241 +PUT 242 242 +PUT 243 243 +PUT 244 244 +PUT 245 245 +PUT 246 246 +PUT 247 247 +PUT 248 248 +PUT 249 249 +PUT 250 250 +PUT 251 251 +PUT 252 252 +PUT 253 253 +PUT 254 254 +PUT 255 255 +PUT 256 256 +GET 129 +GET 130 +GET 131 +GET 132 +GET 133 +GET 134 +GET 135 +GET 136 +GET 137 +GET 138 +GET 139 +GET 140 +GET 141 +GET 142 +GET 143 +GET 144 +GET 145 +GET 146 +GET 147 +GET 148 +GET 149 +GET 150 +GET 151 +GET 152 +GET 153 +GET 154 +GET 155 +GET 156 +GET 157 +GET 158 +GET 159 +GET 160 +GET 161 +GET 162 +GET 163 +GET 164 +GET 165 +GET 166 +GET 167 +GET 168 +GET 169 +GET 170 +GET 171 +GET 172 +GET 173 +GET 174 +GET 175 +GET 176 +GET 177 +GET 178 +GET 179 +GET 180 +GET 181 +GET 182 +GET 183 +GET 184 +GET 185 +GET 186 +GET 187 +GET 188 +GET 189 +GET 190 +GET 191 +GET 192 +GET 193 +GET 194 +GET 195 +GET 196 +GET 197 +GET 198 +GET 199 +GET 200 +GET 201 +GET 202 +GET 203 +GET 204 +GET 205 +GET 206 +GET 207 +GET 208 +GET 209 +GET 210 +GET 211 +GET 212 +GET 213 +GET 214 +GET 215 +GET 216 +GET 217 +GET 218 +GET 219 +GET 220 +GET 221 +GET 222 +GET 223 +GET 224 +GET 225 +GET 226 +GET 227 +GET 228 +GET 229 +GET 230 +GET 231 +GET 232 +GET 233 +GET 234 +GET 235 +GET 236 +GET 237 +GET 238 +GET 239 +GET 240 +GET 241 +GET 242 +GET 243 +GET 244 +GET 245 +GET 246 +GET 247 +GET 248 +GET 249 +GET 250 +GET 251 +GET 252 +GET 253 +GET 254 +GET 255 +GET 256 +PUT 257 257 +PUT 258 258 +PUT 259 259 +PUT 260 260 +PUT 261 261 +PUT 262 262 +PUT 263 263 +PUT 264 264 +PUT 265 265 +PUT 266 266 +PUT 267 267 +PUT 268 268 +PUT 269 269 +PUT 270 270 +PUT 271 271 +PUT 272 272 +PUT 273 273 +PUT 274 274 +PUT 275 275 +PUT 276 276 +PUT 277 277 +PUT 278 278 +PUT 279 279 +PUT 280 280 +PUT 281 281 +PUT 282 282 +PUT 283 283 +PUT 284 284 +PUT 285 285 +PUT 286 286 +PUT 287 287 +PUT 288 288 +PUT 289 289 +PUT 290 290 +PUT 291 291 +PUT 292 292 +PUT 293 293 +PUT 294 294 +PUT 295 295 +PUT 296 296 +PUT 297 297 +PUT 298 298 +PUT 299 299 +PUT 300 300 +PUT 301 301 +PUT 302 302 +PUT 303 303 +PUT 304 304 +PUT 305 305 +PUT 306 306 +PUT 307 307 +PUT 308 308 +PUT 309 309 +PUT 310 310 +PUT 311 311 +PUT 312 312 +PUT 313 313 +PUT 314 314 +PUT 315 315 +PUT 316 316 +PUT 317 317 +PUT 318 318 +PUT 319 319 +PUT 320 320 +PUT 321 321 +PUT 322 322 +PUT 323 323 +PUT 324 324 +PUT 325 325 +PUT 326 326 +PUT 327 327 +PUT 328 328 +PUT 329 329 +PUT 330 330 +PUT 331 331 +PUT 332 332 +PUT 333 333 +PUT 334 334 +PUT 335 335 +PUT 336 336 +PUT 337 337 +PUT 338 338 +PUT 339 339 +PUT 340 340 +PUT 341 341 +PUT 342 342 +PUT 343 343 +PUT 344 344 +PUT 345 345 +PUT 346 346 +PUT 347 347 +PUT 348 348 +PUT 349 349 +PUT 350 350 +PUT 351 351 +PUT 352 352 +PUT 353 353 +PUT 354 354 +PUT 355 355 +PUT 356 356 +PUT 357 357 +PUT 358 358 +PUT 359 359 +PUT 360 360 +PUT 361 361 +PUT 362 362 +PUT 363 363 +PUT 364 364 +PUT 365 365 +PUT 366 366 +PUT 367 367 +PUT 368 368 +PUT 369 369 +PUT 370 370 +PUT 371 371 +PUT 372 372 +PUT 373 373 +PUT 374 374 +PUT 375 375 +PUT 376 376 +PUT 377 377 +PUT 378 378 +PUT 379 379 +PUT 380 380 +PUT 381 381 +PUT 382 382 +PUT 383 383 +PUT 384 384 +GET 257 +GET 258 +GET 259 +GET 260 +GET 261 +GET 262 +GET 263 +GET 264 +GET 265 +GET 266 +GET 267 +GET 268 +GET 269 +GET 270 +GET 271 +GET 272 +GET 273 +GET 274 +GET 275 +GET 276 +GET 277 +GET 278 +GET 279 +GET 280 +GET 281 +GET 282 +GET 283 +GET 284 +GET 285 +GET 286 +GET 287 +GET 288 +GET 289 +GET 290 +GET 291 +GET 292 +GET 293 +GET 294 +GET 295 +GET 296 +GET 297 +GET 298 +GET 299 +GET 300 +GET 301 +GET 302 +GET 303 +GET 304 +GET 305 +GET 306 +GET 307 +GET 308 +GET 309 +GET 310 +GET 311 +GET 312 +GET 313 +GET 314 +GET 315 +GET 316 +GET 317 +GET 318 +GET 319 +GET 320 +GET 321 +GET 322 +GET 323 +GET 324 +GET 325 +GET 326 +GET 327 +GET 328 +GET 329 +GET 330 +GET 331 +GET 332 +GET 333 +GET 334 +GET 335 +GET 336 +GET 337 +GET 338 +GET 339 +GET 340 +GET 341 +GET 342 +GET 343 +GET 344 +GET 345 +GET 346 +GET 347 +GET 348 +GET 349 +GET 350 +GET 351 +GET 352 +GET 353 +GET 354 +GET 355 +GET 356 +GET 357 +GET 358 +GET 359 +GET 360 +GET 361 +GET 362 +GET 363 +GET 364 +GET 365 +GET 366 +GET 367 +GET 368 +GET 369 +GET 370 +GET 371 +GET 372 +GET 373 +GET 374 +GET 375 +GET 376 +GET 377 +GET 378 +GET 379 +GET 380 +GET 381 +GET 382 +GET 383 +GET 384 +PUT 385 385 +PUT 386 386 +PUT 387 387 +PUT 388 388 +PUT 389 389 +PUT 390 390 +PUT 391 391 +PUT 392 392 +PUT 393 393 +PUT 394 394 +PUT 395 395 +PUT 396 396 +PUT 397 397 +PUT 398 398 +PUT 399 399 +PUT 400 400 +PUT 401 401 +PUT 402 402 +PUT 403 403 +PUT 404 404 +PUT 405 405 +PUT 406 406 +PUT 407 407 +PUT 408 408 +PUT 409 409 +PUT 410 410 +PUT 411 411 +PUT 412 412 +PUT 413 413 +PUT 414 414 +PUT 415 415 +PUT 416 416 +PUT 417 417 +PUT 418 418 +PUT 419 419 +PUT 420 420 +PUT 421 421 +PUT 422 422 +PUT 423 423 +PUT 424 424 +PUT 425 425 +PUT 426 426 +PUT 427 427 +PUT 428 428 +PUT 429 429 +PUT 430 430 +PUT 431 431 +PUT 432 432 +PUT 433 433 +PUT 434 434 +PUT 435 435 +PUT 436 436 +PUT 437 437 +PUT 438 438 +PUT 439 439 +PUT 440 440 +PUT 441 441 +PUT 442 442 +PUT 443 443 +PUT 444 444 +PUT 445 445 +PUT 446 446 +PUT 447 447 +PUT 448 448 +PUT 449 449 +PUT 450 450 +PUT 451 451 +PUT 452 452 +PUT 453 453 +PUT 454 454 +PUT 455 455 +PUT 456 456 +PUT 457 457 +PUT 458 458 +PUT 459 459 +PUT 460 460 +PUT 461 461 +PUT 462 462 +PUT 463 463 +PUT 464 464 +PUT 465 465 +PUT 466 466 +PUT 467 467 +PUT 468 468 +PUT 469 469 +PUT 470 470 +PUT 471 471 +PUT 472 472 +PUT 473 473 +PUT 474 474 +PUT 475 475 +PUT 476 476 +PUT 477 477 +PUT 478 478 +PUT 479 479 +PUT 480 480 +PUT 481 481 +PUT 482 482 +PUT 483 483 +PUT 484 484 +PUT 485 485 +PUT 486 486 +PUT 487 487 +PUT 488 488 +PUT 489 489 +PUT 490 490 +PUT 491 491 +PUT 492 492 +PUT 493 493 +PUT 494 494 +PUT 495 495 +PUT 496 496 +PUT 497 497 +PUT 498 498 +PUT 499 499 +PUT 500 500 +PUT 501 501 +PUT 502 502 +PUT 503 503 +PUT 504 504 +PUT 505 505 +PUT 506 506 +PUT 507 507 +PUT 508 508 +PUT 509 509 +PUT 510 510 +PUT 511 511 +PUT 512 512 +GET 385 +GET 386 +GET 387 +GET 388 +GET 389 +GET 390 +GET 391 +GET 392 +GET 393 +GET 394 +GET 395 +GET 396 +GET 397 +GET 398 +GET 399 +GET 400 +GET 401 +GET 402 +GET 403 +GET 404 +GET 405 +GET 406 +GET 407 +GET 408 +GET 409 +GET 410 +GET 411 +GET 412 +GET 413 +GET 414 +GET 415 +GET 416 +GET 417 +GET 418 +GET 419 +GET 420 +GET 421 +GET 422 +GET 423 +GET 424 +GET 425 +GET 426 +GET 427 +GET 428 +GET 429 +GET 430 +GET 431 +GET 432 +GET 433 +GET 434 +GET 435 +GET 436 +GET 437 +GET 438 +GET 439 +GET 440 +GET 441 +GET 442 +GET 443 +GET 444 +GET 445 +GET 446 +GET 447 +GET 448 +GET 449 +GET 450 +GET 451 +GET 452 +GET 453 +GET 454 +GET 455 +GET 456 +GET 457 +GET 458 +GET 459 +GET 460 +GET 461 +GET 462 +GET 463 +GET 464 +GET 465 +GET 466 +GET 467 +GET 468 +GET 469 +GET 470 +GET 471 +GET 472 +GET 473 +GET 474 +GET 475 +GET 476 +GET 477 +GET 478 +GET 479 +GET 480 +GET 481 +GET 482 +GET 483 +GET 484 +GET 485 +GET 486 +GET 487 +GET 488 +GET 489 +GET 490 +GET 491 +GET 492 +GET 493 +GET 494 +GET 495 +GET 496 +GET 497 +GET 498 +GET 499 +GET 500 +GET 501 +GET 502 +GET 503 +GET 504 +GET 505 +GET 506 +GET 507 +GET 508 +GET 509 +GET 510 +GET 511 +GET 512 +PUT 513 513 +FREE \ No newline at end of file diff --git a/tests/cache/cache_lru_replace.expect b/tests/cache/cache_lru_replace.expect new file mode 100644 index 000000000..eae319247 --- /dev/null +++ b/tests/cache/cache_lru_replace.expect @@ -0,0 +1,3 @@ +NEW CACHE +REPLACE 1 +FREE CACHE diff --git a/tests/cache/cache_lru_replace.in b/tests/cache/cache_lru_replace.in new file mode 100644 index 000000000..a89d135ad --- /dev/null +++ b/tests/cache/cache_lru_replace.in @@ -0,0 +1,259 @@ +NEW +PUT 1 1 +PUT 2 2 +PUT 3 3 +PUT 4 4 +PUT 5 5 +PUT 6 6 +PUT 7 7 +PUT 8 8 +PUT 9 9 +PUT 10 10 +PUT 11 11 +PUT 12 12 +PUT 13 13 +PUT 14 14 +PUT 15 15 +PUT 16 16 +PUT 17 17 +PUT 18 18 +PUT 19 19 +PUT 20 20 +PUT 21 21 +PUT 22 22 +PUT 23 23 +PUT 24 24 +PUT 25 25 +PUT 26 26 +PUT 27 27 +PUT 28 28 +PUT 29 29 +PUT 30 30 +PUT 31 31 +PUT 32 32 +PUT 33 33 +PUT 34 34 +PUT 35 35 +PUT 36 36 +PUT 37 37 +PUT 38 38 +PUT 39 39 +PUT 40 40 +PUT 41 41 +PUT 42 42 +PUT 43 43 +PUT 44 44 +PUT 45 45 +PUT 46 46 +PUT 47 47 +PUT 48 48 +PUT 49 49 +PUT 50 50 +PUT 51 51 +PUT 52 52 +PUT 53 53 +PUT 54 54 +PUT 55 55 +PUT 56 56 +PUT 57 57 +PUT 58 58 +PUT 59 59 +PUT 60 60 +PUT 61 61 +PUT 62 62 +PUT 63 63 +PUT 64 64 +PUT 65 65 +PUT 66 66 +PUT 67 67 +PUT 68 68 +PUT 69 69 +PUT 70 70 +PUT 71 71 +PUT 72 72 +PUT 73 73 +PUT 74 74 +PUT 75 75 +PUT 76 76 +PUT 77 77 +PUT 78 78 +PUT 79 79 +PUT 80 80 +PUT 81 81 +PUT 82 82 +PUT 83 83 +PUT 84 84 +PUT 85 85 +PUT 86 86 +PUT 87 87 +PUT 88 88 +PUT 89 89 +PUT 90 90 +PUT 91 91 +PUT 92 92 +PUT 93 93 +PUT 94 94 +PUT 95 95 +PUT 96 96 +PUT 97 97 +PUT 98 98 +PUT 99 99 +PUT 100 100 +PUT 101 101 +PUT 102 102 +PUT 103 103 +PUT 104 104 +PUT 105 105 +PUT 106 106 +PUT 107 107 +PUT 108 108 +PUT 109 109 +PUT 110 110 +PUT 111 111 +PUT 112 112 +PUT 113 113 +PUT 114 114 +PUT 115 115 +PUT 116 116 +PUT 117 117 +PUT 118 118 +PUT 119 119 +PUT 120 120 +PUT 121 121 +PUT 122 122 +PUT 123 123 +PUT 124 124 +PUT 125 125 +PUT 126 126 +PUT 127 127 +PUT 128 128 +PUT 129 129 +PUT 130 130 +PUT 131 131 +PUT 132 132 +PUT 133 133 +PUT 134 134 +PUT 135 135 +PUT 136 136 +PUT 137 137 +PUT 138 138 +PUT 139 139 +PUT 140 140 +PUT 141 141 +PUT 142 142 +PUT 143 143 +PUT 144 144 +PUT 145 145 +PUT 146 146 +PUT 147 147 +PUT 148 148 +PUT 149 149 +PUT 150 150 +PUT 151 151 +PUT 152 152 +PUT 153 153 +PUT 154 154 +PUT 155 155 +PUT 156 156 +PUT 157 157 +PUT 158 158 +PUT 159 159 +PUT 160 160 +PUT 161 161 +PUT 162 162 +PUT 163 163 +PUT 164 164 +PUT 165 165 +PUT 166 166 +PUT 167 167 +PUT 168 168 +PUT 169 169 +PUT 170 170 +PUT 171 171 +PUT 172 172 +PUT 173 173 +PUT 174 174 +PUT 175 175 +PUT 176 176 +PUT 177 177 +PUT 178 178 +PUT 179 179 +PUT 180 180 +PUT 181 181 +PUT 182 182 +PUT 183 183 +PUT 184 184 +PUT 185 185 +PUT 186 186 +PUT 187 187 +PUT 188 188 +PUT 189 189 +PUT 190 190 +PUT 191 191 +PUT 192 192 +PUT 193 193 +PUT 194 194 +PUT 195 195 +PUT 196 196 +PUT 197 197 +PUT 198 198 +PUT 199 199 +PUT 200 200 +PUT 201 201 +PUT 202 202 +PUT 203 203 +PUT 204 204 +PUT 205 205 +PUT 206 206 +PUT 207 207 +PUT 208 208 +PUT 209 209 +PUT 210 210 +PUT 211 211 +PUT 212 212 +PUT 213 213 +PUT 214 214 +PUT 215 215 +PUT 216 216 +PUT 217 217 +PUT 218 218 +PUT 219 219 +PUT 220 220 +PUT 221 221 +PUT 222 222 +PUT 223 223 +PUT 224 224 +PUT 225 225 +PUT 226 226 +PUT 227 227 +PUT 228 228 +PUT 229 229 +PUT 230 230 +PUT 231 231 +PUT 232 232 +PUT 233 233 +PUT 234 234 +PUT 235 235 +PUT 236 236 +PUT 237 237 +PUT 238 238 +PUT 239 239 +PUT 240 240 +PUT 241 241 +PUT 242 242 +PUT 243 243 +PUT 244 244 +PUT 245 245 +PUT 246 246 +PUT 247 247 +PUT 248 248 +PUT 249 249 +PUT 250 250 +PUT 251 251 +PUT 252 252 +PUT 253 253 +PUT 254 254 +PUT 255 255 +PUT 256 256 +PUT 257 257 +FREE \ No newline at end of file diff --git a/tests/cache/cache_new.expect b/tests/cache/cache_new.expect new file mode 100644 index 000000000..134d8b8e5 --- /dev/null +++ b/tests/cache/cache_new.expect @@ -0,0 +1,2 @@ +NEW CACHE +FREE CACHE diff --git a/tests/cache/cache_new.in b/tests/cache/cache_new.in new file mode 100644 index 000000000..f3603c17f --- /dev/null +++ b/tests/cache/cache_new.in @@ -0,0 +1,2 @@ +NEW +FREE \ No newline at end of file diff --git a/tests/cache/cache_put.expect b/tests/cache/cache_put.expect new file mode 100644 index 000000000..eae319247 --- /dev/null +++ b/tests/cache/cache_put.expect @@ -0,0 +1,3 @@ +NEW CACHE +REPLACE 1 +FREE CACHE diff --git a/tests/cache/cache_put.in b/tests/cache/cache_put.in new file mode 100644 index 000000000..a89d135ad --- /dev/null +++ b/tests/cache/cache_put.in @@ -0,0 +1,259 @@ +NEW +PUT 1 1 +PUT 2 2 +PUT 3 3 +PUT 4 4 +PUT 5 5 +PUT 6 6 +PUT 7 7 +PUT 8 8 +PUT 9 9 +PUT 10 10 +PUT 11 11 +PUT 12 12 +PUT 13 13 +PUT 14 14 +PUT 15 15 +PUT 16 16 +PUT 17 17 +PUT 18 18 +PUT 19 19 +PUT 20 20 +PUT 21 21 +PUT 22 22 +PUT 23 23 +PUT 24 24 +PUT 25 25 +PUT 26 26 +PUT 27 27 +PUT 28 28 +PUT 29 29 +PUT 30 30 +PUT 31 31 +PUT 32 32 +PUT 33 33 +PUT 34 34 +PUT 35 35 +PUT 36 36 +PUT 37 37 +PUT 38 38 +PUT 39 39 +PUT 40 40 +PUT 41 41 +PUT 42 42 +PUT 43 43 +PUT 44 44 +PUT 45 45 +PUT 46 46 +PUT 47 47 +PUT 48 48 +PUT 49 49 +PUT 50 50 +PUT 51 51 +PUT 52 52 +PUT 53 53 +PUT 54 54 +PUT 55 55 +PUT 56 56 +PUT 57 57 +PUT 58 58 +PUT 59 59 +PUT 60 60 +PUT 61 61 +PUT 62 62 +PUT 63 63 +PUT 64 64 +PUT 65 65 +PUT 66 66 +PUT 67 67 +PUT 68 68 +PUT 69 69 +PUT 70 70 +PUT 71 71 +PUT 72 72 +PUT 73 73 +PUT 74 74 +PUT 75 75 +PUT 76 76 +PUT 77 77 +PUT 78 78 +PUT 79 79 +PUT 80 80 +PUT 81 81 +PUT 82 82 +PUT 83 83 +PUT 84 84 +PUT 85 85 +PUT 86 86 +PUT 87 87 +PUT 88 88 +PUT 89 89 +PUT 90 90 +PUT 91 91 +PUT 92 92 +PUT 93 93 +PUT 94 94 +PUT 95 95 +PUT 96 96 +PUT 97 97 +PUT 98 98 +PUT 99 99 +PUT 100 100 +PUT 101 101 +PUT 102 102 +PUT 103 103 +PUT 104 104 +PUT 105 105 +PUT 106 106 +PUT 107 107 +PUT 108 108 +PUT 109 109 +PUT 110 110 +PUT 111 111 +PUT 112 112 +PUT 113 113 +PUT 114 114 +PUT 115 115 +PUT 116 116 +PUT 117 117 +PUT 118 118 +PUT 119 119 +PUT 120 120 +PUT 121 121 +PUT 122 122 +PUT 123 123 +PUT 124 124 +PUT 125 125 +PUT 126 126 +PUT 127 127 +PUT 128 128 +PUT 129 129 +PUT 130 130 +PUT 131 131 +PUT 132 132 +PUT 133 133 +PUT 134 134 +PUT 135 135 +PUT 136 136 +PUT 137 137 +PUT 138 138 +PUT 139 139 +PUT 140 140 +PUT 141 141 +PUT 142 142 +PUT 143 143 +PUT 144 144 +PUT 145 145 +PUT 146 146 +PUT 147 147 +PUT 148 148 +PUT 149 149 +PUT 150 150 +PUT 151 151 +PUT 152 152 +PUT 153 153 +PUT 154 154 +PUT 155 155 +PUT 156 156 +PUT 157 157 +PUT 158 158 +PUT 159 159 +PUT 160 160 +PUT 161 161 +PUT 162 162 +PUT 163 163 +PUT 164 164 +PUT 165 165 +PUT 166 166 +PUT 167 167 +PUT 168 168 +PUT 169 169 +PUT 170 170 +PUT 171 171 +PUT 172 172 +PUT 173 173 +PUT 174 174 +PUT 175 175 +PUT 176 176 +PUT 177 177 +PUT 178 178 +PUT 179 179 +PUT 180 180 +PUT 181 181 +PUT 182 182 +PUT 183 183 +PUT 184 184 +PUT 185 185 +PUT 186 186 +PUT 187 187 +PUT 188 188 +PUT 189 189 +PUT 190 190 +PUT 191 191 +PUT 192 192 +PUT 193 193 +PUT 194 194 +PUT 195 195 +PUT 196 196 +PUT 197 197 +PUT 198 198 +PUT 199 199 +PUT 200 200 +PUT 201 201 +PUT 202 202 +PUT 203 203 +PUT 204 204 +PUT 205 205 +PUT 206 206 +PUT 207 207 +PUT 208 208 +PUT 209 209 +PUT 210 210 +PUT 211 211 +PUT 212 212 +PUT 213 213 +PUT 214 214 +PUT 215 215 +PUT 216 216 +PUT 217 217 +PUT 218 218 +PUT 219 219 +PUT 220 220 +PUT 221 221 +PUT 222 222 +PUT 223 223 +PUT 224 224 +PUT 225 225 +PUT 226 226 +PUT 227 227 +PUT 228 228 +PUT 229 229 +PUT 230 230 +PUT 231 231 +PUT 232 232 +PUT 233 233 +PUT 234 234 +PUT 235 235 +PUT 236 236 +PUT 237 237 +PUT 238 238 +PUT 239 239 +PUT 240 240 +PUT 241 241 +PUT 242 242 +PUT 243 243 +PUT 244 244 +PUT 245 245 +PUT 246 246 +PUT 247 247 +PUT 248 248 +PUT 249 249 +PUT 250 250 +PUT 251 251 +PUT 252 252 +PUT 253 253 +PUT 254 254 +PUT 255 255 +PUT 256 256 +PUT 257 257 +FREE \ No newline at end of file diff --git a/tests/cache/test_cache.c b/tests/cache/test_cache.c new file mode 100644 index 000000000..a3720a200 --- /dev/null +++ b/tests/cache/test_cache.c @@ -0,0 +1,69 @@ +#include +#include +#include +#include + +#include "cache.h" + +void print_value(int *val) +{ + if (val) + printf("%d\n", *val); + else + printf("NULL\n"); +} + +void split(char **arr, char *str, const char *del) +{ + char *s = strtok(str, del); + + while (s != NULL) { + *arr++ = s; + s = strtok(NULL, del); + } +} + +/* Commands of test_cache + * 1. NEW: cache_create(8), the cache size is set to 256. + * 2. GET key: cache_get(cache, key) + * 3. PUT key val: cache_put(cache, key, val) + * 4. FREE: cache_free(cache, free) + */ +int main(int argc, char *argv[]) +{ + if (argc < 2) { + printf("Fail\n"); + } + FILE *fp = fopen(argv[1], "r"); + char *line = NULL, *ptr = NULL; + size_t len = 0; + struct cache *cache = NULL; + int key, *ans, *val; + while (getline(&line, &len, fp) != -1) { + char *arr[3]; + split(arr, line, " "); + if (!strcmp(arr[0], "GET")) { + key = (int) strtol(arr[1], &ptr, 10); + ans = cache_get(cache, key); + print_value(ans); + } else if (!strcmp(arr[0], "PUT")) { + key = (int) strtol(arr[1], &ptr, 10); + val = malloc(sizeof(int)); + *val = (int) strtol(arr[2], &ptr, 10); + val = cache_put(cache, key, val); + if (val) { + printf("REPLACE %d\n", *val); + free(val); + } + } else if (!strcmp(arr[0], "NEW\n")) { + cache = cache_create(8); + assert(cache); + printf("NEW CACHE\n"); + } else if (!strcmp(arr[0], "FREE")) { + cache_free(cache, free); + printf("FREE CACHE\n"); + } + } + fclose(fp); + return 0; +} \ No newline at end of file