diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-11-07 01:20:58 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-11-07 01:20:58 +0200 |
commit | 7d5d676eac56d2e34fd34ea7508594c6e50ae141 (patch) | |
tree | 84eb350a88e87afc6558860af9c72765fa1bffb2 /src | |
parent | 61f2cc45c275ce493ec7f53e6f22fb8cda89db31 (diff) | |
download | minetest-7d5d676eac56d2e34fd34ea7508594c6e50ae141.tar.gz minetest-7d5d676eac56d2e34fd34ea7508594c6e50ae141.tar.bz2 minetest-7d5d676eac56d2e34fd34ea7508594c6e50ae141.zip |
Infinite packet flood test for debugging the new network layer
Diffstat (limited to 'src')
-rw-r--r-- | src/test.cpp | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/src/test.cpp b/src/test.cpp index c1f04b2ef..a911f0cb1 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -953,10 +953,10 @@ struct TestConnection u16 peer_id_client = 2; #if 0 + /* + Send consequent packets in different order + */ { - /* - Send consequent packets in different order - */ //u8 data1[] = "hello1"; //u8 data2[] = "hello2"; SharedBuffer<u8> data1 = SharedBufferFromString("hello1"); @@ -1027,6 +1027,42 @@ struct TestConnection assert(got_exception); } #endif + /* + Send large amounts of packets (infinite test) + */ + { + infostream<<"Sending large amounts of packets (infinite test)"<<std::endl; + int sendcount = 0; + for(;;){ + int datasize = myrand_range(0,10)==0?myrand_range(100,10000):myrand_range(0,100); + SharedBuffer<u8> data1(datasize); + for(u16 i=0; i<datasize; i++) + data1[i] = i/4; + + int sendtimes = myrand_range(1,10); + for(int i=0; i<sendtimes; i++){ + server.Send(peer_id_client, 0, data1, true); + sendcount++; + } + infostream<<"sendcount="<<sendcount<<std::endl; + + int receivetimes = myrand_range(1,11); + for(int i=0; i<receivetimes; i++){ + u8 recvdata[datasize + 1000]; + u16 peer_id = 132; + u16 size = 0; + bool received = false; + try{ + size = client.Receive(peer_id, recvdata, datasize + 1000); + received = true; + }catch(con::NoIncomingDataException &e){ + } + } + } + } + /* + Send a large packet + */ { const int datasize = 30000; SharedBuffer<u8> data1(datasize); |