repo: Add OSTREE_BOOTID override envvar for debugging
It's useful for test cases to be able to influence this. Conflicts: src/libostree/ostree-repo.c Closes: #170 Approved by: jlebon
This commit is contained in:
parent
15b3cab65e
commit
e3ec83a934
|
|
@ -2431,12 +2431,20 @@ ostree_repo_open (OstreeRepo *self,
|
||||||
/* We use a per-boot identifier to keep track of which file contents
|
/* We use a per-boot identifier to keep track of which file contents
|
||||||
* possibly haven't been sync'd to disk.
|
* possibly haven't been sync'd to disk.
|
||||||
*/
|
*/
|
||||||
if (!g_file_get_contents ("/proc/sys/kernel/random/boot_id",
|
{ const char *env_bootid = getenv ("OSTREE_BOOTID");
|
||||||
&self->boot_id,
|
|
||||||
NULL,
|
if (env_bootid != NULL)
|
||||||
error))
|
self->boot_id = g_strdup (env_bootid);
|
||||||
goto out;
|
else
|
||||||
g_strdelimit (self->boot_id, "\n", '\0');
|
{
|
||||||
|
if (!g_file_get_contents ("/proc/sys/kernel/random/boot_id",
|
||||||
|
&self->boot_id,
|
||||||
|
NULL,
|
||||||
|
error))
|
||||||
|
goto out;
|
||||||
|
g_strdelimit (self->boot_id, "\n", '\0');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!glnx_opendirat (AT_FDCWD, gs_file_get_path_cached (self->repodir), TRUE,
|
if (!glnx_opendirat (AT_FDCWD, gs_file_get_path_cached (self->repodir), TRUE,
|
||||||
&self->repo_dir_fd, error))
|
&self->repo_dir_fd, error))
|
||||||
|
|
|
||||||
|
|
@ -400,11 +400,24 @@ echo "ok disable cache checkout"
|
||||||
cd ${test_tmpdir}
|
cd ${test_tmpdir}
|
||||||
rm checkout-test2 -rf
|
rm checkout-test2 -rf
|
||||||
$OSTREE checkout test2 checkout-test2
|
$OSTREE checkout test2 checkout-test2
|
||||||
if env OSTREE_REPO_TEST_ERROR=pre-commit $OSTREE commit -b test2 -s '' $test_tmpdir/checkout-test2 2>err.txt; then
|
date > checkout-test2/date.txt
|
||||||
|
rm repo/tmp/* -rf
|
||||||
|
export TEST_BOOTID=3072029c-8b10-60d1-d31b-8422eeff9b42
|
||||||
|
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
|
||||||
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
|
||||||
echo "ok test error pre commit"
|
found_staging=0
|
||||||
|
for d in $(find repo/tmp/ -maxdepth 1 -type d); do
|
||||||
|
bn=$(basename $d)
|
||||||
|
if test ${bn##staging-} != ${bn}; then
|
||||||
|
assert_str_match "${bn}" "^staging-${TEST_BOOTID}-"
|
||||||
|
found_staging=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
assert_streq "${found_staging}" 1
|
||||||
|
echo "ok test error pre commit/bootid"
|
||||||
|
|
||||||
# Whiteouts
|
# Whiteouts
|
||||||
cd ${test_tmpdir}
|
cd ${test_tmpdir}
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,12 @@ assert_streq () {
|
||||||
test "$1" = "$2" || (echo 1>&2 "$1 != $2"; exit 1)
|
test "$1" = "$2" || (echo 1>&2 "$1 != $2"; exit 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert_str_match () {
|
||||||
|
if ! echo "$1" | grep -E -q "$2"; then
|
||||||
|
(echo 1>&2 "$1 does not match regexp $2"; exit 1)
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
assert_not_streq () {
|
assert_not_streq () {
|
||||||
(! test "$1" = "$2") || (echo 1>&2 "$1 == $2"; exit 1)
|
(! test "$1" = "$2") || (echo 1>&2 "$1 == $2"; exit 1)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue