summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/test_solter.py54
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)