add a recursion test that will crash roker-linux
authorRoker <roker@pep-project.org>
Sun, 03 Jul 2016 01:11:23 +0200
branchroker-linux
changeset 799f60a61e7d403
parent 787 274c303a0c5a
child 800 6564b62a26e5
add a recursion test that will crash
test/pEpEngineTest.cc
     1.1 --- a/test/pEpEngineTest.cc	Fri Jul 01 11:00:13 2016 +0200
     1.2 +++ b/test/pEpEngineTest.cc	Sun Jul 03 01:11:23 2016 +0200
     1.3 @@ -9,6 +9,7 @@
     1.4  
     1.5  #include "../src/pEpEngine.h"
     1.6  #include "../src/keymanagement.h"
     1.7 +#include "../src/stringpair.h"
     1.8  
     1.9  
    1.10  using namespace std;
    1.11 @@ -56,6 +57,37 @@
    1.12  }
    1.13  
    1.14  
    1.15 +int stringlist_test()
    1.16 +{
    1.17 +	char stringkey[32] = {0};
    1.18 +	char stringvalue[32] = {0};
    1.19 +
    1.20 +	for(double len=1.0; len<1E18; len=(len*3.8251)+1)
    1.21 +	{
    1.22 +		const unsigned ulen = unsigned(len);
    1.23 +		std::cout << "Stringpairlist length=" << ulen << ": " << std::endl;
    1.24 +		stringpair_list_t* sl = new_stringpair_list(nullptr);
    1.25 +		for(unsigned n=0; n<ulen; ++n)
    1.26 +		{
    1.27 +			snprintf(stringkey,63, "%x %x %a", n, ulen, len);
    1.28 +			snprintf(stringvalue,63, "%u %u %a", n, ulen, len);
    1.29 +			//std::cout << "\r\t\"" << stringvalue << "\" " << std::flush;
    1.30 +			auto sp = new_stringpair( stringkey, stringvalue);
    1.31 +			auto ret = stringpair_list_add(sl, sp);
    1.32 +			if(ret==NULL)
    1.33 +			{
    1.34 +				std::cout << " OUT OF MEMORY! n=" << n  << std::endl;
    1.35 +				return -1;
    1.36 +			}
    1.37 +		}
    1.38 +		std::cout << "\tfree_stringpairlist()..." << std::flush;
    1.39 +		free_stringpair_list(sl);
    1.40 +		std::cout << std::endl;
    1.41 +	}
    1.42 +	return 0;
    1.43 +}
    1.44 +
    1.45 +
    1.46  int main(int argc, char* argv[])
    1.47  {
    1.48      PEP_SESSION session;
    1.49 @@ -66,6 +98,8 @@
    1.50      cout << "returning from init() with result == " << init_result << "\n";
    1.51      assert(init_result == PEP_STATUS_OK);
    1.52  
    1.53 +	stringlist_test();
    1.54 +
    1.55      PEP_SESSION second_session;
    1.56      cout << "second session test\n";
    1.57      PEP_STATUS second_init_result = init(&second_session);