Compare commits

...

4 Commits

Author SHA1 Message Date
Robert Landers
11da3be7e5 try cgo flags anyway 2023-12-14 20:13:31 +01:00
Robert Landers
4ffb8c4793 apparently only go code needs to be built with pie 2023-12-14 19:59:01 +01:00
Robert Landers
890b7d12ac hard code some values to see what breaks 2023-12-14 19:31:21 +01:00
Robert Landers
a98ca7f9de add back fibers test 2023-12-14 19:29:47 +01:00
4 changed files with 29 additions and 4 deletions

View File

@@ -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/

View File

@@ -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

View File

@@ -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{})
}

9
testdata/fiber-basic.php vendored Normal file
View File

@@ -0,0 +1,9 @@
<?php
require_once __DIR__.'/_executor.php';
return function() {
$fiber = new Fiber(function() {
echo 'Fiber '.($_GET['i'] ?? '');
});
$fiber->start();
};