Skip to content

Commit

Permalink
libxkbcommon: add 1.6.0 build patch
Browse files Browse the repository at this point in the history
```
==> meson test -C build --print-errorlogs
ninja: Entering directory `/private/tmp/libxkbcommon-20240315-20625-xfimti/libxkbcommon-1.6.0/build'
ninja: no work to do.
 1/24 libxkbcommon / keysym                               OK              0.05s
 2/24 libxkbcommon / keymap                               OK              0.10s
 3/24 libxkbcommon / filecomp                             OK              0.14s
 4/24 libxkbcommon / rules-file                           OK              0.16s
 5/24 libxkbcommon / context                              OK              0.20s
 6/24 libxkbcommon / rules-file-includes                  OK              0.24s
 7/24 libxkbcommon / stringcomp                           OK              0.28s
 8/24 libxkbcommon / buffercomp                           OK              0.32s
 9/24 libxkbcommon / log                                  OK              0.34s
10/24 libxkbcommon / atom                                 OK              0.39s
11/24 libxkbcommon / utf8                                 OK              0.36s
12/24 libxkbcommon / state                                OK              0.36s
13/24 libxkbcommon / keyseq                               OK              0.37s
14/24 libxkbcommon / rulescomp                            OK              0.39s
15/24 libxkbcommon / compose                              OK              0.38s
16/24 libxkbcommon / utils                                OK              0.35s
17/24 libxkbcommon / modifiers                            OK              0.33s
18/24 libxkbcommon / messages                             OK              0.33s
19/24 libxkbcommon:python-tests / symbols-leak-test       OK              0.42s
20/24 libxkbcommon / x11                                  OK              0.79s
21/24 libxkbcommon / x11comp                              OK              0.09s
22/24 libxkbcommon / registry                             OK              0.13s
23/24 libxkbcommon:python-tests / keysym-test-XF86Macro23 OK              0.33s
24/24 libxkbcommon:python-tests / tool-option-parsing     OK              0.87s

