summaryrefslogtreecommitdiffstats
path: root/tests/bits
Commit message (Collapse)AuthorAgeFilesLines
* tests: bitrev_test: Fix dynamic-stack-buffer-overflowPau Espin Pedrol2018-05-162-4/+3
| | | | | | | | | | | | | | | | | Fixes following AddressSanitizer report: ==1983==ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address 0x7ffc245f47e6 at pc 0x7f3e2deea68c bp 0x7ffc245f4750 sp 0x7ffc245f4740 WRITE of size 1 at 0x7ffc245f47e6 thread T0 #0 0x7f3e2deea68b in osmo_nibble_shift_right libosmocore/src/bits.c:92 #1 0x55c01902e1ab in sh_chk libosmocore/tests/bits/bitrev_test.c:215 #2 0x55c01902ed8f in main libosmocore/tests/bits/bitrev_test.c:305 #3 0x7f3e2c93006a in __libc_start_main (/usr/lib/libc.so.6+0x2306a) #4 0x55c01902c059 in _start (libosmocore/tests/bits/.libs/lt-bitrev_test+0x5059) This patch can be seen as a follow-up of commit 4fd6023b0383e7efa3b7b0211104a86ff5d3d4f6, which already fixed the left-shift case in the same way. Change-Id: I6e86d0164b7e982bf7b7449d5b3abfb3e1e5da46
* Add tests for bitvec_write_field()Max2017-10-242-0/+200
| | | | | | | | | | | | This function is actively used by OsmoPCU but have not been covered by tests so far. The test code is based on Minh-Quang Nguyen <minh-quang.nguyen@nutaq.com> submission with some modifications. The test's FIXME will be addressed in follow-up patches. Change-Id: I2ee544256b8675bc62a42493aab66a8eeee54f90 Related: OS#1526
* bitcomp: Remove the t4 decoding from libosmocoreHolger Hans Peter Freyther2016-11-102-22/+0
| | | | | | | | | | | | As outlined by mail on the 13th of July the tree based approach to decoding in the PCU is faster by order of magnitude. Instead of having a slow implementation in the library and a quick one in the PCU, let's only have a quick one in the PCU and at some point in the future move it to libosmocore. Execute the plan and remove t4_decode. Change-Id: I021424444625a097560d086c217c81eac4a5ee44
* bitrev_test: don't omit last byte from test result checkNeels Hofmeyr2016-09-262-25/+28
| | | | | | | | | | | | | | 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-262-3/+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-202-0/+130
| | | | | | | | | 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
* Add T4 bit map compression routinesMax2016-02-182-0/+95
| | | | | | | | | | | | | | | Add bit map encoder and decoder functions: decoder is fully functional while encoder is good enough for testing - no backtracking to find the best possible compression is implemented. If somebody is willing to implement MS side of EDGE than this has to be expanded. Add corresponding tests. N. B: the encoding is implemented according to ETSI TS 44.060 which is slightly different from T4 used for fax according to CCITT G31D (RFC 804). Ticket: OW#2407 Sponsored-by: On-Waves ehf Signed-off-by: Max <msuraev@sysmocom.de>
* 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-162-1/+248
| | | | | Submitted-by: Max <max.suraev@fairwaves.co> Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
* build: simplify test handling and speed up build.Diego Elio Pettenò2012-06-301-7/+0
| | | | | | | | | | | | Instead of using a ./configure parameter to decide whehter to build tests or not, use the check_PROGRAMS variable so that the tests are only built when running `make check`. To avoid slowing down the test phase itself, collapse the declaration of the test targets in the tests/Makefile.am file, this way they can be built and linked in parallel before the testsuite is executed. Signed-off-by: Diego Elio Pettenò <flameeyes@flameeyes.eu>
* tests: Fix the make distcheck of libosmocore with the testsHolger Hans Peter Freyther2011-11-141-0/+1
|
* tests: Use GNU autotest to execute our tests and compare textual outputHolger Hans Peter Freyther2011-11-141-0/+24
| | | | | | | | | | | | | The output of make check is looking like this now: Regression tests. 1: bits ok 2: msgfile ok 3: sms ok 4: smscb ok 5: timer FAILED (testsuite.at:38) 6: ussd FAILED (testsuite.at:44)
* add functions for bit-reversalHarald Welte2011-09-012-0/+42
Sometimes we need stuff like reversing every bit in each byte (but not the byte-order).