Coverage report: /home/ellis/comp/core/ffi/btrfs/tests.lisp
Kind | Covered | All | % |
expression | 0 | 15 | 0.0 |
branch | 0 | 0 | nil |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
;;; src/fs/btrfs/tests.lisp --- BTRFS common-lisp tests
4
(defpackage btrfs/tests
5
(:use :cl :std :rt :btrfs :sb-alien))
6
(in-package :btrfs/tests)
14
(defvar *test-btrfs-pathname* (directory-path (symbol-name (gensym "/tmp/btrfs"))))
17
(is (typep +btrfs-lib-version+ 'fixnum))
18
(is (eq 0 (btrfs-util-error :ok)))
19
(is (equal "Cannot allocate memory" (btrfs-util-strerror (btrfs-util-error :no-memory)))))
22
(is (zerop (btrfs::btrfs-util-subvolume-is-valid "/")))
23
(is (zerop (btrfs::btrfs-util-fs-sync "/")))
24
(sb-alien:with-alien ((id (unsigned 64))
25
(path c-string (make-alien-string ""))
26
(iter (* btrfs-util-subvolume-iterator)))
27
(is (zerop (btrfs-util-subvolume-iter-create "/" 0 0 (addr iter))))
28
(isnt (btrfs-util-subvolume-iter-destroy iter))))
30
(deftest root-fs (:skip (or (not (sudo-p)) (not (zerop (btrfs-util-subvolume-is-valid "/")))))
31
;; will only work on a BTRFS Linux root partition
33
(with-alien ((id (unsigned 64)))
34
(iszero (btrfs-util-fs-sync path))
35
;; returns 0 on success
36
(iszero (btrfs-util-subvolume-is-valid path))
37
(iszero (btrfs-util-subvolume-get-id path (addr id)))
38
(with-alien ((path1 c-string))
39
(btrfs-util-subvolume-get-path "/" id (addr path1))
41
(with-alien ((info btrfs-util-subvolume-info))
42
;; :error-search-failed
43
(iszero (btrfs-util-subvolume-get-info "/" id (addr info))))
45
(with-alien ((ret boolean))
46
(iszero (btrfs-util-subvolume-get-read-only "/" (addr ret))))
48
(with-alien ((qgroups (* btrfs-util-qgroup-inherit)))
49
(iszero (btrfs-util-qgroup-inherit-create 0 (addr qgroups)))
50
(iszero (btrfs-util-subvolume-snapshot "/" "/tmp/btrfs-sn1" 0 nil qgroups))))))
53
Subvolume iterators require appropriate privilege (CAP_SYS_ADMIN) unless @top
54
is zero and the kernel supports BTRFS_IOC_GET_SUBVOL_ROOTREF and
55
BTRFS_IOC_INO_LOOKUP_USER (kernel >= 4.18). In this case, subvolumes which
56
cannot be accessed (e.g., due to permissions or other mounts) will be
59
The returned iterator must be freed with
60
btrfs_util_subvolume_iter_destroy().
62
Return: %BTRFS_UTIL_OK on success, non-zero error code on failure.
65
(deftest subvolume-iter (:skip (or (not (sudo-p)) (not (zerop (btrfs-util-subvolume-is-valid "/")))))
67
(with-alien ((iter (* btrfs-util-subvolume-iterator)))
68
(iszero (btrfs-util-subvolume-iter-create path 0 0 (addr iter)))
69
(isnt (btrfs-util-subvolume-iter-destroy iter))
70
(with-alien ((pret c-string) (id unsigned-long))
72
(iszero (btrfs-util-subvolume-iter-next iter (addr pret) (addr id)))))))