Ok:                 24
Expected Fail:      0
Fail:               0
Unexpected Pass:    0
Skipped:            0
Timeout:            0
```

relates to:

- Homebrew/homebrew-core#165881
- xkbcommon/libxkbcommon#468

Signed-off-by: Rui Chen <[email protected]>
  • Loading branch information
chenrui333 committed Mar 15, 2024
1 parent ae02b93 commit d074f6e
Showing 1 changed file with 229 additions and 0 deletions.
229 changes: 229 additions & 0 deletions libxkbcommon/1.6.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
diff --git a/meson.build b/meson.build
index eaef4fb..2a73ba7 100644
--- a/meson.build
+++ b/meson.build
@@ -753,11 +753,13 @@ if get_option('enable-x11')
'x11',
executable('test-x11', 'test/x11.c', dependencies: x11_test_dep),
env: test_env,
+ is_parallel : false,
)
test(
'x11comp',
executable('test-x11comp', 'test/x11comp.c', dependencies: x11_test_dep),
env: test_env,
+ is_parallel : false,
)
endif
if get_option('enable-xkbregistry')
diff --git a/src/utils.h b/src/utils.h
index aa7969c..5d79288 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -64,6 +64,8 @@

#define STRINGIFY(x) #x
#define STRINGIFY2(x) STRINGIFY(x)
+#define CONCAT(x,y) x ## y
+#define CONCAT2(x,y) CONCAT(x,y)

/* Check if a character is valid in a string literal */
static inline bool
diff --git a/test/test.h b/test/test.h
index afeec78..3ba0e03 100644
--- a/test/test.h
+++ b/test/test.h
@@ -31,8 +31,10 @@
#include "xkbcommon/xkbcommon-compose.h"
#include "utils.h"

-/* Automake test exit code to signify SKIP (à la PASS, FAIL, etc). */
+/* Automake test exit code to signify SKIP (à la PASS, FAIL, etc).
+ * See: https://www.gnu.org/software/automake/manual/html_node/Scripts_002dbased-Testsuites.html */
#define SKIP_TEST 77
+#define TEST_SETUP_FAILURE 99

/* The offset between KEY_* numbering, and keycodes in the XKB evdev
* dataset. */
diff --git a/test/x11.c b/test/x11.c
index 3742a0b..a6b5dc9 100644
--- a/test/x11.c
+++ b/test/x11.c
@@ -45,7 +45,7 @@ X11_TEST(test_basic)
*/
conn = xcb_connect(display, NULL);
if (!conn || xcb_connection_has_error(conn)) {
- exit_code = SKIP_TEST;
+ exit_code = TEST_SETUP_FAILURE;
goto err_conn;
}

@@ -55,7 +55,7 @@ X11_TEST(test_basic)
XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS,
NULL, NULL, NULL, NULL);
if (!ret) {
- exit_code = SKIP_TEST;
+ exit_code = TEST_SETUP_FAILURE;
goto err_conn;
}

diff --git a/test/x11comp.c b/test/x11comp.c
index d2cc447..3f145d7 100644
--- a/test/x11comp.c
+++ b/test/x11comp.c
@@ -51,7 +51,7 @@ X11_TEST(test_basic)

conn = xcb_connect(display, NULL);
if (xcb_connection_has_error(conn)) {
- ret = SKIP_TEST;
+ ret = TEST_SETUP_FAILURE;
goto err_conn;
}
ret = xkb_x11_setup_xkb_extension(conn,
@@ -60,7 +60,7 @@ X11_TEST(test_basic)
XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS,
NULL, NULL, NULL, NULL);
if (!ret) {
- ret = SKIP_TEST;
+ ret = TEST_SETUP_FAILURE;
goto err_xcb;
}
device_id = xkb_x11_get_core_keyboard_device_id(conn);
@@ -72,12 +72,12 @@ X11_TEST(test_basic)
ret = posix_spawnp(&xkbcomp_pid, "xkbcomp", NULL, NULL, xkbcomp_argv, envp);
free(xkb_path);
if (ret != 0) {
- ret = SKIP_TEST;
+ ret = TEST_SETUP_FAILURE;
goto err_xcb;
}
ret = waitpid(xkbcomp_pid, &status, 0);
if (ret < 0 || !WIFEXITED(status) || WEXITSTATUS(status) != 0) {
- ret = SKIP_TEST;
+ ret = TEST_SETUP_FAILURE;
goto err_xcb;
}

diff --git a/test/xvfb-wrapper.c b/test/xvfb-wrapper.c
index 38d159b..ab0c645 100644
--- a/test/xvfb-wrapper.c
+++ b/test/xvfb-wrapper.c
@@ -67,6 +67,7 @@ xvfb_wrapper(int (*test_func)(char* display))
goto err_display_fd;
}
snprintf(display_fd_string, sizeof(display_fd_string), "%d", fileno(display_fd));
+ fprintf(stderr, "display_fd_string: %s\n", display_fd_string);

/* Set SIGUSR1 to SIG_IGN so Xvfb will send us that signal
* when it's ready to accept connections */
@@ -90,7 +91,8 @@ xvfb_wrapper(int (*test_func)(char* display))
*/
ret = posix_spawnp(&xvfb_pid, "Xvfb", NULL, NULL, xvfb_argv, envp);
if (ret != 0) {
- ret = SKIP_TEST;
+ fprintf(stderr, "posix_spawnp error %d: %s\n", ret, strerror(ret));
+ ret = TEST_SETUP_FAILURE;
goto err_xvfd;
}

@@ -115,7 +117,8 @@ xvfb_wrapper(int (*test_func)(char* display))
rewind(display_fd);
length = fread(&display[1], 1, sizeof(display) - 1, display_fd);
if (length <= 0) {
- ret = SKIP_TEST;
+ fprintf(stderr, "fread error: length=%zu\n", length);
+ ret = TEST_SETUP_FAILURE;
goto err_xvfd;
} else {
/* Drop the newline character */
@@ -133,25 +136,25 @@ err_display_fd:
return ret;
}

-/* All X11_TEST functions are in the test_functions_section ELF section.
+/* All X11_TEST functions are in the test_func_sec ELF section.
* __start and __stop point to the start and end of that section. See the
* __attribute__(section) documentation.
*/
-extern const struct test_function __start_test_functions_section, __stop_test_functions_section;
+DECLARE_TEST_ELF_SECTION_POINTERS(TEST_ELF_SECTION);

int
x11_tests_run()
{
size_t count = 1; /* For NULL-terminated entry */

- for (const struct test_function *t = &__start_test_functions_section;
- t < &__stop_test_functions_section;
+ for (const struct test_function *t = &__start_test_func_sec;
+ t < &__stop_test_func_sec;
t++)
count++;

int rc;
- for (const struct test_function *t = &__start_test_functions_section;
- t < &__stop_test_functions_section;
+ for (const struct test_function *t = &__start_test_func_sec;
+ t < &__stop_test_func_sec;
t++) {
fprintf(stderr, "Running test: %s from %s\n", t->name, t->file);
rc = xvfb_wrapper(t->func);
diff --git a/test/xvfb-wrapper.h b/test/xvfb-wrapper.h
index 222fa3e..b78e752 100644
--- a/test/xvfb-wrapper.h
+++ b/test/xvfb-wrapper.h
@@ -15,6 +15,10 @@

#pragma once

+int xvfb_wrapper(int (*f)(char* display));
+
+int x11_tests_run(void);
+
typedef int (* x11_test_func_t)(char* display);

struct test_function {
@@ -28,17 +32,37 @@ struct test_function {
* loop over in x11_tests_run() to extract the tests. This removes the
* need of manually adding the tests to a suite or listing them somewhere.
*/
+#define TEST_ELF_SECTION test_func_sec
+
+#if defined(__APPLE__) && defined(__MACH__)
+#define SET_TEST_ELF_SECTION(_section) \
+ __attribute__((retain,used)) \
+ __attribute__((section("__DATA," STRINGIFY(_section))))
+
+/* Custom section pointers. See: https://stackoverflow.com/a/22366882 */
+#define DECLARE_TEST_ELF_SECTION_POINTERS(_section) \
+extern const struct test_function CONCAT2(__start_, _section) \
+ __asm("section$start$__DATA$" STRINGIFY2(_section)); \
+extern const struct test_function CONCAT2(__stop_, _section) \
+ __asm("section$end$__DATA$" STRINGIFY2(_section))
+
+#else
+
+#define SET_TEST_ELF_SECTION(_section) \
+ __attribute__((retain,used)) \
+ __attribute__((section(STRINGIFY(_section))))
+
+#define DECLARE_TEST_ELF_SECTION_POINTERS(_section) \
+ extern const struct test_function \
+ CONCAT2(__start_, _section), CONCAT2(__stop_, _section)
+#endif
+
#define X11_TEST(_func) \
static int _func(char* display); \
static const struct test_function _test_##_func \
-__attribute__((used)) \
-__attribute__((section("test_functions_section"))) = { \
+SET_TEST_ELF_SECTION(TEST_ELF_SECTION) = { \
.name = #_func, \
.func = _func, \
.file = __FILE__, \
}; \
static int _func(char* display)
-
-int xvfb_wrapper(int (*f)(char* display));
-
-int x11_tests_run(void);

0 comments on commit d074f6e

Please sign in to comment.