00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00024 #include "config.h"
00025
00026 #include <scalestack/kernel/test.h>
00027
00028 class test_suite: public scalestack::kernel::test_suite<test_suite>
00029 {
00030 public:
00031
00032 void setup(void)
00033 {
00034 add_default_threading_service();
00035 add_default_event_service();
00036 core->add_module_option_value("proxy", "addresses", "localhost:32123");
00037 core->add_module_option_value("proxy", "server_address", "localhost:32124");
00038 core->add_module_option_value("echo::server::tcp", "addresses",
00039 "localhost:32124");
00040 core->add_module_option_value("echo::flood::tcp", "addresses",
00041 "localhost:32123");
00042 core->set_signal_handlers();
00043 }
00044
00045 void test_default(void)
00046 {
00047 core->run();
00048 }
00049
00050 void test_iterations(void)
00051 {
00052 core->add_module_option_value("echo::flood::tcp", "iterations", "5");
00053 core->run();
00054 }
00055
00056 void test_reconnect(void)
00057 {
00058 core->add_module_option_value("echo::flood::tcp", "iterations", "5");
00059 core->add_module_option_value("echo::flood::tcp", "reconnect", "True");
00060 core->run();
00061 }
00062
00063 void test_count(void)
00064 {
00065 core->add_module_option_value("echo::flood::tcp", "count", "5");
00066 core->run();
00067 }
00068
00069 void test_write_size(void)
00070 {
00071 core->add_module_option_value("echo::flood::tcp", "write_size", "128");
00072 core->run();
00073 }
00074
00075 void test_buffered_write_size(void)
00076 {
00077 core->add_module_option_value("echo::flood::tcp", "write_size", "128");
00078 core->add_module_option_value("echo::flood::tcp", "flush", "False");
00079 core->run();
00080 }
00081
00082 void test_large_buffer(void)
00083 {
00084 core->add_module_option_value("echo::flood", "random_buffer_size",
00085 "1048576");
00086 core->run();
00087 }
00088
00089 void test_server_timeout(void)
00090 {
00091 core->add_module_option_value("proxy", "server_address", "localhost:32125");
00092 core->add_module_option_value("proxy", "server_timeout", "1");
00093 core->run();
00094 }
00095
00096 test_suite(int argc, const char** argv):
00097 scalestack::kernel::test_suite<test_suite>(argc, argv)
00098 {
00099 test_case(test_suite::test_default);
00100 test_case(test_suite::test_iterations);
00101 test_case(test_suite::test_reconnect);
00102 test_case(test_suite::test_count);
00103 test_case(test_suite::test_write_size);
00104 test_case(test_suite::test_buffered_write_size);
00105 test_case(test_suite::test_large_buffer);
00106 test_case(test_suite::test_server_timeout);
00107 }
00108 };
00109
00110 int main(int argc, const char* argv[])
00111 {
00112 test_suite test_suite(argc - 1, argv + 1);
00113 test_suite.run();
00114 return 0;
00115 }