summaryrefslogtreecommitdiffstats
path: root/tests/endians
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/endians175
1 files changed, 175 insertions, 0 deletions
diff --git a/tests/endians b/tests/endians
new file mode 100644
index 0000000..13f29f8
--- /dev/null
+++ b/tests/endians
@@ -0,0 +1,175 @@
+# -*- sh -*-
+# See LICENSE file for copyright and license details.
+
+check_endian () {
+ xvalue="$1"
+ text0="$2"
+ text1="$3"
+ textoff="$4"
+ bits="$5"
+ shift 5
+
+ sxvalue="$(printf '%s\n' "$xvalue" | sed 's/^0*//' | sed 's/^$/0/')"
+
+ test "$(to-tracer-endian.tu $text0 $textoff $bits $@)" = "$sxvalue"
+ test "$(to-tracer-endian.tu $text1 $textoff $bits $@)" = "$sxvalue"
+ test "$(to-tracee-endian.tu $xvalue $textoff $bits $@)" = "$text0 $text1"
+}
+
+check_endian0 () {
+ xvalue="$1"
+ text="$2"
+ textoff="$3"
+ bits="$4"
+ shift 4
+ check_endian $xvalue $text $text $textoff $bits $@
+}
+
+check_endian 0 00 FE 0 1 0
+check_endian 0 00 FD 1 1 0
+check_endian 0 00 FB 2 1 0
+check_endian 0 00 F7 3 1 0
+check_endian 0 00 EF 4 1 0
+check_endian 0 00 DF 5 1 0
+check_endian 0 00 BF 6 1 0
+check_endian 0 00 7F 7 1 0
+check_endian 0 0000 FFFE 8 1 0
+
+check_endian 1 01 FF 0 1 0
+check_endian 1 02 FF 1 1 0
+check_endian 1 04 FF 2 1 0
+check_endian 1 08 FF 3 1 0
+check_endian 1 10 FF 4 1 0
+check_endian 1 20 FF 5 1 0
+check_endian 1 40 FF 6 1 0
+check_endian 1 80 FF 7 1 0
+check_endian 1 0001 FFFF 8 1 0
+
+check_endian 0 00 F0 0 4 0
+check_endian 1 01 F1 0 4 0
+check_endian 2 02 F2 0 4 0
+check_endian 3 03 F3 0 4 0
+check_endian 4 04 F4 0 4 0
+check_endian 8 08 F8 0 4 0
+check_endian A 0A FA 0 4 0
+check_endian F 0F FF 0 4 0
+
+check_endian 0 00 E1 1 4 0
+check_endian 0 00 C3 2 4 0
+check_endian 0 00 87 3 4 0
+check_endian 0 00 0F 4 4 0
+check_endian F 1E FF 1 4 0
+check_endian F 3C FF 2 4 0
+check_endian F 78 FF 3 4 0
+check_endian F F0 FF 4 4 0
+check_endian 0 0000 1FFE 5 4 0
+check_endian F E001 FFFF 5 4 0
+check_endian 0 0000 3FFC 6 4 0
+check_endian F C003 FFFF 6 4 0
+
+check_endian0 00 00 0 8 0
+check_endian0 10 10 0 8 0
+check_endian0 01 01 0 8 0
+check_endian0 80 80 0 8 0
+check_endian0 08 08 0 8 0
+check_endian0 FF FF 0 8 0
+
+check_endian 00 0000 01FE 1 8 0
+check_endian FF FE01 FFFF 1 8 0
+
+check_endian 000 0000 00FE 0 9 0
+check_endian 1FF FF01 FFFF 0 9 0
+
+check_endian 000 0000 00FC 0 10 0
+check_endian 3FF FF03 FFFF 0 10 0
+
+check_endian 000 0000 01FC 1 9 0
+check_endian 1FF FE03 FFFF 1 9 0
+
+check_endian 000 0000 01F8 1 10 0
+check_endian 3FF FE07 FFFF 1 10 0
+
+check_endian0 0000 0000 0 16 8 0
+check_endian0 FFFF FFFF 0 16 8 0
+check_endian0 1234 1234 0 16 8 0
+check_endian0 0800 0800 0 16 8 0
+
+check_endian0 0000 0000 0 16 0 8
+check_endian0 FFFF FFFF 0 16 0 8
+check_endian0 1234 3412 0 16 0 8
+check_endian0 0800 0008 0 16 0 8
+
+check_endian0 0000 0000 0 16 0
+check_endian0 FFFF FFFF 0 16 0
+check_endian0 1234 3412 0 16 0
+check_endian0 0800 0008 0 16 0
+
+check_endian0 000000 000000 0 24 16 8 0
+check_endian0 FFFFFF FFFFFF 0 24 16 8 0
+check_endian0 160800 160800 0 24 16 8 0
+
+check_endian0 000000 000000 0 24 16 0 8
+check_endian0 FFFFFF FFFFFF 0 24 16 0 8
+check_endian0 160800 160008 0 24 16 0 8
+
+check_endian0 000000 000000 0 24 0 8 16
+check_endian0 FFFFFF FFFFFF 0 24 0 8 16
+check_endian0 160800 000816 0 24 0 8 16
+
+check_endian0 000000 000000 0 24 8 0 16
+check_endian0 FFFFFF FFFFFF 0 24 8 0 16
+check_endian0 160800 080016 0 24 8 0 16
+
+check_endian0 000000 000000 0 24 0 16 8
+check_endian0 FFFFFF FFFFFF 0 24 0 16 8
+check_endian0 160800 001608 0 24 0 16 8
+
+check_endian0 000000 000000 0 24 8 16 0
+check_endian0 FFFFFF FFFFFF 0 24 8 16 0
+check_endian0 160800 081600 0 24 8 16 0
+
+check_endian0 00000000 00000000 0 32 24 16 8 0
+check_endian0 FFFFFFFF FFFFFFFF 0 32 24 16 8 0
+check_endian0 12345678 12345678 0 32 24 16 8 0
+check_endian0 24160800 24160800 0 32 24 16 8 0
+
+check_endian0 00000000 00000000 0 32 8 0 24 16
+check_endian0 FFFFFFFF FFFFFFFF 0 32 8 0 24 16
+check_endian0 12345678 56781234 0 32 8 0 24 16
+check_endian0 24160800 08002416 0 32 8 0 24 16
+
+check_endian0 00000000 00000000 0 32 0 8 16 24
+check_endian0 FFFFFFFF FFFFFFFF 0 32 0 8 16 24
+check_endian0 12345678 78563412 0 32 0 8 16 24
+check_endian0 24160800 00081624 0 32 0 8 16 24
+
+check_endian0 00000000 00000000 0 32 0 16 8 24
+check_endian0 FFFFFFFF FFFFFFFF 0 32 0 16 8 24
+check_endian0 12345678 78345612 0 32 0 16 8 24
+check_endian0 24160800 00160824 0 32 0 16 8 24
+
+check_endian0 0000000000000000 0000000000000000 0 64 56 48 40 32 24 16 8 0
+check_endian0 FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF 0 64 56 48 40 32 24 16 8 0
+check_endian0 0123456789ABCDEF 0123456789ABCDEF 0 64 56 48 40 32 24 16 8 0
+check_endian0 5648403224160800 5648403224160800 0 64 56 48 40 32 24 16 8 0
+
+check_endian0 0000000000000000 0000000000000000 0 64 24 16 8 0 56 48 40 32
+check_endian0 FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF 0 64 24 16 8 0 56 48 40 32
+check_endian0 0123456789ABCDEF 89ABCDEF01234567 0 64 24 16 8 0 56 48 40 32
+check_endian0 5648403224160800 2416080056484032 0 64 24 16 8 0 56 48 40 32
+
+check_endian0 0000000000000000 0000000000000000 0 64 8 0 24 16 40 32 56 48
+check_endian0 FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF 0 64 8 0 24 16 40 32 56 48
+check_endian0 0123456789ABCDEF CDEF89AB45670123 0 64 8 0 24 16 40 32 56 48
+check_endian0 5648403224160800 0800241640325648 0 64 8 0 24 16 40 32 56 48
+
+check_endian0 0000000000000000 0000000000000000 0 64 0 8 16 24 32 40 48 56
+check_endian0 FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF 0 64 0 8 16 24 32 40 48 56
+check_endian0 0123456789ABCDEF EFCDAB8967452301 0 64 0 8 16 24 32 40 48 56
+check_endian0 5648403224160800 0008162432404856 0 64 0 8 16 24 32 40 48 56
+
+check_endian 000 0000 00FE 0 9 0 8
+check_endian 1FF FF01 FFFF 0 9 0 8
+
+check_endian 000 0000 FE00 0 9 8 0
+check_endian 1FF 01FF FFFF 0 9 8 0