* tests/test-selinux-context-h.c: New file.
* tests/test-selinux-label-h.c: New file.
* tests/test-selinux-selinux-h.c: New file.
* modules/selinux-h-tests: New file.
* tests/test-selinux-context-h-c++.cc: New file.
* tests/test-selinux-label-h-c++.cc: New file.
* tests/test-selinux-selinux-h-c++.cc: New file.
* modules/selinux-h-c++-tests: New file.
+2026-01-16 Bruno Haible <bruno@clisp.org>
+
+ selinux-h: Add tests.
+ * tests/test-selinux-context-h.c: New file.
+ * tests/test-selinux-label-h.c: New file.
+ * tests/test-selinux-selinux-h.c: New file.
+ * modules/selinux-h-tests: New file.
+ * tests/test-selinux-context-h-c++.cc: New file.
+ * tests/test-selinux-label-h-c++.cc: New file.
+ * tests/test-selinux-selinux-h-c++.cc: New file.
+ * modules/selinux-h-c++-tests: New file.
+
2026-01-16 Bruno Haible <bruno@clisp.org>
selinux-h: Fix compilation errors and link errors in C++ mode.
--- /dev/null
+Files:
+tests/test-selinux-context-h-c++.cc
+tests/test-selinux-label-h-c++.cc
+tests/test-selinux-selinux-h-c++.cc
+
+Status:
+c++-test
+
+Depends-on:
+ansi-c++-opt
+
+configure.ac:
+
+Makefile.am:
+if ANSICXX
+TESTS += \
+ test-selinux-context-h-c++ \
+ test-selinux-label-h-c++ \
+ test-selinux-selinux-h-c++
+check_PROGRAMS += \
+ test-selinux-context-h-c++ \
+ test-selinux-label-h-c++ \
+ test-selinux-selinux-h-c++
+test_selinux_context_h_c___SOURCES = test-selinux-context-h-c++.cc
+test_selinux_context_h_c___LDADD = $(LDADD) @LIB_SELINUX@
+test_selinux_label_h_c___SOURCES = test-selinux-label-h-c++.cc
+test_selinux_label_h_c___LDADD = $(LDADD) @LIB_SELINUX@
+test_selinux_selinux_h_c___SOURCES = test-selinux-selinux-h-c++.cc
+test_selinux_selinux_h_c___LDADD = $(LDADD) @LIB_SELINUX@
+endif
--- /dev/null
+Files:
+tests/test-selinux-context-h.c
+tests/test-selinux-label-h.c
+tests/test-selinux-selinux-h.c
+
+Depends-on:
+selinux-h-c++-tests
+
+configure.ac:
+
+Makefile.am:
+TESTS += \
+ test-selinux-context-h \
+ test-selinux-label-h \
+ test-selinux-selinux-h
+check_PROGRAMS += \
+ test-selinux-context-h \
+ test-selinux-label-h \
+ test-selinux-selinux-h
+test_selinux_context_h_LDADD = $(LDADD) @LIB_SELINUX@
+test_selinux_label_h_LDADD = $(LDADD) @LIB_SELINUX@
+test_selinux_selinux_h_LDADD = $(LDADD) @LIB_SELINUX@
--- /dev/null
+/* Test of <selinux/context.h> substitute in C++ mode.
+ Copyright (C) 2026 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2026. */
+
+#include "test-selinux-context-h.c"
--- /dev/null
+/* Test of <selinux/context.h> substitute.
+ Copyright (C) 2026 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2026. */
+
+#include <config.h>
+
+#include <selinux/context.h>
+
+/* Check that context_t is defined. */
+context_t t1;
+
+int
+main ()
+{
+ context_t c = context_new ("system_u:system_r:init_t:s0");
+ context_type_set (c, "bar");
+ context_range_set (c, "bar");
+ context_role_set (c, "bar");
+ context_user_set (c, "bar");
+ (void) context_type_get (c);
+ (void) context_range_get (c);
+ (void) context_role_get (c);
+ (void) context_user_get (c);
+ (void) context_str (c);
+ context_free (c);
+
+ return 0;
+}
--- /dev/null
+/* Test of <selinux/label.h> substitute in C++ mode.
+ Copyright (C) 2026 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2026. */
+
+#include "test-selinux-label-h.c"
--- /dev/null
+/* Test of <selinux/label.h> substitute.
+ Copyright (C) 2026 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2026. */
+
+#include <config.h>
+
+#include <selinux/label.h>
+
+#include <stddef.h>
+
+int
+main ()
+{
+ struct selabel_handle *l = selabel_open (SELABEL_CTX_FILE, NULL, 0);
+ if (l)
+ selabel_close (l);
+
+ return 0;
+}
--- /dev/null
+/* Test of <selinux/selinux.h> substitute in C++ mode.
+ Copyright (C) 2026 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2026. */
+
+#include "test-selinux-selinux-h.c"
--- /dev/null
+/* Test of <selinux/selinux.h> substitute.
+ Copyright (C) 2026 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2026. */
+
+#include <config.h>
+
+#include <selinux/selinux.h>
+
+int
+main ()
+{
+ /* The people at the NSA who created this API obviously did not know
+ French. */
+ char *con;
+ if (getcon (&con) == 0)
+ freecon (con);
+
+ return 0;
+}