xref: /netbsd-src/external/apache2/llvm/dist/llvm/utils/lit/tests/Inputs/test_retry_attempts/test.py (revision 82d56013d7b633d116a93943de88e08335357a7c)
1# RUN: "%python" "%s" "%counter"
2
3import sys
4import os
5
6counter_file = sys.argv[1]
7
8# The first time the test is run, initialize the counter to 1.
9if not os.path.exists(counter_file):
10    with open(counter_file, 'w') as counter:
11        counter.write("1")
12
13# Succeed if this is the fourth time we're being run.
14with open(counter_file, 'r') as counter:
15    num = int(counter.read())
16    if num == 4:
17        sys.exit(0)
18
19# Otherwise, increment the counter and fail
20with open(counter_file, 'w') as counter:
21    counter.write(str(num + 1))
22    sys.exit(1)
23