mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-11 09:18:20 +03:00
Merge pull request #2923 from alexlarsson/fix-composefs-test
tests: Fix composefs test
This commit is contained in:
commit
5b7277513b
@ -35,6 +35,7 @@ static gboolean opt_list_metadata_keys;
|
||||
static gboolean opt_list_detached_metadata_keys;
|
||||
static gboolean opt_print_sizes;
|
||||
static gboolean opt_raw;
|
||||
static gboolean opt_print_hex;
|
||||
static gboolean opt_no_byteswap;
|
||||
static char *opt_gpg_homedir;
|
||||
static char *opt_gpg_verify_remote;
|
||||
@ -53,6 +54,15 @@ static GOptionEntry options[]
|
||||
"List the available metadata keys", NULL },
|
||||
{ "print-metadata-key", 0, 0, G_OPTION_ARG_STRING, &opt_print_metadata_key,
|
||||
"Print string value of metadata key", "KEY" },
|
||||
{
|
||||
"print-hex",
|
||||
0,
|
||||
0,
|
||||
G_OPTION_ARG_NONE,
|
||||
&opt_print_hex,
|
||||
"For byte array valued keys, output an unquoted hexadecimal string",
|
||||
NULL,
|
||||
},
|
||||
{ "list-detached-metadata-keys", 0, 0, G_OPTION_ARG_NONE, &opt_list_detached_metadata_keys,
|
||||
"List the available detached metadata keys", NULL },
|
||||
{ "print-detached-metadata-key", 0, 0, G_OPTION_ARG_STRING,
|
||||
@ -186,6 +196,14 @@ do_print_metadata_key (OstreeRepo *repo, const char *resolved_rev, gboolean deta
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (opt_print_hex && g_variant_is_of_type (value, (GVariantType *)"ay"))
|
||||
{
|
||||
g_autofree char *buf = g_malloc (g_variant_get_size (value) * 2 + 1);
|
||||
ot_bin2hex (buf, g_variant_get_data (value), g_variant_get_size (value));
|
||||
g_print ("%s\n", buf);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (opt_no_byteswap)
|
||||
{
|
||||
g_autofree char *formatted = g_variant_print (value, TRUE);
|
||||
|
@ -29,12 +29,16 @@ setup_test_repository "bare-user"
|
||||
|
||||
cd ${test_tmpdir}
|
||||
$OSTREE checkout test2 test2-co
|
||||
rm test2-co/whiteouts -rf # This may or may not exist
|
||||
COMMIT_ARGS="--owner-uid=0 --owner-gid=0 --no-xattrs --canonical-permissions"
|
||||
$OSTREE commit ${COMMIT_ARGS} -b test-composefs --generate-composefs-metadata test2-co
|
||||
orig_composefs_digest=$($OSTREE show --print-metadata-key ostree.composefs.v0 test-composefs)
|
||||
assert_streq "${orig_composefs_digest}" '[byte 0x1f, 0x08, 0xe5, 0x8b, 0x14, 0x3b, 0x75, 0x34, 0x76, 0xb5, 0xef, 0x0c, 0x0c, 0x6e, 0xce, 0xbf, 0xde, 0xbb, 0x6d, 0x40, 0x30, 0x5e, 0x35, 0xbd, 0x6f, 0x8e, 0xc1, 0x9c, 0xd0, 0xd1, 0x5b, 0xae]'
|
||||
# If the test fails we'll dump this out
|
||||
$OSTREE ls -RCX test-composefs /
|
||||
orig_composefs_digest=$($OSTREE show --print-hex --print-metadata-key ostree.composefs.digest.v0 test-composefs)
|
||||
$OSTREE commit ${COMMIT_ARGS} -b test-composefs2 --generate-composefs-metadata test2-co
|
||||
new_composefs_digest=$($OSTREE show --print-metadata-key ostree.composefs.v0 test-composefs)
|
||||
new_composefs_digest=$($OSTREE show --print-hex --print-metadata-key ostree.composefs.digest.v0 test-composefs2)
|
||||
assert_streq "${orig_composefs_digest}" "${new_composefs_digest}"
|
||||
assert_streq "${new_composefs_digest}" "4d97f295ac9d379b7b3c42ddec49cc55b570c5b8b2a6f3f835f473854b0ad0cd"
|
||||
tap_ok "composefs metadata"
|
||||
|
||||
tap_end
|
||||
|
Loading…
Reference in New Issue
Block a user