|
17 | 17 | # 8. --validate --subset filesystem validates filesystem-only subset |
18 | 18 | # 9. --validate reports clear error for socket patches without filesystem |
19 | 19 | # 10. --help includes --validate and --subset documentation |
| 20 | +# 11. --subset dns on full 8-patch set validates only DNS patches |
| 21 | +# 12. --subset with unknown domain exits non-zero |
| 22 | +# 13. dependency that comes later in series produces distinct error |
20 | 23 | # |
21 | 24 | # Usage: |
22 | 25 | # ./rebase-libc.test.sh Run all tests |
@@ -380,6 +383,60 @@ else |
380 | 383 | fail "--help missing --validate and/or --subset. Output: ${OUTPUT}" |
381 | 384 | fi |
382 | 385 |
|
| 386 | +# ── Test 11: --subset filters domain from full patch set ────────────── |
| 387 | + |
| 388 | +log "Test 11: --subset dns on full 8-patch set validates only DNS patches" |
| 389 | + |
| 390 | +PATCHES="${_tmpdir}/test11-patches" |
| 391 | +mkdir -p "${PATCHES}" |
| 392 | +make_valid_patch_set "${PATCHES}" |
| 393 | + |
| 394 | +EXIT_CODE=0 |
| 395 | +OUTPUT=$(run_validate "${PATCHES}" --subset dns 2>&1) || EXIT_CODE=$? |
| 396 | + |
| 397 | +# Should pass (DNS subset is self-consistent) and only validate 3 patches |
| 398 | +if [ ${EXIT_CODE} -eq 0 ] && echo "${OUTPUT}" | grep -q "3 patch"; then |
| 399 | + pass "--subset dns on full set validates only 3 DNS patches" |
| 400 | +else |
| 401 | + fail "--subset dns on full set should pass with 3 patches (exit=${EXIT_CODE}). Output: ${OUTPUT}" |
| 402 | +fi |
| 403 | + |
| 404 | +# ── Test 12: --subset with unknown domain exits non-zero ────────────── |
| 405 | + |
| 406 | +log "Test 12: --subset with unknown domain exits non-zero" |
| 407 | + |
| 408 | +PATCHES="${_tmpdir}/test12-patches" |
| 409 | +mkdir -p "${PATCHES}" |
| 410 | +make_valid_patch_set "${PATCHES}" |
| 411 | + |
| 412 | +EXIT_CODE=0 |
| 413 | +OUTPUT=$(run_validate "${PATCHES}" --subset bogus 2>&1) || EXIT_CODE=$? |
| 414 | + |
| 415 | +if [ ${EXIT_CODE} -ne 0 ] && echo "${OUTPUT}" | grep -qi "no patches found.*bogus\|bogus"; then |
| 416 | + pass "--subset with unknown domain exits non-zero" |
| 417 | +else |
| 418 | + fail "--subset bogus should fail (exit=${EXIT_CODE}). Output: ${OUTPUT}" |
| 419 | +fi |
| 420 | + |
| 421 | +# ── Test 13: dependency that comes later produces distinct error ─────── |
| 422 | + |
| 423 | +log "Test 13: dependency that comes later in series produces distinct error" |
| 424 | + |
| 425 | +PATCHES="${_tmpdir}/test13-patches" |
| 426 | +mkdir -p "${PATCHES}" |
| 427 | +# Create patches where 0001 declares a dependency on 0002 (which exists but comes after) |
| 428 | +make_patch "${PATCHES}" "0001-dns.patch" "dns" "0002" "warpgrid:shim/dns" |
| 429 | +make_patch "${PATCHES}" "0002-fs.patch" "filesystem" "none" "warpgrid:shim/filesystem" |
| 430 | + |
| 431 | +EXIT_CODE=0 |
| 432 | +OUTPUT=$(run_validate "${PATCHES}" 2>&1) || EXIT_CODE=$? |
| 433 | + |
| 434 | +if [ ${EXIT_CODE} -ne 0 ] && echo "${OUTPUT}" | grep -qi "comes later"; then |
| 435 | + pass "--validate distinguishes 'comes later' from 'not present'" |
| 436 | +else |
| 437 | + fail "--validate should report 'comes later' for forward deps (exit=${EXIT_CODE}). Output: ${OUTPUT}" |
| 438 | +fi |
| 439 | + |
383 | 440 | # ── Summary ────────────────────────────────────────────────────────── |
384 | 441 |
|
385 | 442 | echo "" |
|
0 commit comments