summaryrefslogtreecommitdiffstats
path: root/tests/bits/bitrev_test.c
Commit message (Collapse)AuthorAgeFilesLines
* bitrev_test: don't omit last byte from test result checkNeels Hofmeyr2016-09-261-1/+4
| | | | | | | | | | | | | | The osmo_hexdump of the output in sh_chk() omitted the last byte of the returned bytes from the osmo_nibble_shift_*() functions. Determine the number of bytes from nibbles divided by two plus one for any odd nibble number. Output this number of bytes of output data. Memset the output buffer to get well-defined bytes for unwritten places. Also assert that we have enough buffer length for all nibbles. Change-Id: I011f42bca555caec0dfe8688ff1f28303fa04fad
* Fix ASAN failure in bitrev_testMax2016-09-261-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously while testing osmo_nibble_shift_left_unal() following error was triggered by AddressSanitizer upon offs == 12 and the last sh_chk line, i.e. shift left of 12 nibbles from in2: ==3890== ERROR: AddressSanitizer: stack-buffer-overflow on address 0xbff5b5b6 at pc 0xb6186862 bp 0xbff5b4a8 sp 0xbff5b49c READ of size 1 at 0xbff5b5b6 thread T0 #0 0xb6186861 (/home/msuraev/source/gsm/libosmocore/src/.libs/libosmocore.so.7.0.0+0xc861) #1 0x8049d8b (/home/msuraev/source/gsm/libosmocore/tests/bits/.libs/lt-bitrev_test+0x8049d8b) #2 0x804a9d1 (/home/msuraev/source/gsm/libosmocore/tests/bits/.libs/lt-bitrev_test+0x804a9d1) #3 0xb5fe3af2 (/lib/i386-linux-gnu/libc-2.19.so+0x19af2) #4 0x8048a30 (/home/msuraev/source/gsm/libosmocore/tests/bits/.libs/lt-bitrev_test+0x8048a30) Address 0xbff5b5b6 is located at offset 38 in frame <main> of T0's stack: This frame has 3 object(s): [32, 38) 'in2' [96, 104) 'out' [160, 168) 'in1' The reason is incorrect range in test cycle. Fix it and adjust test output accordingly. Tweaked-by: Neels Hofmeyr <nhofmeyr@sysmocom.de> Fixes: OW#1589 ("undefined behavior in libosmocore triggered by tests") Change-Id: I5eb3f600290c05b4ab9ac2450a28d616e6b415fd
* Add octet-aligned/unaligned shift functionsMax2016-06-201-0/+25
| | | | | | | | | The actual code is from OsmoBTS' tch.c by Harald Welte. Add unit tests, doxygen annotation and extra memory safety check. Those functions are used in several BTS implementations but seems generic enough to be generally useful. Change-Id: I2b1901c4161e8035f059585901dca593b661556d
* tests/bits: Make sure all 'inline' are also staticSylvain Munaut2014-06-161-17/+43
| | | | | | Not doing so seems to break the BSD build Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
* core: Add generic LE/BE load/store uint type convertors and use them in msgbMax2014-06-161-1/+217
| | | | | Submitted-by: Max <max.suraev@fairwaves.co> Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
* add functions for bit-reversalHarald Welte2011-09-011-0/+36
Sometimes we need stuff like reversing every bit in each byte (but not the byte-order).