# HG changeset patch # User kzhaldyb # Date 1480348470 -10800 # Mon Nov 28 18:54:30 2016 +0300 # Node ID 1d071d75aef12e242be5f54b6cb9730b1099996c # Parent ca0634bba7b0c5187a668f3f17f3484397e8722c 8166156: Convert test_semaphore to GTest Reviewed-by: duke diff --git a/src/share/vm/utilities/internalVMTests.cpp b/src/share/vm/utilities/internalVMTests.cpp --- a/src/share/vm/utilities/internalVMTests.cpp +++ b/src/share/vm/utilities/internalVMTests.cpp @@ -41,7 +41,6 @@ void InternalVMTests::run() { tty->print_cr("Running internal VM tests"); - run_unit_test(test_semaphore); run_unit_test(TestReservedSpace_test); run_unit_test(TestReserveMemorySpecial_test); run_unit_test(TestVirtualSpace_test); diff --git a/src/share/vm/runtime/semaphore.cpp b/test/native/runtime/test_semaphore.cpp rename from src/share/vm/runtime/semaphore.cpp rename to test/native/runtime/test_semaphore.cpp --- a/src/share/vm/runtime/semaphore.cpp +++ b/test/native/runtime/test_semaphore.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -19,16 +19,11 @@ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. - * */ #include "precompiled.hpp" -#include "utilities/debug.hpp" #include "runtime/semaphore.hpp" - -/////////////// Unit tests /////////////// - -#ifndef PRODUCT +#include "unittest.hpp" static void test_semaphore_single_separate(uint count) { Semaphore sem(0); @@ -67,7 +62,19 @@ } } -static void test_semaphore_many() { +TEST(Semaphore, single_separate) { + for (uint i = 1; i < 10; i++) { + test_semaphore_single_separate(i); + } +} + +TEST(Semaphore, single_combined) { + for (uint i = 1; i < 10; i++) { + test_semaphore_single_combined(i); + } +} + +TEST(Semaphore, many) { for (uint max = 0; max < 10; max++) { for (uint value = 0; value < max; value++) { for (uint inc = 1; inc <= max - value; inc++) { @@ -76,18 +83,3 @@ } } } - -void test_semaphore() { - for (uint i = 1; i < 10; i++) { - test_semaphore_single_separate(i); - } - - for (uint i = 0; i < 10; i++) { - test_semaphore_single_combined(i); - } - - test_semaphore_many(); -} - -#endif // PRODUCT -