From a98ca7f9de4d6feaccc903654b453d4bdf4505fd Mon Sep 17 00:00:00 2001 From: Robert Landers Date: Thu, 14 Dec 2023 19:29:47 +0100 Subject: [PATCH 1/4] add back fibers test --- frankenphp_test.go | 17 +++++++++++++++++ testdata/fiber-basic.php | 9 +++++++++ 2 files changed, 26 insertions(+) create mode 100644 testdata/fiber-basic.php 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 From 890b7d12acc4bede6e6095e985b5322d9c8a2498 Mon Sep 17 00:00:00 2001 From: Robert Landers Date: Thu, 14 Dec 2023 19:31:21 +0100 Subject: [PATCH 2/4] hard code some values to see what breaks --- .github/workflows/tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From 4ffb8c4793d4f60f7b5c0c7fde152aee6fb524f3 Mon Sep 17 00:00:00 2001 From: Robert Landers Date: Thu, 14 Dec 2023 19:59:01 +0100 Subject: [PATCH 3/4] apparently only go code needs to be built with pie --- .github/workflows/docker.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 28ca1b8c3..f85c2c0ec 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 ' 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/ From 11da3be7e51b6f0b4f003a05170e7d982cbe8364 Mon Sep 17 00:00:00 2001 From: Robert Landers Date: Thu, 14 Dec 2023 20:13:31 +0100 Subject: [PATCH 4/4] try cgo flags anyway --- .github/workflows/docker.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index f85c2c0ec..dc59ed498 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -181,7 +181,7 @@ jobs: run: | docker run --platform=${{ matrix.platform }} --rm \ "$(jq -r '."builder-${{ matrix.variant }}"."containerimage.config.digest"' <<< "${METADATA}")" \ - sh -c ' go test -buildmode=pie -v ./... && cd caddy && go test -buildmode=pie -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/