diff options
| author | Maxim Cournoyer <maxim@guixotic.coop> | 2025-10-30 16:19:51 +0900 |
|---|---|---|
| committer | Maxim Cournoyer <maxim@guixotic.coop> | 2025-10-30 16:19:51 +0900 |
| commit | 3ae5c9f2a78ce85beceb7467479c741e4c046830 (patch) | |
| tree | 64b2cdadb7f3d48682afb0c852ef2ef609e5f419 /tests/syscalls.scm | |
| parent | 0f39db9c1942969bcbc603b306d8e47f8feb8566 (diff) | |
Revert "syscalls: Add mmap support."
This reverts commit e1994a021437b3fd73089c08d7e8db876fad698d.
Diffstat (limited to 'tests/syscalls.scm')
| -rw-r--r-- | tests/syscalls.scm | 70 |
1 files changed, 1 insertions, 69 deletions
diff --git a/tests/syscalls.scm b/tests/syscalls.scm index 1ea49b0acc4..a0483e68f08 100644 --- a/tests/syscalls.scm +++ b/tests/syscalls.scm | |||
| @@ -22,11 +22,8 @@ | |||
| 22 | 22 | ||
| 23 | (define-module (test-syscalls) | 23 | (define-module (test-syscalls) |
| 24 | #:use-module (guix utils) | 24 | #:use-module (guix utils) |
| 25 | #:use-module (guix build io) | ||
| 26 | #:use-module (guix build syscalls) | 25 | #:use-module (guix build syscalls) |
| 27 | #:use-module (guix build utils) | ||
| 28 | #:use-module (gnu build linux-container) | 26 | #:use-module (gnu build linux-container) |
| 29 | #:use-module (rnrs bytevectors) | ||
| 30 | #:use-module (srfi srfi-1) | 27 | #:use-module (srfi srfi-1) |
| 31 | #:use-module (srfi srfi-26) | 28 | #:use-module (srfi srfi-26) |
| 32 | #:use-module (srfi srfi-64) | 29 | #:use-module (srfi srfi-64) |
| @@ -34,7 +31,7 @@ | |||
| 34 | #:use-module (system foreign) | 31 | #:use-module (system foreign) |
| 35 | #:use-module ((ice-9 ftw) #:select (scandir)) | 32 | #:use-module ((ice-9 ftw) #:select (scandir)) |
| 36 | #:use-module (ice-9 match) | 33 | #:use-module (ice-9 match) |
| 37 | #:use-module (ice-9 textual-ports)) | 34 | #:use-module (ice-9 threads)) |
| 38 | 35 | ||
| 39 | ;; Test the (guix build syscalls) module, although there's not much that can | 36 | ;; Test the (guix build syscalls) module, although there's not much that can |
| 40 | ;; actually be tested without being root. | 37 | ;; actually be tested without being root. |
| @@ -42,9 +39,6 @@ | |||
| 42 | (define temp-file | 39 | (define temp-file |
| 43 | (string-append "t-utils-" (number->string (getpid)))) | 40 | (string-append "t-utils-" (number->string (getpid)))) |
| 44 | 41 | ||
| 45 | (define strace-output | ||
| 46 | (string-append "t-utils-strace" (number->string (getpid)))) | ||
| 47 | |||
| 48 | 42 | ||
| 49 | (test-begin "syscalls") | 43 | (test-begin "syscalls") |
| 50 | 44 | ||
| @@ -741,68 +735,6 @@ | |||
| 741 | (member (system-error-errno args) | 735 | (member (system-error-errno args) |
| 742 | (list EPERM ENOSYS))))) | 736 | (list EPERM ENOSYS))))) |
| 743 | 737 | ||
| 744 | (test-assert "mmap and munmap" | ||
| 745 | (begin | ||
| 746 | (call-with-output-file temp-file | ||
| 747 | (lambda (p) | ||
| 748 | (display "abcdefghij"))) | ||
| 749 | (let* ((len 5) | ||
| 750 | (bv (mmap (open-fdes temp-file O_RDONLY) len))) | ||
| 751 | (munmap bv)))) | ||
| 752 | |||
| 753 | (test-equal "file->bytevector, reading" | ||
| 754 | #\6 | ||
| 755 | (begin | ||
| 756 | (call-with-output-file temp-file | ||
| 757 | (lambda (p) | ||
| 758 | (display "0123456789\n" p))) | ||
| 759 | (sync) | ||
| 760 | (integer->char | ||
| 761 | (bytevector-u8-ref (file->bytevector temp-file) 6)))) | ||
| 762 | |||
| 763 | (test-equal "file->bytevector, writing" | ||
| 764 | "0000000700" | ||
| 765 | (begin | ||
| 766 | (call-with-output-file temp-file | ||
| 767 | (lambda (p) | ||
| 768 | (display "0000000000" p))) | ||
| 769 | (sync) | ||
| 770 | (let ((bv (file->bytevector temp-file | ||
| 771 | #:protection PROT_WRITE))) | ||
| 772 | |||
| 773 | (bytevector-u8-set! bv 7 (char->integer #\7)) | ||
| 774 | (msync bv)) ;ensure the file gets written | ||
| 775 | (call-with-input-file temp-file get-string-all))) | ||
| 776 | |||
| 777 | (unless (which "strace") | ||
| 778 | (test-skip 1)) | ||
| 779 | ;;; This test currently fails, due to protected items in a guardian being | ||
| 780 | ;;; dropped from weak hash tables (see: | ||
| 781 | ;;; <https://codeberg.org/guile/guile/issues/44>). | ||
| 782 | (test-expect-fail 1) | ||
| 783 | (test-equal "manual munmap does not lead to double free" | ||
| 784 | 1 ;single munmap call | ||
| 785 | (begin | ||
| 786 | (call-with-output-file temp-file | ||
| 787 | (lambda (p) | ||
| 788 | (display "something interesting\n" p))) | ||
| 789 | (sync) | ||
| 790 | (gc) | ||
| 791 | (system (string-append "strace -o " strace-output | ||
| 792 | " -p " (number->string (getpid)) | ||
| 793 | " -e trace=munmap &")) | ||
| 794 | (sleep 1) ;allow strace to start | ||
| 795 | (let ((bv (file->bytevector temp-file))) | ||
| 796 | (munmap bv)) | ||
| 797 | (gc) | ||
| 798 | (sync) | ||
| 799 | (let ((text (call-with-input-file strace-output get-string-all))) | ||
| 800 | ;; The address seen by strace is not the same as the one seen by Guile, | ||
| 801 | ;; so we can't use it in the pattern. | ||
| 802 | (length (filter (cut string-prefix? "munmap(0x" <>) | ||
| 803 | (string-split text #\newline)))))) | ||
| 804 | |||
| 805 | (test-end) | 738 | (test-end) |
| 806 | 739 | ||
| 807 | (false-if-exception (delete-file temp-file)) | 740 | (false-if-exception (delete-file temp-file)) |
| 808 | (false-if-exception (delete-file strace-output)) | ||
