aboutsummaryrefslogtreecommitdiff
path: root/testing/sbcl/0003-Fix-foreign-tests-on-musl-libc.patch
diff options
context:
space:
mode:
Diffstat (limited to 'testing/sbcl/0003-Fix-foreign-tests-on-musl-libc.patch')
-rw-r--r--testing/sbcl/0003-Fix-foreign-tests-on-musl-libc.patch127
1 files changed, 0 insertions, 127 deletions
diff --git a/testing/sbcl/0003-Fix-foreign-tests-on-musl-libc.patch b/testing/sbcl/0003-Fix-foreign-tests-on-musl-libc.patch
deleted file mode 100644
index 2c4da211a0..0000000000
--- a/testing/sbcl/0003-Fix-foreign-tests-on-musl-libc.patch
+++ /dev/null
@@ -1,127 +0,0 @@
1#2020/01/30 Patch has not yet been accepted upstream
2From 87b1eca2b719fb5e2d6f10352dcdb86f4d389ca9 Mon Sep 17 00:00:00 2001
3From: Eric Timmons <etimmons@mit.edu>
4Date: Sat, 1 Feb 2020 17:33:59 -0500
5Subject: [PATCH 3/5] Teach foreign.test.sh about noop dlclose implementations
6
7Musl libc's implementation of dlclose(3) is (intentionally) a noop (see:
8https://wiki.musl-libc.org/functional-differences-from-glibc.html). When
9running regression tests, test if dlclose is a noop and if so, skip all tests
10that depend on objects being unmapped.
11---
12 src/code/foreign-load.lisp | 2 +-
13 tests/foreign.test.sh | 67 ++++++++++++++++++++++++++++----------
14 2 files changed, 51 insertions(+), 18 deletions(-)
15
16diff --git a/src/code/foreign-load.lisp b/src/code/foreign-load.lisp
17index ada107c36..4510f2ccf 100644
18--- a/src/code/foreign-load.lisp
19+++ b/src/code/foreign-load.lisp
20@@ -48,7 +48,7 @@ (defun load-shared-object (pathname &key dont-save)
21 definitions; if a symbol was previously referenced through the object and
22 is not present in the reloaded version an error will be signalled. Reloading
23 may not work as expected if user or library-code has called dlopen(3) on the
24-same shared object.
25+same shared object or running on a system where dlclose(3) is a noop.
26
27 LOAD-SHARED-OBJECT interacts with SB-EXT:SAVE-LISP-AND-DIE:
28
29diff --git a/tests/foreign.test.sh b/tests/foreign.test.sh
30index fabba1246..53131bdd2 100755
31--- a/tests/foreign.test.sh
32+++ b/tests/foreign.test.sh
33@@ -140,6 +140,28 @@ echo 'int late_foo = 43;' > $TEST_FILESTEM-c.c
34 echo 'int late_bar() { return 14; }' >> $TEST_FILESTEM-c.c
35 build_so $TEST_FILESTEM-c
36
37+cat > $TEST_FILESTEM-noop-dlclose-test.c <<EOF
38+#include <dlfcn.h>
39+#include <stddef.h>
40+
41+int dlclose_is_noop () {
42+ void * handle = dlopen("./$TEST_FILESTEM-noop-dlclose-test-helper.so", RTLD_NOW | RTLD_GLOBAL);
43+ dlclose(handle);
44+
45+ handle = dlopen("./$TEST_FILESTEM-noop-dlclose-test-helper.so", RTLD_NOW | RTLD_NOLOAD);
46+ if (handle != NULL) {
47+ return 1;
48+ }
49+ return 0;
50+}
51+EOF
52+build_so $TEST_FILESTEM-noop-dlclose-test
53+
54+cat > $TEST_FILESTEM-noop-dlclose-test-helper.c <<EOF
55+int sbcl_dlclose_test = 42;
56+EOF
57+build_so $TEST_FILESTEM-noop-dlclose-test-helper
58+
59 ## Foreign definitions & load
60
61 cat > $TEST_FILESTEM.base.lisp <<EOF
62@@ -246,20 +268,28 @@ cat > $TEST_FILESTEM.test.lisp <<EOF
63
64 (note "/initial assertions ok")
65
66+ ;; determine if dlclose is a noop.
67+ (load-shared-object (truename "$TEST_FILESTEM-noop-dlclose-test.so"))
68+ (define-alien-routine dlclose-is-noop int)
69+ (defparameter *dlclose-noop-p* (plusp (dlclose-is-noop)))
70+
71 ;; test reloading object file with new definitions
72 (assert (= 13 foo))
73 (assert (= 42 (bar)))
74 (note "/original definitions ok")
75- (rename-file "$TEST_FILESTEM-b.so" "$TEST_FILESTEM-b.bak")
76- (rename-file "$TEST_FILESTEM-b2.so" "$TEST_FILESTEM-b.so")
77- (load-shared-object (truename "$TEST_FILESTEM-b.so"))
78- (note "/reloading ok")
79- (assert (= 42 foo))
80- (assert (= 13 (bar)))
81- (note "/redefined versions ok")
82- (rename-file "$TEST_FILESTEM-b.so" "$TEST_FILESTEM-b2.so")
83- (rename-file "$TEST_FILESTEM-b.bak" "$TEST_FILESTEM-b.so")
84- (note "/renamed back to originals")
85+ (if *dlclose-noop-p*
86+ (note "/skipping reloading tests")
87+ (progn
88+ (rename-file "$TEST_FILESTEM-b.so" "$TEST_FILESTEM-b.bak")
89+ (rename-file "$TEST_FILESTEM-b2.so" "$TEST_FILESTEM-b.so")
90+ (load-shared-object (truename "$TEST_FILESTEM-b.so"))
91+ (note "/reloading ok")
92+ (assert (= 42 foo))
93+ (assert (= 13 (bar)))
94+ (note "/redefined versions ok")
95+ (rename-file "$TEST_FILESTEM-b.so" "$TEST_FILESTEM-b2.so")
96+ (rename-file "$TEST_FILESTEM-b.bak" "$TEST_FILESTEM-b.so")
97+ (note "/renamed back to originals")))
98
99 ;; test late resolution
100 #+linkage-table
101@@ -276,13 +306,16 @@ cat > $TEST_FILESTEM.test.lisp <<EOF
102 (load-shared-object (truename "$TEST_FILESTEM-c.so"))
103 (assert (= 43 late-foo))
104 (assert (= 14 (late-bar)))
105- (unload-shared-object (truename "$TEST_FILESTEM-c.so"))
106- (multiple-value-bind (val err) (ignore-errors late-foo)
107- (assert (not val))
108- (assert (typep err 'undefined-alien-error)))
109- (multiple-value-bind (val err) (ignore-errors (late-bar))
110- (assert (not val))
111- (assert (typep err 'undefined-alien-error)))
112+ (if *dlclose-noop-p*
113+ (note "/skipping linkage table unloading tests")
114+ (progn
115+ (unload-shared-object (truename "$TEST_FILESTEM-c.so"))
116+ (multiple-value-bind (val err) (ignore-errors late-foo)
117+ (assert (not val))
118+ (assert (typep err 'undefined-alien-error)))
119+ (multiple-value-bind (val err) (ignore-errors (late-bar))
120+ (assert (not val))
121+ (assert (typep err 'undefined-alien-error)))))
122 (note "/linkage table ok"))
123
124 (sb-ext:exit :code $EXIT_LISP_WIN) ; success convention for Lisp program
125--
1262.25.0
127