mirror of
https://github.com/ostreedev/ostree.git
synced 2025-03-19 22:50:35 +03:00
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
|
||||
* possibly haven't been sync'd to disk.
|
||||
*/
|
||||
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');
|
||||
{ const char *env_bootid = getenv ("OSTREE_BOOTID");
|
||||
|
||||
if (env_bootid != NULL)
|
||||
self->boot_id = g_strdup (env_bootid);
|
||||
else
|
||||
{
|
||||
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,
|
||||
&self->repo_dir_fd, error))
|
||||
|
@ -400,11 +400,24 @@ echo "ok disable cache checkout"
|
||||
cd ${test_tmpdir}
|
||||
rm checkout-test2 -rf
|
||||
$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"
|
||||
fi
|
||||
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
|
||||
cd ${test_tmpdir}
|
||||
|
@ -86,6 +86,12 @@ assert_streq () {
|
||||
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 () {
|
||||
(! test "$1" = "$2") || (echo 1>&2 "$1 == $2"; exit 1)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user