diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 28ca1b8c3..dc59ed498 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -92,7 +92,6 @@ jobs: qemu: true - platform: linux/amd64 qemu: false - race: "-race" # The Go race detector is only supported on amd64 - platform: linux/386 qemu: false steps: @@ -182,7 +181,7 @@ jobs: run: | docker run --platform=${{ matrix.platform }} --rm \ "$(jq -r '."builder-${{ matrix.variant }}"."containerimage.config.digest"' <<< "${METADATA}")" \ - sh -c 'go test ${{ matrix.race }} -v ./... && cd caddy && go test ${{ matrix.race }} -v ./...' + sh -c 'CGO_CXXFLAGS=-fPIE CGO_CFLAGS=-fPIE CGO_LDFLAGS=-pie go test -buildmode=pie -v ./... && cd caddy && go test -buildmode=pie -v ./...' env: METADATA: ${{ steps.build.outputs.metadata }} # Adapted from https://docs.docker.com/build/ci/github-actions/multi-platform/ diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index aed737559..eb2398583 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -48,11 +48,11 @@ jobs: run: go build - name: Run library tests - run: go test -race -v ./... + run: CGO_CXXFLAGS=-fPIE CGO_CFLAGS=-fPIE CGO_LDFLAGS=-pie go test -buildmode=pie -v ./... - name: Run Caddy module tests working-directory: caddy/ - run: go test -race -v ./... + run: CGO_CXXFLAGS=-fPIE CGO_CFLAGS=-fPIE CGO_LDFLAGS=-pie go test -buildmode=pie -v ./... - name: Lint Go code uses: golangci/golangci-lint-action@v3 diff --git a/frankenphp_test.go b/frankenphp_test.go index ec9b653a3..2a0e898cb 100644 --- a/frankenphp_test.go +++ b/frankenphp_test.go @@ -503,6 +503,23 @@ func testFlush(t *testing.T, opts *testOptions) { }, opts) } +func TestFiberBasic_module(t *testing.T) { testFiberBasic(t, &testOptions{}) } +func TestFiberBasic_worker(t *testing.T) { + testFiberBasic(t, &testOptions{workerScript: "fiber-basic.php"}) +} +func testFiberBasic(t *testing.T, opts *testOptions) { + runTest(t, func(handler func(http.ResponseWriter, *http.Request), _ *httptest.Server, i int) { + req := httptest.NewRequest("GET", fmt.Sprintf("http://example.com/fiber-basic.php?i=%d", i), nil) + w := httptest.NewRecorder() + handler(w, req) + + resp := w.Result() + body, _ := io.ReadAll(resp.Body) + + assert.Equal(t, string(body), fmt.Sprintf("Fiber %d", i)) + }, opts) +} + func TestLargeRequest_module(t *testing.T) { testLargeRequest(t, &testOptions{}) } diff --git a/testdata/fiber-basic.php b/testdata/fiber-basic.php new file mode 100644 index 000000000..0ca750f48 --- /dev/null +++ b/testdata/fiber-basic.php @@ -0,0 +1,9 @@ +start(); +}; \ No newline at end of file