summaryrefslogtreecommitdiffstats
path: root/tests/helpers
diff options
context:
space:
mode:
authorKarel Zak2009-01-20 13:18:22 +0100
committerKarel Zak2009-02-11 23:32:58 +0100
commit1f943449548a81bb5c22c9ae29dcc8236d1a5ad3 (patch)
treefdaa52cf3b8b90d6c7c633e84e7026f21d4c27c8 /tests/helpers
parenttests: fix output string (diff)
downloadkernel-qcow2-util-linux-1f943449548a81bb5c22c9ae29dcc8236d1a5ad3.tar.gz
kernel-qcow2-util-linux-1f943449548a81bb5c22c9ae29dcc8236d1a5ad3.tar.xz
kernel-qcow2-util-linux-1f943449548a81bb5c22c9ae29dcc8236d1a5ad3.zip
tests: add "byte-order" to helpers/test_sysinfo
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'tests/helpers')
-rw-r--r--tests/helpers/test_sysinfo.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/helpers/test_sysinfo.c b/tests/helpers/test_sysinfo.c
index 4b71955c7..8ce1fe72d 100644
--- a/tests/helpers/test_sysinfo.c
+++ b/tests/helpers/test_sysinfo.c
@@ -18,9 +18,13 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-
+#include <endian.h>
#include <limits.h>
+#if !defined __BYTE_ORDER || !(__BYTE_ORDER == __LITTLE_ENDIAN) && !(__BYTE_ORDER == __BIG_ENDIAN)
+#error missing __BYTE_ORDER
+#endif
+
typedef struct {
const char *name;
int (*fnc)(void);
@@ -34,6 +38,18 @@ hlp_wordsize(void)
}
int
+hlp_endianness(void)
+{
+#if (__BYTE_ORDER == __LITTLE_ENDIAN)
+ printf("LE\n");
+#else
+ printf("BE\n");
+#endif
+ return 0;
+}
+
+
+int
hlp_pagesize(void)
{
printf("%d\n", getpagesize());
@@ -88,6 +104,7 @@ mntHlpfnc hlps[] =
{ "LONG_MAX", hlp_long_max },
{ "ULONG_MAX", hlp_ulong_max },
{ "ULONG_MAX32",hlp_ulong_max32 },
+ { "byte-order", hlp_endianness },
{ NULL, NULL }
};