blob: b260ce408cc3fdc44bb28ed2787268dcd494320a [file] [log] [blame]
Jonathan Peyton50e8f182016-04-04 19:38:32 +00001// RUN: %libomp-compile && env OMP_WAIT_POLICY=active %libomp-run active
2// RUN: %libomp-compile && env OMP_WAIT_POLICY=passive %libomp-run passive
3//
Jonathan Peyton37310762016-05-17 21:08:52 +00004// OMP_WAIT_POLICY=active should imply blocktime == INT_MAX
Jonathan Peyton50e8f182016-04-04 19:38:32 +00005// i.e., threads spin-wait forever
Jonathan Peyton37310762016-05-17 21:08:52 +00006// OMP_WAIT_POLICY=passive should imply blocktime == 0
Jonathan Peyton50e8f182016-04-04 19:38:32 +00007// i.e., threads immediately sleep
8#include <stdio.h>
9#include <string.h>
10#include <limits.h>
11#include "omp_testsuite.h"
12
13void usage() {
14 fprintf(stderr, "usage: omp_wait_policy active|passive\n");
15}
16
17int main(int argc, char** argv)
18{
19 int blocktime, retval=1;
20 const char* env_var_value;
21
22 if (argc != 2) {
23 usage();
24 return 1;
25 }
26
27 blocktime = kmp_get_blocktime();
Jonathan Peyton37310762016-05-17 21:08:52 +000028
Jonathan Peyton50e8f182016-04-04 19:38:32 +000029 env_var_value = argv[1];
30 if (!strcmp(env_var_value, "active")) {
31 retval = (blocktime != INT_MAX);
32 } else if (!strcmp(env_var_value, "passive")) {
33 retval = (blocktime != 0);
34 } else {
35 usage();
36 retval = 1;
37 }
38
39 return retval;
40}