diff options
author | Olivier Gayot <olivier.gayot@sigexec.com> | 2020-10-14 20:33:50 +0200 |
---|---|---|
committer | Olivier Gayot <olivier.gayot@sigexec.com> | 2020-10-14 20:33:50 +0200 |
commit | de0497b72046624df7ab17f3c57628e38c7af452 (patch) | |
tree | 23ac2776f3b4b67ef2322113760428c859799a1d /tests/test_solter.py | |
parent | 2970aa61feddd11c9b4421cc8a5e31e8ad31ef10 (diff) |
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
Diffstat (limited to 'tests/test_solter.py')
-rw-r--r-- | tests/test_solter.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/test_solter.py b/tests/test_solter.py index 5166a4f..6a41d50 100644 --- a/tests/test_solter.py +++ b/tests/test_solter.py @@ -13,3 +13,57 @@ class TestSolter(unittest.TestCase): with self.assertRaises(ValueError): solter.get_commands_send_data(sockfd=3, data='Hello\nWorld') + + def test_get_commands_change_tcp_option(self): + expected = ( + "set $rsp -= sizeof(int)", + "set {int}$rsp = 137", + "call (int)setsockopt(42, 6, 4, $rsp, sizeof(int))", + "set $rsp += sizeof(int)", + ) + self.assertEqual(solter._get_commands_change_tcp_option(sockfd=42, value=137, param=4), expected) + + def test_get_commands_enable_keepalive(self): + expected = ( + "set $rsp -= sizeof(int)", + "set {int}$rsp = 1", + "call (int)setsockopt(13, 1, 9, $rsp, sizeof(int))", + "set $rsp += sizeof(int)", + ) + self.assertEqual(solter.get_commands_enable_keepalive(sockfd=13), expected) + + def test_get_commands_disable_keepalive(self): + expected = ( + "set $rsp -= sizeof(int)", + "set {int}$rsp = 0", + "call (int)setsockopt(14, 1, 9, $rsp, sizeof(int))", + "set $rsp += sizeof(int)", + ) + self.assertEqual(solter.get_commands_disable_keepalive(sockfd=14), expected) + + def test_get_commands_change_keepalive_time(self): + expected = ( + "set $rsp -= sizeof(int)", + "set {int}$rsp = 60", + "call (int)setsockopt(15, 6, 4, $rsp, sizeof(int))", + "set $rsp += sizeof(int)", + ) + self.assertEqual(solter.get_commands_change_keepalive_time(sockfd=15, value=60), expected) + + def test_get_commands_change_keepalive_count(self): + expected = ( + "set $rsp -= sizeof(int)", + "set {int}$rsp = 10", + "call (int)setsockopt(16, 6, 6, $rsp, sizeof(int))", + "set $rsp += sizeof(int)", + ) + self.assertEqual(solter.get_commands_change_keepalive_count(sockfd=16, value=10), expected) + + def test_get_commands_change_keepalive_interval(self): + expected = ( + "set $rsp -= sizeof(int)", + "set {int}$rsp = 40", + "call (int)setsockopt(17, 6, 5, $rsp, sizeof(int))", + "set $rsp += sizeof(int)", + ) + self.assertEqual(solter.get_commands_change_keepalive_intvl(sockfd=17, value=40), expected) |