File: test-basic-bare-split-xattrs.sh

package info (click to toggle)
ostree 2025.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,996 kB
  • sloc: ansic: 70,831; sh: 15,652; xml: 5,007; yacc: 1,236; javascript: 531; makefile: 243; python: 155
file content (77 lines) | stat: -rwxr-xr-x 2,201 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env bash
#
# SPDX-License-Identifier: LGPL-2.0+

set -euo pipefail

. $(dirname $0)/libtest.sh

mode="bare-split-xattrs"
OSTREE="${CMD_PREFIX} ostree --repo=${test_tmpdir}/repo"

skip_without_sudo
SUDO="sudo --non-interactive"

PRIVILEGED="false"
if [ $(id -u) -eq 0 ]; then
  PRIVILEGED="true"
  SUDO=""
elif $(${SUDO} -v); then
  PRIVILEGED="true"
fi

cd ${test_tmpdir}
${OSTREE} init --mode "${mode}"
${OSTREE} config get core.mode > mode.txt
assert_file_has_content mode.txt "${mode}"
tap_ok "repo init"
rm -rf -- repo mode.txt

cd ${test_tmpdir}
${OSTREE} init --mode "${mode}"
${OSTREE} fsck --all
tap_ok "repo fsck"
rm -rf -- repo

cd ${test_tmpdir}
mkdir -p "${test_tmpdir}/files"
touch files/foo
${OSTREE} init --mode "${mode}"
if ${OSTREE} commit --orphan -m "not implemented" files; then
    assert_not_reached "commit to bare-split-xattrs should have failed"
fi
${OSTREE} fsck --all
tap_ok "commit not implemented"
rm -rf -- repo files

cd ${test_tmpdir}
mkdir -p "${test_tmpdir}/files"
touch files/foo
${OSTREE} init --mode "${mode}"
OSTREE_EXP_WRITE_BARE_SPLIT_XATTRS=true ${OSTREE} commit --orphan -m "experimental" files
if ${OSTREE} fsck --all; then
    assert_not_reached "fsck should have failed"
fi
tap_ok "commit exp override"
rm -rf -- repo files

if [ "${PRIVILEGED}" = "true" ]; then
    COMMIT="d614c428015227259031b0f19b934dade908942fd71c49047e0daa70e7800a5d"
    cd ${test_tmpdir}
    ${SUDO} tar --same-permissions --same-owner -xaf ${test_srcdir}/bare-split-xattrs-basic.tar.xz
    ${SUDO} ${OSTREE} fsck --all
    ${OSTREE} log ${COMMIT} > out.txt
    assert_file_has_content_literal out.txt "fixtures: bare-split-xattrs repo"
    ${OSTREE} ls ${COMMIT} -X /foo > out.txt
    assert_file_has_content_literal out.txt "{ @a(ayay) [] } /foo"
    ${OSTREE} ls ${COMMIT} -X /bar > out.txt
    assert_file_has_content_literal out.txt "{ [(b'user.mykey', [byte 0x6d, 0x79, 0x76, 0x61, 0x6c, 0x75, 0x65])] } /bar"
    ${OSTREE} ls ${COMMIT} /foolink > out.txt
    assert_file_has_content_literal out.txt "/foolink -> foo"
    tap_ok "reading simple fixture"
    ${SUDO} rm -rf -- repo log.txt
else
    tap_ok "reading simple fixture # skip Unable to sudo"
fi

tap_end