Add basic tests for bare-user-only repo modes

This is somewhat complicated by such repos only properly supporting
some subset of file metadata (uid/gid 0, etc). We fix this by
always commiting with filters that make it work.

Closes: #750
Approved by: cgwalters
This commit is contained in:
Alexander Larsson 2017-03-26 11:03:47 +02:00 committed by Atomic Bot
parent b2d10dcaaa
commit 7c8f95c86f
4 changed files with 96 additions and 50 deletions

View File

@ -46,6 +46,7 @@ dist_uninstalled_test_scripts = tests/test-symbols.sh
dist_test_scripts = \ dist_test_scripts = \
tests/test-basic.sh \ tests/test-basic.sh \
tests/test-basic-user.sh \ tests/test-basic-user.sh \
tests/test-basic-user-only.sh \
tests/test-pull-subpath.sh \ tests/test-pull-subpath.sh \
tests/test-archivez.sh \ tests/test-archivez.sh \
tests/test-remote-add.sh \ tests/test-remote-add.sh \

View File

@ -25,6 +25,19 @@ $CMD_PREFIX ostree --version > version.yaml
python -c 'import yaml; yaml.safe_load(open("version.yaml"))' python -c 'import yaml; yaml.safe_load(open("version.yaml"))'
echo "ok yaml version" echo "ok yaml version"
CHECKOUT_U_ARG=""
COMMIT_ARGS=""
DIFF_ARGS=""
if grep bare-user-only repo/config; then
# In bare-user-only repos we can only represent files with uid/gid 0, no
# xattrs and canonical permissions, so we need to commit them as such, or
# we end up with repos that don't pass fsck
COMMIT_ARGS="--canonical-permissions"
DIFF_ARGS="--owner-uid=0 --owner-gid=0 --no-xattrs"
# Also, since we can't check out uid=0 files we need to check out in user mode
CHECKOUT_U_ARG="-U"
fi
$OSTREE checkout test2 checkout-test2 $OSTREE checkout test2 checkout-test2
echo "ok checkout" echo "ok checkout"
@ -59,7 +72,7 @@ assert_has_file baz/deeper/ohyeah
echo "ok content" echo "ok content"
rm firstfile rm firstfile
$OSTREE commit -b test2 -s delete $OSTREE commit ${COMMIT_ARGS} -b test2 -s delete
cd $test_tmpdir cd $test_tmpdir
$OSTREE checkout test2 $test_tmpdir/checkout-test2-2 $OSTREE checkout test2 $test_tmpdir/checkout-test2-2
@ -80,7 +93,7 @@ mkdir -p another/nested/tree
echo anotherone > another/nested/tree/1 echo anotherone > another/nested/tree/1
echo whee2 > another/whee echo whee2 > another/whee
# FIXME - remove grep for . # FIXME - remove grep for .
$OSTREE commit -b test2 -s "Another commit" $OSTREE commit ${COMMIT_ARGS} -b test2 -s "Another commit"
echo "ok commit" echo "ok commit"
cd ${test_tmpdir} cd ${test_tmpdir}
@ -96,7 +109,7 @@ mkdir -p yet/another/tree
echo leaf > yet/another/tree/green echo leaf > yet/another/tree/green
echo helloworld > yet/message echo helloworld > yet/message
rm a/5 rm a/5
$OSTREE commit -b test2 -s "Current directory" $OSTREE commit ${COMMIT_ARGS} -b test2 -s "Current directory"
echo "ok cwd commit" echo "ok cwd commit"
cd ${test_tmpdir} cd ${test_tmpdir}
@ -107,15 +120,15 @@ assert_file_has_content four '4'
echo "ok cwd contents" echo "ok cwd contents"
cd ${test_tmpdir} cd ${test_tmpdir}
$OSTREE commit -b test2-no-parent -s '' $test_tmpdir/checkout-test2-4 $OSTREE commit ${COMMIT_ARGS} -b test2-no-parent -s '' $test_tmpdir/checkout-test2-4
assert_streq $($OSTREE log test2-no-parent |grep '^commit' | wc -l) "1" assert_streq $($OSTREE log test2-no-parent |grep '^commit' | wc -l) "1"
$OSTREE commit -b test2-no-parent -s '' --parent=none $test_tmpdir/checkout-test2-4 $OSTREE commit ${COMMIT_ARGS} -b test2-no-parent -s '' --parent=none $test_tmpdir/checkout-test2-4
assert_streq $($OSTREE log test2-no-parent |grep '^commit' | wc -l) "1" assert_streq $($OSTREE log test2-no-parent |grep '^commit' | wc -l) "1"
echo "ok commit no parent" echo "ok commit no parent"
cd ${test_tmpdir} cd ${test_tmpdir}
empty_rev=$($OSTREE commit -b test2-no-subject -s '' --timestamp="2005-10-29 12:43:29 +0000" $test_tmpdir/checkout-test2-4) empty_rev=$($OSTREE commit ${COMMIT_ARGS} -b test2-no-subject -s '' --timestamp="2005-10-29 12:43:29 +0000" $test_tmpdir/checkout-test2-4)
omitted_rev=$($OSTREE commit -b test2-no-subject-2 --timestamp="2005-10-29 12:43:29 +0000" $test_tmpdir/checkout-test2-4) omitted_rev=$($OSTREE commit ${COMMIT_ARGS} -b test2-no-subject-2 --timestamp="2005-10-29 12:43:29 +0000" $test_tmpdir/checkout-test2-4)
assert_streq $empty_rev $omitted_rev assert_streq $empty_rev $omitted_rev
echo "ok commit no subject" echo "ok commit no subject"
@ -127,7 +140,7 @@ commit message.
Build-Host: foo.example.com Build-Host: foo.example.com
Crunchy-With-Extra-Ketchup: true Crunchy-With-Extra-Ketchup: true
EOF EOF
$OSTREE commit -b branch-with-commitmsg -F commitmsg.txt -s 'a message' $test_tmpdir/checkout-test2-4 $OSTREE commit ${COMMIT_ARGS} -b branch-with-commitmsg -F commitmsg.txt -s 'a message' $test_tmpdir/checkout-test2-4
$OSTREE log branch-with-commitmsg > log.txt $OSTREE log branch-with-commitmsg > log.txt
assert_file_has_content log.txt '^ *This is a long$' assert_file_has_content log.txt '^ *This is a long$'
assert_file_has_content log.txt '^ *Build-Host:.*example.com$' assert_file_has_content log.txt '^ *Build-Host:.*example.com$'
@ -136,17 +149,17 @@ $OSTREE refs --delete branch-with-commitmsg
echo "ok commit body file" echo "ok commit body file"
cd ${test_tmpdir} cd ${test_tmpdir}
$OSTREE commit -b test2-custom-parent -s '' $test_tmpdir/checkout-test2-4 $OSTREE commit ${COMMIT_ARGS} -b test2-custom-parent -s '' $test_tmpdir/checkout-test2-4
$OSTREE commit -b test2-custom-parent -s '' $test_tmpdir/checkout-test2-4 $OSTREE commit ${COMMIT_ARGS} -b test2-custom-parent -s '' $test_tmpdir/checkout-test2-4
$OSTREE commit -b test2-custom-parent -s '' $test_tmpdir/checkout-test2-4 $OSTREE commit ${COMMIT_ARGS} -b test2-custom-parent -s '' $test_tmpdir/checkout-test2-4
assert_streq $($OSTREE log test2-custom-parent |grep '^commit' | wc -l) "3" assert_streq $($OSTREE log test2-custom-parent |grep '^commit' | wc -l) "3"
prevparent=$($OSTREE rev-parse test2-custom-parent^) prevparent=$($OSTREE rev-parse test2-custom-parent^)
$OSTREE commit -b test2-custom-parent -s '' --parent=${prevparent} $test_tmpdir/checkout-test2-4 $OSTREE commit ${COMMIT_ARGS} -b test2-custom-parent -s '' --parent=${prevparent} $test_tmpdir/checkout-test2-4
assert_streq $($OSTREE log test2-custom-parent |grep '^commit' | wc -l) "3" assert_streq $($OSTREE log test2-custom-parent |grep '^commit' | wc -l) "3"
echo "ok commit custom parent" echo "ok commit custom parent"
cd ${test_tmpdir} cd ${test_tmpdir}
orphaned_rev=$($OSTREE commit --orphan -s "$(date)" $test_tmpdir/checkout-test2-4) orphaned_rev=$($OSTREE commit ${COMMIT_ARGS} --orphan -s "$(date)" $test_tmpdir/checkout-test2-4)
$OSTREE ls ${orphaned_rev} >/dev/null $OSTREE ls ${orphaned_rev} >/dev/null
$OSTREE prune --refs-only $OSTREE prune --refs-only
if $OSTREE ls ${orphaned_rev} 2>err.txt; then if $OSTREE ls ${orphaned_rev} 2>err.txt; then
@ -172,15 +185,15 @@ assert_file_has_content diff-test2-2 'A *oh-look-a-file$'
echo "ok diff cwd" echo "ok diff cwd"
cd ${test_tmpdir}/checkout-test2-4 cd ${test_tmpdir}/checkout-test2-4
$OSTREE diff test2 ./ > ${test_tmpdir}/diff-test2 $OSTREE diff ${DIFF_ARGS} test2 ./ > ${test_tmpdir}/diff-test2
assert_file_empty ${test_tmpdir}/diff-test2 assert_file_empty ${test_tmpdir}/diff-test2
$OSTREE diff test2 --owner-uid=$((`id -u`+1)) ./ > ${test_tmpdir}/diff-test2 $OSTREE diff ${DIFF_ARGS} test2 --owner-uid=$((`id -u`+1)) ./ > ${test_tmpdir}/diff-test2
assert_file_has_content ${test_tmpdir}/diff-test2 'M */yet$' assert_file_has_content ${test_tmpdir}/diff-test2 'M */yet$'
assert_file_has_content ${test_tmpdir}/diff-test2 'M */yet/message$' assert_file_has_content ${test_tmpdir}/diff-test2 'M */yet/message$'
assert_file_has_content ${test_tmpdir}/diff-test2 'M */yet/another/tree/green$' assert_file_has_content ${test_tmpdir}/diff-test2 'M */yet/another/tree/green$'
echo "ok diff file with different uid" echo "ok diff file with different uid"
$OSTREE diff test2 --owner-gid=$((`id -g`+1)) ./ > ${test_tmpdir}/diff-test2 $OSTREE diff ${DIFF_ARGS} test2 --owner-gid=$((`id -g`+1)) ./ > ${test_tmpdir}/diff-test2
assert_file_has_content ${test_tmpdir}/diff-test2 'M */yet$' assert_file_has_content ${test_tmpdir}/diff-test2 'M */yet$'
assert_file_has_content ${test_tmpdir}/diff-test2 'M */yet/message$' assert_file_has_content ${test_tmpdir}/diff-test2 'M */yet/message$'
assert_file_has_content ${test_tmpdir}/diff-test2 'M */yet/another/tree/green$' assert_file_has_content ${test_tmpdir}/diff-test2 'M */yet/another/tree/green$'
@ -197,12 +210,12 @@ echo "ok diff file changing type"
cd ${test_tmpdir} cd ${test_tmpdir}
mkdir repo2 mkdir repo2
ostree_repo_init repo2 ostree_repo_init repo2 --mode=bare-user
${CMD_PREFIX} ostree --repo=repo2 pull-local repo ${CMD_PREFIX} ostree --repo=repo2 pull-local repo
echo "ok pull-local" echo "ok pull-local"
cd ${test_tmpdir} cd ${test_tmpdir}
${CMD_PREFIX} ostree --repo=repo2 checkout test2 test2-checkout-from-local-clone ${CMD_PREFIX} ostree --repo=repo2 checkout ${CHECKOUT_U_ARG} test2 test2-checkout-from-local-clone
cd test2-checkout-from-local-clone cd test2-checkout-from-local-clone
assert_file_has_content yet/another/tree/green 'leaf' assert_file_has_content yet/another/tree/green 'leaf'
echo "ok local clone checkout" echo "ok local clone checkout"
@ -210,31 +223,33 @@ echo "ok local clone checkout"
$OSTREE checkout -U test2 checkout-user-test2 $OSTREE checkout -U test2 checkout-user-test2
echo "ok user checkout" echo "ok user checkout"
$OSTREE commit -b test2 -s "Another commit" --tree=ref=test2 $OSTREE commit ${COMMIT_ARGS} -b test2 -s "Another commit" --tree=ref=test2
echo "ok commit from ref" echo "ok commit from ref"
$OSTREE commit -b test2 -s "Another commit with modifier" --tree=ref=test2 --owner-uid=`id -u` $OSTREE commit ${COMMIT_ARGS} -b test2 -s "Another commit with modifier" --tree=ref=test2 --owner-uid=`id -u`
echo "ok commit from ref with modifier" echo "ok commit from ref with modifier"
$OSTREE commit -b trees/test2 -s 'ref with / in it' --tree=ref=test2 $OSTREE commit ${COMMIT_ARGS} -b trees/test2 -s 'ref with / in it' --tree=ref=test2
echo "ok commit ref with /" echo "ok commit ref with /"
old_rev=$($OSTREE rev-parse test2) old_rev=$($OSTREE rev-parse test2)
$OSTREE commit --skip-if-unchanged -b test2 -s 'should not be committed' --tree=ref=test2 $OSTREE ls -R -C test2
$OSTREE commit ${COMMIT_ARGS} --skip-if-unchanged -b trees/test2 -s 'should not be committed' --tree=ref=test2
$OSTREE ls -R -C test2
new_rev=$($OSTREE rev-parse test2) new_rev=$($OSTREE rev-parse test2)
assert_streq "${old_rev}" "${new_rev}" assert_streq "${old_rev}" "${new_rev}"
echo "ok commit --skip-if-unchanged" echo "ok commit --skip-if-unchanged"
cd ${test_tmpdir}/checkout-test2-4 cd ${test_tmpdir}/checkout-test2-4
$OSTREE commit -b test2 -s "no xattrs" --no-xattrs $OSTREE commit ${COMMIT_ARGS} -b test2 -s "no xattrs" --no-xattrs
echo "ok commit with no xattrs" echo "ok commit with no xattrs"
mkdir tree-A tree-B mkdir tree-A tree-B
touch tree-A/file-a tree-B/file-b touch tree-A/file-a tree-B/file-b
$OSTREE commit -b test3-1 -s "Initial tree" --tree=dir=tree-A $OSTREE commit ${COMMIT_ARGS} -b test3-1 -s "Initial tree" --tree=dir=tree-A
$OSTREE commit -b test3-2 -s "Replacement tree" --tree=dir=tree-B $OSTREE commit ${COMMIT_ARGS} -b test3-2 -s "Replacement tree" --tree=dir=tree-B
$OSTREE commit -b test3-combined -s "combined tree" --tree=ref=test3-1 --tree=ref=test3-2 $OSTREE commit ${COMMIT_ARGS} -b test3-combined -s "combined tree" --tree=ref=test3-1 --tree=ref=test3-2
$OSTREE checkout test3-combined checkout-test3-combined $OSTREE checkout test3-combined checkout-test3-combined
@ -250,7 +265,7 @@ cat > test-statoverride.txt <<EOF
2048 /a/nested/3 2048 /a/nested/3
EOF EOF
cd ${test_tmpdir}/checkout-test2-4 cd ${test_tmpdir}/checkout-test2-4
$OSTREE commit -b test2-override -s "with statoverride" --statoverride=../test-statoverride.txt $OSTREE commit ${COMMIT_ARGS} -b test2-override -s "with statoverride" --statoverride=../test-statoverride.txt
cd ${test_tmpdir} cd ${test_tmpdir}
$OSTREE checkout test2-override checkout-test2-override $OSTREE checkout test2-override checkout-test2-override
test -g checkout-test2-override/a/nested/2 test -g checkout-test2-override/a/nested/2
@ -263,7 +278,7 @@ cat > test-skiplist.txt <<EOF
EOF EOF
cd ${test_tmpdir}/checkout-test2-4 cd ${test_tmpdir}/checkout-test2-4
assert_has_file a/nested/3 assert_has_file a/nested/3
$OSTREE commit -b test2-skiplist -s "with skiplist" --skip-list=../test-skiplist.txt $OSTREE commit ${COMMIT_ARGS} -b test2-skiplist -s "with skiplist" --skip-list=../test-skiplist.txt
cd ${test_tmpdir} cd ${test_tmpdir}
$OSTREE checkout test2-skiplist checkout-test2-skiplist $OSTREE checkout test2-skiplist checkout-test2-skiplist
assert_not_has_file checkout-test2-skiplist/a/nested/3 assert_not_has_file checkout-test2-skiplist/a/nested/3
@ -285,9 +300,9 @@ assert_file_has_content tree/green "leaf"
echo "ok checkout subpath" echo "ok checkout subpath"
cd ${test_tmpdir} cd ${test_tmpdir}
$OSTREE checkout --union test2 checkout-test2-union $OSTREE checkout --union test2 checkout-test2-union
find checkout-test2-union | wc -l > union-files-count find checkout-test2-union | wc -l > union-files-count
$OSTREE checkout --union test2 checkout-test2-union $OSTREE checkout --union test2 checkout-test2-union
find checkout-test2-union | wc -l > union-files-count.new find checkout-test2-union | wc -l > union-files-count.new
cmp union-files-count{,.new} cmp union-files-count{,.new}
cd checkout-test2-union cd checkout-test2-union
@ -295,11 +310,11 @@ assert_file_has_content ./yet/another/tree/green "leaf"
echo "ok checkout union 1" echo "ok checkout union 1"
cd ${test_tmpdir} cd ${test_tmpdir}
$OSTREE commit -b test-union-add --tree=ref=test2 $OSTREE commit ${COMMIT_ARGS} -b test-union-add --tree=ref=test2
$OSTREE checkout test-union-add checkout-test-union-add $OSTREE checkout test-union-add checkout-test-union-add
echo 'file for union add testing' > checkout-test-union-add/union-add-test echo 'file for union add testing' > checkout-test-union-add/union-add-test
echo 'another file for union add testing' > checkout-test-union-add/union-add-test2 echo 'another file for union add testing' > checkout-test-union-add/union-add-test2
$OSTREE commit -b test-union-add --tree=dir=checkout-test-union-add $OSTREE commit ${COMMIT_ARGS} -b test-union-add --tree=dir=checkout-test-union-add
rm checkout-test-union-add -rf rm checkout-test-union-add -rf
# Check out previous # Check out previous
$OSTREE checkout test-union-add^ checkout-test-union-add $OSTREE checkout test-union-add^ checkout-test-union-add
@ -319,7 +334,7 @@ ostree_repo_init shadow-repo
${CMD_PREFIX} ostree --repo=shadow-repo config set core.parent $(pwd)/repo ${CMD_PREFIX} ostree --repo=shadow-repo config set core.parent $(pwd)/repo
rm -rf test2-checkout rm -rf test2-checkout
parent_rev_test2=$(${CMD_PREFIX} ostree --repo=repo rev-parse test2) parent_rev_test2=$(${CMD_PREFIX} ostree --repo=repo rev-parse test2)
${CMD_PREFIX} ostree --repo=shadow-repo checkout "${parent_rev_test2}" test2-checkout ${CMD_PREFIX} ostree --repo=shadow-repo checkout ${CHECKOUT_U_ARG} "${parent_rev_test2}" test2-checkout
echo "ok checkout from shadow repo" echo "ok checkout from shadow repo"
cd ${test_tmpdir} cd ${test_tmpdir}
@ -335,7 +350,7 @@ echo "ok subdir noent"
cd ${test_tmpdir} cd ${test_tmpdir}
mkdir repo3 mkdir repo3
ostree_repo_init repo3 ostree_repo_init repo3 --mode=bare-user
${CMD_PREFIX} ostree --repo=repo3 pull-local --remote=aremote repo test2 ${CMD_PREFIX} ostree --repo=repo3 pull-local --remote=aremote repo test2
${CMD_PREFIX} ostree --repo=repo3 rev-parse aremote/test2 ${CMD_PREFIX} ostree --repo=repo3 rev-parse aremote/test2
echo "ok pull-local with --remote arg" echo "ok pull-local with --remote arg"
@ -368,7 +383,7 @@ echo "ok prune in archive-z2 deleted everything"
cd ${test_tmpdir} cd ${test_tmpdir}
rm -rf test2-checkout rm -rf test2-checkout
$OSTREE checkout test2 test2-checkout $OSTREE checkout test2 test2-checkout
(cd test2-checkout && $OSTREE commit --link-checkout-speedup -b test2 -s "tmp") (cd test2-checkout && $OSTREE commit ${COMMIT_ARGS} --link-checkout-speedup -b test2 -s "tmp")
echo "ok commit with link speedup" echo "ok commit with link speedup"
cd ${test_tmpdir} cd ${test_tmpdir}
@ -387,7 +402,7 @@ $OSTREE show test2
echo "ok show with non-checksum" echo "ok show with non-checksum"
cd $test_tmpdir/checkout-test2 cd $test_tmpdir/checkout-test2
checksum=$($OSTREE commit -b test4 -s "Third commit") checksum=$($OSTREE commit ${COMMIT_ARGS} -b test4 -s "Third commit")
cd ${test_tmpdir} cd ${test_tmpdir}
$OSTREE show test4 > show-output $OSTREE show test4 > show-output
assert_file_has_content show-output "Third commit" assert_file_has_content show-output "Third commit"
@ -395,8 +410,8 @@ assert_file_has_content show-output "commit $checksum"
echo "ok show full output" echo "ok show full output"
cd $test_tmpdir/checkout-test2 cd $test_tmpdir/checkout-test2
checksum1=$($OSTREE commit -b test5 -s "First commit") checksum1=$($OSTREE commit ${COMMIT_ARGS} -b test5 -s "First commit")
checksum2=$($OSTREE commit -b test5 -s "Second commit") checksum2=$($OSTREE commit ${COMMIT_ARGS} -b test5 -s "Second commit")
cd ${test_tmpdir} cd ${test_tmpdir}
$OSTREE log test5 > log-output $OSTREE log test5 > log-output
assert_file_has_content log-output "First commit" assert_file_has_content log-output "First commit"
@ -406,8 +421,8 @@ assert_file_has_content log-output "commit $checksum2"
echo "ok log output" echo "ok log output"
cd $test_tmpdir/checkout-test2 cd $test_tmpdir/checkout-test2
checksum1=$($OSTREE commit -b test6 -s "First commit") checksum1=$($OSTREE commit ${COMMIT_ARGS} -b test6 -s "First commit")
checksum2=$($OSTREE commit -b test6 -s "Second commit") checksum2=$($OSTREE commit ${COMMIT_ARGS} -b test6 -s "Second commit")
cd ${test_tmpdir} cd ${test_tmpdir}
$OSTREE show test6 > show-output $OSTREE show test6 > show-output
assert_file_has_content show-output "commit $checksum2" assert_file_has_content show-output "commit $checksum2"
@ -420,11 +435,11 @@ cd ${test_tmpdir}
rm checkout-test2 -rf rm checkout-test2 -rf
$OSTREE checkout test2 checkout-test2 $OSTREE checkout test2 checkout-test2
touch checkout-test2/sometestfile touch checkout-test2/sometestfile
$OSTREE commit -s sometest -b test2 checkout-test2 $OSTREE commit ${COMMIT_ARGS} -s sometest -b test2 checkout-test2
echo "ok commit with directory filename" echo "ok commit with directory filename"
cd $test_tmpdir/checkout-test2 cd $test_tmpdir/checkout-test2
$OSTREE commit -b test2 -s "Metadata string" --add-metadata-string=FOO=BAR --add-metadata-string=KITTENS=CUTE --add-detached-metadata-string=SIGNATURE=HANCOCK --tree=ref=test2 $OSTREE commit ${COMMIT_ARGS} -b test2 -s "Metadata string" --add-metadata-string=FOO=BAR --add-metadata-string=KITTENS=CUTE --add-detached-metadata-string=SIGNATURE=HANCOCK --tree=ref=test2
cd ${test_tmpdir} cd ${test_tmpdir}
$OSTREE show --print-metadata-key=FOO test2 > test2-meta $OSTREE show --print-metadata-key=FOO test2 > test2-meta
assert_file_has_content test2-meta "BAR" assert_file_has_content test2-meta "BAR"
@ -437,7 +452,7 @@ echo "ok metadata commit with strings"
cd ${test_tmpdir} cd ${test_tmpdir}
rm repo2 -rf rm repo2 -rf
mkdir repo2 mkdir repo2
ostree_repo_init repo2 ostree_repo_init repo2 --mode=bare-user
${CMD_PREFIX} ostree --repo=repo2 pull-local repo ${CMD_PREFIX} ostree --repo=repo2 pull-local repo
${CMD_PREFIX} ostree --repo=repo2 show --print-detached-metadata-key=SIGNATURE test2 > test2-meta ${CMD_PREFIX} ostree --repo=repo2 show --print-detached-metadata-key=SIGNATURE test2 > test2-meta
assert_file_has_content test2-meta "HANCOCK" assert_file_has_content test2-meta "HANCOCK"
@ -472,7 +487,7 @@ rm -rf test2-checkout
mkdir -p test2-checkout mkdir -p test2-checkout
cd test2-checkout cd test2-checkout
mkfifo afifo mkfifo afifo
if $OSTREE commit -b test2 -s "Attempt to commit a FIFO" 2>../errmsg; then if $OSTREE commit ${COMMIT_ARGS} -b test2 -s "Attempt to commit a FIFO" 2>../errmsg; then
assert_not_reached "Committing a FIFO unexpetedly succeeded!" assert_not_reached "Committing a FIFO unexpetedly succeeded!"
assert_file_has_content ../errmsg "Unsupported file type" assert_file_has_content ../errmsg "Unsupported file type"
fi fi
@ -504,7 +519,7 @@ date > checkout-test2/date.txt
rm repo/tmp/* -rf rm repo/tmp/* -rf
export TEST_BOOTID=3072029c-8b10-60d1-d31b-8422eeff9b42 export TEST_BOOTID=3072029c-8b10-60d1-d31b-8422eeff9b42
if env OSTREE_REPO_TEST_ERROR=pre-commit OSTREE_BOOTID=${TEST_BOOTID} \ if env OSTREE_REPO_TEST_ERROR=pre-commit OSTREE_BOOTID=${TEST_BOOTID} \
$OSTREE commit -b test2 -s '' $test_tmpdir/checkout-test2 2>err.txt; then $OSTREE commit ${COMMIT_ARGS} -b test2 -s '' $test_tmpdir/checkout-test2 2>err.txt; then
assert_not_reached "Should have hit OSTREE_REPO_TEST_ERROR_PRE_COMMIT" assert_not_reached "Should have hit OSTREE_REPO_TEST_ERROR_PRE_COMMIT"
fi fi
assert_file_has_content err.txt OSTREE_REPO_TEST_ERROR_PRE_COMMIT assert_file_has_content err.txt OSTREE_REPO_TEST_ERROR_PRE_COMMIT
@ -526,7 +541,7 @@ if touch overlay/baz/.wh.cow && touch overlay/.wh.deeper; then
touch overlay/anewfile touch overlay/anewfile
mkdir overlay/anewdir/ mkdir overlay/anewdir/
touch overlay/anewdir/blah touch overlay/anewdir/blah
$OSTREE --repo=repo commit -b overlay -s 'overlay' --tree=dir=overlay $OSTREE --repo=repo commit ${COMMIT_ARGS} -b overlay -s 'overlay' --tree=dir=overlay
rm overlay -rf rm overlay -rf
for branch in test2 overlay; do for branch in test2 overlay; do
@ -563,7 +578,7 @@ rm -rf test2-checkout
mkdir -p test2-checkout mkdir -p test2-checkout
cd test2-checkout cd test2-checkout
touch should-not-be-fsynced touch should-not-be-fsynced
$OSTREE commit -b test2 -s "Unfsynced commit" --fsync=false $OSTREE commit ${COMMIT_ARGS} -b test2 -s "Unfsynced commit" --fsync=false
# Run this test only as non-root user. When run as root, the chmod # Run this test only as non-root user. When run as root, the chmod
# won't have any effect. # won't have any effect.
@ -587,7 +602,7 @@ mkdir -p test2-checkout
cd test2-checkout cd test2-checkout
touch blah touch blah
stat --printf="%.Y\n" ${test_tmpdir}/repo > ${test_tmpdir}/timestamp-orig.txt stat --printf="%.Y\n" ${test_tmpdir}/repo > ${test_tmpdir}/timestamp-orig.txt
$OSTREE commit -b test2 -s "Should bump the mtime" $OSTREE commit ${COMMIT_ARGS} -b test2 -s "Should bump the mtime"
stat --printf="%.Y\n" ${test_tmpdir}/repo > ${test_tmpdir}/timestamp-new.txt stat --printf="%.Y\n" ${test_tmpdir}/repo > ${test_tmpdir}/timestamp-new.txt
cd .. cd ..
if cmp timestamp-{orig,new}.txt; then if cmp timestamp-{orig,new}.txt; then

View File

@ -206,6 +206,11 @@ setup_test_repository () {
oldpwd=`pwd` oldpwd=`pwd`
COMMIT_ARGS=""
if [ $mode == "bare-user-only" ] ; then
COMMIT_ARGS="--owner-uid=0 --owner-gid=0 --no-xattrs --canonical-permissions"
fi
cd ${test_tmpdir} cd ${test_tmpdir}
if test -n "${mode}"; then if test -n "${mode}"; then
ostree_repo_init repo --mode=${mode} ostree_repo_init repo --mode=${mode}
@ -224,7 +229,7 @@ setup_test_repository () {
echo first > firstfile echo first > firstfile
cd ${test_tmpdir}/files cd ${test_tmpdir}/files
$OSTREE commit -b test2 -s "Test Commit 1" -m "Commit body first" $OSTREE commit ${COMMIT_ARGS} -b test2 -s "Test Commit 1" -m "Commit body first"
mkdir baz mkdir baz
echo moo > baz/cow echo moo > baz/cow
@ -236,7 +241,7 @@ setup_test_repository () {
echo x > baz/another/y echo x > baz/another/y
cd ${test_tmpdir}/files cd ${test_tmpdir}/files
$OSTREE commit -b test2 -s "Test Commit 2" -m "Commit body second" $OSTREE commit ${COMMIT_ARGS} -b test2 -s "Test Commit 2" -m "Commit body second"
$OSTREE fsck -q $OSTREE fsck -q
cd $oldpwd cd $oldpwd

25
tests/test-basic-user-only.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
#
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
set -euo pipefail
. $(dirname $0)/libtest.sh
setup_test_repository "bare-user-only"
. $(dirname $0)/basic-test.sh