summaryrefslogtreecommitdiffstats
path: root/selftest/trial_test.py
blob: ba3f01b0c3b9029a2be6c65f885dc037fab7ef46 (plain)
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
48
49
#!/usr/bin/env python3

import time
import _prep
import os
from osmo_gsm_tester import util
from osmo_gsm_tester.trial import Trial

workdir = util.get_tempdir()

trials_dir = util.Dir(workdir)

print('- make a few trials dirs')
print(trials_dir.mkdir('first'))
time.sleep(1)
print(trials_dir.mkdir('second'))
time.sleep(1)
print(trials_dir.mkdir('third'))

print('- fetch trial dirs in order')
t = Trial.next(trials_dir)
print(t)
print(repr(sorted(t.dir.children())))
print(Trial.next(trials_dir))
print(Trial.next(trials_dir))

print('- no more trial dirs left')
print(repr(Trial.next(trials_dir)))

print('- test checksum verification')
d = util.Dir('trial_test')
t = Trial(d.child('valid_checksums'))
t.verify()

print('- detect wrong checksum')
t = Trial(d.child('invalid_checksum'))
try:
    t.verify()
except RuntimeError as e:
    print('ok, got %r' % e)

print('- detect missing file')
t = Trial(d.child('missing_file'))
try:
    t.verify()
except RuntimeError as e:
    print('ok, got %r' % e)

# vim: expandtab tabstop=4 shiftwidth=4