Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Assert that byte-order is swapped on LE but not BE CPUs #1393

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Makefile-tests.am
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,13 @@ experimental_test_scripts = \
tests/test-summary-collections.sh \
tests/test-pull-collections.sh \
$(NULL)
test_extra_programs = $(NULL)
test_extra_programs = \
tests/get-byte-order \
$(NULL)

tests_get_byte_order_SOURCES = tests/get-byte-order.c
tests_get_byte_order_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS)
tests_get_byte_order_LDADD = $(GLIB_LIBS)

tests_repo_finder_mount_SOURCES = tests/repo-finder-mount.c
tests_repo_finder_mount_CFLAGS = $(common_tests_cflags)
Expand Down
14 changes: 13 additions & 1 deletion tests/basic-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -759,8 +759,20 @@ $OSTREE show --print-metadata-key=FOO test2 > test2-meta
assert_file_has_content test2-meta "BAR"
$OSTREE show --print-metadata-key=KITTENS test2 > test2-meta
assert_file_has_content test2-meta "CUTE"

$OSTREE show --print-metadata-key=SOMENUM test2 > test2-meta
assert_file_has_content test2-meta "uint64 3026418949592973312"
case "$("${test_builddir}/get-byte-order")" in
(4321)
assert_file_has_content test2-meta "uint64 42"
;;
(1234)
assert_file_has_content test2-meta "uint64 3026418949592973312"
;;
(*)
fatal "neither little-endian nor big-endian?"
;;
esac

$OSTREE show -B --print-metadata-key=SOMENUM test2 > test2-meta
assert_file_has_content test2-meta "uint64 42"
$OSTREE show --print-detached-metadata-key=SIGNATURE test2 > test2-meta
Expand Down
12 changes: 12 additions & 0 deletions tests/get-byte-order.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* Helper for OSTree tests: return host byte order */

#include "config.h"

#include <glib.h>

int
main (void)
{
g_print ("%d\n", G_BYTE_ORDER);
return 0;
}