Skip to content

Fix shared library loading without dev packages on Linux #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Tests

on:
pull_request:
paths-ignore:
- '*.md'
push:
branches:
- master
- release/*
paths-ignore:
- '*.md'


concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true


jobs:
tests:
name: Tests
runs-on: ubuntu-latest
container:
image: openresty/openresty:${{ matrix.openresty }}-jammy

strategy:
fail-fast: false
matrix:
openresty: ["1.19.9.1-14", "1.21.4.1-0"]

steps:
- name: Checkout source code
uses: actions/checkout@v3

- name: Install valgrind
run: |
apt-get update
apt-get install -y valgrind

# ensure the library works even without dev packages installed (libz.so.1 instead of libz.so)
- name: Remove dev packages
run: |
apt-get purge -y libc-dev-bin

- name: Run test with LuaJIT
run: |
luajit test.lua /usr/local/openresty/nginx/sbin/nginx 65536000

- name: Run test with resty-cli
run: |
resty --no-stream test.lua /usr/local/openresty/nginx/sbin/nginx 65536000

- name: Run test with resty-cli (valgrind)
if: contains(matrix.extras, 'valgrind')
run: |
resty --no-stream --valgrind test.lua /usr/local/openresty/nginx/sbin/nginx 65536000
12 changes: 11 additions & 1 deletion lib/ffi-zlib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,17 @@ unsigned long crc32_combine(unsigned long, unsigned long, long);

]])

local zlib = ffi.load(ffi.os == "Windows" and "zlib1" or "z")
local zlib
if ffi.os == "Windows" then
zlib = ffi.load("zlib1")
elseif ffi.os == "OSX" then
zlib = ffi.load("z")
elseif ffi.os == "Linux" then
zlib = ffi.load("libz.so.1")
else
error("lua-ffi-zlib doesn't support platform: " .. ffi.os)
end

_M.zlib = zlib

-- Default to 16k output buffer
Expand Down