(root)/
glib-2.79.0/
gthread/
tests/
init.c
       1  /* GLib testing framework examples and tests
       2   *
       3   * Copyright © 2022 Endless OS Foundation, LLC
       4   *
       5   * SPDX-License-Identifier: LGPL-2.1-or-later
       6   *
       7   * This library is free software; you can redistribute it and/or
       8   * modify it under the terms of the GNU Lesser General Public
       9   * License as published by the Free Software Foundation; either
      10   * version 2.1 of the License, or (at your option) any later version.
      11   *
      12   * This library is distributed in the hope that it will be useful,
      13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15   * Lesser General Public License for more details.
      16   *
      17   * You should have received a copy of the GNU Lesser General
      18   * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
      19   *
      20   * Author: Philip Withnall <pwithnall@endlessos.org>
      21   */
      22  
      23  #include <glib.h>
      24  #include <locale.h>
      25  
      26  
      27  /* All of GThread is deprecated, but that’s OK */
      28  G_GNUC_BEGIN_IGNORE_DEPRECATIONS
      29  
      30  static void
      31  test_thread_deprecated_init (void)
      32  {
      33    const GThreadFunctions functions = {
      34      NULL, NULL, NULL, NULL,
      35      NULL, NULL, NULL, NULL,
      36      NULL, NULL, NULL, NULL,
      37      NULL, NULL, NULL, NULL,
      38      NULL, NULL, NULL, NULL,
      39      NULL
      40    };
      41  
      42    /* Should be a no-op. */
      43    g_thread_init (NULL);
      44  
      45    /* Should emit a warning. */
      46    g_test_expect_message ("GThread", G_LOG_LEVEL_WARNING,
      47                           "GThread system no longer supports custom thread implementations.");
      48    g_thread_init ((gpointer) &functions);
      49    g_test_assert_expected_messages ();
      50  }
      51  
      52  static void
      53  test_thread_deprecated_init_with_errorcheck_mutexes (void)
      54  {
      55    /* Should warn. */
      56    g_test_expect_message ("GThread", G_LOG_LEVEL_WARNING,
      57                           "GThread system no longer supports errorcheck mutexes.");
      58    g_thread_init_with_errorcheck_mutexes (NULL);
      59    g_test_assert_expected_messages ();
      60  }
      61  
      62  int
      63  main (int   argc,
      64        char *argv[])
      65  {
      66    setlocale (LC_ALL, "");
      67    g_test_init (&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
      68  
      69    g_test_add_func ("/thread/deprecated/init", test_thread_deprecated_init);
      70    g_test_add_func ("/thread/deprecated/init-with-errorcheck-mutexes", test_thread_deprecated_init_with_errorcheck_mutexes);
      71  
      72    return g_test_run ();
      73  }
      74  
      75  G_GNUC_END_IGNORE_DEPRECATIONS