From 7395beaf002cf078b478744be107deb7af4ed9dc Mon Sep 17 00:00:00 2001 From: Kristian Larsson Date: Mon, 1 Aug 2022 16:23:16 +0200 Subject: [PATCH] Use Tasty for RTS thread count test This removes test/Makefile since all tests have been moved to be run by Tasty! Yay! The thread count is a pretty good example for how the shell is pretty useful for this kind of tests. DSLs aren't that bad after all... --- Makefile | 1 - compiler/test.hs | 22 +++++++++++++++++++++- test/Makefile | 18 ------------------ 3 files changed, 21 insertions(+), 20 deletions(-) delete mode 100644 test/Makefile diff --git a/Makefile b/Makefile index 057ae558a..271101756 100644 --- a/Makefile +++ b/Makefile @@ -349,7 +349,6 @@ rts: $(ARCHIVES) test: cd compiler && stack test $(MAKE) -C backend test - $(MAKE) -C test test-builtins: cd compiler && stack test --ta '-p "Builtins"' diff --git a/compiler/test.hs b/compiler/test.hs index 2bc1983ff..16a1b3d8f 100644 --- a/compiler/test.hs +++ b/compiler/test.hs @@ -4,7 +4,6 @@ import Data.List.Split import Data.Maybe import Data.Ord import Data.Time.Clock.POSIX - import System.Directory import System.Directory.Recursive import System.Exit @@ -142,6 +141,27 @@ rtsTests = assertEqual "RTS wthreads error retCode" (ExitFailure 1) returnCode assertEqual "RTS wthreads error cmdErr" "ERROR: --rts-wthreads requires an argument.\n" cmdErr + , testCase "thread count" $ do + -- check the number of threads, which should be 10, consisting of 7 + -- worker threads (as specified on command line), IO+new IO & main + testBuild "" ExitSuccess False "../test/rts/wthreads1.act" + (pin, pout, perr, ph) <- runInteractiveProcess "../test/rts/wthreads1" ["--rts-wthreads=7"] Nothing Nothing + mpid <- getPid ph + case mpid of + Just pid -> do +#if defined(darwin_HOST_OS) + let cmd = "ps -M " ++ show pid ++ " | tail -n +2 | wc -l" +#else + let cmd = "ps -o thcount " ++ show pid +#endif + (returnCode, cmdOut, cmdErr) <- readCreateProcessWithExitCode (shell $ cmd) "" + let tCount = read (last $ lines cmdOut)::Int + assertEqual "RTS thread count" 10 tCount + Nothing -> do + assertFailure "whtreads1 program should be running" + terminateProcess ph + waitForProcess ph + return () ] rtsDDBTests = diff --git a/test/Makefile b/test/Makefile deleted file mode 100644 index d583bbbfd..000000000 --- a/test/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -MK_PATH:=$(shell dirname $(dir $(abspath $(lastword $(MAKEFILE_LIST))))) -ACTONC=$(MK_PATH)/dist/bin/actonc --cpedantic -TESTS=test_db_app_no_quorum rts/wthreads1 -test: - $(MAKE) $(TESTS) - -.PHONY: $(TESTS) - -test_db_app_no_quorum: - @echo "Skipping because this is essentially broken" - #$(ACTONC) --root main test_db_app.act - #./test_db.py TestDbAppsNoQuorum - - -# Expect 10 threads given 7 workers + main process + IO + new IO -rts/wthreads1: - $(ACTONC) $@.act - ./$@ --rts-wthreads 7 & PID=$$! && ps -o thcount $${PID} | tail -n1 | awk '{ print $$1 }' | grep "^10$$"