New upstream version 2020.8
This commit is contained in:
commit
2b5dac2d58
83 files changed
+6548
-4073
No files matched your search
@@ -20,113 +20,118 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
sysroot = ''
|
||||
else:
|
||||
sysroot = sys.argv[1]
|
||||
|
||||
bootloader = sys.argv[2]
|
||||
loaderpath = sysroot + '/boot/loader/entries'
|
||||
syslinuxpath = sysroot + '/boot/syslinux/syslinux.cfg'
|
||||
def main(argv):
|
||||
_, sysroot, bootloader = argv
|
||||
|
||||
if bootloader == "grub2":
|
||||
sys.stdout.write('GRUB2 configuration validation not implemented.\n')
|
||||
return 0
|
||||
else:
|
||||
return validate_syslinux(sysroot)
|
||||
|
||||
if bootloader == "grub2":
|
||||
sys.stdout.write('GRUB2 configuration validation not implemented.\n')
|
||||
sys.exit(0)
|
||||
|
||||
def fatal(msg):
|
||||
sys.stderr.write(msg)
|
||||
sys.stderr.write('\n')
|
||||
sys.exit(1)
|
||||
|
||||
def entry_get_version(entry):
|
||||
return int(entry['version'])
|
||||
|
||||
def get_ostree_option(optionstring):
|
||||
for o in optionstring.split():
|
||||
if o.startswith('ostree='):
|
||||
return o[8:]
|
||||
raise ValueError('ostree= not found')
|
||||
|
||||
entries = []
|
||||
syslinux_entries = []
|
||||
raise ValueError('ostree= not found in %r' % (optionstring,))
|
||||
|
||||
# Parse loader configs
|
||||
for fname in os.listdir(loaderpath):
|
||||
path = os.path.join(loaderpath, fname)
|
||||
with open(path) as f:
|
||||
|
||||
def parse_loader_configs(sysroot):
|
||||
loaderpath = sysroot + '/boot/loader/entries'
|
||||
entries = []
|
||||
|
||||
# Parse loader configs
|
||||
for fname in os.listdir(loaderpath):
|
||||
path = os.path.join(loaderpath, fname)
|
||||
entry = {}
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if (line == '' or line.startswith('#')):
|
||||
continue
|
||||
s = line.find(' ')
|
||||
assert s > 0
|
||||
k = line[0:s]
|
||||
v = line[s+1:]
|
||||
entry[k] = v
|
||||
with open(path) as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if (line == '' or line.startswith('#')):
|
||||
continue
|
||||
k, v = line.split(' ', 1)
|
||||
entry[k] = v
|
||||
entries.append(entry)
|
||||
entries.sort(key=entry_get_version, reverse=True)
|
||||
entries.sort(key=lambda e: int(e['version']), reverse=True)
|
||||
return entries
|
||||
|
||||
# Parse SYSLINUX config
|
||||
with open(syslinuxpath) as f:
|
||||
in_ostree_config = False
|
||||
syslinux_entry = None
|
||||
syslinux_default = None
|
||||
for line in f:
|
||||
try:
|
||||
k, v = line.strip().split(" ", 1)
|
||||
except ValueError:
|
||||
continue
|
||||
if k == 'DEFAULT':
|
||||
if syslinux_entry is not None:
|
||||
syslinux_default = v
|
||||
elif k == 'LABEL':
|
||||
if syslinux_entry is not None:
|
||||
syslinux_entries.append(syslinux_entry)
|
||||
syslinux_entry = {}
|
||||
syslinux_entry['title'] = v
|
||||
elif k == 'KERNEL':
|
||||
syslinux_entry['linux'] = v
|
||||
elif k == 'INITRD':
|
||||
syslinux_entry['initrd'] = v
|
||||
elif k == 'APPEND':
|
||||
syslinux_entry['options'] = v
|
||||
if syslinux_entry is not None:
|
||||
syslinux_entries.append(syslinux_entry)
|
||||
|
||||
if len(entries) != len(syslinux_entries):
|
||||
fatal("Found {0} loader entries, but {1} SYSLINUX entries\n".format(len(entries), len(syslinux_entries)))
|
||||
def validate_syslinux(sysroot):
|
||||
syslinuxpath = sysroot + '/boot/syslinux/syslinux.cfg'
|
||||
|
||||
entries = parse_loader_configs(sysroot)
|
||||
syslinux_entries = []
|
||||
|
||||
# Parse SYSLINUX config
|
||||
with open(syslinuxpath) as f:
|
||||
syslinux_entry = None
|
||||
for line in f:
|
||||
try:
|
||||
k, v = line.strip().split(" ", 1)
|
||||
except ValueError:
|
||||
continue
|
||||
if k == 'DEFAULT':
|
||||
if syslinux_entry is not None:
|
||||
syslinux_default = v
|
||||
elif k == 'LABEL':
|
||||
if syslinux_entry is not None:
|
||||
syslinux_entries.append(syslinux_entry)
|
||||
syslinux_entry = {}
|
||||
syslinux_entry['title'] = v
|
||||
elif k == 'KERNEL':
|
||||
syslinux_entry['linux'] = v
|
||||
elif k == 'INITRD':
|
||||
syslinux_entry['initrd'] = v
|
||||
elif k == 'APPEND':
|
||||
syslinux_entry['options'] = v
|
||||
if syslinux_entry is not None:
|
||||
syslinux_entries.append(syslinux_entry)
|
||||
|
||||
if len(entries) != len(syslinux_entries):
|
||||
fatal("Found {0} loader entries, but {1} SYSLINUX entries\n".format(
|
||||
len(entries), len(syslinux_entries)))
|
||||
|
||||
def assert_key_same_file(a, b, key):
|
||||
aval = a[key]
|
||||
bval = b[key]
|
||||
sys.stderr.write("aval: %r\nbval: %r\n" % (aval, bval))
|
||||
|
||||
# Paths in entries are always relative to /boot
|
||||
entry = os.stat(sysroot + "/boot" + aval)
|
||||
|
||||
# Syslinux entries can be relative to /boot (if it's on another filesystem)
|
||||
# or relative to / if /boot is on /.
|
||||
s1 = os.stat(sysroot + bval)
|
||||
s2 = os.stat(sysroot + "/boot" + bval)
|
||||
|
||||
# A symlink ensures that no matter what they point at the same file
|
||||
assert_eq(entry, s1)
|
||||
assert_eq(entry, s2)
|
||||
|
||||
for i, (entry, syslinuxentry) in enumerate(zip(entries, syslinux_entries)):
|
||||
assert_key_same_file(entry, syslinuxentry, 'linux')
|
||||
assert_key_same_file(entry, syslinuxentry, 'initrd')
|
||||
entry_ostree = get_ostree_option(entry['options'])
|
||||
syslinux_ostree = get_ostree_option(syslinuxentry['options'])
|
||||
if entry_ostree != syslinux_ostree:
|
||||
fatal("Mismatch on ostree option: {0} != {1}".format(
|
||||
entry_ostree, syslinux_ostree))
|
||||
|
||||
sys.stdout.write('SYSLINUX configuration validated\n')
|
||||
return 0
|
||||
|
||||
|
||||
def assert_eq(a, b):
|
||||
assert a == b, "%r == %r" % (a, b)
|
||||
|
||||
|
||||
def assert_key_same_file(a, b, key):
|
||||
aval = a[key]
|
||||
bval = b[key]
|
||||
sys.stderr.write("aval: %r\nbval: %r\n" % (aval, bval))
|
||||
|
||||
# Paths in entries are always relative to /boot
|
||||
entry = os.stat(sysroot + "/boot" + aval)
|
||||
|
||||
# Syslinux entries can be relative to /boot (if it's on another filesystem)
|
||||
# or relative to / if /boot is on /.
|
||||
s1 = os.stat(sysroot + bval)
|
||||
s2 = os.stat(sysroot + "/boot" + bval)
|
||||
|
||||
# A symlink ensures that no matter what they point at the same file
|
||||
assert_eq(entry, s1)
|
||||
assert_eq(entry, s2)
|
||||
|
||||
|
||||
for i,(entry,syslinuxentry) in enumerate(zip(entries, syslinux_entries)):
|
||||
assert_key_same_file(entry, syslinuxentry, 'linux')
|
||||
assert_key_same_file(entry, syslinuxentry, 'initrd')
|
||||
entry_ostree = get_ostree_option(entry['options'])
|
||||
syslinux_ostree = get_ostree_option(syslinuxentry['options'])
|
||||
if entry_ostree != syslinux_ostree:
|
||||
fatal("Mismatch on ostree option: {0} != {1}".format(entry_ostree, syslinux_ostree))
|
||||
|
||||
sys.stdout.write('SYSLINUX configuration validated\n')
|
||||
sys.exit(0)
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv))
|
||||
+21
-2
@@ -55,10 +55,10 @@ function verify_initial_contents() {
|
||||
}
|
||||
|
||||
if has_gpgme; then
|
||||
echo "1..35"
|
||||
echo "1..36"
|
||||
else
|
||||
# 3 tests needs GPG support
|
||||
echo "1..32"
|
||||
echo "1..33"
|
||||
fi
|
||||
|
||||
# Try both syntaxes
|
||||
@@ -381,6 +381,25 @@ assert_file_has_content err.txt "Upgrade.*is chronologically older"
|
||||
${CMD_PREFIX} ostree --repo=repo pull --timestamp-check-from-rev=${oldrev} origin main@${middlerev}
|
||||
echo "ok pull timestamp checking"
|
||||
|
||||
# test pull without override commit use summary, but with doesn't use summary
|
||||
# We temporarily replace summary with broken one to detect if it is used
|
||||
mv ostree-srv/gnomerepo/summary ostree-srv/gnomerepo/summary.backup
|
||||
echo "broken" > ostree-srv/gnomerepo/summary
|
||||
|
||||
repo_init --no-sign-verify
|
||||
rev=$(ostree --repo=ostree-srv/gnomerepo rev-parse main)
|
||||
# This will need summary, so will fail
|
||||
if ${CMD_PREFIX} ostree --repo=repo -v pull origin main; then
|
||||
assert_not_reached "Should have failed with broken summary"
|
||||
fi
|
||||
# This won't need summary so will not fail
|
||||
${CMD_PREFIX} ostree --repo=repo pull origin main@${rev}
|
||||
|
||||
# Restore summary
|
||||
mv ostree-srv/gnomerepo/summary.backup ostree-srv/gnomerepo/summary
|
||||
|
||||
echo "ok pull with override id doesn't use summary"
|
||||
|
||||
cd ${test_tmpdir}
|
||||
repo_init --no-sign-verify
|
||||
${CMD_PREFIX} ostree --repo=repo pull origin main
|
||||
|
||||
+47
-1
@@ -28,7 +28,7 @@ skip_without_user_xattrs
|
||||
bindatafiles="bash true ostree"
|
||||
morebindatafiles="false ls"
|
||||
|
||||
echo '1..12'
|
||||
echo '1..13'
|
||||
|
||||
mkdir repo
|
||||
ostree_repo_init repo --mode=archive
|
||||
@@ -90,6 +90,11 @@ ${CMD_PREFIX} ostree --repo=repo static-delta list | grep ${origrev} || exit 1
|
||||
${CMD_PREFIX} ostree --repo=repo prune
|
||||
${CMD_PREFIX} ostree --repo=repo static-delta list | grep ${origrev} || exit 1
|
||||
|
||||
${CMD_PREFIX} ostree --repo=repo static-delta reindex
|
||||
${CMD_PREFIX} ostree --repo=repo static-delta indexes | wc -l > indexcount
|
||||
assert_file_has_content indexcount "^1$"
|
||||
${CMD_PREFIX} ostree --repo=repo static-delta indexes | grep ${origrev} || exit 1
|
||||
|
||||
permuteDirectory 1 files
|
||||
${CMD_PREFIX} ostree --repo=repo commit -b test -s test --tree=dir=files
|
||||
|
||||
@@ -119,6 +124,12 @@ ${CMD_PREFIX} ostree --repo=repo static-delta generate --max-bsdiff-size=10000 -
|
||||
|
||||
${CMD_PREFIX} ostree --repo=repo static-delta list | grep ${origrev}-${newrev} || exit 1
|
||||
|
||||
${CMD_PREFIX} ostree --repo=repo static-delta reindex
|
||||
${CMD_PREFIX} ostree --repo=repo static-delta indexes | wc -l > indexcount
|
||||
assert_file_has_content indexcount "^2$"
|
||||
${CMD_PREFIX} ostree --repo=repo static-delta indexes | grep ${origrev} || exit 1
|
||||
${CMD_PREFIX} ostree --repo=repo static-delta indexes | grep ${newrev} || exit 1
|
||||
|
||||
if ${CMD_PREFIX} ostree --repo=repo static-delta generate --from=${origrev} --to=${newrev} --empty 2>>err.txt; then
|
||||
assert_not_reached "static-delta generate --from=${origrev} --empty unexpectedly succeeded"
|
||||
fi
|
||||
@@ -249,6 +260,41 @@ ${CMD_PREFIX} ostree --repo=repo2 ls ${samerev} >/dev/null
|
||||
|
||||
echo 'ok pull empty delta part'
|
||||
|
||||
rm -rf repo/delta-indexes
|
||||
${CMD_PREFIX} ostree --repo=repo summary -u
|
||||
${CMD_PREFIX} ostree summary -v --raw --repo=repo > summary.txt
|
||||
assert_file_has_content summary.txt "ostree\.static\-deltas"
|
||||
|
||||
${CMD_PREFIX} ostree --repo=repo config set core.no-deltas-in-summary true
|
||||
${CMD_PREFIX} ostree --repo=repo summary -u
|
||||
|
||||
${CMD_PREFIX} ostree summary -v --raw --repo=repo > summary.txt
|
||||
assert_not_file_has_content summary.txt "ostree\.static\-deltas"
|
||||
|
||||
rm -rf repo2
|
||||
mkdir repo2 && ostree_repo_init repo2 --mode=bare-user
|
||||
${CMD_PREFIX} ostree --repo=repo2 pull-local repo ${newrev}
|
||||
|
||||
rm -rf repo/delta-indexes
|
||||
if ${CMD_PREFIX} ostree --repo=repo2 pull-local --require-static-deltas repo ${samerev} &> no-delta.txt; then
|
||||
assert_not_reached "failing pull with --require-static-deltas unexpectedly succeeded"
|
||||
fi
|
||||
assert_file_has_content no-delta.txt "Static deltas required, but none found for"
|
||||
|
||||
${CMD_PREFIX} ostree --repo=repo static-delta reindex
|
||||
${CMD_PREFIX} ostree --repo=repo2 pull-local --require-static-deltas repo ${samerev}
|
||||
|
||||
${CMD_PREFIX} ostree --repo=repo2 fsck
|
||||
${CMD_PREFIX} ostree --repo=repo2 ls ${samerev} >/dev/null
|
||||
|
||||
${CMD_PREFIX} ostree --repo=repo config set core.no-deltas-in-summary false
|
||||
${CMD_PREFIX} ostree --repo=repo summary -u
|
||||
|
||||
${CMD_PREFIX} ostree summary -v --raw --repo=repo > summary.txt
|
||||
assert_file_has_content summary.txt "ostree\.static\-deltas"
|
||||
|
||||
echo 'ok pull delta part with delta index'
|
||||
|
||||
# Make a new branch to test "rebase deltas"
|
||||
echo otherbranch-content > files/otherbranch-content
|
||||
${CMD_PREFIX} ostree --repo=repo commit -b otherbranch --tree=dir=files
|
||||
|
||||
Executable
+66
@@ -0,0 +1,66 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright © 2020 Endless OS Foundation LLC
|
||||
#
|
||||
# SPDX-License-Identifier: LGPL-2.0+
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# Authors:
|
||||
# - Philip Withnall <pwithnall@endlessos.org>
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
. $(dirname $0)/libtest.sh
|
||||
|
||||
if ! has_gpgme; then
|
||||
echo "1..0 #SKIP no gpg support compiled in"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
|
||||
|
||||
echo "1..1"
|
||||
|
||||
setup_fake_remote_repo2 "archive" "${COMMIT_SIGN}"
|
||||
|
||||
# Create a few branches and update the summary file (and sign it)
|
||||
mkdir ${test_tmpdir}/ostree-srv/other-files
|
||||
cd ${test_tmpdir}/ostree-srv/other-files
|
||||
echo 'hello world another object' > hello-world
|
||||
${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo commit ${COMMIT_SIGN} -b other -s "A commit" -m "Another Commit body"
|
||||
|
||||
mkdir ${test_tmpdir}/ostree-srv/yet-other-files
|
||||
cd ${test_tmpdir}/ostree-srv/yet-other-files
|
||||
echo 'hello world yet another object' > yet-another-hello-world
|
||||
${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo commit ${COMMIT_SIGN} -b yet-another -s "A commit" -m "Another Commit body"
|
||||
|
||||
${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo summary -u ${COMMIT_SIGN}
|
||||
|
||||
# Test that pulling twice in a row doesn’t re-download the summary file or its signature
|
||||
cd ${test_tmpdir}
|
||||
rm -rf repo
|
||||
ostree_repo_init repo --mode=archive
|
||||
${OSTREE} --repo=repo remote add --set=gpg-verify-summary=true origin $(cat httpd-address)/ostree/gnomerepo
|
||||
${OSTREE} --repo=repo pull origin other
|
||||
assert_has_file repo/tmp/cache/summaries/origin
|
||||
assert_has_file repo/tmp/cache/summaries/origin.sig
|
||||
summary_inode="$(stat -c '%i' repo/tmp/cache/summaries/origin)"
|
||||
summary_sig_inode="$(stat -c '%i' repo/tmp/cache/summaries/origin.sig)"
|
||||
${OSTREE} --repo=repo pull origin other
|
||||
assert_streq "$(stat -c '%i' repo/tmp/cache/summaries/origin)" "${summary_inode}"
|
||||
assert_streq "$(stat -c '%i' repo/tmp/cache/summaries/origin.sig)" "${summary_sig_inode}"
|
||||
echo "ok pull caches the summary files"
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright © 2020 Endless OS Foundation LLC
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.0+
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Authors:
|
||||
* - Philip Withnall <pwithnall@endlessos.org>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "ostree-date-utils-private.h"
|
||||
|
||||
static void
|
||||
test_ostree_parse_rfc2616_date_time (void)
|
||||
{
|
||||
#if GLIB_CHECK_VERSION(2, 62, 0)
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
const struct
|
||||
{
|
||||
const char *rfc2616;
|
||||
const char *expected_iso8601; /* (nullable) if parsing is expected to fail */
|
||||
}
|
||||
tests[] =
|
||||
{
|
||||
{ "Wed, 21 Oct 2015 07:28:00 GMT", "2015-10-21T07:28:00Z" },
|
||||
{ "Wed, 21 Oct 2015 07:28:00", NULL }, /* too short */
|
||||
{ "Wed, 21 Oct 2015 07:28:00 CEST", NULL }, /* too long; not GMT */
|
||||
{ "Cat, 21 Oct 2015 07:28:00 GMT", NULL }, /* invalid day */
|
||||
{ "Wed 21 Oct 2015 07:28:00 GMT", NULL }, /* no comma */
|
||||
{ "Wed,21 Oct 2015 07:28:00 GMT ", NULL }, /* missing space */
|
||||
{ "Wed, xx Oct 2015 07:28:00 GMT", NULL }, /* no day-of-month */
|
||||
{ "Wed, 011Oct 2015 07:28:00 GMT", NULL }, /* overlong day-of-month */
|
||||
{ "Wed, 00 Oct 2015 07:28:00 GMT", NULL }, /* day-of-month underflow */
|
||||
{ "Wed, 32 Oct 2015 07:28:00 GMT", NULL }, /* day-of-month overflow */
|
||||
{ "Wed, 21,Oct 2015 07:28:00 GMT", NULL }, /* missing space */
|
||||
{ "Wed, 21 Cat 2015 07:28:00 GMT", NULL }, /* invalid month */
|
||||
{ "Wed, 21 Oct,2015 07:28:00 GMT", NULL }, /* missing space */
|
||||
{ "Wed, 21 Oct xxxx 07:28:00 GMT", NULL }, /* no year */
|
||||
{ "Wed, 21 Oct 0201507:28:00 GMT", NULL }, /* overlong year */
|
||||
{ "Wed, 21 Oct 0000 07:28:00 GMT", NULL }, /* year underflow */
|
||||
{ "Wed, 21 Oct 10000 07:28:00 GM", NULL }, /* year overflow */
|
||||
{ "Wed, 21 Oct 2015,07:28:00 GMT", NULL }, /* missing space */
|
||||
{ "Wed, 21 Oct 2015 07 28:00 GMT", NULL }, /* missing colon */
|
||||
{ "Wed, 21 Oct 2015 007:28:00 GM", NULL }, /* overlong hour */
|
||||
{ "Wed, 21 Oct 2015 xx:28:00 GMT", NULL }, /* missing hour */
|
||||
{ "Wed, 21 Oct 2015 -1:28:00 GMT", NULL }, /* hour underflow */
|
||||
{ "Wed, 21 Oct 2015 24:28:00 GMT", NULL }, /* hour overflow */
|
||||
{ "Wed, 21 Oct 2015 07:28 00 GMT", NULL }, /* missing colon */
|
||||
{ "Wed, 21 Oct 2015 07:028:00 GM", NULL }, /* overlong minute */
|
||||
{ "Wed, 21 Oct 2015 07:xx:00 GMT", NULL }, /* missing minute */
|
||||
{ "Wed, 21 Oct 2015 07:-1:00 GMT", NULL }, /* minute underflow */
|
||||
{ "Wed, 21 Oct 2015 07:60:00 GMT", NULL }, /* minute overflow */
|
||||
{ "Wed, 21 Oct 2015 07:28:00CEST", NULL }, /* missing space */
|
||||
{ "Wed, 21 Oct 2015 07:28:000 GM", NULL }, /* overlong second */
|
||||
{ "Wed, 21 Oct 2015 07:28:xx GMT", NULL }, /* missing second */
|
||||
{ "Wed, 21 Oct 2015 07:28:-1 GMT", NULL }, /* seconds underflow */
|
||||
{ "Wed, 21 Oct 2015 07:28:61 GMT", NULL }, /* seconds overflow */
|
||||
{ "Wed, 21 Oct 2015 07:28:00 UTC", NULL }, /* invalid timezone (only GMT is allowed) */
|
||||
{ "Thu, 01 Jan 1970 00:00:00 GMT", "1970-01-01T00:00:00Z" }, /* extreme but valid date */
|
||||
{ "Mon, 31 Dec 9999 23:59:59 GMT", "9999-12-31T23:59:59Z" }, /* extreme but valid date */
|
||||
};
|
||||
|
||||
for (gsize i = 0; i < G_N_ELEMENTS (tests); i++)
|
||||
{
|
||||
g_test_message ("Test %" G_GSIZE_FORMAT ": %s", i, tests[i].rfc2616);
|
||||
|
||||
/* Parse once with a trailing nul */
|
||||
g_autoptr(GDateTime) dt1 = _ostree_parse_rfc2616_date_time (tests[i].rfc2616, strlen (tests[i].rfc2616));
|
||||
if (tests[i].expected_iso8601 == NULL)
|
||||
g_assert_null (dt1);
|
||||
else
|
||||
{
|
||||
g_assert_nonnull (dt1);
|
||||
g_autofree char *iso8601 = g_date_time_format_iso8601 (dt1);
|
||||
g_assert_cmpstr (iso8601, ==, tests[i].expected_iso8601);
|
||||
}
|
||||
|
||||
/* And parse again with no trailing nul */
|
||||
g_autofree char *rfc2616_no_nul = g_malloc (strlen (tests[i].rfc2616));
|
||||
memcpy (rfc2616_no_nul, tests[i].rfc2616, strlen (tests[i].rfc2616));
|
||||
g_autoptr(GDateTime) dt2 = _ostree_parse_rfc2616_date_time (rfc2616_no_nul, strlen (tests[i].rfc2616));
|
||||
if (tests[i].expected_iso8601 == NULL)
|
||||
g_assert_null (dt2);
|
||||
else
|
||||
{
|
||||
g_assert_nonnull (dt2);
|
||||
g_autofree char *iso8601 = g_date_time_format_iso8601 (dt2);
|
||||
g_assert_cmpstr (iso8601, ==, tests[i].expected_iso8601);
|
||||
}
|
||||
}
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
#else
|
||||
/* GLib 2.62 is needed for g_date_time_format_iso8601(). */
|
||||
g_test_skip ("RFC 2616 date parsing test needs GLib ≥ 2.62.0");
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
g_test_add_func ("/ostree_parse_rfc2616_date_time", test_ostree_parse_rfc2616_date_time);
|
||||
return g_test_run ();
|
||||
}
|
||||
@@ -66,7 +66,7 @@ echo 'ok documented symbols'
|
||||
|
||||
# ONLY update this checksum in release commits!
|
||||
cat > released-sha256.txt <<EOF
|
||||
540ee37ff081a8649fd1b1fa3cf1b80f7b8abb01f6ba71eead0b3b828d6cb696 ${released_syms}
|
||||
3e677623543b7fdc57b0e3d9c66eb477105b014411259762a328c1b5e82068f0 ${released_syms}
|
||||
EOF
|
||||
sha256sum -c released-sha256.txt
|
||||
|
||||
|
||||
Reference in new issue
Block a user