blob: 244f01b5dc5745ff2ed7fea15b335d9119a42fa4 [file] [log] [blame]
apw6e551622006-04-04 08:50:53 +00001import test
2from autotest_utils import *
3from error import *
4
5class selftest(test.test):
6 def setup(self):
7 name = self.job.resultdir + '/sequence'
8 if (not os.path.exists(name)):
9 fd = file(name, 'w')
10 fd.write('0')
11 fd.close()
12
apw2f571232006-04-22 10:30:17 +000013 def __mark(self, checkpoint):
apw6e551622006-04-04 08:50:53 +000014 name = self.job.resultdir + '/sequence'
15 fd = file(name, 'r')
16 current = int(fd.readline())
17 fd.close()
18
19 current += 1
20 fd = file(name + '.new', 'w')
21 fd.write('%d' % current)
22 fd.close()
23
24 os.rename(name + '.new', name)
25
26 print "checkpoint %d %d" % (current, checkpoint)
27
28 if (current != checkpoint):
29 raise JobError("selftest: sequence was " +
30 "%d when %d expected" % (current, checkpoint))
apw2f571232006-04-22 10:30:17 +000031
32 def __throw(self):
33 __does_not_exist = __does_not_exist_either
34
35 def execute(self, cmd, *args):
36 if cmd == 'mark':
37 self.__mark(*args)
38 elif cmd == 'throw':
39 self.__throw(*args)