1/*
2 Copyright (c) 2005-2019 Intel Corporation
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17// Program for basic correctness of handle_perror, which is internal
18// to the TBB shared library.
19
20#include <cerrno>
21#include <stdexcept>
22
23#include "../tbb/tbb_misc.h"
24#include "harness.h"
25
26#if TBB_USE_EXCEPTIONS
27
28static void TestHandlePerror() {
29 bool caught = false;
30 try {
31 tbb::internal::handle_perror( EAGAIN, "apple" );
32 } catch( std::runtime_error& e ) {
33#if TBB_USE_EXCEPTIONS
34 REMARK("caught runtime_exception('%s')\n",e.what());
35 ASSERT( memcmp(e.what(),"apple: ",7)==0, NULL );
36 ASSERT( strlen(strstr(e.what(), strerror(EAGAIN))), "bad error message?" );
37#endif /* TBB_USE_EXCEPTIONS */
38 caught = true;
39 }
40 ASSERT( caught, NULL );
41}
42
43int TestMain () {
44 TestHandlePerror();
45 return Harness::Done;
46}
47
48#else /* !TBB_USE_EXCEPTIONS */
49
50int TestMain () {
51 return Harness::Skipped;
52}
53
54#endif /* TBB_USE_EXCEPTIONS */
55