Skip to content

Commit 4c7fee0

Browse files
authored
Feature/better ci (#2)
* Refactor of CI and solved issues with osx implementation. * Minor issue fail-fast. * Solve more issues. * Remove sanitizers for uclibc. * Add debug info. * Add debug symbols to sanitizers. * Trying valgrind on arm. * Try again. * Try again. * Reset. * Test. * Workaround for issues. * Testing optimization level. * Restore optimization. * Solve windows issues. * Remove newer versions of msvc. * Add versions again. * Solve other issues.
1 parent 0dd10e9 commit 4c7fee0

File tree

6 files changed

+71
-80
lines changed

6 files changed

+71
-80
lines changed

.github/workflows/oracle-client.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: oracle_client
1+
name: Oracle Client Test
22
on:
33
push:
44

.github/workflows/run-tests.yml

Lines changed: 57 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ jobs:
2626
tests_on_ubuntu:
2727
name: Tests on Ubuntu (x86_64 and i686)
2828
if: github.event.inputs.tests_on_ubuntu == 'true' || github.event.inputs.tests_on_ubuntu == ''
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
optimization: ["", "-O3"]
33+
sanitize: ["", "-g -fsanitize=address -fsanitize=undefined"]
2934
runs-on: ubuntu-latest
3035
defaults:
3136
run:
@@ -39,43 +44,37 @@ jobs:
3944
sudo dpkg --add-architecture i386
4045
sudo apt update
4146
sudo apt install -y libc6-dbg:i386 libgcc-s1:i386
42-
- name: x86_64 without optimization
43-
run: |
44-
make relro_pie_tests
45-
- name: i686 without optimization
46-
run: |
47-
make relro_pie_m32_tests
48-
- name: x86_64 on valgrind without optimization
49-
run: |
50-
make relro_pie_tests_on_valgrind
51-
- name: uclibc x86_64 without optimization
52-
run: |
53-
./uclibc-test.sh x86_64
54-
- name: uclibc i686 without optimization
55-
run: |
56-
./uclibc-test.sh i686
5747
- name: set OPT_CLFAGS
5848
run: |
59-
echo OPT_CFLAGS=-O3 >> $GITHUB_ENV
60-
- name: x86_64 with optimization
49+
echo OPT_CFLAGS="${{ matrix.optimization }} ${{ matrix.sanitize }}" >> $GITHUB_ENV
50+
- name: x86_64
6151
run: |
6252
make relro_pie_tests
63-
- name: i686 with optimization
53+
- name: i686
6454
run: |
6555
make relro_pie_m32_tests
66-
- name: x86_64 on valgrind with optimization
56+
- name: x86_64 on valgrind
57+
if: ${{ matrix.sanitize == '' }} # Run without sanitizers only
6758
run: |
6859
make relro_pie_tests_on_valgrind
69-
- name: uclib x86_64 with optimization
60+
- name: uclibc x86_64
61+
if: ${{ matrix.sanitize == '' }} # Run without sanitizers only
7062
run: |
7163
./uclibc-test.sh x86_64
72-
- name: uclibc i686 with optimization
64+
- name: uclibc i686
65+
if: ${{ matrix.sanitize == '' }} # Run without sanitizers only
7366
run: |
7467
./uclibc-test.sh i686
7568
7669
tests_on_qemu:
7770
name: Tests on Qemu (arm, armhf, arm64, ppc, ppc64le and riscv64)
7871
if: github.event.inputs.tests_on_qemu == 'true' || github.event.inputs.tests_on_qemu == ''
72+
strategy:
73+
fail-fast: false
74+
matrix:
75+
optimization: ["", "-O2", "-O3"]
76+
# TODO: Sanitizer fails in armhf and aarch64
77+
# sanitize: ["", "-g -fsanitize=address -fsanitize=undefined"]
7978
runs-on: ubuntu-latest
8079
defaults:
8180
run:
@@ -86,53 +85,46 @@ jobs:
8685
run: |
8786
sudo apt update
8887
sudo apt install -y qemu-user gcc-arm-linux-gnueabi gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu gcc-powerpc-linux-gnu gcc-powerpc64le-linux-gnu gcc-riscv64-linux-gnu libc6-dev-armhf-cross libc6-dev-ppc64el-cross libc6-dev-powerpc-cross libc6-dev-armel-cross libc6-dev-arm64-cross
89-
- name: arm-linux-gnueabi without optimization
88+
- name: Set OPT_CLFAGS
89+
run: |
90+
echo OPT_CFLAGS="${{ matrix.optimization }}" >> $GITHUB_ENV
91+
# TODO: Sanitizer fails in armhf and aarch64
92+
# echo OPT_CFLAGS="${{ matrix.optimization }} ${{ matrix.sanitize }}" >> $GITHUB_ENV
93+
- name: arm-linux-gnueabi
94+
env:
95+
OPT_CFLAGS: "-latomic"
9096
run: |
9197
make relro_pie_tests TARGET_PLATFORM=arm-linux-gnueabi
92-
- name: arm-linux-gnueabihf without optimization
98+
- name: arm-linux-gnueabihf
99+
env:
100+
# TODO: detect_leaks=0 because it fails to create the ptrace thread
101+
LSAN_OPTIONS: "verbosity=1:log_threads=1:detect_leaks=0"
93102
run: |
94103
make relro_pie_tests TARGET_PLATFORM=arm-linux-gnueabihf
95-
- name: aarch64-linux-gnu without optimization
104+
- name: aarch64-linux-gnu
105+
# TODO: aarch64 fails with optimizations https://github.com/kubo/plthook/issues/51
106+
if: ${{ matrix.optimization == '' }}
96107
run: |
97108
make relro_pie_tests TARGET_PLATFORM=aarch64-linux-gnu
98-
- name: powerpc-linux-gnu without optimization
99-
run: |
100-
make relro_pie_tests TARGET_PLATFORM=powerpc-linux-gnu QEMU_ARCH=ppc
101-
- name: powerpc64le-linux-gnu without optimization
102-
run: |
103-
make relro_pie_tests TARGET_PLATFORM=powerpc64le-linux-gnu QEMU_ARCH=ppc64le
104-
- name: riscv64-linux-gnu without optimization
105-
run: |
106-
make relro_pie_tests TARGET_PLATFORM=riscv64-linux-gnu QEMU_ARCH=riscv64
107-
- name: set OPT_CLFAGS
108-
run: |
109-
echo OPT_CFLAGS=-O3 >> $GITHUB_ENV
110-
- name: arm-linux-gnueabi with optimization
111-
run: |
112-
make relro_pie_tests TARGET_PLATFORM=arm-linux-gnueabi
113-
- name: arm-linux-gnueabihf with optimization
114-
run: |
115-
make relro_pie_tests TARGET_PLATFORM=arm-linux-gnueabihf
116-
# TODO: https://github.com/kubo/plthook/issues/51
117-
# - name: aarch64-linux-gnu with optimization
118-
# run: |
119-
# make relro_pie_tests TARGET_PLATFORM=aarch64-linux-gnu
120-
- name: powerpc-linux-gnu with optimization
109+
- name: powerpc-linux-gnu
121110
run: |
122111
make relro_pie_tests TARGET_PLATFORM=powerpc-linux-gnu QEMU_ARCH=ppc
123-
- name: powerpc64le-linux-gnu with optimization
112+
- name: powerpc64le-linux-gnu
124113
run: |
125114
make relro_pie_tests TARGET_PLATFORM=powerpc64le-linux-gnu QEMU_ARCH=ppc64le
126-
- name: riscv64-linux-gnu with optimization
115+
- name: riscv64-linux-gnu
127116
run: |
128117
make relro_pie_tests TARGET_PLATFORM=riscv64-linux-gnu QEMU_ARCH=riscv64
129118
130119
tests_on_macos:
131120
name: Tests on macOS
132121
if: github.event.inputs.tests_on_macos == 'true' || github.event.inputs.tests_on_macos == ''
133122
strategy:
123+
fail-fast: false
134124
matrix:
135125
os: [macos-13, macos-14, macos-15]
126+
optimization: ["", "-O3"]
127+
sanitize: ["", "-g -fsanitize=address -fsanitize=undefined"]
136128
runs-on: ${{ matrix.os }}
137129
defaults:
138130
run:
@@ -155,42 +147,35 @@ jobs:
155147
- name: dyld_info
156148
run: |
157149
for arg in -segments -dependents -inits -exports -imports -objc -fixups -fixup_chains -fixup_chain_details -symbolic_fixups; do echo "======== $arg ========"; xcrun dyld_info $arg libtest.so; done; true
158-
- name: tests without optimization
159-
run: |
160-
make run_tests
161150
- name: set OPT_CLFAGS
162151
run: |
163-
echo OPT_CFLAGS=-O3 >> $GITHUB_ENV
164-
- name: tests with optimization
152+
echo OPT_CFLAGS="${{ matrix.optimization }} ${{ matrix.sanitize }}" >> $GITHUB_ENV
153+
- name: Tests
165154
run: |
166155
make run_tests
167156
168157
tests_on_windows:
169158
name: Tests on Windows (x64 and x86)
170159
if: github.event.inputs.tests_on_windows == 'true' || github.event.inputs.tests_on_windows == ''
171-
runs-on: windows-latest
160+
strategy:
161+
fail-fast: false
162+
matrix:
163+
os: [2019, 2022, 2025]
164+
architecture: [x86, amd64]
165+
options: [
166+
{ dll: "/LD /MD", exe: "/MD" },
167+
{ dll: "/LD /MD /O2", exe: "/MD /O2" },
168+
{ dll: "/LDd /MDd", exe: "/MDd" },
169+
{ dll: "/LDd /MDd /Z7 /fsanitize=address", exe: "/MDd /Z7 /fsanitize=address" }
170+
]
171+
runs-on: windows-${{ matrix.os }}
172172
defaults:
173173
run:
174174
shell: cmd
175175
working-directory: test
176176
steps:
177177
- uses: actions/checkout@v4
178178
- uses: ilammy/msvc-dev-cmd@v1
179-
- name: x64 without optimization
180-
run: |
181-
run-test.bat amd64 "-LD -MD" "-MD"
182-
- name: x86 without optimization
183-
run: |
184-
run-test.bat x86 "-LD -MD" "-MD"
185-
- name: x64 with optimization
186-
run: |
187-
run-test.bat amd64 "-LD -MD -O2" "-MD -O2"
188-
- name: x86 with optimization
189-
run: |
190-
run-test.bat x86 "-LD -MD -O2" "-MD -O2"
191-
- name: x64 with debug
192-
run: |
193-
run-test.bat amd64 "-LDd -MDd" "-MDd"
194-
- name: x86 with debug
179+
- name: Test
195180
run: |
196-
run-test.bat x86 "-LDd -MDd" "-MDd"
181+
run-test.bat ${{ matrix.os }} ${{ matrix.architecture }} "${{ matrix.options.dll }}" "${{ matrix.options.exe }}"

plthook_osx.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,6 @@ int plthook_open(plthook_t **plthook_out, const char *filename)
248248
}
249249
cnt = _dyld_image_count();
250250
namelen = strlen(filename);
251-
namelen = strlen(filename);
252-
cnt = _dyld_image_count();
253251

