added cpp unit, simple bootstrap build script, added unit test to check a few coreclr pal datatypes

This commit is contained in:
Peter Honeder committed 2015-02-12 17:04:28 -08:00
1 parent 1e91e69085
commit 3b676df8c5
9 files changed
+137 -4

No files matched your search

+5
View File
@@ -1 +1,6 @@
.idea
CMakeCache.txt
CMakeFiles/
Makefile
cmake_install.cmake
externals
+4 -1
View File
@@ -3,4 +3,7 @@
url = https://msostc.visualstudio.com/DefaultCollection/PS/_git/monad
[submodule "src/coreclr"]
path = src/coreclr
url = https://github.com/dotnet/coreclr.git
url = https://msostc.visualstudio.com/DefaultCollection/PS/_git/coreclr-fork
[submodule "ext-src/cppunit"]
path = ext-src/cppunit
url = git://anongit.freedesktop.org/git/libreoffice/cppunit/
+1
Submodule ext-src/cppunit added at 9c5b500604.
+16
View File
@@ -0,0 +1,16 @@
#!/bin/bash
if [ ! -d ext-src/cppunit ]; then
echo "Please call from root folder of project"
exit 1
fi
pushd ext-src/cppunit
./autogen.sh
./configure --prefix=../../externals/cppunit
make
make install
popd
+17 -1
View File
@@ -1,7 +1,23 @@
cmake_minimum_required(VERSION 2.8.4)
project(linux)
# generic settings
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
# add coreclr
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPLATFORM_UNIX -DPAL_IMPLEMENTATION -D__LINUX__")
include_directories(${root_SOURCE_DIR}../coreclr/src/pal/inc)
set(SOURCE_FILES main.cpp
test/test_pal.cpp
# ../monad/monad/nttargets/assemblies/nativemsh/pwrshexe/CssMainEntry.cpp
)
add_executable(linux ${SOURCE_FILES})
# add cppunit
include_directories(${root_SOURCE_DIR}../../externals/cppunit/include)
find_library(LIB_CPPUNIT cppunit ${root_SOURCE_DIR}../../externals/cppunit/lib)
target_link_libraries(linux ${LIB_CPPUNIT})
message(STATUS "cppunit lib: ${LIB_CPPUNIT}")
+33 -1
View File
@@ -1,6 +1,38 @@
#include <iostream>
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
int runTests()
{
// Create the event manager and test controller
CPPUNIT_NS::TestResult controller;
// Add a listener that collects test result
CPPUNIT_NS::TestResultCollector result;
controller.addListener(&result);
// Add a listener that prints status update dots while the tests run
CPPUNIT_NS::BriefTestProgressListener progress;
controller.addListener(&progress);
// Add the top suite to the test runner
CPPUNIT_NS::TestRunner runner;
runner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());
runner.run(controller);
// Print test in a compiler compatible format.
CPPUNIT_NS::CompilerOutputter outputter(&result,CPPUNIT_NS::stdCOut());
outputter.write();
return result.wasSuccessful() ? 0 : 1;
}
int main(int, char**) {
std::cout << "Hello, World!" << std::endl;
return 0;
return runTests();
}
+45
View File
@@ -0,0 +1,45 @@
#include "test_pal.h"
#include "pal.h"
//#include <cppunit/config/SourcePrefix.h>
namespace Microsoft {
CPPUNIT_TEST_SUITE_REGISTRATION(PalTestSuite);
void PalTestSuite::testDatatypes() {
// windows datatypes
CPPUNIT_ASSERT_EQUAL(sizeof(WORD),(std::size_t)2);
CPPUNIT_ASSERT_EQUAL(sizeof(DWORD),(std::size_t)4);
// windows integer datatypes
CPPUNIT_ASSERT_EQUAL(sizeof(INT),(std::size_t)4);
CPPUNIT_ASSERT_EQUAL(sizeof(INT8),(std::size_t)1);
CPPUNIT_ASSERT_EQUAL(sizeof(INT16),(std::size_t)2);
CPPUNIT_ASSERT_EQUAL(sizeof(INT32),(std::size_t)4);
CPPUNIT_ASSERT_EQUAL(sizeof(INT64),(std::size_t)8);
CPPUNIT_ASSERT_EQUAL(sizeof(UINT),(std::size_t)4);
CPPUNIT_ASSERT_EQUAL(sizeof(UINT8),(std::size_t)1);
CPPUNIT_ASSERT_EQUAL(sizeof(UINT16),(std::size_t)2);
CPPUNIT_ASSERT_EQUAL(sizeof(UINT32),(std::size_t)4);
CPPUNIT_ASSERT_EQUAL(sizeof(UINT64),(std::size_t)8);
// windows integer max and min size constants
CPPUNIT_ASSERT_EQUAL(CHAR_BIT,8);
CPPUNIT_ASSERT_EQUAL(SCHAR_MIN,-127-1);
CPPUNIT_ASSERT_EQUAL(SCHAR_MAX,127);
CPPUNIT_ASSERT_EQUAL(UCHAR_MAX,0xff);
CPPUNIT_ASSERT_EQUAL(SHRT_MIN,-32767-1);
CPPUNIT_ASSERT_EQUAL(SHRT_MAX,32767);
CPPUNIT_ASSERT_EQUAL(USHRT_MAX,0xffff);
CPPUNIT_ASSERT_EQUAL(INT_MIN,-2147483647-1);
CPPUNIT_ASSERT_EQUAL(INT_MAX,2147483647);
CPPUNIT_ASSERT_EQUAL(UINT_MAX,0xffffffff);
CPPUNIT_ASSERT_EQUAL(LONG_MIN,-2147483647L-1);
CPPUNIT_ASSERT_EQUAL(LONG_MAX,2147483647L);
CPPUNIT_ASSERT_EQUAL(ULONG_MAX,0xffffffff);
}
}
+15
View File
@@ -0,0 +1,15 @@
#include <cppunit/extensions/HelperMacros.h>
namespace Microsoft {
class PalTestSuite : public CPPUNIT_NS::TestFixture {
CPPUNIT_TEST_SUITE(PalTestSuite);
CPPUNIT_TEST(testDatatypes);
CPPUNIT_TEST_SUITE_END();
public:
void testDatatypes();
};
}