libosmocore/tests/utils/utils_test.ok

1022 lines
62 KiB
Plaintext
Raw Normal View History

Plain dump
00 01 02 03
00010203
Corner case
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54
000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfe
osmo_hexdump_buf(buf, sizeof(buf), data, 4, "[delim]", false)
= "00[delim]01[delim]02[delim]03"
osmo_hexdump_buf(buf, sizeof(buf), data, 4, "[delim]", true)
= "00[delim]01[delim]02[delim]03[delim]"
osmo_hexdump_buf(buf, 6, data, 4, "[delim]", false)
= ""
osmo_hexdump_buf(buf, 7, data, 4, "[delim]", false)
= ""
osmo_hexdump_buf(buf, 8, data, 4, "[delim]", false)
= ""
osmo_hexdump_buf(buf, 6, data, 4, "[delim]", true)
= ""
osmo_hexdump_buf(buf, 7, data, 4, "[delim]", true)
= ""
osmo_hexdump_buf(buf, 8, data, 4, "[delim]", true)
= ""
osmo_hexdump_buf(buf, sizeof(buf), data, 4, " ", false)
= "00 01 02 03"
osmo_hexdump_buf(buf, sizeof(buf), data, 4, " ", true)
= "00 01 02 03 "
osmo_hexdump_buf(buf, 6, data, 4, " ", false)
= "00 "
osmo_hexdump_buf(buf, 7, data, 4, " ", false)
= "00 01 "
osmo_hexdump_buf(buf, 8, data, 4, " ", false)
= "00 01 "
osmo_hexdump_buf(buf, 6, data, 4, " ", true)
= "00 "
osmo_hexdump_buf(buf, 7, data, 4, " ", true)
= "00 01 "
osmo_hexdump_buf(buf, 8, data, 4, " ", true)
= "00 01 "
osmo_hexdump_buf(buf, sizeof(buf), data, 4, ":", false)
= "00:01:02:03"
osmo_hexdump_buf(buf, sizeof(buf), data, 4, ":", true)
= "00:01:02:03:"
osmo_hexdump_buf(buf, 6, data, 4, ":", false)
= "00:"
osmo_hexdump_buf(buf, 7, data, 4, ":", false)
= "00:01:"
osmo_hexdump_buf(buf, 8, data, 4, ":", false)
= "00:01:"
osmo_hexdump_buf(buf, 6, data, 4, ":", true)
= "00:"
osmo_hexdump_buf(buf, 7, data, 4, ":", true)
= "00:01:"
osmo_hexdump_buf(buf, 8, data, 4, ":", true)
= "00:01:"
osmo_hexdump_buf(buf, sizeof(buf), data, 4, "::", false)
= "00::01::02::03"
osmo_hexdump_buf(buf, sizeof(buf), data, 4, "::", true)
= "00::01::02::03::"
osmo_hexdump_buf(buf, 6, data, 4, "::", false)
= "00::"
osmo_hexdump_buf(buf, 7, data, 4, "::", false)
= "00::"
osmo_hexdump_buf(buf, 8, data, 4, "::", false)
= "00::"
osmo_hexdump_buf(buf, 6, data, 4, "::", true)
= "00::"
osmo_hexdump_buf(buf, 7, data, 4, "::", true)
= "00::"
osmo_hexdump_buf(buf, 8, data, 4, "::", true)
= "00::"
osmo_hexdump_buf(buf, sizeof(buf), data, 4, "", false)
= "00010203"
osmo_hexdump_buf(buf, sizeof(buf), data, 4, "", true)
= "00010203"
osmo_hexdump_buf(buf, 6, data, 4, "", false)
= "0001"
osmo_hexdump_buf(buf, 7, data, 4, "", false)
= "000102"
osmo_hexdump_buf(buf, 8, data, 4, "", false)
= "000102"
osmo_hexdump_buf(buf, 6, data, 4, "", true)
= "0001"
osmo_hexdump_buf(buf, 7, data, 4, "", true)
= "000102"
osmo_hexdump_buf(buf, 8, data, 4, "", true)
= "000102"
osmo_hexdump_buf(buf, sizeof(buf), data, 4, NULL, false)
= "00010203"
osmo_hexdump_buf(buf, sizeof(buf), data, 4, NULL, true)
= "00010203"
osmo_hexdump_buf(buf, 6, data, 4, NULL, false)
= "0001"
osmo_hexdump_buf(buf, 7, data, 4, NULL, false)
= "000102"
osmo_hexdump_buf(buf, 8, data, 4, NULL, false)
= "000102"
osmo_hexdump_buf(buf, 6, data, 4, NULL, true)
= "0001"
osmo_hexdump_buf(buf, 7, data, 4, NULL, true)
= "000102"
osmo_hexdump_buf(buf, 8, data, 4, NULL, true)
= "000102"
Hexparse 0..255 in lower case
rc = 256
--> 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff
Hexparse 0..255 in upper case
rc = 256
--> 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff
Hexparse 0..255 in mixed case
rc = 256
--> 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff
Hexparse 0..255 with whitespace
rc = 256
--> 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff
Hexparse with buffer too short
rc = -1
Hexparse with uneven amount of digits
rc = -1
Hexparse with invalid char
rc = -1
Testing IPA CCM ID GET parsing
Testing IPA CCM ID RESP parsing
----- test_is_hexstr
0: pass str='(null)' min=0 max=10 even=0 expect=valid
1: pass str='(null)' min=1 max=10 even=0 expect=invalid
2: pass str='' min=0 max=10 even=0 expect=valid
3: pass str='' min=1 max=10 even=0 expect=invalid
4: pass str=' ' min=0 max=10 even=0 expect=invalid
5: pass str='1' min=0 max=10 even=0 expect=valid
6: pass str='1' min=1 max=10 even=0 expect=valid
7: pass str='1' min=1 max=10 even=1 expect=invalid
8: pass str='1' min=2 max=10 even=0 expect=invalid
9: pass str='123' min=1 max=10 even=0 expect=valid
10: pass str='123' min=1 max=10 even=1 expect=invalid
11: pass str='123' min=4 max=10 even=0 expect=invalid
12: pass str='1234' min=4 max=10 even=1 expect=valid
13: pass str='12345' min=4 max=10 even=1 expect=invalid
14: pass str='123456' min=4 max=10 even=1 expect=valid
15: pass str='1234567' min=4 max=10 even=1 expect=invalid
16: pass str='12345678' min=4 max=10 even=1 expect=valid
17: pass str='123456789' min=4 max=10 even=1 expect=invalid
18: pass str='123456789a' min=4 max=10 even=1 expect=valid
19: pass str='123456789ab' min=4 max=10 even=1 expect=invalid
20: pass str='123456789abc' min=4 max=10 even=1 expect=invalid
21: pass str='123456789ab' min=4 max=10 even=0 expect=invalid
22: pass str='123456789abc' min=4 max=10 even=0 expect=invalid
23: pass str='0123456789abcdefABCDEF' min=0 max=100 even=0 expect=valid
24: pass str='0123456789 abcdef ABCDEF' min=0 max=100 even=0 expect=invalid
25: pass str='foobar' min=0 max=100 even=0 expect=invalid
26: pass str='BeadedBeeAced1EbbedDefacedFacade' min=32 max=32 even=1 expect=valid
27: pass str='C01ffedC1cadaeAc1d1f1edAcac1aB0a' min=32 max=32 even=0 expect=valid
28: pass str='DeafBeddedBabeAcceededFadedDecaff' min=32 max=32 even=0 expect=invalid
Testing BCD conversion
val=0x0, expected=0, found=0
val=0x1, expected=1, found=1
val=0x2, expected=2, found=2
val=0x3, expected=3, found=3
val=0x4, expected=4, found=4
val=0x5, expected=5, found=5
val=0x6, expected=6, found=6
val=0x7, expected=7, found=7
val=0x8, expected=8, found=8
val=0x9, expected=9, found=9
val=0xa, expected=A, found=A
val=0xb, expected=B, found=B
val=0xc, expected=C, found=C
val=0xd, expected=D, found=D
val=0xe, expected=E, found=E
val=0xf, expected=F, found=F
Testing bcd to string conversion
- BCD-input='1a 32 54 76 98 f0' nibbles=[1..11[ str_size=64
rc=10
-> "1234567890"
add osmo_mobile_identity API Implement better API around 3GPP TS 24.008 Mobile Identity coding. struct osmo_mobile_identity is a decoded representation of the raw Mobile Identity, with a string representation as well as dedicated raw uint32_t TMSI. The aim is to remove all uncertainty about decoded buffer sizes / data types. I have patches ready for current osmo CNI programs, replacing the Mobile Identity coding with this new API. Deprecate the old MI API. osmo-bsc: I71c3b4c65dbfdfa51409e09d4868aea83225338a osmo-msc: Ic3f969e739654c1e8c387aedeeba5cce07fe2307 osmo-sgsn: I4cacb10bac419633ca0c14f244f9903f7f517b49 Note that some GPRS and SGs related coding is done here in libosmocore and hence currently remains using the old implementation (see previous version of this patch: Ic3f969e739654c1e8c387aedeeba5cce07fe2307). New API functions provide properly size-checking implementations of: - decoding a raw MI from a bunch of MI octets; - locating and decoding MI from a full 3GPP TS 24.008 Complete Layer 3 msgb; - encoding to a buffer; - encoding to the end of a msgb. Other than the old gsm48_generate_mid(), omit a TLV tag and length from encoding. Many callers manually stripped the tag and value after calling gsm48_generate_mid(). The aim is to leave writing a TL to the caller entirely, especially since some callers need to use a TvL, i.e. support a variable-size length of 8 or 16 bit. New validity checks so far not implemented anywhere else: - stricter validation of number of digits of IMSI, IMEI, IMEI-SV MI. - stricter on filler nibbles to be 0xf. As a result, applications using osmo_mobile_identity will be stricter in rejecting coding mistakes (some of which we currently have in our test suites, and which we'll need to fix). Rationale: While implementing osmo-bsc's MSC pooling feature in osmo-bsc, this API will be used to reduce the number of times a Mobile Identity is extracted from a raw RSL message. Extracting the Mobile Identity from messages has numerous duplicate implementations across our code with various levels of specialization. https://xkcd.com/927/ To name a few: - libosmocore: gsm48_mi_to_string(), osmo_mi_name_buf() - osmo-bsc: extract_sub() - osmo-msc: mm_rx_loc_upd_req(), cm_serv_reuse_conn(), gsm48_rx_mm_serv_req(), vlr_proc_acc_req() We have existing functions to produce a human readable string from a Mobile Identity, more or less awkward: - gsm48_mi_to_string() decodes a TMSI as a decimal number. These days we use hexadecimal TMSI everywhere. - osmo_mi_name_buf() decodes the BCD digits from a raw MI every time, so we'd need to pass around the raw message bytes. Also, osmo_mi_name_buf() has the wrong signature, it should return a length like snprintf(). - osmo-bsc's extract_sub() first uses gsm48_mi_to_string() which encodes the raw uint32_t TMSI to a string, and then calls strtoul() via tmsi_from_string() to code those back to a raw uint32_t. Each of the above implementations employ their own size overflow checks, each invoke osmo_bcd2str() and implement their own TMSI osmo_load32be() handling. Too much code dup, let's hope that each and every one is correct. In osmo-bsc, I am now implementing MSC pooling, and need to extract NRI bits from a TMSI Mobile Identity. Since none of the above functions are general enough to be re-used, I found myself again copy-pasting Mobile Identity code: locating the MI in a 24.008 message with proper size checks, decoding MI octets. This time I would like it to become a generally re-usable API. This patch was first merged as Ic3f969e739654c1e8c387aedeeba5cce07fe2307 and caused test fallout, because it re-implemented old API with the new stricter decoding. In this patch version, old API remains 1:1 unchanged to avoid such fallout. Applications will soon switch to the new osmo_mobile_identity API and become stricter on MI coding when that happens, not implicitly by a new libosmocore version. Change-Id: If4f7be606e54cfa1c59084cf169785b1cbda5cf5
2020-05-26 00:45:23 +00:00
osmo_str2bcd(start_nibble=1) -> rc=6
= 1f 32 54 76 98 f0
- BCD-input='1a 32 a4 cb 9d f0' nibbles=[1..11[ str_size=64
rc=-22
-> "1234ABCD90"
add osmo_mobile_identity API Implement better API around 3GPP TS 24.008 Mobile Identity coding. struct osmo_mobile_identity is a decoded representation of the raw Mobile Identity, with a string representation as well as dedicated raw uint32_t TMSI. The aim is to remove all uncertainty about decoded buffer sizes / data types. I have patches ready for current osmo CNI programs, replacing the Mobile Identity coding with this new API. Deprecate the old MI API. osmo-bsc: I71c3b4c65dbfdfa51409e09d4868aea83225338a osmo-msc: Ic3f969e739654c1e8c387aedeeba5cce07fe2307 osmo-sgsn: I4cacb10bac419633ca0c14f244f9903f7f517b49 Note that some GPRS and SGs related coding is done here in libosmocore and hence currently remains using the old implementation (see previous version of this patch: Ic3f969e739654c1e8c387aedeeba5cce07fe2307). New API functions provide properly size-checking implementations of: - decoding a raw MI from a bunch of MI octets; - locating and decoding MI from a full 3GPP TS 24.008 Complete Layer 3 msgb; - encoding to a buffer; - encoding to the end of a msgb. Other than the old gsm48_generate_mid(), omit a TLV tag and length from encoding. Many callers manually stripped the tag and value after calling gsm48_generate_mid(). The aim is to leave writing a TL to the caller entirely, especially since some callers need to use a TvL, i.e. support a variable-size length of 8 or 16 bit. New validity checks so far not implemented anywhere else: - stricter validation of number of digits of IMSI, IMEI, IMEI-SV MI. - stricter on filler nibbles to be 0xf. As a result, applications using osmo_mobile_identity will be stricter in rejecting coding mistakes (some of which we currently have in our test suites, and which we'll need to fix). Rationale: While implementing osmo-bsc's MSC pooling feature in osmo-bsc, this API will be used to reduce the number of times a Mobile Identity is extracted from a raw RSL message. Extracting the Mobile Identity from messages has numerous duplicate implementations across our code with various levels of specialization. https://xkcd.com/927/ To name a few: - libosmocore: gsm48_mi_to_string(), osmo_mi_name_buf() - osmo-bsc: extract_sub() - osmo-msc: mm_rx_loc_upd_req(), cm_serv_reuse_conn(), gsm48_rx_mm_serv_req(), vlr_proc_acc_req() We have existing functions to produce a human readable string from a Mobile Identity, more or less awkward: - gsm48_mi_to_string() decodes a TMSI as a decimal number. These days we use hexadecimal TMSI everywhere. - osmo_mi_name_buf() decodes the BCD digits from a raw MI every time, so we'd need to pass around the raw message bytes. Also, osmo_mi_name_buf() has the wrong signature, it should return a length like snprintf(). - osmo-bsc's extract_sub() first uses gsm48_mi_to_string() which encodes the raw uint32_t TMSI to a string, and then calls strtoul() via tmsi_from_string() to code those back to a raw uint32_t. Each of the above implementations employ their own size overflow checks, each invoke osmo_bcd2str() and implement their own TMSI osmo_load32be() handling. Too much code dup, let's hope that each and every one is correct. In osmo-bsc, I am now implementing MSC pooling, and need to extract NRI bits from a TMSI Mobile Identity. Since none of the above functions are general enough to be re-used, I found myself again copy-pasting Mobile Identity code: locating the MI in a 24.008 message with proper size checks, decoding MI octets. This time I would like it to become a generally re-usable API. This patch was first merged as Ic3f969e739654c1e8c387aedeeba5cce07fe2307 and caused test fallout, because it re-implemented old API with the new stricter decoding. In this patch version, old API remains 1:1 unchanged to avoid such fallout. Applications will soon switch to the new osmo_mobile_identity API and become stricter on MI coding when that happens, not implicitly by a new libosmocore version. Change-Id: If4f7be606e54cfa1c59084cf169785b1cbda5cf5
2020-05-26 00:45:23 +00:00
osmo_str2bcd(start_nibble=1) -> rc=-22
- BCD-input='1a 32 a4 cb 9d f0' nibbles=[1..11[ str_size=64
rc=10
-> "1234ABCD90"
add osmo_mobile_identity API Implement better API around 3GPP TS 24.008 Mobile Identity coding. struct osmo_mobile_identity is a decoded representation of the raw Mobile Identity, with a string representation as well as dedicated raw uint32_t TMSI. The aim is to remove all uncertainty about decoded buffer sizes / data types. I have patches ready for current osmo CNI programs, replacing the Mobile Identity coding with this new API. Deprecate the old MI API. osmo-bsc: I71c3b4c65dbfdfa51409e09d4868aea83225338a osmo-msc: Ic3f969e739654c1e8c387aedeeba5cce07fe2307 osmo-sgsn: I4cacb10bac419633ca0c14f244f9903f7f517b49 Note that some GPRS and SGs related coding is done here in libosmocore and hence currently remains using the old implementation (see previous version of this patch: Ic3f969e739654c1e8c387aedeeba5cce07fe2307). New API functions provide properly size-checking implementations of: - decoding a raw MI from a bunch of MI octets; - locating and decoding MI from a full 3GPP TS 24.008 Complete Layer 3 msgb; - encoding to a buffer; - encoding to the end of a msgb. Other than the old gsm48_generate_mid(), omit a TLV tag and length from encoding. Many callers manually stripped the tag and value after calling gsm48_generate_mid(). The aim is to leave writing a TL to the caller entirely, especially since some callers need to use a TvL, i.e. support a variable-size length of 8 or 16 bit. New validity checks so far not implemented anywhere else: - stricter validation of number of digits of IMSI, IMEI, IMEI-SV MI. - stricter on filler nibbles to be 0xf. As a result, applications using osmo_mobile_identity will be stricter in rejecting coding mistakes (some of which we currently have in our test suites, and which we'll need to fix). Rationale: While implementing osmo-bsc's MSC pooling feature in osmo-bsc, this API will be used to reduce the number of times a Mobile Identity is extracted from a raw RSL message. Extracting the Mobile Identity from messages has numerous duplicate implementations across our code with various levels of specialization. https://xkcd.com/927/ To name a few: - libosmocore: gsm48_mi_to_string(), osmo_mi_name_buf() - osmo-bsc: extract_sub() - osmo-msc: mm_rx_loc_upd_req(), cm_serv_reuse_conn(), gsm48_rx_mm_serv_req(), vlr_proc_acc_req() We have existing functions to produce a human readable string from a Mobile Identity, more or less awkward: - gsm48_mi_to_string() decodes a TMSI as a decimal number. These days we use hexadecimal TMSI everywhere. - osmo_mi_name_buf() decodes the BCD digits from a raw MI every time, so we'd need to pass around the raw message bytes. Also, osmo_mi_name_buf() has the wrong signature, it should return a length like snprintf(). - osmo-bsc's extract_sub() first uses gsm48_mi_to_string() which encodes the raw uint32_t TMSI to a string, and then calls strtoul() via tmsi_from_string() to code those back to a raw uint32_t. Each of the above implementations employ their own size overflow checks, each invoke osmo_bcd2str() and implement their own TMSI osmo_load32be() handling. Too much code dup, let's hope that each and every one is correct. In osmo-bsc, I am now implementing MSC pooling, and need to extract NRI bits from a TMSI Mobile Identity. Since none of the above functions are general enough to be re-used, I found myself again copy-pasting Mobile Identity code: locating the MI in a 24.008 message with proper size checks, decoding MI octets. This time I would like it to become a generally re-usable API. This patch was first merged as Ic3f969e739654c1e8c387aedeeba5cce07fe2307 and caused test fallout, because it re-implemented old API with the new stricter decoding. In this patch version, old API remains 1:1 unchanged to avoid such fallout. Applications will soon switch to the new osmo_mobile_identity API and become stricter on MI coding when that happens, not implicitly by a new libosmocore version. Change-Id: If4f7be606e54cfa1c59084cf169785b1cbda5cf5
2020-05-26 00:45:23 +00:00
osmo_str2bcd(start_nibble=1) -> rc=6
= 1f 32 a4 cb 9d f0
- BCD-input='1a 32 54 76 98 f0' nibbles=[1..12[ str_size=64
rc=-22
-> "1234567890F"
add osmo_mobile_identity API Implement better API around 3GPP TS 24.008 Mobile Identity coding. struct osmo_mobile_identity is a decoded representation of the raw Mobile Identity, with a string representation as well as dedicated raw uint32_t TMSI. The aim is to remove all uncertainty about decoded buffer sizes / data types. I have patches ready for current osmo CNI programs, replacing the Mobile Identity coding with this new API. Deprecate the old MI API. osmo-bsc: I71c3b4c65dbfdfa51409e09d4868aea83225338a osmo-msc: Ic3f969e739654c1e8c387aedeeba5cce07fe2307 osmo-sgsn: I4cacb10bac419633ca0c14f244f9903f7f517b49 Note that some GPRS and SGs related coding is done here in libosmocore and hence currently remains using the old implementation (see previous version of this patch: Ic3f969e739654c1e8c387aedeeba5cce07fe2307). New API functions provide properly size-checking implementations of: - decoding a raw MI from a bunch of MI octets; - locating and decoding MI from a full 3GPP TS 24.008 Complete Layer 3 msgb; - encoding to a buffer; - encoding to the end of a msgb. Other than the old gsm48_generate_mid(), omit a TLV tag and length from encoding. Many callers manually stripped the tag and value after calling gsm48_generate_mid(). The aim is to leave writing a TL to the caller entirely, especially since some callers need to use a TvL, i.e. support a variable-size length of 8 or 16 bit. New validity checks so far not implemented anywhere else: - stricter validation of number of digits of IMSI, IMEI, IMEI-SV MI. - stricter on filler nibbles to be 0xf. As a result, applications using osmo_mobile_identity will be stricter in rejecting coding mistakes (some of which we currently have in our test suites, and which we'll need to fix). Rationale: While implementing osmo-bsc's MSC pooling feature in osmo-bsc, this API will be used to reduce the number of times a Mobile Identity is extracted from a raw RSL message. Extracting the Mobile Identity from messages has numerous duplicate implementations across our code with various levels of specialization. https://xkcd.com/927/ To name a few: - libosmocore: gsm48_mi_to_string(), osmo_mi_name_buf() - osmo-bsc: extract_sub() - osmo-msc: mm_rx_loc_upd_req(), cm_serv_reuse_conn(), gsm48_rx_mm_serv_req(), vlr_proc_acc_req() We have existing functions to produce a human readable string from a Mobile Identity, more or less awkward: - gsm48_mi_to_string() decodes a TMSI as a decimal number. These days we use hexadecimal TMSI everywhere. - osmo_mi_name_buf() decodes the BCD digits from a raw MI every time, so we'd need to pass around the raw message bytes. Also, osmo_mi_name_buf() has the wrong signature, it should return a length like snprintf(). - osmo-bsc's extract_sub() first uses gsm48_mi_to_string() which encodes the raw uint32_t TMSI to a string, and then calls strtoul() via tmsi_from_string() to code those back to a raw uint32_t. Each of the above implementations employ their own size overflow checks, each invoke osmo_bcd2str() and implement their own TMSI osmo_load32be() handling. Too much code dup, let's hope that each and every one is correct. In osmo-bsc, I am now implementing MSC pooling, and need to extract NRI bits from a TMSI Mobile Identity. Since none of the above functions are general enough to be re-used, I found myself again copy-pasting Mobile Identity code: locating the MI in a 24.008 message with proper size checks, decoding MI octets. This time I would like it to become a generally re-usable API. This patch was first merged as Ic3f969e739654c1e8c387aedeeba5cce07fe2307 and caused test fallout, because it re-implemented old API with the new stricter decoding. In this patch version, old API remains 1:1 unchanged to avoid such fallout. Applications will soon switch to the new osmo_mobile_identity API and become stricter on MI coding when that happens, not implicitly by a new libosmocore version. Change-Id: If4f7be606e54cfa1c59084cf169785b1cbda5cf5
2020-05-26 00:45:23 +00:00
osmo_str2bcd(start_nibble=1) -> rc=-22
- BCD-input='1a 32 54 76 98 f0' nibbles=[1..12[ str_size=64
rc=11
-> "1234567890F"
add osmo_mobile_identity API Implement better API around 3GPP TS 24.008 Mobile Identity coding. struct osmo_mobile_identity is a decoded representation of the raw Mobile Identity, with a string representation as well as dedicated raw uint32_t TMSI. The aim is to remove all uncertainty about decoded buffer sizes / data types. I have patches ready for current osmo CNI programs, replacing the Mobile Identity coding with this new API. Deprecate the old MI API. osmo-bsc: I71c3b4c65dbfdfa51409e09d4868aea83225338a osmo-msc: Ic3f969e739654c1e8c387aedeeba5cce07fe2307 osmo-sgsn: I4cacb10bac419633ca0c14f244f9903f7f517b49 Note that some GPRS and SGs related coding is done here in libosmocore and hence currently remains using the old implementation (see previous version of this patch: Ic3f969e739654c1e8c387aedeeba5cce07fe2307). New API functions provide properly size-checking implementations of: - decoding a raw MI from a bunch of MI octets; - locating and decoding MI from a full 3GPP TS 24.008 Complete Layer 3 msgb; - encoding to a buffer; - encoding to the end of a msgb. Other than the old gsm48_generate_mid(), omit a TLV tag and length from encoding. Many callers manually stripped the tag and value after calling gsm48_generate_mid(). The aim is to leave writing a TL to the caller entirely, especially since some callers need to use a TvL, i.e. support a variable-size length of 8 or 16 bit. New validity checks so far not implemented anywhere else: - stricter validation of number of digits of IMSI, IMEI, IMEI-SV MI. - stricter on filler nibbles to be 0xf. As a result, applications using osmo_mobile_identity will be stricter in rejecting coding mistakes (some of which we currently have in our test suites, and which we'll need to fix). Rationale: While implementing osmo-bsc's MSC pooling feature in osmo-bsc, this API will be used to reduce the number of times a Mobile Identity is extracted from a raw RSL message. Extracting the Mobile Identity from messages has numerous duplicate implementations across our code with various levels of specialization. https://xkcd.com/927/ To name a few: - libosmocore: gsm48_mi_to_string(), osmo_mi_name_buf() - osmo-bsc: extract_sub() - osmo-msc: mm_rx_loc_upd_req(), cm_serv_reuse_conn(), gsm48_rx_mm_serv_req(), vlr_proc_acc_req() We have existing functions to produce a human readable string from a Mobile Identity, more or less awkward: - gsm48_mi_to_string() decodes a TMSI as a decimal number. These days we use hexadecimal TMSI everywhere. - osmo_mi_name_buf() decodes the BCD digits from a raw MI every time, so we'd need to pass around the raw message bytes. Also, osmo_mi_name_buf() has the wrong signature, it should return a length like snprintf(). - osmo-bsc's extract_sub() first uses gsm48_mi_to_string() which encodes the raw uint32_t TMSI to a string, and then calls strtoul() via tmsi_from_string() to code those back to a raw uint32_t. Each of the above implementations employ their own size overflow checks, each invoke osmo_bcd2str() and implement their own TMSI osmo_load32be() handling. Too much code dup, let's hope that each and every one is correct. In osmo-bsc, I am now implementing MSC pooling, and need to extract NRI bits from a TMSI Mobile Identity. Since none of the above functions are general enough to be re-used, I found myself again copy-pasting Mobile Identity code: locating the MI in a 24.008 message with proper size checks, decoding MI octets. This time I would like it to become a generally re-usable API. This patch was first merged as Ic3f969e739654c1e8c387aedeeba5cce07fe2307 and caused test fallout, because it re-implemented old API with the new stricter decoding. In this patch version, old API remains 1:1 unchanged to avoid such fallout. Applications will soon switch to the new osmo_mobile_identity API and become stricter on MI coding when that happens, not implicitly by a new libosmocore version. Change-Id: If4f7be606e54cfa1c59084cf169785b1cbda5cf5
2020-05-26 00:45:23 +00:00
osmo_str2bcd(start_nibble=1) -> rc=6
= 1f 32 54 76 98 f0
- BCD-input='1a 32 54 76 98 f0' nibbles=[0..12[ str_size=64
rc=12
-> "A1234567890F"
add osmo_mobile_identity API Implement better API around 3GPP TS 24.008 Mobile Identity coding. struct osmo_mobile_identity is a decoded representation of the raw Mobile Identity, with a string representation as well as dedicated raw uint32_t TMSI. The aim is to remove all uncertainty about decoded buffer sizes / data types. I have patches ready for current osmo CNI programs, replacing the Mobile Identity coding with this new API. Deprecate the old MI API. osmo-bsc: I71c3b4c65dbfdfa51409e09d4868aea83225338a osmo-msc: Ic3f969e739654c1e8c387aedeeba5cce07fe2307 osmo-sgsn: I4cacb10bac419633ca0c14f244f9903f7f517b49 Note that some GPRS and SGs related coding is done here in libosmocore and hence currently remains using the old implementation (see previous version of this patch: Ic3f969e739654c1e8c387aedeeba5cce07fe2307). New API functions provide properly size-checking implementations of: - decoding a raw MI from a bunch of MI octets; - locating and decoding MI from a full 3GPP TS 24.008 Complete Layer 3 msgb; - encoding to a buffer; - encoding to the end of a msgb. Other than the old gsm48_generate_mid(), omit a TLV tag and length from encoding. Many callers manually stripped the tag and value after calling gsm48_generate_mid(). The aim is to leave writing a TL to the caller entirely, especially since some callers need to use a TvL, i.e. support a variable-size length of 8 or 16 bit. New validity checks so far not implemented anywhere else: - stricter validation of number of digits of IMSI, IMEI, IMEI-SV MI. - stricter on filler nibbles to be 0xf. As a result, applications using osmo_mobile_identity will be stricter in rejecting coding mistakes (some of which we currently have in our test suites, and which we'll need to fix). Rationale: While implementing osmo-bsc's MSC pooling feature in osmo-bsc, this API will be used to reduce the number of times a Mobile Identity is extracted from a raw RSL message. Extracting the Mobile Identity from messages has numerous duplicate implementations across our code with various levels of specialization. https://xkcd.com/927/ To name a few: - libosmocore: gsm48_mi_to_string(), osmo_mi_name_buf() - osmo-bsc: extract_sub() - osmo-msc: mm_rx_loc_upd_req(), cm_serv_reuse_conn(), gsm48_rx_mm_serv_req(), vlr_proc_acc_req() We have existing functions to produce a human readable string from a Mobile Identity, more or less awkward: - gsm48_mi_to_string() decodes a TMSI as a decimal number. These days we use hexadecimal TMSI everywhere. - osmo_mi_name_buf() decodes the BCD digits from a raw MI every time, so we'd need to pass around the raw message bytes. Also, osmo_mi_name_buf() has the wrong signature, it should return a length like snprintf(). - osmo-bsc's extract_sub() first uses gsm48_mi_to_string() which encodes the raw uint32_t TMSI to a string, and then calls strtoul() via tmsi_from_string() to code those back to a raw uint32_t. Each of the above implementations employ their own size overflow checks, each invoke osmo_bcd2str() and implement their own TMSI osmo_load32be() handling. Too much code dup, let's hope that each and every one is correct. In osmo-bsc, I am now implementing MSC pooling, and need to extract NRI bits from a TMSI Mobile Identity. Since none of the above functions are general enough to be re-used, I found myself again copy-pasting Mobile Identity code: locating the MI in a 24.008 message with proper size checks, decoding MI octets. This time I would like it to become a generally re-usable API. This patch was first merged as Ic3f969e739654c1e8c387aedeeba5cce07fe2307 and caused test fallout, because it re-implemented old API with the new stricter decoding. In this patch version, old API remains 1:1 unchanged to avoid such fallout. Applications will soon switch to the new osmo_mobile_identity API and become stricter on MI coding when that happens, not implicitly by a new libosmocore version. Change-Id: If4f7be606e54cfa1c59084cf169785b1cbda5cf5
2020-05-26 00:45:23 +00:00
osmo_str2bcd(start_nibble=0) -> rc=6
= 1a 32 54 76 98 f0
- BCD-input='1a 32 54 76 98 f0' nibbles=[1..12[ str_size=5
rc=11
-> "1234"
add osmo_mobile_identity API Implement better API around 3GPP TS 24.008 Mobile Identity coding. struct osmo_mobile_identity is a decoded representation of the raw Mobile Identity, with a string representation as well as dedicated raw uint32_t TMSI. The aim is to remove all uncertainty about decoded buffer sizes / data types. I have patches ready for current osmo CNI programs, replacing the Mobile Identity coding with this new API. Deprecate the old MI API. osmo-bsc: I71c3b4c65dbfdfa51409e09d4868aea83225338a osmo-msc: Ic3f969e739654c1e8c387aedeeba5cce07fe2307 osmo-sgsn: I4cacb10bac419633ca0c14f244f9903f7f517b49 Note that some GPRS and SGs related coding is done here in libosmocore and hence currently remains using the old implementation (see previous version of this patch: Ic3f969e739654c1e8c387aedeeba5cce07fe2307). New API functions provide properly size-checking implementations of: - decoding a raw MI from a bunch of MI octets; - locating and decoding MI from a full 3GPP TS 24.008 Complete Layer 3 msgb; - encoding to a buffer; - encoding to the end of a msgb. Other than the old gsm48_generate_mid(), omit a TLV tag and length from encoding. Many callers manually stripped the tag and value after calling gsm48_generate_mid(). The aim is to leave writing a TL to the caller entirely, especially since some callers need to use a TvL, i.e. support a variable-size length of 8 or 16 bit. New validity checks so far not implemented anywhere else: - stricter validation of number of digits of IMSI, IMEI, IMEI-SV MI. - stricter on filler nibbles to be 0xf. As a result, applications using osmo_mobile_identity will be stricter in rejecting coding mistakes (some of which we currently have in our test suites, and which we'll need to fix). Rationale: While implementing osmo-bsc's MSC pooling feature in osmo-bsc, this API will be used to reduce the number of times a Mobile Identity is extracted from a raw RSL message. Extracting the Mobile Identity from messages has numerous duplicate implementations across our code with various levels of specialization. https://xkcd.com/927/ To name a few: - libosmocore: gsm48_mi_to_string(), osmo_mi_name_buf() - osmo-bsc: extract_sub() - osmo-msc: mm_rx_loc_upd_req(), cm_serv_reuse_conn(), gsm48_rx_mm_serv_req(), vlr_proc_acc_req() We have existing functions to produce a human readable string from a Mobile Identity, more or less awkward: - gsm48_mi_to_string() decodes a TMSI as a decimal number. These days we use hexadecimal TMSI everywhere. - osmo_mi_name_buf() decodes the BCD digits from a raw MI every time, so we'd need to pass around the raw message bytes. Also, osmo_mi_name_buf() has the wrong signature, it should return a length like snprintf(). - osmo-bsc's extract_sub() first uses gsm48_mi_to_string() which encodes the raw uint32_t TMSI to a string, and then calls strtoul() via tmsi_from_string() to code those back to a raw uint32_t. Each of the above implementations employ their own size overflow checks, each invoke osmo_bcd2str() and implement their own TMSI osmo_load32be() handling. Too much code dup, let's hope that each and every one is correct. In osmo-bsc, I am now implementing MSC pooling, and need to extract NRI bits from a TMSI Mobile Identity. Since none of the above functions are general enough to be re-used, I found myself again copy-pasting Mobile Identity code: locating the MI in a 24.008 message with proper size checks, decoding MI octets. This time I would like it to become a generally re-usable API. This patch was first merged as Ic3f969e739654c1e8c387aedeeba5cce07fe2307 and caused test fallout, because it re-implemented old API with the new stricter decoding. In this patch version, old API remains 1:1 unchanged to avoid such fallout. Applications will soon switch to the new osmo_mobile_identity API and become stricter on MI coding when that happens, not implicitly by a new libosmocore version. Change-Id: If4f7be606e54cfa1c59084cf169785b1cbda5cf5
2020-05-26 00:45:23 +00:00
osmo_str2bcd(start_nibble=1) -> rc=3
= 1f 32 f4
- BCD-input='' nibbles=[1..1[ str_size=64
rc=0
-> ""
add osmo_mobile_identity API Implement better API around 3GPP TS 24.008 Mobile Identity coding. struct osmo_mobile_identity is a decoded representation of the raw Mobile Identity, with a string representation as well as dedicated raw uint32_t TMSI. The aim is to remove all uncertainty about decoded buffer sizes / data types. I have patches ready for current osmo CNI programs, replacing the Mobile Identity coding with this new API. Deprecate the old MI API. osmo-bsc: I71c3b4c65dbfdfa51409e09d4868aea83225338a osmo-msc: Ic3f969e739654c1e8c387aedeeba5cce07fe2307 osmo-sgsn: I4cacb10bac419633ca0c14f244f9903f7f517b49 Note that some GPRS and SGs related coding is done here in libosmocore and hence currently remains using the old implementation (see previous version of this patch: Ic3f969e739654c1e8c387aedeeba5cce07fe2307). New API functions provide properly size-checking implementations of: - decoding a raw MI from a bunch of MI octets; - locating and decoding MI from a full 3GPP TS 24.008 Complete Layer 3 msgb; - encoding to a buffer; - encoding to the end of a msgb. Other than the old gsm48_generate_mid(), omit a TLV tag and length from encoding. Many callers manually stripped the tag and value after calling gsm48_generate_mid(). The aim is to leave writing a TL to the caller entirely, especially since some callers need to use a TvL, i.e. support a variable-size length of 8 or 16 bit. New validity checks so far not implemented anywhere else: - stricter validation of number of digits of IMSI, IMEI, IMEI-SV MI. - stricter on filler nibbles to be 0xf. As a result, applications using osmo_mobile_identity will be stricter in rejecting coding mistakes (some of which we currently have in our test suites, and which we'll need to fix). Rationale: While implementing osmo-bsc's MSC pooling feature in osmo-bsc, this API will be used to reduce the number of times a Mobile Identity is extracted from a raw RSL message. Extracting the Mobile Identity from messages has numerous duplicate implementations across our code with various levels of specialization. https://xkcd.com/927/ To name a few: - libosmocore: gsm48_mi_to_string(), osmo_mi_name_buf() - osmo-bsc: extract_sub() - osmo-msc: mm_rx_loc_upd_req(), cm_serv_reuse_conn(), gsm48_rx_mm_serv_req(), vlr_proc_acc_req() We have existing functions to produce a human readable string from a Mobile Identity, more or less awkward: - gsm48_mi_to_string() decodes a TMSI as a decimal number. These days we use hexadecimal TMSI everywhere. - osmo_mi_name_buf() decodes the BCD digits from a raw MI every time, so we'd need to pass around the raw message bytes. Also, osmo_mi_name_buf() has the wrong signature, it should return a length like snprintf(). - osmo-bsc's extract_sub() first uses gsm48_mi_to_string() which encodes the raw uint32_t TMSI to a string, and then calls strtoul() via tmsi_from_string() to code those back to a raw uint32_t. Each of the above implementations employ their own size overflow checks, each invoke osmo_bcd2str() and implement their own TMSI osmo_load32be() handling. Too much code dup, let's hope that each and every one is correct. In osmo-bsc, I am now implementing MSC pooling, and need to extract NRI bits from a TMSI Mobile Identity. Since none of the above functions are general enough to be re-used, I found myself again copy-pasting Mobile Identity code: locating the MI in a 24.008 message with proper size checks, decoding MI octets. This time I would like it to become a generally re-usable API. This patch was first merged as Ic3f969e739654c1e8c387aedeeba5cce07fe2307 and caused test fallout, because it re-implemented old API with the new stricter decoding. In this patch version, old API remains 1:1 unchanged to avoid such fallout. Applications will soon switch to the new osmo_mobile_identity API and become stricter on MI coding when that happens, not implicitly by a new libosmocore version. Change-Id: If4f7be606e54cfa1c59084cf169785b1cbda5cf5
2020-05-26 00:45:23 +00:00
osmo_str2bcd(start_nibble=1) -> rc=1
= ff
- zero output buffer
bcd2str(NULL, ...) -> -12
bcd2str(dst, 0, ...) -> -12
add osmo_escape_cstr and osmo_quote_cstr Provide string escaping that - returns the required buffer size, so it can be used with OSMO_STRBUF_APPEND(). - uses C compatible string constant escaping sequences. This is intended as a replacement for all previous osmo_escape_str* and osmo_quote_str* API. It pains me that I didn't get them right the first nor the second time: - The buffer functions do not return the chars needed, which is required for allocating sufficient memory in the *_c versions of the functions. - Because of that, these functions are accurately usable for OSMO_STRBUF_APPEND(), producing truncated strings, for example when dumping a GSUP message. - They do not use the C equivalent string constant escaping: for some reason I thought "\15" would be valid, but it should be "\x0f". If I could, I would completely drop those mislead implementations ... but backwards compat prohibits that. A previous patch already provided internal static functions that accurately return the required buffer size. Enhance these to also support C compatible string escaping, and use them as implementation of the new functions: osmo_escape_cstr_buf() osmo_escape_cstr_c() osmo_quote_cstr_buf() osmo_quote_cstr_c() In the tests for these, also test C string equivalence. Naming: from API versions, it would be kind of logical to call them osmo_escape_str_buf3() and osmo_escape_str_c2(). Since these anyway return a different escaping, it makes sense to me to have distinct names instead. Quasi missing are variants of the non-C-compatible weird legacy escaping that return the required buffer size, but I refrain from adding those, because we have enough API cruft as it is. Just always use these new cstr variants. Change-Id: I3dfb892036e01000033dd8e7e4a6a0c32a3caa9b
2019-11-20 23:12:10 +00:00
Testing string escaping: osmo_escape_str()
- all chars from 0 to 255 in batches of 16:
"\0\1\2\3\4\5\6\a\b\t\n\v\f\r\14\15"
"\16\17\18\19\20\21\22\23\24\25\26\27\28\29\30\31"
" !\"#$%&'()*+,-./"
"0123456789:;<=>?"
"@ABCDEFGHIJKLMNO"
"PQRSTUVWXYZ[\\]^_"
"`abcdefghijklmno"
"pqrstuvwxyz{|}~\127"
"\128\129\130\131\132\133\134\135\136\137\138\139\140\141\142\143"
"\144\145\146\147\148\149\150\151\152\153\154\155\156\157\158\159"
"\160\161\162\163\164\165\166\167\168\169\170\171\172\173\174\175"
"\176\177\178\179\180\181\182\183\184\185\186\187\188\189\190\191"
"\192\193\194\195\196\197\198\199\200\201\202\203\204\205\206\207"
"\208\209\210\211\212\213\214\215\216\217\218\219\220\221\222\223"
"\224\225\226\227\228\229\230\231\232\233\234\235\236\237\238\239"
"\240\241\242\243\244\245\246\247\248\249\250\251\252\253\254\255"
- nul terminated:
"termi\nated"
- passthru:
passed through unchanged "printable"
- zero length:
""
- truncation when too long:
"\axxxxxxE"
add osmo_escape_cstr and osmo_quote_cstr Provide string escaping that - returns the required buffer size, so it can be used with OSMO_STRBUF_APPEND(). - uses C compatible string constant escaping sequences. This is intended as a replacement for all previous osmo_escape_str* and osmo_quote_str* API. It pains me that I didn't get them right the first nor the second time: - The buffer functions do not return the chars needed, which is required for allocating sufficient memory in the *_c versions of the functions. - Because of that, these functions are accurately usable for OSMO_STRBUF_APPEND(), producing truncated strings, for example when dumping a GSUP message. - They do not use the C equivalent string constant escaping: for some reason I thought "\15" would be valid, but it should be "\x0f". If I could, I would completely drop those mislead implementations ... but backwards compat prohibits that. A previous patch already provided internal static functions that accurately return the required buffer size. Enhance these to also support C compatible string escaping, and use them as implementation of the new functions: osmo_escape_cstr_buf() osmo_escape_cstr_c() osmo_quote_cstr_buf() osmo_quote_cstr_c() In the tests for these, also test C string equivalence. Naming: from API versions, it would be kind of logical to call them osmo_escape_str_buf3() and osmo_escape_str_c2(). Since these anyway return a different escaping, it makes sense to me to have distinct names instead. Quasi missing are variants of the non-C-compatible weird legacy escaping that return the required buffer size, but I refrain from adding those, because we have enough API cruft as it is. Just always use these new cstr variants. Change-Id: I3dfb892036e01000033dd8e7e4a6a0c32a3caa9b
2019-11-20 23:12:10 +00:00
Testing string quoting: osmo_quote_str()
- all chars from 0 to 255 in batches of 16:
'"\0\1\2\3\4\5\6\a\b\t\n\v\f\r\14\15"'
'"\16\17\18\19\20\21\22\23\24\25\26\27\28\29\30\31"'
'" !\"#$%&'()*+,-./"'
'"0123456789:;<=>?"'
'"@ABCDEFGHIJKLMNO"'
'"PQRSTUVWXYZ[\\]^_"'
'"`abcdefghijklmno"'
'"pqrstuvwxyz{|}~\127"'
'"\128\129\130\131\132\133\134\135\136\137\138\139\140\141\142\143"'
'"\144\145\146\147\148\149\150\151\152\153\154\155\156\157\158\159"'
'"\160\161\162\163\164\165\166\167\168\169\170\171\172\173\174\175"'
'"\176\177\178\179\180\181\182\183\184\185\186\187\188\189\190\191"'
'"\192\193\194\195\196\197\198\199\200\201\202\203\204\205\206\207"'
'"\208\209\210\211\212\213\214\215\216\217\218\219\220\221\222\223"'
'"\224\225\226\227\228\229\230\231\232\233\234\235\236\237\238\239"'
'"\240\241\242\243\244\245\246\247\248\249\250\251\252\253\254\255"'
- nul terminated:
'"termi\nated"'
- never passthru:
NOT passed through. '"printable"'
- zero length:
'""'
- truncation when too long:
add osmo_{escape,quote}_str_buf2() for standard args ordering To be able to append an escaped or quoted string using OSMO_STRBUF_APPEND_NOLEN(), the function signature must have the buf and len as first args, like most other *_buf() functions. Add osmo_escape_str_buf2() and osmo_quote_str_buf2() to match this signature. A recent patch [1] has changed the return value of osmo_escape_str_buf() to char*, removing the const. However, the functions may return const strings, hence re-add the const. The new signatures always return the non-const buffer. To avoid code duplication, implement osmo_quote_str_buf() and osmo_escape_str_buf() by calling the new functions. I decided to allow slight changes to the behavior for current osmo_escape_str() and osmo_escape_str_buf(), because impact on callers is minimal: (1) The new implementation uses OSMO_STRBUF_*, and in consequence osmo_quote_str() no longer prints an ending double quote after truncated strings; Before, a truncated output was, sic: "this string is trunca" and now this becomes, sic: "this string is truncat I decided to not keep the old behavior because it is questionable to begin with. It looks like the string actually ended at the truncation boundary instead of the reason being not enough space in the output buffer. (2) The new osmo_escape_str_buf2() function obviously cannot pass-thru an unchanged char* if no escaping was needed. Sacrifice this tiny optimization feature to avoid code duplication: - it is an unnoticeable optimization, - the caller anyway always passes a string buffer, - the feature caused handling strings and buffers differently depending on their content (i.e. code that usually writes out strings in full length "suddenly" truncates because a non-printable character is contained, etc.) I considered adding a skip_if_unescaped flag to the osmo_quote_str_buf2() function signature, but in the end decided that the API clutter is not worth having for all the above reasons. Adjust tests to accomodate above changes. [1] 4a62eda225ab7f3c9556990c81a6fc5e19b5eec8 Ibf85f79e93244f53b2684ff6f1095c5b41203e05 Change-Id: Id748b906b0083b1f1887f2be7a53cae705a8a9ae
2019-03-05 15:42:50 +00:00
'"\axxxxxE'
- always truncation, even when no escaping needed:
add osmo_{escape,quote}_str_buf2() for standard args ordering To be able to append an escaped or quoted string using OSMO_STRBUF_APPEND_NOLEN(), the function signature must have the buf and len as first args, like most other *_buf() functions. Add osmo_escape_str_buf2() and osmo_quote_str_buf2() to match this signature. A recent patch [1] has changed the return value of osmo_escape_str_buf() to char*, removing the const. However, the functions may return const strings, hence re-add the const. The new signatures always return the non-const buffer. To avoid code duplication, implement osmo_quote_str_buf() and osmo_escape_str_buf() by calling the new functions. I decided to allow slight changes to the behavior for current osmo_escape_str() and osmo_escape_str_buf(), because impact on callers is minimal: (1) The new implementation uses OSMO_STRBUF_*, and in consequence osmo_quote_str() no longer prints an ending double quote after truncated strings; Before, a truncated output was, sic: "this string is trunca" and now this becomes, sic: "this string is truncat I decided to not keep the old behavior because it is questionable to begin with. It looks like the string actually ended at the truncation boundary instead of the reason being not enough space in the output buffer. (2) The new osmo_escape_str_buf2() function obviously cannot pass-thru an unchanged char* if no escaping was needed. Sacrifice this tiny optimization feature to avoid code duplication: - it is an unnoticeable optimization, - the caller anyway always passes a string buffer, - the feature caused handling strings and buffers differently depending on their content (i.e. code that usually writes out strings in full length "suddenly" truncates because a non-printable character is contained, etc.) I considered adding a skip_if_unescaped flag to the osmo_quote_str_buf2() function signature, but in the end decided that the API clutter is not worth having for all the above reasons. Adjust tests to accomodate above changes. [1] 4a62eda225ab7f3c9556990c81a6fc5e19b5eec8 Ibf85f79e93244f53b2684ff6f1095c5b41203e05 Change-Id: Id748b906b0083b1f1887f2be7a53cae705a8a9ae
2019-03-05 15:42:50 +00:00
'"xxxxxxxE'
- try to feed too little buf for quoting:
add osmo_{escape,quote}_str_buf2() for standard args ordering To be able to append an escaped or quoted string using OSMO_STRBUF_APPEND_NOLEN(), the function signature must have the buf and len as first args, like most other *_buf() functions. Add osmo_escape_str_buf2() and osmo_quote_str_buf2() to match this signature. A recent patch [1] has changed the return value of osmo_escape_str_buf() to char*, removing the const. However, the functions may return const strings, hence re-add the const. The new signatures always return the non-const buffer. To avoid code duplication, implement osmo_quote_str_buf() and osmo_escape_str_buf() by calling the new functions. I decided to allow slight changes to the behavior for current osmo_escape_str() and osmo_escape_str_buf(), because impact on callers is minimal: (1) The new implementation uses OSMO_STRBUF_*, and in consequence osmo_quote_str() no longer prints an ending double quote after truncated strings; Before, a truncated output was, sic: "this string is trunca" and now this becomes, sic: "this string is truncat I decided to not keep the old behavior because it is questionable to begin with. It looks like the string actually ended at the truncation boundary instead of the reason being not enough space in the output buffer. (2) The new osmo_escape_str_buf2() function obviously cannot pass-thru an unchanged char* if no escaping was needed. Sacrifice this tiny optimization feature to avoid code duplication: - it is an unnoticeable optimization, - the caller anyway always passes a string buffer, - the feature caused handling strings and buffers differently depending on their content (i.e. code that usually writes out strings in full length "suddenly" truncates because a non-printable character is contained, etc.) I considered adding a skip_if_unescaped flag to the osmo_quote_str_buf2() function signature, but in the end decided that the API clutter is not worth having for all the above reasons. Adjust tests to accomodate above changes. [1] 4a62eda225ab7f3c9556990c81a6fc5e19b5eec8 Ibf85f79e93244f53b2684ff6f1095c5b41203e05 Change-Id: Id748b906b0083b1f1887f2be7a53cae705a8a9ae
2019-03-05 15:42:50 +00:00
'"'
- NULL string becomes a "NULL" literal:
'NULL'
add osmo_escape_cstr and osmo_quote_cstr Provide string escaping that - returns the required buffer size, so it can be used with OSMO_STRBUF_APPEND(). - uses C compatible string constant escaping sequences. This is intended as a replacement for all previous osmo_escape_str* and osmo_quote_str* API. It pains me that I didn't get them right the first nor the second time: - The buffer functions do not return the chars needed, which is required for allocating sufficient memory in the *_c versions of the functions. - Because of that, these functions are accurately usable for OSMO_STRBUF_APPEND(), producing truncated strings, for example when dumping a GSUP message. - They do not use the C equivalent string constant escaping: for some reason I thought "\15" would be valid, but it should be "\x0f". If I could, I would completely drop those mislead implementations ... but backwards compat prohibits that. A previous patch already provided internal static functions that accurately return the required buffer size. Enhance these to also support C compatible string escaping, and use them as implementation of the new functions: osmo_escape_cstr_buf() osmo_escape_cstr_c() osmo_quote_cstr_buf() osmo_quote_cstr_c() In the tests for these, also test C string equivalence. Naming: from API versions, it would be kind of logical to call them osmo_escape_str_buf3() and osmo_escape_str_c2(). Since these anyway return a different escaping, it makes sense to me to have distinct names instead. Quasi missing are variants of the non-C-compatible weird legacy escaping that return the required buffer size, but I refrain from adding those, because we have enough API cruft as it is. Just always use these new cstr variants. Change-Id: I3dfb892036e01000033dd8e7e4a6a0c32a3caa9b
2019-11-20 23:12:10 +00:00
Testing string escaping: osmo_escape_cstr_buf()
- all chars from 0 to 255 in batches of 16:
"\0\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f"
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
" !\"#$%&'()*+,-./"
"0123456789:;<=>?"
"@ABCDEFGHIJKLMNO"
"PQRSTUVWXYZ[\\]^_"
"`abcdefghijklmno"
"pqrstuvwxyz{|}~\x7f"
"\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
"\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
"\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
- nul terminated:
"termi\nated"
- passthru:
passed through unchanged "printable"
- zero length:
""
- truncation when too long:
"\x07xxxxx"
- Test escaping an escaped string:
0: '\x02\x03\n'
1: '\\x02\\x03\\n'
2: '\\\\x02\\\\x03\\\\n'
3: '\\\\\\\\x02\\\\\\\\x03\\\\\\\\n'
Testing string quoting: osmo_quote_cstr_buf()
- all chars from 0 to 255 in batches of 16:
"\0\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f"
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
" !\"#$%&'()*+,-./"
"0123456789:;<=>?"
"@ABCDEFGHIJKLMNO"
"PQRSTUVWXYZ[\\]^_"
"`abcdefghijklmno"
"pqrstuvwxyz{|}~\x7f"
"\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
"\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
"\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
- nul terminated:
'"termi\nated"'
- never passthru:
NOT passed through. '"printable"'
- zero length:
'""'
- truncation when too long:
'"\x07xxxx'
- always truncation, even when no escaping needed:
'"xxxxxxxE'
- try to feed too little buf for quoting:
'"'
- Test quoting a quoted+escaped string:
0: "\x02\x03\n"
1: "\"\\x02\\x03\\n\""
2: "\"\\\"\\\\x02\\\\x03\\\\n\\\"\""
3: "\"\\\"\\\\\\\"\\\\\\\\x02\\\\\\\\x03\\\\\\\\n\\\\\\\"\\\"\""
- Test C-string equivalence:
strcmp(OSMO_STRINGIFY_VAL(TEST_STR), osmo_quote_cstr_c(ctx, TEST_STR, 256)) == 0
strcmp(OSMO_STRINGIFY_VAL(EMPTY_STR), osmo_quote_cstr_c(ctx, EMPTY_STR, -1)) == 0
strcmp("NULL", osmo_quote_cstr_c(ctx, NULL, -1)) == 0
Testing integer square-root
Testing built in truncated modulo for comparison:
8 mod 3 = 2 = 2
8 mod -3 = 2 = 2
-8 mod 3 = -2 = -2
-8 mod -3 = -2 = -2
1 mod 2 = 1 = 1
1 mod -2 = 1 = 1
-1 mod 2 = -1 = -1
-1 mod -2 = -1 = -1
Testing OSMO_MOD_FLR():
8 mod_flr 3 = 2 = 2
8 mod_flr -3 = -1 = -1
-8 mod_flr 3 = 1 = 1
-8 mod_flr -3 = -2 = -2
1 mod_flr 2 = 1 = 1
1 mod_flr -2 = -1 = -1
-1 mod_flr 2 = 1 = 1
-1 mod_flr -2 = -1 = -1
Testing OSMO_MOD_EUC():
8 mod_euc 3 = 2 = 2
8 mod_euc -3 = 2 = 2
-8 mod_euc 3 = 1 = 1
-8 mod_euc -3 = 1 = 1
1 mod_euc 2 = 1 = 1
1 mod_euc -2 = 1 = 1
-1 mod_euc 2 = 1 = 1
-1 mod_euc -2 = 1 = 1
osmo_sockaddr_to_str_and_uint_test
[0] [0.0.0.0]:0 addr_len=20 --> [0.0.0.0]:0 rc=7
[1] [255.255.255.255]:65535 addr_len=20 --> [255.255.255.255]:65535 rc=15
[2] [234.23.42.123]:1234 addr_len=20 --> [234.23.42.123]:1234 rc=13
[3] [234.23.42.123]:1234 addr_len=10 --> [234.23.42]:1234 rc=13
[4] [234.23.42.123]:1234 (omit port) addr_len=20 --> [234.23.42.123]:0 rc=13
[5] [234.23.42.123]:1234 (omit addr) addr_len=0 --> []:1234 rc=0
[6] [234.23.42.123]:1234 addr_len=0 --> []:1234 rc=13
[7] [234.23.42.123]:1234 (omit addr) (omit port) addr_len=0 --> []:0 rc=0
[8] [::]:1234 addr_len=20 --> [::]:1234 rc=2
[9] [::1]:1234 addr_len=20 --> [::1]:1234 rc=3
[10] [::1]:1234 (omit port) addr_len=20 --> [::1]:0 rc=3
[11] [::1]:1234 (omit addr) addr_len=20 --> []:1234 rc=0
[12] [fd02:db8:1::1]:1234 addr_len=20 --> [fd02:db8:1::1]:1234 rc=13
[13] [2001:db8:1::ab9:C0A8:102]:1234 addr_len=40 --> [2001:db8:1::ab9:c0a8:102]:1234 rc=24
[14] [2001:0db8:0001:0000:0000:0ab9:C0A8:0102]:1234 addr_len=32 --> [2001:db8:1::ab9:c0a8:102]:1234 rc=24
[15] [::ffff:192.168.20.34]:1234 addr_len=32 --> [::ffff:192.168.20.34]:1234 rc=20
osmo_str_tolowupper_test
osmo_str_tolower("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()")
= "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz!@#$%^&*()"
osmo_str_toupper("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()")
= "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()"
osmo_str_tolower_buf(99, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()")
= 62, "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz!@#$%^&*()"
osmo_str_tolower_buf(99, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()", in-place)
= 62, "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz!@#$%^&*()"
osmo_str_toupper_buf(99, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()")
= 62, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()"
osmo_str_toupper_buf(99, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()", in-place)
= 62, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()"
osmo_str_tolower_buf(0, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()")
= 62, "Unset"
osmo_str_tolower_buf(0, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()", in-place)
= 0, "Unset"
osmo_str_toupper_buf(0, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()")
= 62, "Unset"
osmo_str_toupper_buf(0, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()", in-place)
= 0, "Unset"
osmo_str_tolower_buf(1, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()")
= 62, ""
osmo_str_tolower_buf(1, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()", in-place)
= 0, ""
osmo_str_toupper_buf(1, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()")
= 62, ""
osmo_str_toupper_buf(1, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()", in-place)
= 0, ""
osmo_str_tolower_buf(2, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()")
= 62, "a"
osmo_str_tolower_buf(2, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()", in-place)
= 1, "a"
osmo_str_toupper_buf(2, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()")
= 62, "A"
osmo_str_toupper_buf(2, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()", in-place)
= 1, "A"
osmo_str_tolower_buf(28, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()")
= 62, "abcdefghijklmnopqrstuvwxyza"
osmo_str_tolower_buf(28, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()", in-place)
= 27, "abcdefghijklmnopqrstuvwxyza"
osmo_str_toupper_buf(28, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()")
= 62, "ABCDEFGHIJKLMNOPQRSTUVWXYZA"
osmo_str_toupper_buf(28, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()", in-place)
= 27, "ABCDEFGHIJKLMNOPQRSTUVWXYZA"
strbuf_test
OSMO_STRBUF_APPEND():
The answer is 42
would have needed 423470 bytes
OSMO_STRBUF_PRINTF():
1: (need 42 chars, had size=23) T minus 10 9 8 7 6 5 4
2: (need 42 chars, had size=42) T minus 10 9 8 7 6 5 4 3 2 1 ... Lift off
3: (need 42 chars, had size=42+1) T minus 10 9 8 7 6 5 4 3 2 1 ... Lift off!
4: (need 42 chars, had size=0) 0x2b 0x2b 0x2b...
5: (need 42 chars, had NULL buffer)
cascade:
(need 134 chars)
T minus 10 9 8 7 6 5 4 3 2 1 ... Lift off! -- T minus 10 9 8 7 6 5 4 3 2 1 ... Lift off! -- T minus 10 9 8 7 6 5 4 3 2 1 ... Lift off!
(need 134 chars, had size=63) T minus 10 9 8 7 6 5 4 3 2 1 ... Lift off! -- T minus 10 9 8 7
strbuf_test_nolen
20: 0001011100101010 (need=16)
more: 0001011100101010000 (need=19)
10: 000101110 (need=9)
startswith_test()
osmo_str_startswith(NULL, NULL) == true
osmo_str_startswith("", NULL) == true
osmo_str_startswith(NULL, "") == true
osmo_str_startswith("", "") == true
osmo_str_startswith("abc", NULL) == true
osmo_str_startswith("abc", "") == true
osmo_str_startswith(NULL, "abc") == false
osmo_str_startswith("", "abc") == false
osmo_str_startswith("abc", "a") == true
osmo_str_startswith("abc", "ab") == true
osmo_str_startswith("abc", "abc") == true
osmo_str_startswith("abc", "abcd") == false
osmo_str_startswith("abc", "xyz") == false
name_c_impl_test
0: "test"
OSMO_NAME_C_IMPL(10, "ERROR") -> "test" allocated 1 10 bytes, name 'foo_name_c'
OSMO_NAME_C_IMPL(10, NULL) -> "test" allocated 1 10 bytes, name 'foo_name_c_null'
OSMO_NAME_C_IMPL(0, "ERROR") -> "test" allocated 1 5 bytes, name 'foo_name_c_zero'
OSMO_NAME_C_IMPL(0, NULL) -> "test" allocated 1 5 bytes, name 'foo_name_c_zero_null'
1: "longer than 10 chars"
OSMO_NAME_C_IMPL(10, "ERROR") -> "longer than 10 chars" allocated 1 21 bytes, name 'foo_name_c'
OSMO_NAME_C_IMPL(10, NULL) -> "longer than 10 chars" allocated 1 21 bytes, name 'foo_name_c_null'
OSMO_NAME_C_IMPL(0, "ERROR") -> "longer than 10 chars" allocated 1 21 bytes, name 'foo_name_c_zero'
OSMO_NAME_C_IMPL(0, NULL) -> "longer than 10 chars" allocated 1 21 bytes, name 'foo_name_c_zero_null'
2: NULL
OSMO_NAME_C_IMPL(10, "ERROR") -> "ERROR" allocated 1 6 bytes, name 'foo_name_c'
OSMO_NAME_C_IMPL(10, NULL) -> NULL allocated 0
OSMO_NAME_C_IMPL(0, "ERROR") -> "ERROR" allocated 1 6 bytes, name 'foo_name_c_zero'
OSMO_NAME_C_IMPL(0, NULL) -> NULL allocated 0
osmo_print_n_test()
"foo=bar" token_len=3 buf_size=100 -> token="foo" rc=3
"foo" token_len=10 buf_size=100 -> token="foo" rc=3
"foo" token_len=3 buf_size=100 -> token="foo" rc=3
NULL token_len=10 buf_size=100 -> token="" rc=0
"" token_len=10 buf_size=100 -> token="" rc=0
"foo=bar" token_len=0 buf_size=100 -> token="" rc=0
"foo=bar" token_len=3 buf_size=2 -> token="f" rc=3
"foo" token_len=10 buf_size=2 -> token="f" rc=3
"foo" token_len=3 buf_size=2 -> token="f" rc=3
NULL token_len=10 buf_size=2 -> token="" rc=0
"" token_len=10 buf_size=2 -> token="" rc=0
"foo=bar" token_len=0 buf_size=2 -> token="" rc=0
"foo=bar" token_len=3 buf_size=1 -> token="" rc=3
"foo" token_len=10 buf_size=1 -> token="" rc=3
"foo" token_len=3 buf_size=1 -> token="" rc=3
NULL token_len=10 buf_size=1 -> token="" rc=0
"" token_len=10 buf_size=1 -> token="" rc=0
"foo=bar" token_len=0 buf_size=1 -> token="" rc=0
"foo=bar" token_len=3 buf_size=0 -> token="unchanged" rc=3
"foo" token_len=10 buf_size=0 -> token="unchanged" rc=3
"foo" token_len=3 buf_size=0 -> token="unchanged" rc=3
NULL token_len=10 buf_size=0 -> token="unchanged" rc=0
"" token_len=10 buf_size=0 -> token="unchanged" rc=0
"foo=bar" token_len=0 buf_size=0 -> token="unchanged" rc=0
osmo_strnchr_test()
osmo_strnchr("foo=bar", 8, '=') -> 3
osmo_strnchr("foo=bar", 4, '=') -> 3
osmo_strnchr("foo=bar", 3, '=') -> -1
osmo_strnchr("foo=bar", 0, '=') -> -1
osmo_strnchr("foo", 9, '=') -> -1
osmo_strnchr("foo", 9, '\0') -> 3
add osmo_float_str_to_int() and osmo_int_to_float_str_*() This will be useful to handle latitude and longitude numbers for GAD, which is the location estimate representation used for LCS (Location Services). The OsmoSMLC VTY user interface will provide floating-point strings like "23.456" while GAD stores them as micro-degress 23456000. The osmo_gad_to_str* will also convert latitude and longitude to floating-point string. There was code review concerns against adding this API, upon which I tried to use floating point string formats. But I encountered various problems with accuracy and trailing zeros. For global positioning data (latitude and longitude), even inaccuracy on the sixth significant decimal digit causes noticeable positional shift. To achieve sufficient accuracy on the least significant end, I need to use double instead of float. To remove trailing zeros, the idea was to use '%.6g' format, but that can cause rounding. '%.6f' on a double looks ok, but always includes trailing zeros. A test program shows: %.6g of ((double)(int32_t)23230100)/1e6 = "23.2301" <-- good %.6g of ((double)(int32_t)42419993)/1e6 = "42.42" <-- bad rounding %.6g of ((double)(int32_t)23230199)/1e6 = "23.2302" <-- bad rounding %.6f of ((double)(int32_t)23230100)/1e6 = "23.230100" <-- trailing zeros %.6f of ((double)(int32_t)42419993)/1e6 = "42.419993" <-- good %.6f of ((double)(int32_t)23230199)/1e6 = "23.230199" <-- good It looks like when accepting that there will be trailing zeros, using double with '%.6f' would work out, but in the end I am not certain enough that there aren't more hidden rounding / precision glitches. Hence I decided to reinforce the need to add this API: it is glitch free in sufficient precision for latitude and longitude data, because it is based on integer arithmetic. The need for this precision is particular to the (new) OsmoSMLC vty configuration, where reading and writing back user config must not modify the values the user entered. Considering to add these functions to osmo-smlc.git, we might as well add them here to libosmocore utils, and also use them in osmo_gad_to_str_*() functions. Change-Id: Ib9aee749cd331712a4dcdadfb6a2dfa4c26da957
2020-09-30 21:47:47 +00:00
--- test_float_str_to_int
osmo_float_str_to_int("0", 0) -> rc=0 val=0
osmo_float_str_to_int("1", 0) -> rc=0 val=1
osmo_float_str_to_int("12.345", 0) -> rc=0 val=12
osmo_float_str_to_int("+12.345", 0) -> rc=0 val=12
osmo_float_str_to_int("-12.345", 0) -> rc=0 val=-12
osmo_float_str_to_int("0.345", 0) -> rc=0 val=0
osmo_float_str_to_int(".345", 0) -> rc=0 val=0
osmo_float_str_to_int("-0.345", 0) -> rc=0 val=0
osmo_float_str_to_int("-.345", 0) -> rc=0 val=0
osmo_float_str_to_int("12.", 0) -> rc=0 val=12
osmo_float_str_to_int("-180", 0) -> rc=0 val=-180
osmo_float_str_to_int("180", 0) -> rc=0 val=180
osmo_float_str_to_int("360", 0) -> rc=0 val=360
osmo_float_str_to_int("123.4567890123", 0) -> rc=0 val=123
osmo_float_str_to_int("123.4567890123456789012345", 0) -> rc=0 val=123
osmo_float_str_to_int("9223372036854775807", 0) -> rc=0 val=9223372036854775807
osmo_float_str_to_int("-9223372036854775807", 0) -> rc=0 val=-9223372036854775807
osmo_float_str_to_int("-9223372036854775808", 0) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("9223372036854775808", 0) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("-9223372036854775809", 0) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("100000000000000000000", 0) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("-100000000000000000000", 0) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("999999999999999999999999999.99", 0) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("-999999999999999999999999999.99", 0) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("1.2.3", 0) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("foo", 0) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("1.foo", 0) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("1.foo", 0) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("12.-345", 0) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("-12.-345", 0) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("12.+345", 0) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("+12.+345", 0) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("", 0) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int(NULL, 0) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("0", 1) -> rc=0 val=0
osmo_float_str_to_int("1", 1) -> rc=0 val=10
osmo_float_str_to_int("12.345", 1) -> rc=0 val=123
osmo_float_str_to_int("+12.345", 1) -> rc=0 val=123
osmo_float_str_to_int("-12.345", 1) -> rc=0 val=-123
osmo_float_str_to_int("0.345", 1) -> rc=0 val=3
osmo_float_str_to_int(".345", 1) -> rc=0 val=3
osmo_float_str_to_int("-0.345", 1) -> rc=0 val=-3
osmo_float_str_to_int("-.345", 1) -> rc=0 val=-3
osmo_float_str_to_int("12.", 1) -> rc=0 val=120
osmo_float_str_to_int("-180", 1) -> rc=0 val=-1800
osmo_float_str_to_int("180", 1) -> rc=0 val=1800
osmo_float_str_to_int("360", 1) -> rc=0 val=3600
osmo_float_str_to_int("123.4567890123", 1) -> rc=0 val=1234
osmo_float_str_to_int("123.4567890123456789012345", 1) -> rc=0 val=1234
osmo_float_str_to_int("922337203685477580.7", 1) -> rc=0 val=9223372036854775807
osmo_float_str_to_int("-922337203685477580.7", 1) -> rc=0 val=-9223372036854775807
osmo_float_str_to_int("-922337203685477580.8", 1) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("922337203685477580.8", 1) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("-922337203685477580.9", 1) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("100000000000000000000", 1) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("-100000000000000000000", 1) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("999999999999999999999999999.99", 1) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("-999999999999999999999999999.99", 1) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("1.2.3", 1) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("foo", 1) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("1.foo", 1) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("1.foo", 1) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("12.-345", 1) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("-12.-345", 1) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("12.+345", 1) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("+12.+345", 1) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("", 1) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int(NULL, 1) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("0", 6) -> rc=0 val=0
osmo_float_str_to_int("1", 6) -> rc=0 val=1000000
osmo_float_str_to_int("12.345", 6) -> rc=0 val=12345000
osmo_float_str_to_int("+12.345", 6) -> rc=0 val=12345000
osmo_float_str_to_int("-12.345", 6) -> rc=0 val=-12345000
osmo_float_str_to_int("0.345", 6) -> rc=0 val=345000
osmo_float_str_to_int(".345", 6) -> rc=0 val=345000
osmo_float_str_to_int("-0.345", 6) -> rc=0 val=-345000
osmo_float_str_to_int("-.345", 6) -> rc=0 val=-345000
osmo_float_str_to_int("12.", 6) -> rc=0 val=12000000
osmo_float_str_to_int("-180", 6) -> rc=0 val=-180000000
osmo_float_str_to_int("180", 6) -> rc=0 val=180000000
osmo_float_str_to_int("360", 6) -> rc=0 val=360000000
osmo_float_str_to_int("123.4567890123", 6) -> rc=0 val=123456789
osmo_float_str_to_int("123.4567890123456789012345", 6) -> rc=0 val=123456789
osmo_float_str_to_int("9223372036854.775807", 6) -> rc=0 val=9223372036854775807
osmo_float_str_to_int("-9223372036854.775807", 6) -> rc=0 val=-9223372036854775807
osmo_float_str_to_int("-9223372036854.775808", 6) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("9223372036854.775808", 6) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("-9223372036854.775809", 6) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("100000000000000000000", 6) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("-100000000000000000000", 6) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("999999999999999999999999999.99", 6) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("-999999999999999999999999999.99", 6) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("1.2.3", 6) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("foo", 6) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("1.foo", 6) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("1.foo", 6) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("12.-345", 6) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("-12.-345", 6) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("12.+345", 6) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("+12.+345", 6) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("", 6) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int(NULL, 6) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("0", 18) -> rc=0 val=0
osmo_float_str_to_int("1", 18) -> rc=0 val=1000000000000000000
osmo_float_str_to_int("1.2345", 18) -> rc=0 val=1234500000000000000
osmo_float_str_to_int("+1.2345", 18) -> rc=0 val=1234500000000000000
osmo_float_str_to_int("-1.2345", 18) -> rc=0 val=-1234500000000000000
osmo_float_str_to_int("0.345", 18) -> rc=0 val=345000000000000000
osmo_float_str_to_int(".345", 18) -> rc=0 val=345000000000000000
osmo_float_str_to_int("-0.345", 18) -> rc=0 val=-345000000000000000
osmo_float_str_to_int("-.345", 18) -> rc=0 val=-345000000000000000
osmo_float_str_to_int("2.", 18) -> rc=0 val=2000000000000000000
osmo_float_str_to_int("-8", 18) -> rc=0 val=-8000000000000000000
osmo_float_str_to_int("1.234567890123", 18) -> rc=0 val=1234567890123000000
osmo_float_str_to_int("1.234567890123456789012345", 18) -> rc=0 val=1234567890123456789
osmo_float_str_to_int("123.4567890123", 18) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("9.223372036854775807", 18) -> rc=0 val=9223372036854775807
osmo_float_str_to_int("-9.223372036854775807", 18) -> rc=0 val=-9223372036854775807
osmo_float_str_to_int("-9.223372036854775808", 18) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("9.223372036854775808", 18) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("-9.223372036854775809", 18) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("100000000000000000000", 18) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("-100000000000000000000", 18) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("999999999999999999999999999.99", 18) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("-999999999999999999999999999.99", 18) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("1.2.3", 18) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("foo", 18) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("1.foo", 18) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("1.foo", 18) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("12.-345", 18) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("-12.-345", 18) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("12.+345", 18) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("+12.+345", 18) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("", 18) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int(NULL, 18) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("0", 19) -> rc=0 val=0
osmo_float_str_to_int(".1", 19) -> rc=0 val=1000000000000000000
osmo_float_str_to_int(".12345", 19) -> rc=0 val=1234500000000000000
osmo_float_str_to_int("+.12345", 19) -> rc=0 val=1234500000000000000
osmo_float_str_to_int("-.12345", 19) -> rc=0 val=-1234500000000000000
osmo_float_str_to_int("0.0345", 19) -> rc=0 val=345000000000000000
osmo_float_str_to_int(".0345", 19) -> rc=0 val=345000000000000000
osmo_float_str_to_int("-0.0345", 19) -> rc=0 val=-345000000000000000
osmo_float_str_to_int("-.0345", 19) -> rc=0 val=-345000000000000000
osmo_float_str_to_int(".2", 19) -> rc=0 val=2000000000000000000
osmo_float_str_to_int("-.8", 19) -> rc=0 val=-8000000000000000000
osmo_float_str_to_int(".1234567890123", 19) -> rc=0 val=1234567890123000000
osmo_float_str_to_int(".1234567890123456789012345", 19) -> rc=0 val=1234567890123456789
osmo_float_str_to_int("123.4567890123", 19) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int(".9223372036854775807", 19) -> rc=0 val=9223372036854775807
osmo_float_str_to_int("-.9223372036854775807", 19) -> rc=0 val=-9223372036854775807
osmo_float_str_to_int("-.9223372036854775808", 19) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int(".9223372036854775808", 19) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("-.9223372036854775809", 19) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("100000000000000000000", 19) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("-100000000000000000000", 19) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("999999999999999999999999999.99", 19) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("-999999999999999999999999999.99", 19) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("1.2.3", 19) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("foo", 19) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("1.foo", 19) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("1.foo", 19) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("12.-345", 19) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("-12.-345", 19) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("12.+345", 19) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("+12.+345", 19) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("", 19) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int(NULL, 19) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("0", 20) -> rc=0 val=0
osmo_float_str_to_int(".01", 20) -> rc=0 val=1000000000000000000
osmo_float_str_to_int(".012345", 20) -> rc=0 val=1234500000000000000
osmo_float_str_to_int("+.012345", 20) -> rc=0 val=1234500000000000000
osmo_float_str_to_int("-.012345", 20) -> rc=0 val=-1234500000000000000
osmo_float_str_to_int("0.00345", 20) -> rc=0 val=345000000000000000
osmo_float_str_to_int(".00345", 20) -> rc=0 val=345000000000000000
osmo_float_str_to_int("-0.00345", 20) -> rc=0 val=-345000000000000000
osmo_float_str_to_int("-.00345", 20) -> rc=0 val=-345000000000000000
osmo_float_str_to_int(".02", 20) -> rc=0 val=2000000000000000000
osmo_float_str_to_int("-.08", 20) -> rc=0 val=-8000000000000000000
osmo_float_str_to_int(".01234567890123", 20) -> rc=0 val=1234567890123000000
osmo_float_str_to_int(".01234567890123456789012345", 20) -> rc=0 val=1234567890123456789
osmo_float_str_to_int("12.34567890123", 20) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int(".09223372036854775807", 20) -> rc=0 val=9223372036854775807
osmo_float_str_to_int("-.09223372036854775807", 20) -> rc=0 val=-9223372036854775807
osmo_float_str_to_int("-.09223372036854775808", 20) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int(".09223372036854775808", 20) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("-.09223372036854775809", 20) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int(".1", 20) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("-.1", 20) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("999999999999999999999999999.99", 20) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("-999999999999999999999999999.99", 20) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("1.2.3", 20) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("foo", 20) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("1.foo", 20) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("1.foo", 20) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("12.-345", 20) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("-12.-345", 20) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("12.+345", 20) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("+12.+345", 20) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("", 20) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int(NULL, 20) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("0", 25) -> rc=0 val=0
osmo_float_str_to_int(".0000001", 25) -> rc=0 val=1000000000000000000
osmo_float_str_to_int(".00000012345", 25) -> rc=0 val=1234500000000000000
osmo_float_str_to_int("+.00000012345", 25) -> rc=0 val=1234500000000000000
osmo_float_str_to_int("-.00000012345", 25) -> rc=0 val=-1234500000000000000
osmo_float_str_to_int("0.0000000345", 25) -> rc=0 val=345000000000000000
osmo_float_str_to_int(".0000000345", 25) -> rc=0 val=345000000000000000
osmo_float_str_to_int("-0.0000000345", 25) -> rc=0 val=-345000000000000000
osmo_float_str_to_int("-.0000000345", 25) -> rc=0 val=-345000000000000000
osmo_float_str_to_int(".0000002", 25) -> rc=0 val=2000000000000000000
osmo_float_str_to_int("-.0000008", 25) -> rc=0 val=-8000000000000000000
osmo_float_str_to_int(".0000001234567890123", 25) -> rc=0 val=1234567890123000000
osmo_float_str_to_int(".0000001234567890123456789012345", 25) -> rc=0 val=1234567890123456789
osmo_float_str_to_int(".0001234567890123", 25) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int(".0000009223372036854775807", 25) -> rc=0 val=9223372036854775807
osmo_float_str_to_int("-.0000009223372036854775807", 25) -> rc=0 val=-9223372036854775807
osmo_float_str_to_int("-.0000009223372036854775808", 25) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int(".0000009223372036854775808", 25) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("-.0000009223372036854775809", 25) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int(".000001", 25) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("-.000001", 25) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("999999999999999999999999999.99", 25) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("-999999999999999999999999999.99", 25) -> rc=-34=-ERANGE val=0
osmo_float_str_to_int("1.2.3", 25) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("foo", 25) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("1.foo", 25) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("1.foo", 25) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("12.-345", 25) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("-12.-345", 25) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("12.+345", 25) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("+12.+345", 25) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int("", 25) -> rc=-22=-EINVAL val=0
osmo_float_str_to_int(NULL, 25) -> rc=-22=-EINVAL val=0
--- test_int_to_float_str
osmo_int_to_float_str_buf(0, 0) -> rc=1 str="0"
osmo_int_to_float_str_buf(1, 0) -> rc=1 str="1"
osmo_int_to_float_str_buf(1000000, 0) -> rc=7 str="1000000"
osmo_int_to_float_str_buf(-1000000, 0) -> rc=8 str="-1000000"
osmo_int_to_float_str_buf(1000001, 0) -> rc=7 str="1000001"
osmo_int_to_float_str_buf(-1000001, 0) -> rc=8 str="-1000001"
osmo_int_to_float_str_buf(1000100, 0) -> rc=7 str="1000100"
osmo_int_to_float_str_buf(-1010000, 0) -> rc=8 str="-1010000"
osmo_int_to_float_str_buf(1100000, 0) -> rc=7 str="1100000"
osmo_int_to_float_str_buf(10000000, 0) -> rc=8 str="10000000"
osmo_int_to_float_str_buf(-10000000, 0) -> rc=9 str="-10000000"
osmo_int_to_float_str_buf(100000000, 0) -> rc=9 str="100000000"
osmo_int_to_float_str_buf(-100000000, 0) -> rc=10 str="-100000000"
osmo_int_to_float_str_buf(9223372036854775807, 0) -> rc=19 str="9223372036854775807"
osmo_int_to_float_str_buf(-9223372036854775807, 0) -> rc=20 str="-9223372036854775807"
osmo_int_to_float_str_buf(-9223372036854775808, 0) -> rc=4 str="-ERR"
osmo_int_to_float_str_buf(0, 1) -> rc=1 str="0"
osmo_int_to_float_str_buf(1, 1) -> rc=3 str="0.1"
osmo_int_to_float_str_buf(1000000, 1) -> rc=6 str="100000"
osmo_int_to_float_str_buf(-1000000, 1) -> rc=7 str="-100000"
osmo_int_to_float_str_buf(1000001, 1) -> rc=8 str="100000.1"
osmo_int_to_float_str_buf(-1000001, 1) -> rc=9 str="-100000.1"
osmo_int_to_float_str_buf(1000100, 1) -> rc=6 str="100010"
osmo_int_to_float_str_buf(-1010000, 1) -> rc=7 str="-101000"
osmo_int_to_float_str_buf(1100000, 1) -> rc=6 str="110000"
osmo_int_to_float_str_buf(10000000, 1) -> rc=7 str="1000000"
osmo_int_to_float_str_buf(-10000000, 1) -> rc=8 str="-1000000"
osmo_int_to_float_str_buf(100000000, 1) -> rc=8 str="10000000"
osmo_int_to_float_str_buf(-100000000, 1) -> rc=9 str="-10000000"
osmo_int_to_float_str_buf(9223372036854775807, 1) -> rc=20 str="922337203685477580.7"
osmo_int_to_float_str_buf(-9223372036854775807, 1) -> rc=21 str="-922337203685477580.7"
osmo_int_to_float_str_buf(-9223372036854775808, 1) -> rc=4 str="-ERR"
osmo_int_to_float_str_buf(0, 3) -> rc=1 str="0"
osmo_int_to_float_str_buf(1, 3) -> rc=5 str="0.001"
osmo_int_to_float_str_buf(1000000, 3) -> rc=4 str="1000"
osmo_int_to_float_str_buf(-1000000, 3) -> rc=5 str="-1000"
osmo_int_to_float_str_buf(1000001, 3) -> rc=8 str="1000.001"
osmo_int_to_float_str_buf(-1000001, 3) -> rc=9 str="-1000.001"
osmo_int_to_float_str_buf(1000100, 3) -> rc=6 str="1000.1"
osmo_int_to_float_str_buf(-1010000, 3) -> rc=5 str="-1010"
osmo_int_to_float_str_buf(1100000, 3) -> rc=4 str="1100"
osmo_int_to_float_str_buf(10000000, 3) -> rc=5 str="10000"
osmo_int_to_float_str_buf(-10000000, 3) -> rc=6 str="-10000"
osmo_int_to_float_str_buf(100000000, 3) -> rc=6 str="100000"
osmo_int_to_float_str_buf(-100000000, 3) -> rc=7 str="-100000"
osmo_int_to_float_str_buf(9223372036854775807, 3) -> rc=20 str="9223372036854775.807"
osmo_int_to_float_str_buf(-9223372036854775807, 3) -> rc=21 str="-9223372036854775.807"
osmo_int_to_float_str_buf(-9223372036854775808, 3) -> rc=4 str="-ERR"
osmo_int_to_float_str_buf(0, 6) -> rc=1 str="0"
osmo_int_to_float_str_buf(1, 6) -> rc=8 str="0.000001"
osmo_int_to_float_str_buf(1000000, 6) -> rc=1 str="1"
osmo_int_to_float_str_buf(-1000000, 6) -> rc=2 str="-1"
osmo_int_to_float_str_buf(1000001, 6) -> rc=8 str="1.000001"
osmo_int_to_float_str_buf(-1000001, 6) -> rc=9 str="-1.000001"
osmo_int_to_float_str_buf(1000100, 6) -> rc=6 str="1.0001"
osmo_int_to_float_str_buf(-1010000, 6) -> rc=5 str="-1.01"
osmo_int_to_float_str_buf(1100000, 6) -> rc=3 str="1.1"
osmo_int_to_float_str_buf(10000000, 6) -> rc=2 str="10"
osmo_int_to_float_str_buf(-10000000, 6) -> rc=3 str="-10"
osmo_int_to_float_str_buf(100000000, 6) -> rc=3 str="100"
osmo_int_to_float_str_buf(-100000000, 6) -> rc=4 str="-100"
osmo_int_to_float_str_buf(9223372036854775807, 6) -> rc=20 str="9223372036854.775807"
osmo_int_to_float_str_buf(-9223372036854775807, 6) -> rc=21 str="-9223372036854.775807"
osmo_int_to_float_str_buf(-9223372036854775808, 6) -> rc=4 str="-ERR"
osmo_int_to_float_str_buf(0, 17) -> rc=1 str="0"
osmo_int_to_float_str_buf(1, 17) -> rc=19 str="0.00000000000000001"
osmo_int_to_float_str_buf(1000000, 17) -> rc=13 str="0.00000000001"
osmo_int_to_float_str_buf(-1000000, 17) -> rc=14 str="-0.00000000001"
osmo_int_to_float_str_buf(1000001, 17) -> rc=19 str="0.00000000001000001"
osmo_int_to_float_str_buf(-1000001, 17) -> rc=20 str="-0.00000000001000001"
osmo_int_to_float_str_buf(1000100, 17) -> rc=17 str="0.000000000010001"
osmo_int_to_float_str_buf(-1010000, 17) -> rc=16 str="-0.0000000000101"
osmo_int_to_float_str_buf(1100000, 17) -> rc=14 str="0.000000000011"
osmo_int_to_float_str_buf(10000000, 17) -> rc=12 str="0.0000000001"
osmo_int_to_float_str_buf(-10000000, 17) -> rc=13 str="-0.0000000001"
osmo_int_to_float_str_buf(100000000, 17) -> rc=11 str="0.000000001"
osmo_int_to_float_str_buf(-100000000, 17) -> rc=12 str="-0.000000001"
osmo_int_to_float_str_buf(9223372036854775807, 17) -> rc=20 str="92.23372036854775807"
osmo_int_to_float_str_buf(-9223372036854775807, 17) -> rc=21 str="-92.23372036854775807"
osmo_int_to_float_str_buf(-9223372036854775808, 17) -> rc=4 str="-ERR"
osmo_int_to_float_str_buf(0, 18) -> rc=1 str="0"
osmo_int_to_float_str_buf(1, 18) -> rc=20 str="0.000000000000000001"
osmo_int_to_float_str_buf(1000000, 18) -> rc=14 str="0.000000000001"
osmo_int_to_float_str_buf(-1000000, 18) -> rc=15 str="-0.000000000001"
osmo_int_to_float_str_buf(1000001, 18) -> rc=20 str="0.000000000001000001"
osmo_int_to_float_str_buf(-1000001, 18) -> rc=21 str="-0.000000000001000001"
osmo_int_to_float_str_buf(1000100, 18) -> rc=18 str="0.0000000000010001"
osmo_int_to_float_str_buf(-1010000, 18) -> rc=17 str="-0.00000000000101"
osmo_int_to_float_str_buf(1100000, 18) -> rc=15 str="0.0000000000011"
osmo_int_to_float_str_buf(10000000, 18) -> rc=13 str="0.00000000001"
osmo_int_to_float_str_buf(-10000000, 18) -> rc=14 str="-0.00000000001"
osmo_int_to_float_str_buf(100000000, 18) -> rc=12 str="0.0000000001"
osmo_int_to_float_str_buf(-100000000, 18) -> rc=13 str="-0.0000000001"
osmo_int_to_float_str_buf(9223372036854775807, 18) -> rc=20 str="9.223372036854775807"
osmo_int_to_float_str_buf(-9223372036854775807, 18) -> rc=21 str="-9.223372036854775807"
osmo_int_to_float_str_buf(-9223372036854775808, 18) -> rc=4 str="-ERR"
osmo_int_to_float_str_buf(0, 19) -> rc=1 str="0"
osmo_int_to_float_str_buf(1, 19) -> rc=21 str="0.0000000000000000001"
osmo_int_to_float_str_buf(1000000, 19) -> rc=15 str="0.0000000000001"
osmo_int_to_float_str_buf(-1000000, 19) -> rc=16 str="-0.0000000000001"
osmo_int_to_float_str_buf(1000001, 19) -> rc=21 str="0.0000000000001000001"
osmo_int_to_float_str_buf(-1000001, 19) -> rc=22 str="-0.0000000000001000001"
osmo_int_to_float_str_buf(1000100, 19) -> rc=19 str="0.00000000000010001"
osmo_int_to_float_str_buf(-1010000, 19) -> rc=18 str="-0.000000000000101"
osmo_int_to_float_str_buf(1100000, 19) -> rc=16 str="0.00000000000011"
osmo_int_to_float_str_buf(10000000, 19) -> rc=14 str="0.000000000001"
osmo_int_to_float_str_buf(-10000000, 19) -> rc=15 str="-0.000000000001"
osmo_int_to_float_str_buf(100000000, 19) -> rc=13 str="0.00000000001"
osmo_int_to_float_str_buf(-100000000, 19) -> rc=14 str="-0.00000000001"
osmo_int_to_float_str_buf(9223372036854775807, 19) -> rc=21 str="0.9223372036854775807"
osmo_int_to_float_str_buf(-9223372036854775807, 19) -> rc=22 str="-0.9223372036854775807"
osmo_int_to_float_str_buf(-9223372036854775808, 19) -> rc=4 str="-ERR"
osmo_int_to_float_str_buf(0, 23) -> rc=1 str="0"
osmo_int_to_float_str_buf(1, 23) -> rc=25 str="0.00000000000000000000001"
osmo_int_to_float_str_buf(1000000, 23) -> rc=19 str="0.00000000000000001"
osmo_int_to_float_str_buf(-1000000, 23) -> rc=20 str="-0.00000000000000001"
osmo_int_to_float_str_buf(1000001, 23) -> rc=25 str="0.00000000000000001000001"
osmo_int_to_float_str_buf(-1000001, 23) -> rc=26 str="-0.00000000000000001000001"
osmo_int_to_float_str_buf(1000100, 23) -> rc=23 str="0.000000000000000010001"
osmo_int_to_float_str_buf(-1010000, 23) -> rc=22 str="-0.0000000000000000101"
osmo_int_to_float_str_buf(1100000, 23) -> rc=20 str="0.000000000000000011"
osmo_int_to_float_str_buf(10000000, 23) -> rc=18 str="0.0000000000000001"
osmo_int_to_float_str_buf(-10000000, 23) -> rc=19 str="-0.0000000000000001"
osmo_int_to_float_str_buf(100000000, 23) -> rc=17 str="0.000000000000001"
osmo_int_to_float_str_buf(-100000000, 23) -> rc=18 str="-0.000000000000001"
osmo_int_to_float_str_buf(9223372036854775807, 23) -> rc=25 str="0.00009223372036854775807"
osmo_int_to_float_str_buf(-9223372036854775807, 23) -> rc=26 str="-0.00009223372036854775807"
osmo_int_to_float_str_buf(-9223372036854775808, 23) -> rc=4 str="-ERR"
--- test_str_to_int
osmo_str_to_int(NULL, 10, -1000, 1000) -> rc=-22=-EINVAL val=0
osmo_str_to_int("", 10, -1000, 1000) -> rc=-22=-EINVAL val=0
osmo_str_to_int(" ", 10, -1000, 1000) -> rc=-22=-EINVAL val=0
osmo_str_to_int("-", 10, -1000, 1000) -> rc=-22=-EINVAL val=0
osmo_str_to_int("--", 10, -1000, 1000) -> rc=-22=-EINVAL val=0
osmo_str_to_int("+", 10, -1000, 1000) -> rc=-22=-EINVAL val=0
osmo_str_to_int("++", 10, -1000, 1000) -> rc=-22=-EINVAL val=0
osmo_str_to_int("0", 10, -1000, 1000) -> rc=0 val=0
osmo_str_to_int("1", 10, -1000, 1000) -> rc=0 val=1
osmo_str_to_int("+1", 10, -1000, 1000) -> rc=0 val=1
osmo_str_to_int("-1", 10, -1000, 1000) -> rc=0 val=-1
osmo_str_to_int("1000", 10, -1000, 1000) -> rc=0 val=1000
osmo_str_to_int("+1000", 10, -1000, 1000) -> rc=0 val=1000
osmo_str_to_int("-1000", 10, -1000, 1000) -> rc=0 val=-1000
osmo_str_to_int("1001", 10, -1000, 1000) -> rc=-34=-ERANGE val=1001
osmo_str_to_int("+1001", 10, -1000, 1000) -> rc=-34=-ERANGE val=1001
osmo_str_to_int("-1001", 10, -1000, 1000) -> rc=-34=-ERANGE val=-1001
osmo_str_to_int("0", 16, -1000, 1000) -> rc=0 val=0
osmo_str_to_int("1", 16, -1000, 1000) -> rc=0 val=1
osmo_str_to_int("0x1", 16, -1000, 1000) -> rc=0 val=1
osmo_str_to_int("+1", 16, -1000, 1000) -> rc=0 val=1
osmo_str_to_int("-1", 16, -1000, 1000) -> rc=0 val=-1
osmo_str_to_int("+0x1", 16, -1000, 1000) -> rc=0 val=1
osmo_str_to_int("-0x1", 16, -1000, 1000) -> rc=0 val=-1
osmo_str_to_int("3e8", 16, -1000, 1000) -> rc=0 val=1000
osmo_str_to_int("3E8", 16, -1000, 1000) -> rc=0 val=1000
osmo_str_to_int("0x3e8", 16, -1000, 1000) -> rc=0 val=1000
osmo_str_to_int("0x3E8", 16, -1000, 1000) -> rc=0 val=1000
osmo_str_to_int("+3e8", 16, -1000, 1000) -> rc=0 val=1000
osmo_str_to_int("+3E8", 16, -1000, 1000) -> rc=0 val=1000
osmo_str_to_int("+0x3e8", 16, -1000, 1000) -> rc=0 val=1000
osmo_str_to_int("+0x3E8", 16, -1000, 1000) -> rc=0 val=1000
osmo_str_to_int("-3e8", 16, -1000, 1000) -> rc=0 val=-1000
osmo_str_to_int("-3E8", 16, -1000, 1000) -> rc=0 val=-1000
osmo_str_to_int("-0x3e8", 16, -1000, 1000) -> rc=0 val=-1000
osmo_str_to_int("-0x3E8", 16, -1000, 1000) -> rc=0 val=-1000
osmo_str_to_int("3e9", 16, -1000, 1000) -> rc=-34=-ERANGE val=1001
osmo_str_to_int("3E9", 16, -1000, 1000) -> rc=-34=-ERANGE val=1001
osmo_str_to_int("0x3e9", 16, -1000, 1000) -> rc=-34=-ERANGE val=1001
osmo_str_to_int("0x3E9", 16, -1000, 1000) -> rc=-34=-ERANGE val=1001
osmo_str_to_int("+3e9", 16, -1000, 1000) -> rc=-34=-ERANGE val=1001
osmo_str_to_int("+3E9", 16, -1000, 1000) -> rc=-34=-ERANGE val=1001
osmo_str_to_int("+0x3e9", 16, -1000, 1000) -> rc=-34=-ERANGE val=1001
osmo_str_to_int("+0x3E9", 16, -1000, 1000) -> rc=-34=-ERANGE val=1001
osmo_str_to_int("-3e9", 16, -1000, 1000) -> rc=-34=-ERANGE val=-1001
osmo_str_to_int("-3E9", 16, -1000, 1000) -> rc=-34=-ERANGE val=-1001
osmo_str_to_int("-0x3e9", 16, -1000, 1000) -> rc=-34=-ERANGE val=-1001
osmo_str_to_int("-0x3E9", 16, -1000, 1000) -> rc=-34=-ERANGE val=-1001
osmo_str_to_int("garble", 10, -1000, 1000) -> rc=-22=-EINVAL val=0
osmo_str_to_int("-garble", 10, -1000, 1000) -> rc=-22=-EINVAL val=0
osmo_str_to_int("0x123", 10, -1000, 1000) -> rc=-7=-E2BIG val=0
osmo_str_to_int("123potatoes", 10, -1000, 1000) -> rc=-7=-E2BIG val=123
osmo_str_to_int("123 potatoes", 10, -1000, 1000) -> rc=-7=-E2BIG val=123
osmo_str_to_int("123 ", 10, -1000, 1000) -> rc=-7=-E2BIG val=123
osmo_str_to_int("123.4", 10, -1000, 1000) -> rc=-7=-E2BIG val=123
--- test_str_to_int64
osmo_str_to_int64(NULL, 10, -1000, 1000) -> rc=-22=-EINVAL val=0
osmo_str_to_int64("", 10, -1000, 1000) -> rc=-22=-EINVAL val=0
osmo_str_to_int64(" ", 10, -1000, 1000) -> rc=-22=-EINVAL val=0
osmo_str_to_int64("-", 10, -1000, 1000) -> rc=-22=-EINVAL val=0
osmo_str_to_int64("--", 10, -1000, 1000) -> rc=-22=-EINVAL val=0
osmo_str_to_int64("+", 10, -1000, 1000) -> rc=-22=-EINVAL val=0
osmo_str_to_int64("++", 10, -1000, 1000) -> rc=-22=-EINVAL val=0
osmo_str_to_int64("0", 10, -1000, 1000) -> rc=0 val=0
osmo_str_to_int64("1", 10, -1000, 1000) -> rc=0 val=1
osmo_str_to_int64("+1", 10, -1000, 1000) -> rc=0 val=1
osmo_str_to_int64("-1", 10, -1000, 1000) -> rc=0 val=-1
osmo_str_to_int64("1000", 10, -1000, 1000) -> rc=0 val=1000
osmo_str_to_int64("+1000", 10, -1000, 1000) -> rc=0 val=1000
osmo_str_to_int64("-1000", 10, -1000, 1000) -> rc=0 val=-1000
osmo_str_to_int64("1001", 10, -1000, 1000) -> rc=-34=-ERANGE val=1001
osmo_str_to_int64("+1001", 10, -1000, 1000) -> rc=-34=-ERANGE val=1001
osmo_str_to_int64("-1001", 10, -1000, 1000) -> rc=-34=-ERANGE val=-1001
osmo_str_to_int64("0", 16, -1000, 1000) -> rc=0 val=0
osmo_str_to_int64("1", 16, -1000, 1000) -> rc=0 val=1
osmo_str_to_int64("0x1", 16, -1000, 1000) -> rc=0 val=1
osmo_str_to_int64("+1", 16, -1000, 1000) -> rc=0 val=1
osmo_str_to_int64("-1", 16, -1000, 1000) -> rc=0 val=-1
osmo_str_to_int64("+0x1", 16, -1000, 1000) -> rc=0 val=1
osmo_str_to_int64("-0x1", 16, -1000, 1000) -> rc=0 val=-1
osmo_str_to_int64("3e8", 16, -1000, 1000) -> rc=0 val=1000
osmo_str_to_int64("3E8", 16, -1000, 1000) -> rc=0 val=1000
osmo_str_to_int64("0x3e8", 16, -1000, 1000) -> rc=0 val=1000
osmo_str_to_int64("0x3E8", 16, -1000, 1000) -> rc=0 val=1000
osmo_str_to_int64("+3e8", 16, -1000, 1000) -> rc=0 val=1000
osmo_str_to_int64("+3E8", 16, -1000, 1000) -> rc=0 val=1000
osmo_str_to_int64("+0x3e8", 16, -1000, 1000) -> rc=0 val=1000
osmo_str_to_int64("+0x3E8", 16, -1000, 1000) -> rc=0 val=1000
osmo_str_to_int64("-3e8", 16, -1000, 1000) -> rc=0 val=-1000
osmo_str_to_int64("-3E8", 16, -1000, 1000) -> rc=0 val=-1000
osmo_str_to_int64("-0x3e8", 16, -1000, 1000) -> rc=0 val=-1000
osmo_str_to_int64("-0x3E8", 16, -1000, 1000) -> rc=0 val=-1000
osmo_str_to_int64("3e9", 16, -1000, 1000) -> rc=-34=-ERANGE val=1001
osmo_str_to_int64("3E9", 16, -1000, 1000) -> rc=-34=-ERANGE val=1001
osmo_str_to_int64("0x3e9", 16, -1000, 1000) -> rc=-34=-ERANGE val=1001
osmo_str_to_int64("0x3E9", 16, -1000, 1000) -> rc=-34=-ERANGE val=1001
osmo_str_to_int64("+3e9", 16, -1000, 1000) -> rc=-34=-ERANGE val=1001
osmo_str_to_int64("+3E9", 16, -1000, 1000) -> rc=-34=-ERANGE val=1001
osmo_str_to_int64("+0x3e9", 16, -1000, 1000) -> rc=-34=-ERANGE val=1001
osmo_str_to_int64("+0x3E9", 16, -1000, 1000) -> rc=-34=-ERANGE val=1001
osmo_str_to_int64("-3e9", 16, -1000, 1000) -> rc=-34=-ERANGE val=-1001
osmo_str_to_int64("-3E9", 16, -1000, 1000) -> rc=-34=-ERANGE val=-1001
osmo_str_to_int64("-0x3e9", 16, -1000, 1000) -> rc=-34=-ERANGE val=-1001
osmo_str_to_int64("-0x3E9", 16, -1000, 1000) -> rc=-34=-ERANGE val=-1001
osmo_str_to_int64("garble", 10, -1000, 1000) -> rc=-22=-EINVAL val=0
osmo_str_to_int64("-garble", 10, -1000, 1000) -> rc=-22=-EINVAL val=0
osmo_str_to_int64("0x123", 10, -1000, 1000) -> rc=-7=-E2BIG val=0
osmo_str_to_int64("123potatoes", 10, -1000, 1000) -> rc=-7=-E2BIG val=123
osmo_str_to_int64("123 potatoes", 10, -1000, 1000) -> rc=-7=-E2BIG val=123
osmo_str_to_int64("123 ", 10, -1000, 1000) -> rc=-7=-E2BIG val=123
osmo_str_to_int64("123.4", 10, -1000, 1000) -> rc=-7=-E2BIG val=123
osmo_str_to_int64("-9223372036854775808", 10, -9223372036854775808, 9223372036854775807) -> rc=0 val=-9223372036854775808
osmo_str_to_int64("9223372036854775807", 10, -9223372036854775808, 9223372036854775807) -> rc=0 val=9223372036854775807
osmo_str_to_int64("-9223372036854775809", 10, -9223372036854775808, 9223372036854775807) -> rc=-75=-EOVERFLOW val=-9223372036854775808
osmo_str_to_int64("9223372036854775808", 10, -9223372036854775808, 9223372036854775807) -> rc=-75=-EOVERFLOW val=9223372036854775807
osmo_str_to_int64("-9223372036854775808", 10, -1000, 1000) -> rc=-34=-ERANGE val=-9223372036854775808
osmo_str_to_int64("9223372036854775807", 10, -1000, 1000) -> rc=-34=-ERANGE val=9223372036854775807
osmo_str_to_int64("-9223372036854775809", 10, -1000, 1000) -> rc=-75=-EOVERFLOW val=-9223372036854775808
osmo_str_to_int64("9223372036854775808", 10, -1000, 1000) -> rc=-75=-EOVERFLOW val=9223372036854775807