254252
for (idx = 0; idx < cnt; idx++) {
255253
const char *image_name = _dyld_get_image_name(idx);

test/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ libtest.lib
55
libtest.so
66
testprog
77
testprog.exe
8+
dummy.c
9+
dummy.o

test/Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
UNAME_S := $(shell uname -s)
66

77
CFLAGS_SHARED = -shared -fPIC
8-
CFLAGS = $(CFLAGS_WARNING) $(EXTRA_CFLAGS) $(OPT_CFLAGS)
98
CFLAGS_WARNING = -Wall
9+
CFLAGS = $(CFLAGS_WARNING) $(EXTRA_CFLAGS) $(OPT_CFLAGS)
10+
LDFLAGS = $(EXTRA_LDFLAGS) $(OPT_LDFLAGS)
1011
EXEEXT =
1112
SOEXT = so
1213
LIBS = -ldl -lm
@@ -58,10 +59,10 @@ endif
5859
all: libtest.$(SOEXT) testprog$(EXEEXT)
5960

6061
libtest.$(SOEXT): libtest.c libtest.h
61-
$(CC) $(CFLAGS_SHARED) $(CFLAGS) -DLIBTEST_DLL -o libtest.$(SOEXT) libtest.c -lm
62+
$(CC) $(CFLAGS_SHARED) $(CFLAGS) -DLIBTEST_DLL -o libtest.$(SOEXT) libtest.c -lm $(LDFLAGS)
6263

6364
testprog$(EXEEXT): testprog.c ../$(PLTHOOK_C) libtest.h
64-
$(CC) $(CFLAGS_EXE) $(CFLAGS) -o testprog$(EXEEXT) -I.. testprog.c ../$(PLTHOOK_C) -L. -ltest $(LIBS)
65+
$(CC) $(CFLAGS_EXE) $(CFLAGS) -o testprog$(EXEEXT) -I.. testprog.c ../$(PLTHOOK_C) -L. -ltest $(LIBS) $(LDFLAGS)
6566

6667
run_tests: clean libtest.$(SOEXT) testprog$(EXEEXT)
6768
LD_LIBRARY_PATH=. $(KICK_CMD) ./testprog$(EXEEXT) open

test/run-test.bat

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
call "c:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" %1
2-
nmake /f Makefile.win32 check clean DLL_CFLAGS=%2 EXE_CFLAGS=%3
1+
if "%1" == "2019" (
2+
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" %2
3+
) else (
4+
@rem "TODO: Implement 2025 support in the future"
5+
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" %2
6+
)
7+
nmake /f Makefile.win32 check clean DLL_CFLAGS=%3 EXE_CFLAGS=%4

0 commit comments

Comments
 (0)