Commit 72053737 authored by john selbie's avatar john selbie

Added unit test for crc32. Adjusted config parser.

parent 4c8f7c9d
...@@ -528,8 +528,8 @@ HRESULT BuildServerConfigurationFromArgs(StartupArgs& argsIn, CStunServerConfig* ...@@ -528,8 +528,8 @@ HRESULT BuildServerConfigurationFromArgs(StartupArgs& argsIn, CStunServerConfig*
Logging::LogMsg(LL_ALWAYS, "Error with --threading. required argument must be between 0 - 64"); Logging::LogMsg(LL_ALWAYS, "Error with --threading. required argument must be between 0 - 64");
Chk(hr); Chk(hr);
} }
config.nThreadsPerSocket = threadcount;
} }
config.nThreadsPerSocket = threadcount;
*pConfigOut = config; *pConfigOut = config;
hr = S_OK; hr = S_OK;
......
include ../common.inc include ../common.inc
PROJECT_TARGET := stuntestcode PROJECT_TARGET := stuntestcode
PROJECT_OBJS := testatomichelpers.o testbuilder.o testclientlogic.o testcmdline.o testcode.o testdatastream.o testfasthash.o testintegrity.o testmessagehandler.o testpolling.o testratelimiter.o testreader.o testrecvfromex.o PROJECT_OBJS := testatomichelpers.o testbuilder.o testclientlogic.o testcmdline.o testcrc32.o testcode.o testdatastream.o testfasthash.o testintegrity.o testmessagehandler.o testpolling.o testratelimiter.o testreader.o testrecvfromex.o
INCLUDES := $(BOOST_INCLUDE) $(OPENSSL_INCLUDE) -I../common -I../stuncore -I../networkutils INCLUDES := $(BOOST_INCLUDE) $(OPENSSL_INCLUDE) -I../common -I../stuncore -I../networkutils
LIB_PATH := -L../networkutils -L../stuncore -L../common LIB_PATH := -L../networkutils -L../stuncore -L../common
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "testclientlogic.h" #include "testclientlogic.h"
#include "testrecvfromex.h" #include "testrecvfromex.h"
#include "testfasthash.h" #include "testfasthash.h"
#include "testcrc32.h"
#include "cmdlineparser.h" #include "cmdlineparser.h"
#include "oshelper.h" #include "oshelper.h"
#include "prettyprint.h" #include "prettyprint.h"
...@@ -71,7 +72,7 @@ void ReaderFuzzTest() ...@@ -71,7 +72,7 @@ void ReaderFuzzTest()
void RunUnitTests() void RunUnitTests()
{ {
std::vector<IUnitTest*> vecTests; std::vector<std::shared_ptr<IUnitTest>> vecTests;
std::shared_ptr<CTestDataStream> spTestDataStream(new CTestDataStream); std::shared_ptr<CTestDataStream> spTestDataStream(new CTestDataStream);
std::shared_ptr<CTestReader> spTestReader(new CTestReader); std::shared_ptr<CTestReader> spTestReader(new CTestReader);
...@@ -86,21 +87,22 @@ void RunUnitTests() ...@@ -86,21 +87,22 @@ void RunUnitTests()
std::shared_ptr<CTestPolling> spTestPolling(new CTestPolling); std::shared_ptr<CTestPolling> spTestPolling(new CTestPolling);
std::shared_ptr<CTestAtomicHelpers> spTestAtomicHelpers(new CTestAtomicHelpers); std::shared_ptr<CTestAtomicHelpers> spTestAtomicHelpers(new CTestAtomicHelpers);
std::shared_ptr<CTestRateLimiter> spTestRateLimiter(new CTestRateLimiter); std::shared_ptr<CTestRateLimiter> spTestRateLimiter(new CTestRateLimiter);
std::shared_ptr<CTestCRC32> spTestCRC32(new CTestCRC32);
vecTests.push_back(spTestDataStream.get());
vecTests.push_back(spTestReader.get()); vecTests.push_back(spTestDataStream);
vecTests.push_back(spTestBuilder.get()); vecTests.push_back(spTestReader);
vecTests.push_back(spTestIntegrity.get()); vecTests.push_back(spTestBuilder);
vecTests.push_back(spTestMessageHandler.get()); vecTests.push_back(spTestIntegrity);
vecTests.push_back(spTestCmdLineParser.get()); vecTests.push_back(spTestMessageHandler);
vecTests.push_back(spTestClientLogic.get()); vecTests.push_back(spTestCmdLineParser);
vecTests.push_back(spTestRecvFromEx4.get()); vecTests.push_back(spTestClientLogic);
vecTests.push_back(spTestRecvFromEx6.get()); vecTests.push_back(spTestRecvFromEx4);
vecTests.push_back(spTestFastHash.get()); vecTests.push_back(spTestRecvFromEx6);
vecTests.push_back(spTestPolling.get()); vecTests.push_back(spTestFastHash);
vecTests.push_back(spTestAtomicHelpers.get()); vecTests.push_back(spTestPolling);
vecTests.push_back(spTestRateLimiter.get()); vecTests.push_back(spTestAtomicHelpers);
vecTests.push_back(spTestRateLimiter);
vecTests.push_back(spTestCRC32);
for (size_t index = 0; index < vecTests.size(); index++) for (size_t index = 0; index < vecTests.size(); index++)
{ {
......
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: testcrc32.cpp
* Author: jselbie
*
* Created on November 5, 2018, 12:07 AM
*/
#include "commonincludes.hpp"
#include "crc32.h"
#include "unittest.h"
#include "testcrc32.h"
struct crc_test
{
const char* psz;
uint32_t expected;
};
static crc_test g_tests[] = {
{"", 0},
{"The quick brown fox jumped over the lazy dog.", 0x82a34642}
};
HRESULT CTestCRC32::Run()
{
size_t numTests = ARRAYSIZE(g_tests);
HRESULT hr = S_OK;
for (size_t i = 0; i < numTests; i++)
{
uint32_t val = crc32(0, (uint8_t*)(g_tests[i].psz), strlen(g_tests[i].psz));
ChkIf(val != g_tests[i].expected, E_FAIL);
}
Cleanup:
return hr;
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: testcrc32.h
* Author: jselbie
*
* Created on November 5, 2018, 12:07 AM
*/
#ifndef TESTCRC32_H
#define TESTCRC32_H
class CTestCRC32 : public IUnitTest
{
public:
HRESULT Run();
UT_DECLARE_TEST_NAME("CTestCRC32");
};
#endif /* TESTCRC32_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment