1/* 2 * Copyright (c) 2011, 2022, Oracle and/or its affiliates. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 * DEALINGS IN THE SOFTWARE. 22 */ 23 24#include <X11/Intrinsic.h> 25#include <glib.h> 26 27/* Test for Solaris bug 4163152 XtCvtIntToPixmap() gets a SIGBUS in 64-bit 28 Fixed by libXt commit 16d9941f3aa38dde115cbff639e131761c1b36d0 29 */ 30static void test_XtCvtIntToPixmap(void) 31{ 32 Display *display = NULL; /* not actually used */ 33 Boolean status; 34 XrmValue args[2]; 35 Cardinal num_args; 36 XrmValue fromVal; 37 XrmValue toVal; 38 Pixmap res; 39 XtPointer *closure_ret = NULL; 40 int num[2]; 41 42 43 XtToolkitInitialize(); 44 45 num[0] = 7; 46 num[1] = -1; 47 48 num_args = 0; 49 fromVal.addr = (XtPointer) num; 50 fromVal.size = sizeof(int); 51 toVal.addr = (XtPointer) &res; 52 toVal.size = sizeof(Pixmap); 53 54 status = XtCvtIntToPixmap(display, &args[0], &num_args, 55 &fromVal, &toVal, closure_ret); 56 57 g_assert_cmpint(status, ==, True); 58 g_assert_cmpint(res, ==, num[0]); 59 60 61 num[0] = -1; 62 num[1] = 7; 63 64 num_args = 0; 65 fromVal.addr = (XtPointer) (&num[1]); 66 fromVal.size = sizeof(int); 67 toVal.addr = (XtPointer) &res; 68 toVal.size = sizeof(Pixmap); 69 70 status = XtCvtIntToPixmap(display, &args[0], &num_args, 71 &fromVal, &toVal, closure_ret); 72 73 g_assert_cmpint(status, ==, True); 74 g_assert_cmpint(res, ==, num[1]); 75} 76 77int main(int argc, char** argv) 78{ 79 g_test_init(&argc, &argv, NULL); 80 g_test_bug_base("https://gitlab.freedesktop.org/xorg/lib/libxt/-/issues/"); 81 82 g_test_add_func("/Converters/XtCvtIntToPixmap", test_XtCvtIntToPixmap); 83 84 return g_test_run(); 85} 86