Browse Source

Extend the tests so that we check for failure in send

Brian Aker 13 years ago
parent
commit
a510ac31ba
3 changed files with 48 additions and 3 deletions
  1. 2 0
      libhostile/hostile.h
  2. 14 0
      libhostile/send.c
  3. 32 3
      tests/stress_worker.cc

+ 2 - 0
libhostile/hostile.h

@@ -28,6 +28,8 @@ extern "C" {
 
 void set_recv_close(bool arg, int frequency, int not_until_arg);
 
+void set_send_close(bool arg, int frequency, int not_until_arg);
+
 #ifdef __cplusplus
 }
 #endif

+ 14 - 0
libhostile/send.c

@@ -50,6 +50,20 @@ static void set_local(void)
   __function= set_function("send", "HOSTILE_SEND");
 }
 
+void set_send_close(bool arg, int frequency, int not_until_arg)
+{
+  if (arg)
+  {
+    __function.frequency= frequency;
+    not_until= not_until_arg;
+  }
+  else
+  {
+    __function.frequency= 0;
+    not_until= 0;
+  }
+}
+
 ssize_t send(int sockfd, const void *buf, size_t len, int flags)
 {
 

+ 32 - 3
tests/stress_worker.cc

@@ -127,6 +127,34 @@ static test_return_t worker_ramp_TEST(void *)
   return TEST_SUCCESS;
 }
 
+static test_return_t pre_recv(void *)
+{
+  set_recv_close(true, 20, 20);
+
+  return TEST_SUCCESS;
+}
+
+static test_return_t post_recv(void *)
+{
+  set_recv_close(true, 0, 0);
+
+  return TEST_SUCCESS;
+}
+
+static test_return_t pre_send(void *)
+{
+  set_send_close(true, 20, 20);
+
+  return TEST_SUCCESS;
+}
+
+static test_return_t post_send(void *)
+{
+  set_send_close(true, 0, 0);
+
+  return TEST_SUCCESS;
+}
+
 /*********************** World functions **************************************/
 
 static void *world_create(server_startup_st& servers, test_return_t& error)
@@ -160,13 +188,14 @@ static bool world_destroy(void *)
 }
 
 test_st tests[] ={
-  {"load", 0, worker_ramp_TEST },
-  {"load 2", 0, worker_ramp_TEST },
+  {"first pass", 0, worker_ramp_TEST },
+  {"second pass", 0, worker_ramp_TEST },
   {0, 0, 0}
 };
 
 collection_st collection[] ={
-  {"worker", 0, 0, tests},
+  {"recv()", pre_recv, post_recv, tests},
+  {"send()", pre_send, post_send, tests},
   {0, 0, 0, 0}
 };