-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtask_wait_test.cc
More file actions
47 lines (39 loc) · 1.34 KB
/
task_wait_test.cc
File metadata and controls
47 lines (39 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "test.h"
#include "controlled_task.h"
using namespace SystematicTesting;
void run_iteration()
{
int value(0);
ControlledTask<void> task([&value] { value++; });
task.start();
task.wait();
assert(value == 1, "Found unexpected value.");
}
int main()
{
std::cout << "[test] started." << std::endl;
auto start_time = std::chrono::steady_clock::now();
try
{
auto settings = CreateDefaultSettings();
SystematicTestEngineContext context(settings, 25);
while (auto iteration = context.next_iteration())
{
run_iteration();
}
auto report = context.report();
std::cout << report.to_string() << std::endl;
assert(context.total_iterations() == report.iterations(), "Number of iterations is not correct.");
assert(context.total_iterations() * 2 == report.total_controlled_operations(), "Number of controlled operations is not correct.");
assert(0 == report.total_uncontrolled_threads(), "Number of uncontrolled threads is not correct.");
}
catch (std::string error)
{
std::cout << "[test] failed: " << error << std::endl;
return 1;
}
std::cout << "[test] done in " << total_time(start_time) << "ms." << std::endl;
return 0;
}