--- old/test/native/runtime/test_semaphore.cpp 2017-06-30 10:53:33.320870752 +0200 +++ new/test/native/runtime/test_semaphore.cpp 2017-06-30 10:53:33.208866076 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, 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 @@ -62,6 +62,18 @@ } } +static void test_semaphore_trywait(uint value, uint max) { + Semaphore sem(value); + + for (uint i = 0; i < max; ++i) { + if (i < value) { + ASSERT_EQ(sem.trywait(), true); + } else { + ASSERT_EQ(sem.trywait(), false); + } + } +} + TEST(Semaphore, single_separate) { for (uint i = 1; i < 10; i++) { test_semaphore_single_separate(i); @@ -83,3 +95,11 @@ } } } + +TEST(Semaphore, trywait) { + for (uint max = 0; max < 10; max++) { + for (uint value = 0; value < max; value++) { + test_semaphore_trywait(value, max); + } + } +}