< prev index next >

test/hotspot/gtest/gtestMain.cpp

Print this page


   1 /*
   2  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include <stdio.h>
  26 #include <string.h>
  27 #include <stdlib.h>
  28 #ifdef __APPLE__
  29 #  include <dlfcn.h>
  30 #endif
  31 
  32 #ifdef _WIN32
  33 #include <windows.h>
  34 #else
  35 #include <pthread.h>
  36 #endif
  37 
  38 #include "prims/jni.h"
  39 #include "unittest.hpp"
  40 
  41 // Default value for -new-thread option: true on AIX because we run into
  42 // problems when attempting to initialize the JVM on the primordial thread.
  43 #ifdef _AIX
  44 const static bool DEFAULT_SPAWN_IN_NEW_THREAD = true;
  45 #else
  46 const static bool DEFAULT_SPAWN_IN_NEW_THREAD = false;
  47 #endif
  48 
  49 static bool is_prefix(const char* prefix, const char* str) {
  50   return strncmp(str, prefix, strlen(prefix)) == 0;
  51 }
  52 
  53 static bool is_suffix(const char* suffix, const char* str) {
  54   size_t suffix_len = strlen(suffix);
  55   size_t str_len = strlen(str);
  56   if (str_len < suffix_len) {
  57       return false;
  58   }


 302   if (pthread_join(tid, NULL) != 0) {
 303     fprintf(stderr, "Failed to join main thread\n");
 304     exit(2);
 305   }
 306 }
 307 
 308 #endif
 309 
 310 extern "C"
 311 JNIEXPORT void JNICALL runUnitTests(int argc, char** argv) {
 312   const bool spawn_new_main_thread = get_spawn_new_main_thread_arg(argc, argv);
 313   if (spawn_new_main_thread) {
 314     args_t args;
 315     args.argc = argc;
 316     args.argv = argv;
 317     run_in_new_thread(&args);
 318   } else {
 319     runUnitTestsInner(argc, argv);
 320   }
 321 }
 322 
   1 /*
   2  * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include <stdio.h>
  26 #include <string.h>
  27 #include <stdlib.h>
  28 #ifdef __APPLE__
  29 #  include <dlfcn.h>
  30 #endif
  31 
  32 #ifdef _WIN32
  33 #include <windows.h>
  34 #else
  35 #include <pthread.h>
  36 #endif
  37 
  38 #include "jni.h"
  39 #include "unittest.hpp"
  40 
  41 // Default value for -new-thread option: true on AIX because we run into
  42 // problems when attempting to initialize the JVM on the primordial thread.
  43 #ifdef _AIX
  44 const static bool DEFAULT_SPAWN_IN_NEW_THREAD = true;
  45 #else
  46 const static bool DEFAULT_SPAWN_IN_NEW_THREAD = false;
  47 #endif
  48 
  49 static bool is_prefix(const char* prefix, const char* str) {
  50   return strncmp(str, prefix, strlen(prefix)) == 0;
  51 }
  52 
  53 static bool is_suffix(const char* suffix, const char* str) {
  54   size_t suffix_len = strlen(suffix);
  55   size_t str_len = strlen(str);
  56   if (str_len < suffix_len) {
  57       return false;
  58   }


 302   if (pthread_join(tid, NULL) != 0) {
 303     fprintf(stderr, "Failed to join main thread\n");
 304     exit(2);
 305   }
 306 }
 307 
 308 #endif
 309 
 310 extern "C"
 311 JNIEXPORT void JNICALL runUnitTests(int argc, char** argv) {
 312   const bool spawn_new_main_thread = get_spawn_new_main_thread_arg(argc, argv);
 313   if (spawn_new_main_thread) {
 314     args_t args;
 315     args.argc = argc;
 316     args.argv = argv;
 317     run_in_new_thread(&args);
 318   } else {
 319     runUnitTestsInner(argc, argv);
 320   }
 321 }

< prev index next >