bitXXgen: add bitgen_test.c

The autogenerated bitXXgen.h headers for osmo_load16le_ext() thru
osmo_store64_be() are not actually tested at all. Add a test.

The test output shows that the osmo_load*be_ext for a shorter len do not return
nicely matching results. A practical example showing the difficulty in storing
and loading 24bit integer values as/from big-endian:

	uint8_t buf[4];
	memset(buf, 0, sizeof(buf));
	osmo_store32be_ext(0x00112233, buf, 3); // stores 11 22 33
	printf("%s\n", osmo_hexdump(buf, 4));
	uint32_t r = osmo_load32be_ext(buf, 3); // returns 0x11223300, not 0x00112233
	printf("0x%x\n", r);

output is:

	11 22 33 00
	0x11223300

In contrast, the little-endian variant properly aligns the loaded bytes on the
least significant octet:

	uint8_t buf[4];
	memset(buf, 0, sizeof(buf));
	osmo_store32le_ext(0x00112233, buf, 3); // stores 33 22 11
	printf("%s\n", osmo_hexdump(buf, 4));
	uint32_t r = osmo_load32le_ext(buf, 3); // returns 0x00112233 as expected
	printf("0x%x\n", r);

output for le is:

	33 22 11 00
	0x112233

Change-Id: I5542ace54376a206aa8574812d4c742c86c293b4
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 56d0ac5..7a0b4b1 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -37,6 +37,7 @@
                  gsm0502/gsm0502_test					\
                  dtx/dtx_gsm0503_test					\
                  i460_mux/i460_mux_test					\
+		 bitgen/bitgen_test					\
 		 $(NULL)
 
 if ENABLE_MSGFILE
@@ -277,6 +278,9 @@
 i460_mux_i460_mux_test_SOURCES = i460_mux/i460_mux_test.c
 i460_mux_i460_mux_test_LDADD = $(LDADD) $(top_builddir)/src/gsm/libosmogsm.la
 
