| | @@ -684,58 +684,95 @@ fn source_change_during_direct_read_prevents_success() { |
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | #[test] |
| 687 | | -삭제: fn small_temporary_quota_lists_and_previews_large_zip_and_seven_zip() { |
| 688 | | -삭제: for named in [false, true] { |
| 689 | | -삭제: let c = Case::new(); |
| 690 | | -삭제: let library = c.library(); |
| 691 | | -삭제: let probe = Command::new("python3") |
| 692 | | -삭제: .arg("-B") |
| 693 | | -삭제: .arg("-c") |
| 694 | | -삭제: .arg( |
| 695 | | -삭제: r#" |
| 687 | +추가: fn small_temporary_quota_counts_closed_files_until_unlinked() { |
| 688 | +추가: let scratch = Scratch::new(); |
| 689 | +추가: fs::create_dir(scratch.0.join("system")).unwrap(); |
| 690 | +추가: let c = Case { |
| 691 | +추가: scratch, |
| 692 | +추가: archive_names: Vec::new(), |
| 693 | +추가: }; |
| 694 | +추가: let library = c.library(); |
| 695 | +추가: let probe = Command::new("python3") |
| 696 | +추가: .arg("-B") |
| 697 | +추가: .arg("-c") |
| 698 | +추가: .arg( |
| 699 | +추가: r#" |
| 696 | 700 | import errno, os, sys |
| 697 | 701 | from pathlib import Path |
| 698 | 702 | root = Path(sys.argv[1]) |
| 703 | +추가: def assert_full(fd): |
| 704 | +추가: try: |
| 705 | +추가: os.write(fd, b"x") |
| 706 | +추가: except OSError as error: |
| 707 | +추가: assert error.errno == errno.ENOSPC |
| 708 | +추가: else: |
| 709 | +추가: raise AssertionError("임시 용량이 너무 일찍 반환됨") |
| 699 | 710 | a = os.open(root / "quota-a", os.O_CREAT | os.O_RDWR, 0o600) |
| 700 | 711 | b = os.open(root / "quota-b", os.O_CREAT | os.O_RDWR, 0o600) |
| 701 | 712 | duplicate = os.dup(a) |
| 702 | 713 | try: |
| 703 | 714 | assert os.write(a, bytes(1024 * 1024)) == 1024 * 1024 |
| 715 | +추가: os.close(duplicate) |
| 716 | +추가: duplicate = -1 |
| 717 | +추가: os.close(a) |
| 718 | +추가: a = -1 |
| 704 | 719 | assert os.write(b, bytes(2 * 1024 * 1024)) == 1024 * 1024 |
| 705 | 720 | try: |
| 706 | 721 | os.write(b, b"x") |
| 707 | 722 | except OSError as error: |
| 708 | 723 | assert error.errno == errno.ENOSPC |
| 709 | 724 | else: |
| 710 | | -삭제: raise AssertionError("공유 임시 용량 한도가 적용되지 않음") |
| 725 | +추가: raise AssertionError("닫힌 파일의 용량이 반환됨") |
| 726 | +추가: assert (root / "quota-a").stat().st_size == 1024 * 1024 |
| 727 | +추가: os.link(root / "quota-a", root / "quota-alias") |
| 728 | +추가: (root / "quota-a").unlink() |
| 729 | +추가: assert_full(b) |
| 730 | +추가: (root / "quota-alias").unlink() |
| 731 | +추가: assert os.write(b, bytes(1024 * 1024)) == 1024 * 1024 |
| 732 | +추가: duplicate = os.dup(b) |
| 733 | +추가: (root / "quota-b").unlink() |
| 734 | +추가: assert_full(b) |
| 735 | +추가: os.close(b) |
| 736 | +추가: b = -1 |
| 737 | +추가: assert_full(duplicate) |
| 711 | 738 | os.close(duplicate) |
| 712 | 739 | duplicate = -1 |
| 713 | | -삭제: os.close(a) |
| 714 | | -삭제: a = -1 |
| 715 | | -삭제: (root / "quota-a").unlink() |
| 716 | | -삭제: assert os.write(b, b"x") == 1 |
| 740 | +추가: b = os.open(root / "quota-b", os.O_CREAT | os.O_RDWR, 0o600) |
| 741 | +추가: assert os.write(b, bytes(2 * 1024 * 1024)) == 2 * 1024 * 1024 |
| 717 | 742 | finally: |
| 718 | 743 | if duplicate >= 0: |
| 719 | 744 | os.close(duplicate) |
| 720 | 745 | if a >= 0: |
| 721 | 746 | os.close(a) |
| 722 | | -삭제: os.close(b) |
| 723 | | -삭제: for name in ["quota-a", "quota-b"]: |
| 747 | +추가: if b >= 0: |
| 748 | +추가: os.close(b) |
| 749 | +추가: for name in ["quota-a", "quota-b", "quota-alias"]: |
| 724 | 750 | (root / name).unlink(missing_ok=True) |
| 725 | 751 | "#, |
| 726 | | -삭제: ) |
| 727 | | -삭제: .arg(c.scratch.0.join("system")) |
| 728 | | -삭제: .env("LD_PRELOAD", library) |
| 729 | | -삭제: .env("ZIPELO_SPOOL_PHASE", "tiny-tmpfs") |
| 730 | | -삭제: .env("ZIPELO_SPOOL_TRACE", c.scratch.0.join("trace")) |
| 731 | | -삭제: .output() |
| 732 | | -삭제: .unwrap(); |
| 733 | | -삭제: assert!(probe.status.success(), "{:?}", probe.stderr); |
| 734 | | -삭제: assert!( |
| 735 | | -삭제: fs::read_to_string(c.scratch.0.join("trace")) |
| 736 | | -삭제: .unwrap() |
| 737 | | -삭제: .contains('F') |
| 738 | | -삭제: ); |
| 752 | +추가: ) |
| 753 | +추가: .arg(c.scratch.0.join("system")) |
| 754 | +추가: .env("TMPDIR", c.scratch.0.join("system")) |
| 755 | +추가: .env("LD_PRELOAD", library) |
| 756 | +추가: .env("ZIPELO_SPOOL_PHASE", "tiny-tmpfs") |
| 757 | +추가: .env("ZIPELO_SPOOL_TRACE", c.scratch.0.join("trace")) |
| 758 | +추가: .output() |
| 759 | +추가: .unwrap(); |
| 760 | +추가: assert!( |
| 761 | +추가: probe.status.success(), |
| 762 | +추가: "{}", |
| 763 | +추가: String::from_utf8_lossy(&probe.stderr) |
| 764 | +추가: ); |
| 765 | +추가: assert!( |
| 766 | +추가: fs::read_to_string(c.scratch.0.join("trace")) |
| 767 | +추가: .unwrap() |
| 768 | +추가: .contains('F') |
| 769 | +추가: ); |
| 770 | +추가: } |
| 771 | +추가: |
| 772 | +추가: #[test] |
| 773 | +추가: fn small_temporary_quota_lists_and_previews_large_zip_and_seven_zip() { |
| 774 | +추가: for named in [false, true] { |
| 775 | +추가: let c = Case::new(); |
| 739 | 776 | for format in ["zip", "7z"] { |
| 740 | 777 | c.assert_preview(format, "tiny-tmpfs", 0, named); |
| 741 | 778 | } |