From b7f2da484322ac6ed1f97c8ed9d801ec642667f3 Mon Sep 17 00:00:00 2001
From: Wei Fu <fuweid89@gmail.com>
Date: Wed, 4 Jan 2023 20:05:20 +0800
Subject: [PATCH] .github/Makefile: support EXTRA_TESTFLAGS for array freelist

Signed-off-by: Wei Fu <fuweid89@gmail.com>
---
 .github/workflows/tests.yaml | 18 +++++++-----------
 Makefile                     | 17 ++++++-----------
 2 files changed, 13 insertions(+), 22 deletions(-)

diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml
index c2a0283..2342f8a 100644
--- a/.github/workflows/tests.yaml
+++ b/.github/workflows/tests.yaml
@@ -6,9 +6,9 @@ jobs:
       fail-fast: false
       matrix:
         target:
-        - linux-amd64-unit-test-2-cpu
         - linux-amd64-unit-test-4-cpu
-        - linux-amd64-unit-test-4-cpu-race
+        - linux-amd64-unit-test-4-cpu-freelist-hashmap-race
+        - linux-amd64-unit-test-2-cpu-freelist-array-short-race
     runs-on: ubuntu-latest
     steps:
     - uses: actions/checkout@v3
@@ -20,17 +20,14 @@ jobs:
         TARGET: ${{ matrix.target }}
       run: |
         case "${TARGET}" in
-          linux-amd64-unit-test-2-cpu)
-            CPU=2 make test-simulate
-            CPU=2 make test
-            ;;
           linux-amd64-unit-test-4-cpu)
-            CPU=4 make test-simulate
             CPU=4 make test
             ;;
-          linux-amd64-unit-test-4-cpu-race)
-            CPU=4 ENABLE_RACE=true make test-simulate
-            CPU=4 ENABLE_RACE=true make test
+          linux-amd64-unit-test-4-cpu-freelist-hashmap-race)
+            CPU=4 ENABLE_RACE=true make test-freelist-hashmap
+            ;;
+          linux-amd64-unit-test-2-cpu-freelist-array-short-race)
+            CPU=2 ENABLE_RACE=true EXTRA_TESTFLAGS="-short" make test-freelist-array
             ;;
           *)
             echo "Failed to find target"
@@ -66,7 +63,6 @@ jobs:
       run: |
         case "${TARGET}" in
           windows-amd64-unit-test-4-cpu)
-            CPU=4 make test-simulate
             CPU=4 make test
             ;;
           *)
diff --git a/Makefile b/Makefile
index c5256eb..fc62301 100644
--- a/Makefile
+++ b/Makefile
@@ -11,8 +11,7 @@ TESTFLAGS_CPU=
 ifdef CPU
 	TESTFLAGS_CPU=-cpu=$(CPU)
 endif
-
-TESTFLAGS = $(TESTFLAGS_RACE) $(TESTFLAGS_CPU)
+TESTFLAGS = $(TESTFLAGS_RACE) $(TESTFLAGS_CPU) $(EXTRA_TESTFLAGS)
 
 fmt:
 	!(gofmt -l -s -d $(shell find . -name \*.go) | grep '[a-z]')
@@ -20,22 +19,18 @@ fmt:
 lint:
 	golangci-lint run ./...
 
-test:
+test: test-freelist-hashmap test-freelist-array
+
+test-freelist-hashmap:
 	@echo "hashmap freelist test"
 	TEST_FREELIST_TYPE=hashmap go test -v ${TESTFLAGS} -timeout 30m
 	TEST_FREELIST_TYPE=hashmap go test -v ${TESTFLAGS} ./cmd/bbolt
 
+test-freelist-array:
 	@echo "array freelist test"
 	TEST_FREELIST_TYPE=array go test -v ${TESTFLAGS} -timeout 30m
 	TEST_FREELIST_TYPE=array go test -v ${TESTFLAGS} ./cmd/bbolt
 
-test-simulate:
-	@echo "hashmap freelist test"
-	TEST_FREELIST_TYPE=hashmap go test -v ${TESTFLAGS} -test.run="TestSimulate_(100op|1000op)"
-
-	@echo "array freelist test"
-	TEST_FREELIST_TYPE=array go test -v ${TESTFLAGS} -test.run="TestSimulate_(100op|1000op)"
-
 coverage:
 	@echo "hashmap freelist test"
 	TEST_FREELIST_TYPE=hashmap go test -v -timeout 30m \
@@ -45,4 +40,4 @@ coverage:
 	TEST_FREELIST_TYPE=array go test -v -timeout 30m \
 		-coverprofile cover-freelist-array.out -covermode atomic
 
-.PHONY: fmt test test-simulate lint
+.PHONY: fmt test test-freelist-hashmap test-freelist-array lint