+bitgen_bitgen_test_SOURCES = bitgen/bitgen_test.c
+bitgen_bitgen_test_LDADD = $(LDADD)
+
 # The `:;' works around a Bash 3.2 bug when the output is not writeable.
 $(srcdir)/package.m4: $(top_srcdir)/configure.ac
 	:;{ \
@@ -356,6 +360,7 @@
 	     dtx/dtx_gsm0503_test.ok \
 	     exec/exec_test.ok exec/exec_test.err \
 	     i460_mux/i460_mux_test.ok \
+	     bitgen/bitgen_test.ok \
 	     $(NULL)
 
 if ENABLE_LIBSCTP
diff --git a/tests/bitgen/bitgen_test.c b/tests/bitgen/bitgen_test.c
new file mode 100644
index 0000000..0c9821e
--- /dev/null
+++ b/tests/bitgen/bitgen_test.c
@@ -0,0 +1,60 @@
+#include <inttypes.h>
+#include <osmocom/core/bit16gen.h>
+#include <osmocom/core/bit32gen.h>
+#include <osmocom/core/bit64gen.h>
+
+#define DO_TEST(BE_LE, SIZE) do { \
+		int8_t len; \
+		printf("--- " #SIZE " " #BE_LE "\n"); \
+		for (len = SIZE / 8; len > 0; len--) { \
+			uint8_t buf[len * 2]; \
+			uint8_t at_idx; \
+			uint##SIZE##_t val = (uint##SIZE##_t)0x8877665544332211; \
+			\
+			for (at_idx = 0; at_idx < len; at_idx++) { \
+				uint##SIZE##_t read_val = 0; \
+				memset(buf, 0, sizeof(buf)); \
+				osmo_store##SIZE####BE_LE##_ext(val, &buf[at_idx], len); \
+				printf("osmo_store" #SIZE #BE_LE "_ext(0x%" PRIx##SIZE ", &buf[%d], %d) = %s\n", \
+				       val, \
+				       at_idx, len, osmo_hexdump(buf, sizeof(buf))); \
+				\
+				read_val = osmo_load##SIZE####BE_LE##_ext(&buf[at_idx], len); \
+				printf("osmo_load" #SIZE #BE_LE "_ext(&buf[%d], %d) = 0x%" PRIx##SIZE "\n", \
+				       at_idx, len, read_val); \
+			} \
+		} \
+	} while (0)
+
+
+int main(int argc, char **argv)
+{
+	DO_TEST(be, 16);
+	DO_TEST(le, 16);
+	DO_TEST(be, 32);
+	DO_TEST(le, 32);
+	DO_TEST(be, 64);
+	DO_TEST(le, 64);
+
+	{
+		printf("--- store/load 0x112233 as 24bit big-endian\n");
+		uint8_t buf[4];
+		memset(buf, 0, sizeof(buf));
+		osmo_store32be_ext(0x00112233, buf, 3); // stores 11 22 33
+		printf("%s\n", osmo_hexdump(buf, 4));
+		uint32_t r = osmo_load32be_ext(buf, 3); // returns 0x11223300, not 0x00112233
+		printf("0x%x\n", r);
+	}
+
+	{
+		printf("--- store/load 0x112233 as 24bit little-endian\n");
+		uint8_t buf[4];
+		memset(buf, 0, sizeof(buf));
+		osmo_store32le_ext(0x00112233, buf, 3); // stores 33 22 11
+		printf("%s\n", osmo_hexdump(buf, 4));
+		uint32_t r = osmo_load32le_ext(buf, 3); // returns 0x00112233
+		printf("0x%x\n", r);
+	}
+
+	return 0;
+}
diff --git a/tests/bitgen/bitgen_test.ok b/tests/bitgen/bitgen_test.ok
new file mode 100644
index 0000000..f89b66a
--- /dev/null
+++ b/tests/bitgen/bitgen_test.ok
@@ -0,0 +1,208 @@
+--- 16 be
+osmo_store16be_ext(0x2211, &buf[0], 2) = 22 11 00 00 
+osmo_load16be_ext(&buf[0], 2) = 0x2211
+osmo_store16be_ext(0x2211, &buf[1], 2) = 00 22 11 00 
+osmo_load16be_ext(&buf[1], 2) = 0x2211
+osmo_store16be_ext(0x2211, &buf[0], 1) = 11 00 
+osmo_load16be_ext(&buf[0], 1) = 0x1100
+--- 16 le
+osmo_store16le_ext(0x2211, &buf[0], 2) = 11 22 00 00 
+osmo_load16le_ext(&buf[0], 2) = 0x2211
+osmo_store16le_ext(0x2211, &buf[1], 2) = 00 11 22 00 
+osmo_load16le_ext(&buf[1], 2) = 0x2211
+osmo_store16le_ext(0x2211, &buf[0], 1) = 11 00 
+osmo_load16le_ext(&buf[0], 1) = 0x11
+--- 32 be
+osmo_store32be_ext(0x44332211, &buf[0], 4) = 44 33 22 11 00 00 00 00 
+osmo_load32be_ext(&buf[0], 4) = 0x44332211
+osmo_store32be_ext(0x44332211, &buf[1], 4) = 00 44 33 22 11 00 00 00 
+osmo_load32be_ext(&buf[1], 4) = 0x44332211
+osmo_store32be_ext(0x44332211, &buf[2], 4) = 00 00 44 33 22 11 00 00 
+osmo_load32be_ext(&buf[2], 4) = 0x44332211
+osmo_store32be_ext(0x44332211, &buf[3], 4) = 00 00 00 44 33 22 11 00 
+osmo_load32be_ext(&buf[3], 4) = 0x44332211
+osmo_store32be_ext(0x44332211, &buf[0], 3) = 33 22 11 00 00 00 
+osmo_load32be_ext(&buf[0], 3) = 0x33221100
+osmo_store32be_ext(0x44332211, &buf[1], 3) = 00 33 22 11 00 00 
+osmo_load32be_ext(&buf[1], 3) = 0x33221100
+osmo_store32be_ext(0x44332211, &buf[2], 3) = 00 00 33 22 11 00 
+osmo_load32be_ext(&buf[2], 3) = 0x33221100
+osmo_store32be_ext(0x44332211, &buf[0], 2) = 22 11 00 00 
+osmo_load32be_ext(&buf[0], 2) = 0x22110000
+osmo_store32be_ext(0x44332211, &buf[1], 2) = 00 22 11 00 
+osmo_load32be_ext(&buf[1], 2) = 0x22110000
+osmo_store32be_ext(0x44332211, &buf[0], 1) = 11 00 
+osmo_load32be_ext(&buf[0], 1) = 0x11000000
+--- 32 le
+osmo_store32le_ext(0x44332211, &buf[0], 4) = 11 22 33 44 00 00 00 00 
+osmo_load32le_ext(&buf[0], 4) = 0x44332211
+osmo_store32le_ext(0x44332211, &buf[1], 4) = 00 11 22 33 44 00 00 00 
+osmo_load32le_ext(&buf[1], 4) = 0x44332211
+osmo_store32le_ext(0x44332211, &buf[2], 4) = 00 00 11 22 33 44 00 00 
+osmo_load32le_ext(&buf[2], 4) = 0x44332211
+osmo_store32le_ext(0x44332211, &buf[3], 4) = 00 00 00 11 22 33 44 00 
+osmo_load32le_ext(&buf[3], 4) = 0x44332211
+osmo_store32le_ext(0x44332211, &buf[0], 3) = 11 22 33 00 00 00 
+osmo_load32le_ext(&buf[0], 3) = 0x332211
+osmo_store32le_ext(0x44332211, &buf[1], 3) = 00 11 22 33 00 00 
+osmo_load32le_ext(&buf[1], 3) = 0x332211
+osmo_store32le_ext(0x44332211, &buf[2], 3) = 00 00 11 22 33 00 
+osmo_load32le_ext(&buf[2], 3) = 0x332211
+osmo_store32le_ext(0x44332211, &buf[0], 2) = 11 22 00 00 
+osmo_load32le_ext(&buf[0], 2) = 0x2211
+osmo_store32le_ext(0x44332211, &buf[1], 2) = 00 11 22 00 
+osmo_load32le_ext(&buf[1], 2) = 0x2211
+osmo_store32le_ext(0x44332211, &buf[0], 1) = 11 00 
+osmo_load32le_ext(&buf[0], 1) = 0x11
+--- 64 be
+osmo_store64be_ext(0x8877665544332211, &buf[0], 8) = 88 77 66 55 44 33 22 11 00 00 00 00 00 00 00 00 
+osmo_load64be_ext(&buf[0], 8) = 0x8877665544332211
+osmo_store64be_ext(0x8877665544332211, &buf[1], 8) = 00 88 77 66 55 44 33 22 11 00 00 00 00 00 00 00 
+osmo_load64be_ext(&buf[1], 8) = 0x8877665544332211
+osmo_store64be_ext(0x8877665544332211, &buf[2], 8) = 00 00 88 77 66 55 44 33 22 11 00 00 00 00 00 00 
+osmo_load64be_ext(&buf[2], 8) = 0x8877665544332211
+osmo_store64be_ext(0x8877665544332211, &buf[3], 8) = 00 00 00 88 77 66 55 44 33 22 11 00 00 00 00 00 
+osmo_load64be_ext(&buf[3], 8) = 0x8877665544332211
+osmo_store64be_ext(0x8877665544332211, &buf[4], 8) = 00 00 00 00 88 77 66 55 44 33 22 11 00 00 00 00 
+osmo_load64be_ext(&buf[4], 8) = 0x8877665544332211
+osmo_store64be_ext(0x8877665544332211, &buf[5], 8) = 00 00 00 00 00 88 77 66 55 44 33 22 11 00 00 00 
+osmo_load64be_ext(&buf[5], 8) = 0x8877665544332211
+osmo_store64be_ext(0x8877665544332211, &buf[6], 8) = 00 00 00 00 00 00 88 77 66 55 44 33 22 11 00 00 
+osmo_load64be_ext(&buf[6], 8) = 0x8877665544332211
+osmo_store64be_ext(0x8877665544332211, &buf[7], 8) = 00 00 00 00 00 00 00 88 77 66 55 44 33 22 11 00 
+osmo_load64be_ext(&buf[7], 8) = 0x8877665544332211
+osmo_store64be_ext(0x8877665544332211, &buf[0], 7) = 77 66 55 44 33 22 11 00 00 00 00 00 00 00 
+osmo_load64be_ext(&buf[0], 7) = 0x7766554433221100
+osmo_store64be_ext(0x8877665544332211, &buf[1], 7) = 00 77 66 55 44 33 22 11 00 00 00 00 00 00 
+osmo_load64be_ext(&buf[1], 7) = 0x7766554433221100
+osmo_store64be_ext(0x8877665544332211, &buf[2], 7) = 00 00 77 66 55 44 33 22 11 00 00 00 00 00 
+osmo_load64be_ext(&buf[2], 7) = 0x7766554433221100
+osmo_store64be_ext(0x8877665544332211, &buf[3], 7) = 00 00 00 77 66 55 44 33 22 11 00 00 00 00 
+osmo_load64be_ext(&buf[3], 7) = 0x7766554433221100
+osmo_store64be_ext(0x8877665544332211, &buf[4], 7) = 00 00 00 00 77 66 55 44 33 22 11 00 00 00 
+osmo_load64be_ext(&buf[4], 7) = 0x7766554433221100
+osmo_store64be_ext(0x8877665544332211, &buf[5], 7) = 00 00 00 00 00 77 66 55 44 33 22 11 00 00 
+osmo_load64be_ext(&buf[5], 7) = 0x7766554433221100
+osmo_store64be_ext(0x8877665544332211, &buf[6], 7) = 00 00 00 00 00 00 77 66 55 44 33 22 11 00 
+osmo_load64be_ext(&buf[6], 7) = 0x7766554433221100
+osmo_store64be_ext(0x8877665544332211, &buf[0], 6) = 66 55 44 33 22 11 00 00 00 00 00 00 
+osmo_load64be_ext(&buf[0], 6) = 0x6655443322110000
+osmo_store64be_ext(0x8877665544332211, &buf[1], 6) = 00 66 55 44 33 22 11 00 00 00 00 00 
+osmo_load64be_ext(&buf[1], 6) = 0x6655443322110000
+osmo_store64be_ext(0x8877665544332211, &buf[2], 6) = 00 00 66 55 44 33 22 11 00 00 00 00 
+osmo_load64be_ext(&buf[2], 6) = 0x6655443322110000
+osmo_store64be_ext(0x8877665544332211, &buf[3], 6) = 00 00 00 66 55 44 33 22 11 00 00 00 
+osmo_load64be_ext(&buf[3], 6) = 0x6655443322110000
+osmo_store64be_ext(0x8877665544332211, &buf[4], 6) = 00 00 00 00 66 55 44 33 22 11 00 00 
+osmo_load64be_ext(&buf[4], 6) = 0x6655443322110000
+osmo_store64be_ext(0x8877665544332211, &buf[5], 6) = 00 00 00 00 00 66 55 44 33 22 11 00 
+osmo_load64be_ext(&buf[5], 6) = 0x6655443322110000
+osmo_store64be_ext(0x8877665544332211, &buf[0], 5) = 55 44 33 22 11 00 00 00 00 00 
+osmo_load64be_ext(&buf[0], 5) = 0x5544332211000000
+osmo_store64be_ext(0x8877665544332211, &buf[1], 5) = 00 55 44 33 22 11 00 00 00 00 
+osmo_load64be_ext(&buf[1], 5) = 0x5544332211000000
+osmo_store64be_ext(0x8877665544332211, &buf[2], 5) = 00 00 55 44 33 22 11 00 00 00 
+osmo_load64be_ext(&buf[2], 5) = 0x5544332211000000
+osmo_store64be_ext(0x8877665544332211, &buf[3], 5) = 00 00 00 55 44 33 22 11 00 00 
+osmo_load64be_ext(&buf[3], 5) = 0x5544332211000000
+osmo_store64be_ext(0x8877665544332211, &buf[4], 5) = 00 00 00 00 55 44 33 22 11 00 
+osmo_load64be_ext(&buf[4], 5) = 0x5544332211000000
+osmo_store64be_ext(0x8877665544332211, &buf[0], 4) = 44 33 22 11 00 00 00 00 
+osmo_load64be_ext(&buf[0], 4) = 0x4433221100000000
+osmo_store64be_ext(0x8877665544332211, &buf[1], 4) = 00 44 33 22 11 00 00 00 
+osmo_load64be_ext(&buf[1], 4) = 0x4433221100000000
+osmo_store64be_ext(0x8877665544332211, &buf[2], 4) = 00 00 44 33 22 11 00 00 
+osmo_load64be_ext(&buf[2], 4) = 0x4433221100000000
+osmo_store64be_ext(0x8877665544332211, &buf[3], 4) = 00 00 00 44 33 22 11 00 
+osmo_load64be_ext(&buf[3], 4) = 0x4433221100000000
+osmo_store64be_ext(0x8877665544332211, &buf[0], 3) = 33 22 11 00 00 00 
+osmo_load64be_ext(&buf[0], 3) = 0x3322110000000000
+osmo_store64be_ext(0x8877665544332211, &buf[1], 3) = 00 33 22 11 00 00 
+osmo_load64be_ext(&buf[1], 3) = 0x3322110000000000
+osmo_store64be_ext(0x8877665544332211, &buf[2], 3) = 00 00 33 22 11 00 
+osmo_load64be_ext(&buf[2], 3) = 0x3322110000000000
+osmo_store64be_ext(0x8877665544332211, &buf[0], 2) = 22 11 00 00 
+osmo_load64be_ext(&buf[0], 2) = 0x2211000000000000
+osmo_store64be_ext(0x8877665544332211, &buf[1], 2) = 00 22 11 00 
+osmo_load64be_ext(&buf[1], 2) = 0x2211000000000000
+osmo_store64be_ext(0x8877665544332211, &buf[0], 1) = 11 00 
+osmo_load64be_ext(&buf[0], 1) = 0x1100000000000000
+--- 64 le
+osmo_store64le_ext(0x8877665544332211, &buf[0], 8) = 11 22 33 44 55 66 77 88 00 00 00 00 00 00 00 00 
+osmo_load64le_ext(&buf[0], 8) = 0x8877665544332211
+osmo_store64le_ext(0x8877665544332211, &buf[1], 8) = 00 11 22 33 44 55 66 77 88 00 00 00 00 00 00 00 
+osmo_load64le_ext(&buf[1], 8) = 0x8877665544332211
+osmo_store64le_ext(0x8877665544332211, &buf[2], 8) = 00 00 11 22 33 44 55 66 77 88 00 00 00 00 00 00 
+osmo_load64le_ext(&buf[2], 8) = 0x8877665544332211
+osmo_store64le_ext(0x8877665544332211, &buf[3], 8) = 00 00 00 11 22 33 44 55 66 77 88 00 00 00 00 00 
+osmo_load64le_ext(&buf[3], 8) = 0x8877665544332211
+osmo_store64le_ext(0x8877665544332211, &buf[4], 8) = 00 00 00 00 11 22 33 44 55 66 77 88 00 00 00 00 
+osmo_load64le_ext(&buf[4], 8) = 0x8877665544332211
+osmo_store64le_ext(0x8877665544332211, &buf[5], 8) = 00 00 00 00 00 11 22 33 44 55 66 77 88 00 00 00 
+osmo_load64le_ext(&buf[5], 8) = 0x8877665544332211
+osmo_store64le_ext(0x8877665544332211, &buf[6], 8) = 00 00 00 00 00 00 11 22 33 44 55 66 77 88 00 00 
+osmo_load64le_ext(&buf[6], 8) = 0x8877665544332211
+osmo_store64le_ext(0x8877665544332211, &buf[7], 8) = 00 00 00 00 00 00 00 11 22 33 44 55 66 77 88 00 
+osmo_load64le_ext(&buf[7], 8) = 0x8877665544332211
+osmo_store64le_ext(0x8877665544332211, &buf[0], 7) = 11 22 33 44 55 66 77 00 00 00 00 00 00 00 
+osmo_load64le_ext(&buf[0], 7) = 0x77665544332211
+osmo_store64le_ext(0x8877665544332211, &buf[1], 7) = 00 11 22 33 44 55 66 77 00 00 00 00 00 00 
+osmo_load64le_ext(&buf[1], 7) = 0x77665544332211
+osmo_store64le_ext(0x8877665544332211, &buf[2], 7) = 00 00 11 22 33 44 55 66 77 00 00 00 00 00 
+osmo_load64le_ext(&buf[2], 7) = 0x77665544332211
+osmo_store64le_ext(0x8877665544332211, &buf[3], 7) = 00 00 00 11 22 33 44 55 66 77 00 00 00 00 
+osmo_load64le_ext(&buf[3], 7) = 0x77665544332211
+osmo_store64le_ext(0x8877665544332211, &buf[4], 7) = 00 00 00 00 11 22 33 44 55 66 77 00 00 00 
+osmo_load64le_ext(&buf[4], 7) = 0x77665544332211
+osmo_store64le_ext(0x8877665544332211, &buf[5], 7) = 00 00 00 00 00 11 22 33 44 55 66 77 00 00 
+osmo_load64le_ext(&buf[5], 7) = 0x77665544332211
+osmo_store64le_ext(0x8877665544332211, &buf[6], 7) = 00 00 00 00 00 00 11 22 33 44 55 66 77 00 
+osmo_load64le_ext(&buf[6], 7) = 0x77665544332211
+osmo_store64le_ext(0x8877665544332211, &buf[0], 6) = 11 22 33 44 55 66 00 00 00 00 00 00 
+osmo_load64le_ext(&buf[0], 6) = 0x665544332211
+osmo_store64le_ext(0x8877665544332211, &buf[1], 6) = 00 11 22 33 44 55 66 00 00 00 00 00 
+osmo_load64le_ext(&buf[1], 6) = 0x665544332211
+osmo_store64le_ext(0x8877665544332211, &buf[2], 6) = 00 00 11 22 33 44 55 66 00 00 00 00 
+osmo_load64le_ext(&buf[2], 6) = 0x665544332211
+osmo_store64le_ext(0x8877665544332211, &buf[3], 6) = 00 00 00 11 22 33 44 55 66 00 00 00 
+osmo_load64le_ext(&buf[3], 6) = 0x665544332211
+osmo_store64le_ext(0x8877665544332211, &buf[4], 6) = 00 00 00 00 11 22 33 44 55 66 00 00 
+osmo_load64le_ext(&buf[4], 6) = 0x665544332211
+osmo_store64le_ext(0x8877665544332211, &buf[5], 6) = 00 00 00 00 00 11 22 33 44 55 66 00 
+osmo_load64le_ext(&buf[5], 6) = 0x665544332211
+osmo_store64le_ext(0x8877665544332211, &buf[0], 5) = 11 22 33 44 55 00 00 00 00 00 
+osmo_load64le_ext(&buf[0], 5) = 0x5544332211
+osmo_store64le_ext(0x8877665544332211, &buf[1], 5) = 00 11 22 33 44 55 00 00 00 00 
+osmo_load64le_ext(&buf[1], 5) = 0x5544332211
+osmo_store64le_ext(0x8877665544332211, &buf[2], 5) = 00 00 11 22 33 44 55 00 00 00 
+osmo_load64le_ext(&buf[2], 5) = 0x5544332211
+osmo_store64le_ext(0x8877665544332211, &buf[3], 5) = 00 00 00 11 22 33 44 55 00 00 
+osmo_load64le_ext(&buf[3], 5) = 0x5544332211
+osmo_store64le_ext(0x8877665544332211, &buf[4], 5) = 00 00 00 00 11 22 33 44 55 00 
+osmo_load64le_ext(&buf[4], 5) = 0x5544332211
+osmo_store64le_ext(0x8877665544332211, &buf[0], 4) = 11 22 33 44 00 00 00 00 
+osmo_load64le_ext(&buf[0], 4) = 0x44332211
+osmo_store64le_ext(0x8877665544332211, &buf[1], 4) = 00 11 22 33 44 00 00 00 
+osmo_load64le_ext(&buf[1], 4) = 0x44332211
+osmo_store64le_ext(0x8877665544332211, &buf[2], 4) = 00 00 11 22 33 44 00 00 
+osmo_load64le_ext(&buf[2], 4) = 0x44332211
+osmo_store64le_ext(0x8877665544332211, &buf[3], 4) = 00 00 00 11 22 33 44 00 
+osmo_load64le_ext(&buf[3], 4) = 0x44332211
+osmo_store64le_ext(0x8877665544332211, &buf[0], 3) = 11 22 33 00 00 00 
+osmo_load64le_ext(&buf[0], 3) = 0x332211
+osmo_store64le_ext(0x8877665544332211, &buf[1], 3) = 00 11 22 33 00 00 
+osmo_load64le_ext(&buf[1], 3) = 0x332211
+osmo_store64le_ext(0x8877665544332211, &buf[2], 3) = 00 00 11 22 33 00 
+osmo_load64le_ext(&buf[2], 3) = 0x332211
+osmo_store64le_ext(0x8877665544332211, &buf[0], 2) = 11 22 00 00 
+osmo_load64le_ext(&buf[0], 2) = 0x2211
+osmo_store64le_ext(0x8877665544332211, &buf[1], 2) = 00 11 22 00 
+osmo_load64le_ext(&buf[1], 2) = 0x2211
+osmo_store64le_ext(0x8877665544332211, &buf[0], 1) = 11 00 
+osmo_load64le_ext(&buf[0], 1) = 0x11
+--- store/load 0x112233 as 24bit big-endian
+11 22 33 00 
+0x11223300
+--- store/load 0x112233 as 24bit little-endian
+33 22 11 00 
+0x112233
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 1955800..493c16f 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -396,3 +396,9 @@
 cat $abs_srcdir/i460_mux/i460_mux_test.ok > expout
 AT_CHECK([$abs_top_builddir/tests/i460_mux/i460_mux_test], [0], [expout], [ignore])
 AT_CLEANUP
+
+AT_SETUP([bitgen])
+AT_KEYWORDS([bitgen])
+cat $abs_srcdir/bitgen/bitgen_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/bitgen/bitgen_test], [0], [expout], [ignore])
+AT_CLEANUP