diff --git a/.gitignore b/.gitignore index 485dee64bc..51d8d2b164 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,6 @@ .idea +CMakeCache.txt +CMakeFiles/ +Makefile +cmake_install.cmake +externals diff --git a/.gitmodules b/.gitmodules index e438d0566e..f8640e6a1c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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/ diff --git a/ext-src/cppunit b/ext-src/cppunit new file mode 160000 index 0000000000..9c5b500604 --- /dev/null +++ b/ext-src/cppunit @@ -0,0 +1 @@ +Subproject commit 9c5b50060411ec71ac1583ae96e8f4652803b564 diff --git a/scripts/simplebuild.sh b/scripts/simplebuild.sh new file mode 100755 index 0000000000..f92b047b50 --- /dev/null +++ b/scripts/simplebuild.sh @@ -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 + + diff --git a/src/coreclr b/src/coreclr index 8c6dd79fb1..c0c31320c1 160000 --- a/src/coreclr +++ b/src/coreclr @@ -1 +1 @@ -Subproject commit 8c6dd79fb18a803b96ebef9bd3ea263907886b4b +Subproject commit c0c31320c1b70d1e4a4b4c865374a296e65b98e4 diff --git a/src/linux/CMakeLists.txt b/src/linux/CMakeLists.txt index 8b0e5f671d..bfedd7448d 100644 --- a/src/linux/CMakeLists.txt +++ b/src/linux/CMakeLists.txt @@ -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_executable(linux ${SOURCE_FILES}) \ No newline at end of file +# 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}") + diff --git a/src/linux/main.cpp b/src/linux/main.cpp index 38d5e8ad02..feb607ef52 100644 --- a/src/linux/main.cpp +++ b/src/linux/main.cpp @@ -1,6 +1,38 @@ #include +#include +#include +#include +#include +#include +#include + +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(); } diff --git a/src/linux/test/test_pal.cpp b/src/linux/test/test_pal.cpp new file mode 100644 index 0000000000..73be3af3f8 --- /dev/null +++ b/src/linux/test/test_pal.cpp @@ -0,0 +1,45 @@ +#include "test_pal.h" + +#include "pal.h" +//#include + +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); + + } + +} \ No newline at end of file diff --git a/src/linux/test/test_pal.h b/src/linux/test/test_pal.h new file mode 100644 index 0000000000..a69fcd00da --- /dev/null +++ b/src/linux/test/test_pal.h @@ -0,0 +1,15 @@ +#include + +namespace Microsoft { + + class PalTestSuite : public CPPUNIT_NS::TestFixture { + CPPUNIT_TEST_SUITE(PalTestSuite); + CPPUNIT_TEST(testDatatypes); + CPPUNIT_TEST_SUITE_END(); + + public: + void testDatatypes(); + + }; + +} \ No newline at end of file