X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fbindings%2Frmr-python%2Ftests%2Ftest_rmr.py;h=33b61f75148ecccbc5e326bbc015f0483c3d570a;hb=refs%2Fchanges%2F42%2F2642%2F1;hp=c7e872a1d76343dd3eee6bf00dff693a202c64cd;hpb=c5de5c7413901b8de1da928b084a3ca2e88d490a;p=ric-plt%2Flib%2Frmr.git diff --git a/src/bindings/rmr-python/tests/test_rmr.py b/src/bindings/rmr-python/tests/test_rmr.py index c7e872a..33b61f7 100644 --- a/src/bindings/rmr-python/tests/test_rmr.py +++ b/src/bindings/rmr-python/tests/test_rmr.py @@ -1,7 +1,7 @@ # vim: ts=4 sw=4 expandtab: # =================================================================================2 -# Copyright (c) 2019 Nokia -# Copyright (c) 2018-2019 AT&T Intellectual Property. +# Copyright (c) 2019-2020 Nokia +# Copyright (c) 2018-2020 AT&T Intellectual Property. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -110,17 +110,23 @@ def test_meid(): assert rmr.rmr_get_meid(sbuf) == rmr.message_summary(sbuf)["meid"] == b"\x01\x02" assert len(rmr.rmr_get_meid(sbuf)) == 2 - rmr.rmr_set_meid(sbuf, b"\x00" * 32) + rmr.rmr_set_meid(sbuf, b"\x00" * 31) assert rmr.rmr_get_meid(sbuf) == rmr.message_summary(sbuf)["meid"] == b"" # NULL bytes get truncated - rmr.rmr_set_meid(sbuf, b"6" * 32) - assert rmr.rmr_get_meid(sbuf) == rmr.message_summary(sbuf)["meid"] == b"6" * 32 # string in string out + rmr.rmr_set_meid(sbuf, b"6" * 31) + assert rmr.rmr_get_meid(sbuf) == rmr.message_summary(sbuf)["meid"] == b"6" * 31 # string in string out rmr.rmr_set_meid(sbuf, b"\x01\x02") assert ( - rmr.rmr_get_meid(sbuf) == rmr.message_summary(sbuf)["meid"] == b"\x01\x02" + b"6" * 30 - ) # bytes in string out, 6s left over - assert len(rmr.rmr_get_meid(sbuf)) == 32 + rmr.rmr_get_meid(sbuf) == rmr.message_summary(sbuf)["meid"] == b"\x01\x02" + ) # Ctypes will chop at first nil, so expect only 2 bytes back + + assert len(rmr.rmr_get_meid(sbuf)) == 2 + + # test that an exception is raised for buffers which are too long + with pytest.raises(exceptions.MeidSizeOutOfRange): + rmr.rmr_set_meid(sbuf, b"8" * 32) + def test_rmr_set_get(): @@ -168,6 +174,13 @@ def test_alloc_fancy(): assert sbuf.contents.sub_id == summary["subscription id"] == 654321 +def test_alloc_overlapping_flags(): + """test allocation with setting the transaction id""" + sbuf = rmr.rmr_alloc_msg(MRC_SEND, SIZE, gen_transaction_id=True, fixed_transaction_id=b"6" * 32) + summary = rmr.message_summary(sbuf) + assert summary["transaction id"] == b"66666666666666666666666666666666" + + def test_rcv_timeout(): """ test torcv; this is a scary test because if it fails... it doesn't fail, it will run forever!