From 3f86ebf1ed4908ad0735a190b239e3f3bcbf4cef Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 10 Feb 2022 19:35:11 -0500 Subject: OSX CI Test (#2126) * #include an absolute path didn't work - because paths were taken to always be relative. * Small fixes. Added compiler crash with generic defined in a function. Added enum-flags test that works (by limiting backing type to int), and using __EnumType constraint. * Add comment about crash. * Disable crashing test. * Fixes to make compile on OSX. * Add github build for OSX. * Make premake generator a utility. * Fix osx compilation issue. * More fixes for OSX build. * OSX fix due to ambiguity around size_t and integer types. * Disable xlib on build on osx. * Use 'prebuildcommands' to make prebuild make utility projects do something. * Small fixes for premake so utility works on linux/osx. * Another hack to try and make generators run when 'utility' * Fix typo in macos.yml. * Revert premake to old style, and disable stdlib embedding on OSX. * OSX testing. * Fix pipe handling for OSX. * Enable testing on OSX. * Small fix because uname -p is not x64 on darwin. --- .github/workflows/macos.yml | 6 ++++++ github_test.sh | 12 +++++++++++- source/core/unix/slang-unix-process.cpp | 17 ++++++++++++++++- tools/slang-test/options.cpp | 4 ++++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 700d9f6a4..ba92715fc 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -30,4 +30,10 @@ jobs: CONFIGURATION=${{matrix.configuration}} ARCH=${{matrix.platform}} source ./github_macos_build.sh + - name: test + run: + CONFIGURATION=${{matrix.configuration}} + CC=${{matrix.compiler}} + ARCH=${{matrix.platform}} + source ./github_test.sh \ No newline at end of file diff --git a/github_test.sh b/github_test.sh index f36a0b950..b18566f84 100644 --- a/github_test.sh +++ b/github_test.sh @@ -11,6 +11,16 @@ fi PLATFORM=$(uname -s | tr '[:upper:]' '[:lower:]') ARCHITECTURE=$(uname -p) +# Darwin is actually macosx (for paths etc) +if [ "${PLATFORM}" == "darwin" ]; then + PLATFORM="macosx" + + # Modern OSX is only 64 bit, so assume that + if [ "${ARCHITECTURE}" == "i386" ]; then + ARCHITECTURE="x64" + fi +fi + if [ "${ARCHITECTURE}" == "x86_64" ]; then ARCHITECTURE="x64" fi @@ -19,7 +29,7 @@ TARGET=${PLATFORM}-${ARCHITECTURE} OUTPUTDIR=bin/${TARGET}/${CONFIGURATION}/ -if [ "${ARCHITECTURE}" == "x64" ]; then +if [ "${ARCHITECTURE}" == "x64" -a "${PLATFORM}" != "macosx" ]; then LOCATION=$(curl -s https://api.github.com/repos/shader-slang/swiftshader/releases/latest \ | grep "tag_name" \ | awk '{print "https://github.com/shader-slang/swiftshader/releases/download/" substr($2, 2, length($2)-3) "/vk_swiftshader_linux_x64.zip"}') diff --git a/source/core/unix/slang-unix-process.cpp b/source/core/unix/slang-unix-process.cpp index 991d905d9..2275238d9 100644 --- a/source/core/unix/slang-unix-process.cpp +++ b/source/core/unix/slang-unix-process.cpp @@ -261,6 +261,12 @@ SlangResult UnixPipeStream::read(void* buffer, size_t length, size_t& outReadByt return SLANG_FAIL; } + // If there are no poll events, we are done + if (pollResult == 0) + { + return SLANG_OK; + } + // If there is data read that first if (pollInfo.revents & POLLIN) { @@ -281,7 +287,16 @@ SlangResult UnixPipeStream::read(void* buffer, size_t length, size_t& outReadByt } outReadBytes = size_t(count); - return SLANG_OK; + + // If no bytes were wanted, then there could still be bytes in the pipe + // before a HUP. So don't fall through to check for HUP. + // + // If some bytes *were* wanted and none were read, we can allow fall through to + // handle HUP. + if (length == 0 || count > 0) + { + return SLANG_OK; + } } if (pollInfo.revents & POLLHUP) diff --git a/tools/slang-test/options.cpp b/tools/slang-test/options.cpp index 38ed902a8..11188d766 100644 --- a/tools/slang-test/options.cpp +++ b/tools/slang-test/options.cpp @@ -125,6 +125,10 @@ static bool _isSubCommand(const char* arg) } optionsOut->binDir = *argCursor++; } + else if (strcmp(arg, "-use-shared-library") == 0) + { + optionsOut->defaultSpawnType = SpawnType::UseSharedLibrary; + } else if (strcmp(arg, "-use-test-server") == 0) { optionsOut->defaultSpawnType = SpawnType::UseTestServer; -- cgit v1.2.3